Object may not be a valid 2-manifold and may need repair!

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Object may not be a valid 2-manifold and may need repair!

Eric Buijs
Hi, I have a small script that generates 2D Supershapes. I want to 3D-print some of these shapes and that works fine until I add a cylinder (or a square) to the shape. When I render it I get: WARNING: Object may not be a valid 2-manifold and may need repair! Is there a way to avoid this?

I added the script. To produce the warning uncomment the last line.

a = 1;
b = 1;

m = 7/6  ;

n1 = 0.3;
n2 = 0.3;
n3 = 0.3;

radius = 30;

range_multiplier = 6;

function superformula(theta) = pow(pow(abs(1 / a * cos(m/4*theta)),n2)+ pow(abs(1 / a * sin(m/4*theta)),n3), 1 / n1);

function supershape(range_multiplier) = [for (theta = [0:1:360 * range_multiplier]) [radius/superformula(theta) * cos(theta), radius/superformula(theta) * sin(theta)] ];

linear_extrude(3.2)
polygon(supershape(range_multiplier));
//cylinder(r=radius,h=1);

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Object may not be a valid 2-manifold and may need repair!

cacb
On 17. mai 2017 12:01, Eric Buijs wrote:
> Hi, I have a small script that generates 2D Supershapes. I want to 3D-print
> some of these shapes and that works fine until I add a cylinder (or a
> square) to the shape. When I render it I get: WARNING: Object may not be a
> valid 2-manifold and may need repair! Is there a way to avoid this?

Yes, do not create non-manifold topology in the first place :-) That is
in fact what you are doing with those shapes. You have solids that share
only single edges with neighbour objects. That is 1-manifold and not
2-manifold.

You can tweak those shapes into creating 2 manifold intersections with
each other simply by adding a small offset to the polygon:

=======

a = 1;
b = 1;

m = 7/6  ;

n1 = 0.3;
n2 = 0.3;
n3 = 0.3;

radius = 30;

range_multiplier = 6;

function superformula(theta) = pow(pow(abs(1 / a * cos(m/4*theta)),n2)+
pow(abs(1 / a * sin(m/4*theta)),n3), 1 / n1);

function supershape(range_multiplier) = [for (theta = [0:1:360 *
range_multiplier]) [radius/superformula(theta) * cos(theta),
radius/superformula(theta) * sin(theta)] ];

linear_extrude(3.2)
offset(r=0.001)
polygon(supershape(range_multiplier));
cylinder(r=radius,h=1);


Carsten Arnholm

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Object may not be a valid 2-manifold and may need repair!

cacb
On 17. mai 2017 13:09, Carsten Arnholm wrote:
> On 17. mai 2017 12:01, Eric Buijs wrote:
>> Hi, I have a small script that generates 2D Supershapes. I want to
>> 3D-print
>> some of these shapes and that works fine until I add a cylinder (or a
>> square) to the shape. When I render it I get: WARNING: Object may not
>> be a
>> valid 2-manifold and may need repair! Is there a way to avoid this?
>
> Yes, do not create non-manifold topology in the first place :-) That is

By the way, after closer inspection it looks like you are creating a
complex shape using a single highly self-intersecting polygon. That is
something I would expect to cause failure either way.

Carsten Arnholm



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Object may not be a valid 2-manifold and may need repair!

Eric Buijs
In reply to this post by cacb
The addition of the offset appears to be working. With the stl file I was able to generate a valid gcode file in Cura. I will print it later today and will let you know the result.  
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Object may not be a valid 2-manifold and may need repair!

Ronaldo
This is a very interesting case. The polygonal line that defines the polygon is not a 1-manifold due to self-intersections. The polygon is not simple. There are a few interpretation alternatives what is inside of a non-simple polygon. The one OpenSCAD/CGAL seems to choose may result in a non-2-manifold when extruded. One example where the extrusion of non-simple polygon is accepted as 2-manifold by CGAL follows:

function circle(r) = [for(a=[0:10:360]) r*[cos(a), sin(a)]];
function reverse(p) = [for(i=[len(p)-1:-1:0]) p[i]];

linear_extrude(2)
polygon(concat(circle(20),reverse(circle(10))));
cube(30);

It generates a 2-manifold even if the reverse() is excluded in the polygon definition. However, if this last polygon is taking as an input shape for sweep.scad the resulting polyhedron will be refused as a 2-manifold.

