# Weird bug with hull() in OpenSCAD 2013.06

11 messages
Open this post in threaded view
|

## Weird bug with hull() in OpenSCAD 2013.06

 [I've enclosed all the info you need to reproduce this bug.] Given the module: module edge(r,phi) polyhedron(points=[[r*cos(phi),r*sin(phi),0], [r*cos(phi),r*sin(phi),1], [0.1*sin(phi),-0.1*cos(phi),0.5], [-0.1*sin(phi),0.1*cos(phi),0.5]], triangles=[[2,1,0],[0,1,3],[3,2,0],[2,3,1]], convexity=2); This example works: {edge(1,0);edge(1,120);edge(1,240);} This example works: {for(i=[0:2]) edge(1,i*120);} This example works: hull() {edge(1,0);edge(1,120);edge(1,240);} This example DOESN'T work: hull() {for(i=[0:2]) edge(1,i*120);} ---- Apparently, the only difference is the additional 'group()' level in the CSG tree: // CSG for 1st test, which works: group() {         hull() {                 group() {                         polyhedron(points = [[1, 0, 0], [1, 0, 1], [0, -0.1, 0.5], [-0, 0.1, 0.5]], triangles = [[2, 1, 0], [0, 1, 3], [3, 2, 0], [2, 3, 1]], convexity = 2);                 }                 group() {                         polyhedron(points = [[-0.5, 0.866025, 0], [-0.5, 0.866025, 1], [0.0866025, 0.05, 0.5], [-0.0866025, -0.05, 0.5]], triangles = [[2, 1, 0], [0, 1, 3], [3, 2, 0], [2, 3, 1]], convexity = 2);                 }                 group() {                         polyhedron(points = [[-0.5, -0.866025, 0], [-0.5, -0.866025, 1], [-0.0866025, 0.05, 0.5], [0.0866025, -0.05, 0.5]], triangles = [[2, 1, 0], [0, 1, 3], [3, 2, 0], [2, 3, 1]], convexity = 2);                 }         } } // CSG for 2nd test, which DOESN'T work, and generates the error message: "Hull() currently requires a valid 2-manifold. Please modify your design.": group() {         hull() {                 group() {                         group() {                                 polyhedron(points = [[1, 0, 0], [1, 0, 1], [0, -0.1, 0.5], [-0, 0.1, 0.5]], triangles = [[2, 1, 0], [0, 1, 3], [3, 2, 0], [2, 3, 1]], convexity = 2);                         }                         group() {                                 polyhedron(points = [[-0.5, 0.866025, 0], [-0.5, 0.866025, 1], [0.0866025, 0.05, 0.5], [-0.0866025, -0.05, 0.5]], triangles = [[2, 1, 0], [0, 1, 3], [3, 2, 0], [2, 3, 1]], convexity = 2);                         }                         group() {                                 polyhedron(points = [[-0.5, -0.866025, 0], [-0.5, -0.866025, 1], [-0.0866025, 0.05, 0.5], [0.0866025, -0.05, 0.5]], triangles = [[2, 1, 0], [0, 1, 3], [3, 2, 0], [2, 3, 1]], convexity = 2);                         }                 }         } } _______________________________________________ OpenSCAD mailing list [hidden email] http://rocklinux.net/mailman/listinfo/openscadhttp://openscad.org - https://flattr.com/thing/121566
Open this post in threaded view
|

## Re: Weird bug with hull() in OpenSCAD 2013.06

 CGAL doesn't think this is manifold {edge(1,0);edge(1,120);edge(1,240);} That might be where the problems stem from. On 4 July 2013 15:58, Henry Baker wrote: [I've enclosed all the info you need to reproduce this bug.] Given the module: module edge(r,phi) polyhedron(points=[[r*cos(phi),r*sin(phi),0], [r*cos(phi),r*sin(phi),1], [0.1*sin(phi),-0.1*cos(phi),0.5], [-0.1*sin(phi),0.1*cos(phi),0.5]], triangles=[[2,1,0],[0,1,3],[3,2,0],[2,3,1]], convexity=2); This example works: {edge(1,0);edge(1,120);edge(1,240);} This example works: {for(i=[0:2]) edge(1,i*120);} This example works: hull() {edge(1,0);edge(1,120);edge(1,240);} This example DOESN'T work: hull() {for(i=[0:2]) edge(1,i*120);} ---- Apparently, the only difference is the additional 'group()' level in the CSG tree: // CSG for 1st test, which works: group() {         hull() {                 group() {                         polyhedron(points = [[1, 0, 0], [1, 0, 1], [0, -0.1, 0.5], [-0, 0.1, 0.5]], triangles = [[2, 1, 0], [0, 1, 3], [3, 2, 0], [2, 3, 1]], convexity = 2);                 }                 group() {                         polyhedron(points = [[-0.5, 0.866025, 0], [-0.5, 0.866025, 1], [0.0866025, 0.05, 0.5], [-0.0866025, -0.05, 0.5]], triangles = [[2, 1, 0], [0, 1, 3], [3, 2, 0], [2, 3, 1]], convexity = 2);                 }                 group() {                         polyhedron(points = [[-0.5, -0.866025, 0], [-0.5, -0.866025, 1], [-0.0866025, 0.05, 0.5], [0.0866025, -0.05, 0.5]], triangles = [[2, 1, 0], [0, 1, 3], [3, 2, 0], [2, 3, 1]], convexity = 2);                 }         } } // CSG for 2nd test, which DOESN'T work, and generates the error message: "Hull() currently requires a valid 2-manifold. Please modify your design.": group() {         hull() {                 group() {                         group() {                                 polyhedron(points = [[1, 0, 0], [1, 0, 1], [0, -0.1, 0.5], [-0, 0.1, 0.5]], triangles = [[2, 1, 0], [0, 1, 3], [3, 2, 0], [2, 3, 1]], convexity = 2);                         }                         group() {                                 polyhedron(points = [[-0.5, 0.866025, 0], [-0.5, 0.866025, 1], [0.0866025, 0.05, 0.5], [-0.0866025, -0.05, 0.5]], triangles = [[2, 1, 0], [0, 1, 3], [3, 2, 0], [2, 3, 1]], convexity = 2);                         }                         group() {                                 polyhedron(points = [[-0.5, -0.866025, 0], [-0.5, -0.866025, 1], [-0.0866025, 0.05, 0.5], [0.0866025, -0.05, 0.5]], triangles = [[2, 1, 0], [0, 1, 3], [3, 2, 0], [2, 3, 1]], convexity = 2);                         }                 }         } } _______________________________________________ OpenSCAD mailing list [hidden email] http://rocklinux.net/mailman/listinfo/openscad http://openscad.org - https://flattr.com/thing/121566 _______________________________________________ OpenSCAD mailing list [hidden email] http://rocklinux.net/mailman/listinfo/openscadhttp://openscad.org - https://flattr.com/thing/121566
