discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Polyhedron and cube: Not a Valid 2-Manifold

S
sukrit_gupta
Fri, Nov 6, 2015 5:44 PM

Can anyone suggest how to make the below model render without showing a
"WARNING: Object may not be a valid 2-manifold and may need repair! "
https://drive.google.com/uc?export=download&id=0Bxg0L-sj9zVtQUlNWVhoS2oxRzQ
p1 = [10,10,0];
p2 = [10,-10,0];
p3 = [-10,-10,0];
p4 = [-10,10,0];
p5 = [ 0,  0,10];

polyhedron(
points = [ p1, p2, p3, p4, p5],
faces = [
[0,1,4], [1,2,4], [2,3,4], [3,0,4],
//[0,1,2], [0,2,3] ,
//[0,1,2,3]
]);
translate([0,0,-2.5])
cube([20,20,5], true);

I've tried increasing or decreasing the size of cube().
Without the bottom cube, no warning is shown, but once I add the below cube,
I get the warning.

--
View this message in context: http://forum.openscad.org/Polyhedron-and-cube-Not-a-Valid-2-Manifold-tp14283.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Can anyone suggest how to make the below model render without showing a "WARNING: Object may not be a valid 2-manifold and may need repair! " https://drive.google.com/uc?export=download&id=0Bxg0L-sj9zVtQUlNWVhoS2oxRzQ p1 = [10,10,0]; p2 = [10,-10,0]; p3 = [-10,-10,0]; p4 = [-10,10,0]; p5 = [ 0, 0,10]; polyhedron( points = [ p1, p2, p3, p4, p5], faces = [ [0,1,4], [1,2,4], [2,3,4], [3,0,4], //[0,1,2], [0,2,3] , //[0,1,2,3] ]); translate([0,0,-2.5]) cube([20,20,5], true); I've tried increasing or decreasing the size of cube(). Without the bottom cube, no warning is shown, but once I add the below cube, I get the warning. -- View this message in context: http://forum.openscad.org/Polyhedron-and-cube-Not-a-Valid-2-Manifold-tp14283.html Sent from the OpenSCAD mailing list archive at Nabble.com.
TP
Torsten Paul
Fri, Nov 6, 2015 5:59 PM

Hi!

On 11/06/2015 06:44 PM, sukrit_gupta wrote:

polyhedron(
points = [ p1, p2, p3, p4, p5],
faces = [
[0,1,4], [1,2,4], [2,3,4], [3,0,4],
//[0,1,2], [0,2,3] ,
//[0,1,2,3]
]);

That polyhedron must be a solid object too, you can't just leave off
the bottom and close it with the cube.

ciao,
Torsten.

