

i have a polyhedron on openscad and i want to 3D print it but it is not coming up as a solid.


Where is it not "coming up as a solid"? Do you have an STL which you
can share with us? Do you have source code that you can share with us?
Jon
On 10/13/2016 1:11 PM, Cole wrote:
> i have a polyhedron on openscad and i want to 3D print it but it is not
> coming up as a solid.
>
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


polyhedron( points=[ [0,0,0], //0 [5,0,0], //1 [5,100,0], //2 [0,100,0], //3 [0,0,10], //4 [5,0,10], //5 [5,100,10], //6 [0,100,10], //7 [2.5,100,20],//8 [2.5,0,20],//9 [2.5,120,0],//10 [0,0,0]],//11
faces = [ [0,1,2,3], //bottom [0,3,7,4], //left [1,2,6,5], //right [1,0,4,5], //front [3,2,6,7], //back [4,7,8,9], //left blade [5,9,8,6], //right blade [4,9,5], // back 2 [7,8,6], //front 2 [3,10,7], //piont left [7,8,10], //tip [10,6,2], [10,8,6]]
); }
(it is only sowing up as a 2D sides instated of the 3D shape i wan to print out or diffreance out of somthing.
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


It shows up as a 3D object in OpenSCAD after I remove the trailing "}"
Jon
On 10/13/2016 1:20 PM, Cole Herbert wrote:
> polyhedron(
> points=[
> [0,0,0], //0
> [5,0,0], //1
> [5,100,0], //2
> [0,100,0], //3
> [0,0,10], //4
> [5,0,10], //5
> [5,100,10], //6
> [0,100,10], //7
> [2.5,100,20],//8
> [2.5,0,20],//9
> [2.5,120,0],//10
> [0,0,0]],//11
>
>
> faces = [
> [0,1,2,3], //bottom
> [0,3,7,4], //left
> [1,2,6,5], //right
> [1,0,4,5], //front
> [3,2,6,7], //back
> [4,7,8,9], //left blade
> [5,9,8,6], //right blade
> [4,9,5], // back 2
> [7,8,6], //front 2
> [3,10,7], //piont left
> [7,8,10], //tip
> [10,6,2],
> [10,8,6]]
>
> );
> }
>
> (it is only sowing up as a 2D sides instated of the 3D shape i wan to
> print out or diffreance out of somthing.
>
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


I'm not sure if you want the answers beyond the explanation provided, but for my own exercise, I found them.
1, 2, 6, 5 > 1, 5, 6, 2
7, 8, 10 > 7, 10, 8
10, 6, 2 > 10, 2, 6
10, 8, 6 > 10, 6, 8
remove:
3, 2, 6, 7
7, 8, 6
add:
10, 3, 2
not being particularly proficient in OpenSCAD, I can't guess what the two faces would do to your model, as they become internal "bulkheads" once you close the nonmanifold with 10, 3, 2, so it's probably a good idea to make that change.


Bit late to the scene on this one but its useful to be able to orient faces when 'throwntogether' shows some faces are the wrong way round. This is the code I use:
// ensure that all faces have a lhs orientation
function reverse(l) =
[for (i=[1:len(l)]) l[len(l)i]];
function orthogonal(v0,v1,v2) = cross(v1v0,v2v1);
function normal(face) =
let (n=orthogonal(face[0],face[1],face[2]))
 n / norm(n);
function vsum(points,i=0) =
i < len(points)
? (points[i] + vsum(points,i+1))
: [0,0,0];
function centroid(points) =
vsum(points) / len(points);
function as_points(indexes,points) =
[for (i=[0:len(indexes)1])
points[indexes[i]]
];
function cosine_between(u, v) =(u * v) / (norm(u) * norm(v));
function lhs_faces(faces,vertices) =
[for (face = faces)
let(points = as_points(face,vertices))
cosine_between(normal(points), centroid(points)) < 0
? reverse(face) : face
];
//original data
points=[
[0,0,0], //0
[5,0,0], //1
[5,100,0], //2
[0,100,0], //3
[0,0,10], //4
[5,0,10], //5
[5,100,10], //6
[0,100,10], //7
[2.5,100,20],//8
[2.5,0,20],//9
[2.5,120,0],//10
[0,0,0]];
faces = [
[0,1,2,3], //bottom
[0,3,7,4], //left
[1,2,6,5], //right
[1,0,4,5], //front
[3,2,6,7], //back
[4,7,8,9], //left blade
[5,9,8,6], //right blade
[4,9,5], // back 2
[7,8,6], //front 2
[3,10,7], //piont left
[7,8,10], //tip
[10,6,2],
[10,8,6]]
;
oriented_faces = lhs_faces(faces,points);
polyhedron(points=points,faces=oriented_faces);


It doesn't work with: //original data p=[ [0,0,0], //0 [5,0,0], //1 [5,100,0], //2 [0,100,0], //3 [0,0,10], //4 [5,0,10], //5 [5,100,10], //6 [0,100,10], //7 [2.5,100,20],//8 [2.5,0,20],//9 [2.5,120,0],//10 [0,0,0]];
points = [for(pi=p) pi[0,200,0]];
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


If we change the test in lhs_faces() to: cosine_between(normal(points), points[0]centroid(vertices)) < 0
it works for both cases. Anyway, this strategy of using centroid will possibly work for all convex objects but it will not work, for instance, for a holed cube. BTW, your example is not a manifold.
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


Still don't see why your second case doesn't work for you  maybe it's a version thing  I'm on 2017.01.20 but its hard to see why a simple translation would affect anything.
BTW It's not my example , its the OP's


Sorry, but I got the same result with both 2017.01.20 and 2015.032 running under Windows 7 what is really odd.
And the reason of this failure is simple: in lhs_faces, your test uses the angle between a vector (the face normal) and a point (the centroid). This has no geometrical meaning.
Even correcting this, the strategy may fail for non convex objects, as I said before.


Ronaldo  you are right of course my apologies for wasting your time  I was over confident and must have slipped out of thrown together mode . There must have been a regression in the code because I use this to clean up Johnson solids which have occasional reversed faces
<redface>
Chris


This post was updated on .
OK, I was looking in the wrong place  it isn't the code, it's the data. I've tested the code and it is correct when the solid is convex (a known limitation). The problem is that this example is not convex  I think the apex of the bottom facet is wrong , and hence its not manifold as you observed
Re cosine  the centroid point defines a line from the origin to the centroid so the angle is welldefined
Chris


20170410 21:31 GMT03:00 kitwallace <[hidden email]>: Re cosine  the centroid point defines a line from the origin to the centroid so the angle is welldefined
Sorry to disagree again. Translating the model I can put the centroid anywhere I like. So the angle between the normal of a face (invariant to translation) and the vector centroid[0,0,0] may be any value I want. So the test is not invariant to translation. But the face winding is. Besides, what happens when the centroid happens to be the origin? All faces, independent of its winding will pass the test.
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


Yes of course. I recall this was a quick solution which works for the polyhedra I was working on which are centred on the origin . i agree, it's not a general solution at all.
On 11 Apr 2017 2:17 a.m., "Ronaldo [via OpenSCAD]" < [hidden email]> wrote:
20170410 21:31 GMT03:00 kitwallace <[hidden email]>: Re cosine  the centroid point defines a line from the origin to the centroid so the angle is welldefined
Sorry to disagree again. Translating the model I can put the centroid anywhere I like. So the angle between the normal of a face (invariant to translation) and the vector centroid[0,0,0] may be any value I want. So the test is not invariant to translation. But the face winding is. Besides, what happens when the centroid happens to be the origin? All faces, independent of its winding will pass the test.
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
To unsubscribe from polyhedron to a 3D printing from, click here.
NAML