Open this post in threaded view
|

## Re: Weird bug with hull() in OpenSCAD 2013.06

 {edge(1,0);edge(1,120);edge(1,240);} works just fine. It's the looping version that doesn't work. Also, see the 'group()' etc. code at the bottom.  One of the versions works, the version with one additional level of 'group()' doesn't work. At 08:17 AM 7/4/2013, nop head wrote: >CGAL doesn't think this is manifold {edge(1,0);edge(1,120);edge(1,240);} > >That might be where the problems stem from. > >On 4 July 2013 15:58, Henry Baker <[hidden email]> wrote: >[I've enclosed all the info you need to reproduce this bug.] > >Given the module: > >module edge(r,phi) >polyhedron(points=[[r*cos(phi),r*sin(phi),0], >[r*cos(phi),r*sin(phi),1], >[0.1*sin(phi),-0.1*cos(phi),0.5], >[-0.1*sin(phi),0.1*cos(phi),0.5]], >triangles=[[2,1,0],[0,1,3],[3,2,0],[2,3,1]], >convexity=2); > >This example works: > >{edge(1,0);edge(1,120);edge(1,240);} > >This example works: > >{for(i=[0:2]) edge(1,i*120);} > >This example works: > >hull() {edge(1,0);edge(1,120);edge(1,240);} > >This example DOESN'T work: > >hull() {for(i=[0:2]) edge(1,i*120);} > >---- >Apparently, the only difference is the additional 'group()' level in the CSG tree: > >// CSG for 1st test, which works: > >group() { >        hull() { >                group() { >                        polyhedron(points = [[1, 0, 0], [1, 0, 1], [0, -0.1, 0.5], [-0, 0.1, 0.5]], triangles = [[2, 1, 0], [0, 1, 3], [3, 2, 0], [2, 3, 1]], convexity = 2); >                } >                group() { >                        polyhedron(points = [[-0.5, 0.866025, 0], [-0.5, 0.866025, 1], [0.0866025, 0.05, 0.5], [-0.0866025, -0.05, 0.5]], triangles = [[2, 1, 0], [0, 1, 3], [3, 2, 0], [2, 3, 1]], convexity = 2); >                } >                group() { >                        polyhedron(points = [[-0.5, -0.866025, 0], [-0.5, -0.866025, 1], [-0.0866025, 0.05, 0.5], [0.0866025, -0.05, 0.5]], triangles = [[2, 1, 0], [0, 1, 3], [3, 2, 0], [2, 3, 1]], convexity = 2); >                } >        } >} > >// CSG for 2nd test, which DOESN'T work, and generates the error message: "Hull() currently requires a valid 2-manifold. Please modify your design.": > >group() { >        hull() { >                group() { >                        group() { >                                polyhedron(points = [[1, 0, 0], [1, 0, 1], [0, -0.1, 0.5], [-0, 0.1, 0.5]], triangles = [[2, 1, 0], [0, 1, 3], [3, 2, 0], [2, 3, 1]], convexity = 2); >                        } >                        group() { >                                polyhedron(points = [[-0.5, 0.866025, 0], [-0.5, 0.866025, 1], [0.0866025, 0.05, 0.5], [-0.0866025, -0.05, 0.5]], triangles = [[2, 1, 0], [0, 1, 3], [3, 2, 0], [2, 3, 1]], convexity = 2); >                        } >                        group() { >                                polyhedron(points = [[-0.5, -0.866025, 0], [-0.5, -0.866025, 1], [-0.0866025, 0.05, 0.5], [0.0866025, -0.05, 0.5]], triangles = [[2, 1, 0], [0, 1, 3], [3, 2, 0], [2, 3, 1]], convexity = 2); >                        } >                } >        } >} _______________________________________________ OpenSCAD mailing list [hidden email] http://rocklinux.net/mailman/listinfo/openscadhttp://openscad.org - https://flattr.com/thing/121566
Open this post in threaded view
|

## Re: Weird bug with hull() in OpenSCAD 2013.06

Open this post in threaded view
|

## Re: Weird bug with hull() in OpenSCAD 2013.06

 But that's the weird thing; as long as I don't use a loop, hull() here works just fine.  For some reason, hull() doesn't like this particular loop. I'll also modify my 'edge()' module to avoid intersections altogether; perhaps that will be a workaround, although a workaround shouldn't be necessary in this instance. hull() should be a relatively simple & efficient operation: it should ignore all face & edge information and simply compute the convex hull of the union of all of the vertices.  Why on Earth it should require manifolds is completely mysterious. At 08:45 AM 7/4/2013, nop head wrote: >{edge(1,0);edge(1,120);edge(1,240);} > >F6 gives simple = no on the version I am using, which means non-manifold. I expect because it has knife edges meeting in the middle. > >hull() normally works with a for loop, but for some reason it does require manifold input. > >On 4 July 2013 16:21, Henry Baker <[hidden email]> wrote: >{edge(1,0);edge(1,120);edge(1,240);} works just fine. > >It's the looping version that doesn't work. > >Also, see the 'group()' etc. code at the bottom.  One of the versions works, the version with one additional level of 'group()' doesn't work. > >At 08:17 AM 7/4/2013, nop head wrote: >>CGAL doesn't think this is manifold {edge(1,0);edge(1,120);edge(1,240);} >> >>That might be where the problems stem from. >> >>On 4 July 2013 15:58, Henry Baker <[hidden email]> wrote: >>[I've enclosed all the info you need to reproduce this bug.] >> >>Given the module: >> >>module edge(r,phi) >>polyhedron(points=[[r*cos(phi),r*sin(phi),0], >>[r*cos(phi),r*sin(phi),1], >>[0.1*sin(phi),-0.1*cos(phi),0.5], >>[-0.1*sin(phi),0.1*cos(phi),0.5]], >>triangles=[[2,1,0],[0,1,3],[3,2,0],[2,3,1]], >>convexity=2); >> >>This example works: >> >>{edge(1,0);edge(1,120);edge(1,240);} >> >>This example works: >> >>{for(i=[0:2]) edge(1,i*120);} >> >>This example works: >> >>hull() {edge(1,0);edge(1,120);edge(1,240);} >> >>This example DOESN'T work: >> >>hull() {for(i=[0:2]) edge(1,i*120);} >> >>---- >>Apparently, the only difference is the additional 'group()' level in the CSG tree: >> >>// CSG for 1st test, which works: >> >>group() { >>        hull() { >>                group() { >>                        polyhedron(points = [[1, 0, 0], [1, 0, 1], [0, -0.1, 0.5], [-0, 0.1, 0.5]], triangles = [[2, 1, 0], [0, 1, 3], [3, 2, 0], [2, 3, 1]], convexity = 2); >>                } >>                group() { >>                        polyhedron(points = [[-0.5, 0.866025, 0], [-0.5, 0.866025, 1], [0.0866025, 0.05, 0.5], [-0.0866025, -0.05, 0.5]], triangles = [[2, 1, 0], [0, 1, 3], [3, 2, 0], [2, 3, 1]], convexity = 2); >>                } >>                group() { >>                        polyhedron(points = [[-0.5, -0.866025, 0], [-0.5, -0.866025, 1], [-0.0866025, 0.05, 0.5], [0.0866025, -0.05, 0.5]], triangles = [[2, 1, 0], [0, 1, 3], [3, 2, 0], [2, 3, 1]], convexity = 2); >>                } >>        } >>} >> >>// CSG for 2nd test, which DOESN'T work, and generates the error message: "Hull() currently requires a valid 2-manifold. Please modify your design.": >> >>group() { >>        hull() { >>                group() { >>                        group() { >>                                polyhedron(points = [[1, 0, 0], [1, 0, 1], [0, -0.1, 0.5], [-0, 0.1, 0.5]], triangles = [[2, 1, 0], [0, 1, 3], [3, 2, 0], [2, 3, 1]], convexity = 2); >>                        } >>                        group() { >>                                polyhedron(points = [[-0.5, 0.866025, 0], [-0.5, 0.866025, 1], [0.0866025, 0.05, 0.5], [-0.0866025, -0.05, 0.5]], triangles = [[2, 1, 0], [0, 1, 3], [3, 2, 0], [2, 3, 1]], convexity = 2); >>                        } >>                        group() { >>                                polyhedron(points = [[-0.5, -0.866025, 0], [-0.5, -0.866025, 1], [-0.0866025, 0.05, 0.5], [0.0866025, -0.05, 0.5]], triangles = [[2, 1, 0], [0, 1, 3], [3, 2, 0], [2, 3, 1]], convexity = 2); >>                        } >>                } >>        } >>} _______________________________________________ OpenSCAD mailing list [hidden email] http://rocklinux.net/mailman/listinfo/openscadhttp://openscad.org - https://flattr.com/thing/121566
