Intersection bug with OpenCSG...?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Intersection bug with OpenCSG...?

Dan Zuras 3D


        Folks,

        The following code snippet is intended to create an
        octahedron next to the top half of an octahedron.
        Which is exactly what one gets with CGAL (f6).
        However, when compiled with OpenCSG (f5) one gets
        an octahedron standing next to nothing.
        It is as if the intersection went wrong for some
        reason.
        It happens on the 2011.06.14 release of OpenSCAD.
        Thoughts?
        Observations?
        Criticisms?
        Anything?

                                Dan


module unitOctahedron() polyhedron(
        points = [[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]],
        triangles = [[0,2,4],[0,5,2],[0,4,3],[0,3,5],[1,4,2],[1,2,5],[1,3,4],
                [1,5,3]],
        convexity = 1);

module scaleOctahedron(s)
        scale([s/sqrt(2),s/sqrt(2),s/sqrt(2)]) unitOctahedron();

translate([-10,0,0]) scaleOctahedron(10);
intersection() {
        translate([10,0,0]) scaleOctahedron(10);
        translate([10,0,10]) cube([20,20,20],center=true);
}

Reply | Threaded
Open this post in threaded view
|

Re: Intersection bug with OpenCSG...?

kintel
Administrator
On Sep 29, 2011, at 12:32 PM, Dan Zuras 3D wrote:

> The following code snippet is intended to create an
> octahedron next to the top half of an octahedron.
> Which is exactly what one gets with CGAL (f6).
> However, when compiled with OpenCSG (f5) one gets
> an octahedron standing next to nothing.

Definitely looks like a bug. I've committed a test case which fails and will look into this.

 -Marius


Reply | Threaded
Open this post in threaded view
|

Re: Intersection bug with OpenCSG...?

kintel
Administrator
In reply to this post by Dan Zuras 3D
Hi again,

I looked into this a bit and it turns out that it's caused by your polyhedron faces being defined clockwise instead of counterclockwise.
CGAL doesn't care, but the OpenCSG renderer does.
Changing the order makes it work:
 triangles = [[0,4,2],[0,2,5],[0,3,4],[0,5,3],[1,2,4],[1,5,2],[1,4,3], [1,3,5]],

To visualize the problem, use the Thrown Together rendering mode.

This should be made easier to deal with - I'll put it on my longer-term list of stuff to keep in mind..

 -Marius


Reply | Threaded
Open this post in threaded view
|

Re: Intersection bug with OpenCSG...?

Dan Zuras 3D
> Subject: Re: [OpenSCAD] Intersection bug with OpenCSG...?
> From: Marius Kintel <[hidden email]>
> Date: Fri, 30 Sep 2011 00:27:58 +0200
> To: Dan Zuras 3D <[hidden email]>,
>  [hidden email]
>
> Hi again,
>
> I looked into this a bit and it turns out that it's caused by your =
> polyhedron faces being defined clockwise instead of counterclockwise.
> CGAL doesn't care, but the OpenCSG renderer does.
> Changing the order makes it work:
>  triangles = [[0,4,2],[0,2,5],[0,3,4],[0,5,3],[1,2,4],[1,5,2],[1,4,3], =
> [1,3,5]],

        Actually I went to some trouble to make sure they WERE
        counterclockwise.  Alas it was on a surface normal
        pointing INTO the object rather than out of.

        So, I'm an idiot.

>
> To visualize the problem, use the Thrown Together rendering mode.
>
> This should be made easier to deal with - I'll put it on my longer-term =
> list of stuff to keep in mind..
>
>  -Marius

        On the one hand, if the polygons were all created using
        computer generated triangles, it would not be a problem.
        But I guess so long as we poor humans are forced to do
        it, it should be more forgiving.

        For the moment it is no big deal.
        I just misunderstood.

        Thanks for your help.


                                Dan