BTW, different slicers choose different ways to interpret similar situations and the 3D printing from them will be different.

2017-05-17 9:15 GMT-03:00 Eric Buijs <[hidden email]>:
The addition of the offset appears to be working. With the stl file I was
able to generate a valid gcode file in Cura. I will print it later today and
will let you know the result.



--
View this message in context: http://forum.openscad.org/Object-may-not-be-a-valid-2-manifold-and-may-need-repair-tp21489p21492.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Object may not be a valid 2-manifold and may need repair!

cacb
On 17. mai 2017 16:57, Ronaldo Persiano wrote:
> One example where the
> extrusion of non-simple polygon is accepted as 2-manifold by CGAL follows:
>
> function circle(r) = [for(a=[0:10:360]) r*[cos(a), sin(a)]];
> function reverse(p) = [for(i=[len(p)-1:-1:0]) p[i]];
>
> linear_extrude(2)
> polygon(concat(circle(20),reverse(circle(10))));
> cube(30);

This is a polygon with 74 edges in a single loop. Edge 37 runs from
[20,0] (vertex37) to [10,0] (vertex38) and the final edge 74 runs from
[10,0] (vertex74) to [20,0] (vertex01).

There are coinciding vertices (37/01 and 38/74) and coinciding edges
(37/74 , parallel and overlapping). It is a classic "2*PI problem". I
would classify that as a self intersecting polygon.

If the polygon had been defined with an inner and outer loop instead, it
would be well defined.

It ultimately falls into "undefined behaviour" category when you have a
polygon with either intersecting non-parallel edges or overlapping
parallel edges.

The model by Eric Buijs that "worked" with an offset was in effect also
relying on undefined behaviour for this reason.

Carsten Arnholm

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Object may not be a valid 2-manifold and may need repair!

Ronaldo
The polygon I have defined will have different nature if the reverse operation is removed. As is, the polygon is not simple but "well defined" in the sense that it has a well defined interior. Its regularization ( regularization(P) = closure(interior(P)) ) would be identical to the one with inner and outer loops. However, if the reverse operation is removed, it will have a boundary cross and then its interior is not well defined anymore and no regularization would be possible.

2017-05-17 14:33 GMT-03:00 Carsten Arnholm <[hidden email]>:
There are coinciding vertices (37/01 and 38/74) and coinciding edges (37/74 , parallel and overlapping). It is a classic "2*PI problem". I would classify that as a self intersecting polygon.

If the polygon had been defined with an inner and outer loop instead, it would be well defined.

It ultimately falls into "undefined behaviour" category when you have a polygon with either intersecting non-parallel edges or overlapping parallel edges.

The model by Eric Buijs that "worked" with an offset was in effect also relying on undefined behaviour for this reason.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Object may not be a valid 2-manifold and may need repair!

Eric Buijs
In reply to this post by cacb
I will not pretend that I fully understand the discussion but the 3D-print came out great.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

can anyone explain nearly parallel triangles

codifies
ok thinking in my limited mathmatically way, I can see there might be an
issue with nearly parallel triangles....

but it kinda seems like I dunno am I missing something to do with the
issues...

On 17/05/17 21:03, Eric Buijs wrote:

> I will not pretend that I fully understand the discussion but the 3D-print
> came out great.
>
>
>
> --
> View this message in context: http://forum.openscad.org/Object-may-not-be-a-valid-2-manifold-and-may-need-repair-tp21489p21500.html
> Sent from the OpenSCAD mailing list archive at Nabble.com.
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: can anyone explain nearly parallel triangles

Ronaldo
Chris,

Eric Buijs issue has not anything in common with nearly parallel triangles. It is a non-manifold issue like the one where two cubes have one edge in common.

cube(10);
translate([10,10,0]) cube(10);


2017-05-17 19:49 GMT-03:00 Mr C Camacho <[hidden email]>:
ok thinking in my limited mathmatically way, I can see there might be an issue with nearly parallel triangles....

but it kinda seems like I dunno am I missing something to do with the issues...

On 17/05/17 21:03, Eric Buijs wrote:
I will not pretend that I fully understand the discussion but the 3D-print
came out great.



--
View this message in context: http://forum.openscad.org/Object-may-not-be-a-valid-2-manifold-and-may-need-repair-tp21489p21500.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Loading...