Open this post in threaded view
|

## Re: Weird bug with hull() in OpenSCAD 2013.06

 This workaround worked; I now use hull() on completely disjoint objects, although this shouldn't be neceesary. At 09:01 AM 7/4/2013, Henry Baker wrote: >I'll also modify my 'edge()' module to avoid intersections altogether; perhaps that will be a workaround, although a workaround shouldn't be necessary in this instance. _______________________________________________ OpenSCAD mailing list [hidden email] http://rocklinux.net/mailman/listinfo/openscadhttp://openscad.org - https://flattr.com/thing/121566
Open this post in threaded view
|

## Re: Weird bug with hull() in OpenSCAD 2013.06

Open this post in threaded view
|

## Re: Weird bug with hull() in OpenSCAD 2013.06

 Yes, the example I gave produced the same as an extruded triangle, but I wanted to find a _simple_ example of the bug. My usual uses of hull() are far more complicated, but luckily I didn't need anything that complex to demonstrate the bug. At 09:48 AM 7/4/2013, nop head wrote: >Yes I agree hull() should just use the vertices. > >But your example seems odd to me as the result is just an extruded triangle isn't it? > >If so it is could by done with cylinder(\$fn = 3, ...) _______________________________________________ OpenSCAD mailing list [hidden email] http://rocklinux.net/mailman/listinfo/openscadhttp://openscad.org - https://flattr.com/thing/121566
Open this post in threaded view
|

## Re: Weird bug with hull() in OpenSCAD 2013.06

 So, to summarise are we saying in general hull() with for() works but if the thing being hulled is non-manifold you get an error message whereas hull without a for loop can sort it out? On 4 July 2013 19:33, Henry Baker wrote: Yes, the example I gave produced the same as an extruded triangle, but I wanted to find a _simple_ example of the bug. My usual uses of hull() are far more complicated, but luckily I didn't need anything that complex to demonstrate the bug. At 09:48 AM 7/4/2013, nop head wrote: >Yes I agree hull() should just use the vertices. > >But your example seems odd to me as the result is just an extruded triangle isn't it? > >If so it is could by done with cylinder(\$fn = 3, ...) _______________________________________________ OpenSCAD mailing list [hidden email] http://rocklinux.net/mailman/listinfo/openscad http://openscad.org - https://flattr.com/thing/121566 _______________________________________________ OpenSCAD mailing list [hidden email] http://rocklinux.net/mailman/listinfo/openscadhttp://openscad.org - https://flattr.com/thing/121566