Hi! On 11/06/2015 06:44 PM, sukrit_gupta wrote: > polyhedron( > points = [ p1, p2, p3, p4, p5], > faces = [ > [0,1,4], [1,2,4], [2,3,4], [3,0,4], > //[0,1,2], [0,2,3] , > //[0,1,2,3] > ]); > That polyhedron must be a solid object too, you can't just leave off the bottom and close it with the cube. ciao, Torsten.
R
runsun
Fri, Nov 6, 2015 6:02 PM

Try adding [0,3,2,1] to faces.


$  Runsun Pan, PhD

$ libs: doctest , faces ( git ), offline doc ( git ),runscad.py( 1 , 2 , git );

$ tips: hash( 1 , 2 ), sweep , var , lerp , animGif

--
View this message in context: http://forum.openscad.org/Polyhedron-and-cube-Not-a-Valid-2-Manifold-tp14283p14285.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Try adding [0,3,2,1] to faces. ----- $ Runsun Pan, PhD $ libs: doctest , faces ( git ), offline doc ( git ),runscad.py( 1 , 2 , git ); $ tips: hash( 1 , 2 ), sweep , var , lerp , animGif -- View this message in context: http://forum.openscad.org/Polyhedron-and-cube-Not-a-Valid-2-Manifold-tp14283p14285.html Sent from the OpenSCAD mailing list archive at Nabble.com.
S
sukrit_gupta
Fri, Nov 6, 2015 6:11 PM

runsun wrote

Try adding [0,3,2,1] to faces.

Thanks.
It resulted in a correct rendering and no warning.
Can you share any tip, in general, that may help us in finding the "cause"
behind this error.

--
View this message in context: http://forum.openscad.org/Polyhedron-and-cube-Not-a-Valid-2-Manifold-tp14283p14286.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

runsun wrote > Try adding [0,3,2,1] to faces. Thanks. It resulted in a correct rendering and no warning. Can you share any tip, in general, that may help us in finding the "cause" behind this error. -- View this message in context: http://forum.openscad.org/Polyhedron-and-cube-Not-a-Valid-2-Manifold-tp14283p14286.html Sent from the OpenSCAD mailing list archive at Nabble.com.
N
Neon22
Fri, Nov 6, 2015 6:31 PM

The term 'solid' means what it says. A solid object.
There are several ways to restate this that might be useful when trying to
determine "Is my object a solid?"

  • No zero thickness walls. All triangles or quads etc have no thickness.
  • All faces must fully connect with each other to form a continuous
    surface. All vertices must meet.
  • The object is watertight:
  • I.e. if filled with water there are no gaps where water might leak out.
  • E.g. if you have a triangle and another two triangles meet in the
    middle of one of it's edges. It appears to be solid but that middle edge is
    not connected at the vertices to the other two. So when filled with water it
    will leak out the gap.
  • Think of the faces as sheets of metal and the vertices as welds.

Check out many links online for help on what a "solid" model is.

--
View this message in context: http://forum.openscad.org/Polyhedron-and-cube-Not-a-Valid-2-Manifold-tp14283p14287.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

The term 'solid' means what it says. A solid object. There are several ways to restate this that might be useful when trying to determine "Is my object a solid?" - No zero thickness walls. All triangles or quads etc have no thickness. - All faces must fully connect with each other to form a continuous surface. All vertices must meet. - The object is watertight: - I.e. if filled with water there are no gaps where water might leak out. - E.g. if you have a triangle and another two triangles meet in the middle of one of it's edges. It appears to be solid but that middle edge is not connected at the vertices to the other two. So when filled with water it will leak out the gap. - Think of the faces as sheets of metal and the vertices as welds. Check out many links online for help on what a "solid" model is. -- View this message in context: http://forum.openscad.org/Polyhedron-and-cube-Not-a-Valid-2-Manifold-tp14283p14287.html Sent from the OpenSCAD mailing list archive at Nabble.com.
NH
nop head
Fri, Nov 6, 2015 7:25 PM

A simple way to think of it is: does it represent a solid that you can have
in real life? A shell with infinitely thin walls cannot exist so there can
be no edges of triangles exposed. They must always share each of their
edges with just one other triangle.

On 6 November 2015 at 18:31, Neon22 mschafer@wireframe.biz wrote:

The term 'solid' means what it says. A solid object.
There are several ways to restate this that might be useful when trying to
determine "Is my object a solid?"

  • No zero thickness walls. All triangles or quads etc have no thickness.
  • All faces must fully connect with each other to form a continuous
    surface. All vertices must meet.
  • The object is watertight:
  • I.e. if filled with water there are no gaps where water might leak
    out.
  • E.g. if you have a triangle and another two triangles meet in the
    middle of one of it's edges. It appears to be solid but that middle edge is
    not connected at the vertices to the other two. So when filled with water
    it
    will leak out the gap.
  • Think of the faces as sheets of metal and the vertices as welds.

Check out many links online for help on what a "solid" model is.

--
View this message in context:
http://forum.openscad.org/Polyhedron-and-cube-Not-a-Valid-2-Manifold-tp14283p14287.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

A simple way to think of it is: does it represent a solid that you can have in real life? A shell with infinitely thin walls cannot exist so there can be no edges of triangles exposed. They must always share each of their edges with just one other triangle. On 6 November 2015 at 18:31, Neon22 <mschafer@wireframe.biz> wrote: > The term 'solid' means what it says. A solid object. > There are several ways to restate this that might be useful when trying to > determine "Is my object a solid?" > - No zero thickness walls. All triangles or quads etc have no thickness. > - All faces must fully connect with each other to form a continuous > surface. All vertices must meet. > - The object is watertight: > - I.e. if filled with water there are no gaps where water might leak > out. > - E.g. if you have a triangle and another two triangles meet in the > middle of one of it's edges. It appears to be solid but that middle edge is > not connected at the vertices to the other two. So when filled with water > it > will leak out the gap. > - Think of the faces as sheets of metal and the vertices as welds. > > > Check out many links online for help on what a "solid" model is. > > > > -- > View this message in context: > http://forum.openscad.org/Polyhedron-and-cube-Not-a-Valid-2-Manifold-tp14283p14287.html > Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
W
wolf
Fri, Nov 6, 2015 8:36 PM

In another  thread
http://forum.openscad.org/3d-hull-with-2d-primitives-needed-tp5845p14276.html
I have placed a piece of code that demonstrates that nophead and Neon22's
comments are at variance with how polyhedron() actually behaves.

In that code, change any of the StartVal_ or EndVal_  parameters and see how
an ellipsoid changes into a vase. If you count the vertices or faces, there
are exactly as many as there should be, and thus the shape is watertight.
But it does not have a volume, irrespective of what OpenSCAD reports, as all
faces are of zero thickness.

But if you create an stl and export it into MeshLab, the number of vertices
triples, and the ellipsoid / vase would no longer be watertight. Whose
messages are then to be trusted?

To me, it means that someone has buggered the C++ code, either in creating
the stl mesh, or in reading it. Does anybody have an idea how to find the
bug, preferably without me first learning C++?

Wolf

--
View this message in context: http://forum.openscad.org/Polyhedron-and-cube-Not-a-Valid-2-Manifold-tp14283p14293.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

In another thread <http://forum.openscad.org/3d-hull-with-2d-primitives-needed-tp5845p14276.html> I have placed a piece of code that demonstrates that nophead and Neon22's comments are at variance with how polyhedron() actually behaves. In that code, change any of the StartVal_ or EndVal_ parameters and see how an ellipsoid changes into a vase. If you count the vertices or faces, there are exactly as many as there should be, and thus the shape is watertight. But it does not have a volume, irrespective of what OpenSCAD reports, as all faces are of zero thickness. But if you create an stl and export it into MeshLab, the number of vertices triples, and the ellipsoid / vase would no longer be watertight. Whose messages are then to be trusted? To me, it means that someone has buggered the C++ code, either in creating the stl mesh, or in reading it. Does anybody have an idea how to find the bug, preferably without me first learning C++? Wolf -- View this message in context: http://forum.openscad.org/Polyhedron-and-cube-Not-a-Valid-2-Manifold-tp14283p14293.html Sent from the OpenSCAD mailing list archive at Nabble.com.
NH
nop head
Fri, Nov 6, 2015 9:24 PM

Openscad buggers STLs when it writes them if the vertices are too close
together, such that after truncation to floats some topologically distinct
vertices become numerically the same.

On 6 November 2015 at 20:36, wolf wv99999@gmail.com wrote:

I have placed a piece of code that demonstrates that nophead and Neon22's
comments are at variance with how polyhedron() actually behaves.

In that code, change any of the StartVal_ or EndVal_  parameters and see
how
an ellipsoid changes into a vase. If you count the vertices or faces, there
are exactly as many as there should be, and thus the shape is watertight.
But it does not have a volume, irrespective of what OpenSCAD reports, as
all
faces are of zero thickness.

But if you create an stl and export it into MeshLab, the number of vertices
triples, and the ellipsoid / vase would no longer be watertight. Whose
messages are then to be trusted?

To me, it means that someone has buggered the C++ code, either in creating
the stl mesh, or in reading it. Does anybody have an idea how to find the
bug, preferably without me first learning C++?

Wolf

--
View this message in context:
http://forum.openscad.org/Polyhedron-and-cube-Not-a-Valid-2-Manifold-tp14283p14293.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Openscad buggers STLs when it writes them if the vertices are too close together, such that after truncation to floats some topologically distinct vertices become numerically the same. On 6 November 2015 at 20:36, wolf <wv99999@gmail.com> wrote: > In another thread > < > http://forum.openscad.org/3d-hull-with-2d-primitives-needed-tp5845p14276.html > > > I have placed a piece of code that demonstrates that nophead and Neon22's > comments are at variance with how polyhedron() actually behaves. > > In that code, change any of the StartVal_ or EndVal_ parameters and see > how > an ellipsoid changes into a vase. If you count the vertices or faces, there > are exactly as many as there should be, and thus the shape is watertight. > But it does not have a volume, irrespective of what OpenSCAD reports, as > all > faces are of zero thickness. > > But if you create an stl and export it into MeshLab, the number of vertices > triples, and the ellipsoid / vase would no longer be watertight. Whose > messages are then to be trusted? > > To me, it means that someone has buggered the C++ code, either in creating > the stl mesh, or in reading it. Does anybody have an idea how to find the > bug, preferably without me first learning C++? > > Wolf > > > > -- > View this message in context: > http://forum.openscad.org/Polyhedron-and-cube-Not-a-Valid-2-Manifold-tp14283p14293.html > Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
MK
Marius Kintel
Sat, Nov 7, 2015 5:10 AM

On Nov 6, 2015, at 16:24 PM, nop head nop.head@gmail.com wrote:

Openscad buggers STLs when it writes them if the vertices are too close together, such that after truncation to floats some topologically distinct vertices become numerically the same.

We are doing a much better job these days, but we’re still limited by floating point precision.
The alternative would be to do some sort of mesh optimization by merging close vertices or edges in a topology-preserving fashion. While this is doable, it’s non-trivial to get the edge cases right.

-Marius

> On Nov 6, 2015, at 16:24 PM, nop head <nop.head@gmail.com> wrote: > > Openscad buggers STLs when it writes them if the vertices are too close together, such that after truncation to floats some topologically distinct vertices become numerically the same. > We are doing a much better job these days, but we’re still limited by floating point precision. The alternative would be to do some sort of mesh optimization by merging close vertices or edges in a topology-preserving fashion. While this is doable, it’s non-trivial to get the edge cases right. -Marius
N
Neon22
Sat, Nov 7, 2015 9:12 AM

Looking at @wolf's code the vertex location calc is done 4(I think) times for
each vertex.
I.e. 4 faces join at a vertex but that vertex is calculated 4 times instead
of once.

Perhaps a way to do it where the vertices are shared, is to calculate all
the points once, in a list, and then build the faces list using those
vertices.
Then there will be no floating point error as the vertices will really be
shared. And therefore it will be a solid.

Sorry don't have time to do it right now :(

--
View this message in context: http://forum.openscad.org/Polyhedron-and-cube-Not-a-Valid-2-Manifold-tp14283p14296.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Looking at @wolf's code the vertex location calc is done 4(I think) times for each vertex. I.e. 4 faces join at a vertex but that vertex is calculated 4 times instead of once. Perhaps a way to do it where the vertices are shared, is to calculate all the points once, in a list, and then build the faces list using those vertices. Then there will be no floating point error as the vertices will really be shared. And therefore it will be a solid. Sorry don't have time to do it right now :( -- View this message in context: http://forum.openscad.org/Polyhedron-and-cube-Not-a-Valid-2-Manifold-tp14283p14296.html Sent from the OpenSCAD mailing list archive at Nabble.com.