discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

polyhedron difference renders ok but bad preview

MG
Matteo Gattanini
Sun, Feb 7, 2021 11:13 AM

Hi,
I'm intersecting two polyedrons (I double checked their faces
definiftions), both taken singularly are previewed and rendered ok, but
when I difference them the preview fails from certain angles, while the
render is ok.
Am I missing something or could be a bug?

$vpr = [85, 0, 50];

//-------------------------------------
module single_roof(dim, sp)
   {
    // P2  P8    p2 +-------------+ p3       P9  P3
    //    \        |      Y+     |           //
    //     \    p1 +-------------+ p4 ->X   //
    //  P1 //P7     |      Y-     |       P10\ P4
    //    //     p0 +-------------+ p5        \
    // P0  P6                               P11  P5
    p0 = [-dim.x/2, -dim.y/2, 0];
    p1 = [p0.x, 0, dim.z];
    p2 = [p0.x, dim.y/2, p0.z];
    p3 = [dim.x/2, p2.y, p0.z];
    p4 = [p3.x, p1.y, p1.z];
    p5 = [p3.x, p0.y, p0.z];
    p6 = [p0.x, p0.y, p0.z+sp];
    p7 = [p1.x, p1.y, p1.z+sp];
    p8 = [p2.x, p2.y, p2.z+sp];
    p9 = [p3.x, p3.y, p3.z+sp];
    p10 = [p4.x, p4.y, p4.z+sp];
    p11 = [p5.x, p5.y, p5.z+sp];
    points = [p0, p1, p2, p3, p4,  p5,
              p6, p7, p8, p9, p10, p11];

    // faces are defined by points indices (CW)
    faces =
       [
        [ 0, 5, 4, 1 ], // Under Y-
        [ 6, 7,10,11 ], // Over Y-
        [ 1, 4, 3, 2 ], // Under Y+
        [ 7, 8, 9,10 ], // Over Y+
        [ 5,11,10, 4 ], // Side Y- X+
        [ 4,10, 9, 3 ], // Side Y+ X+
        [ 1, 7, 6, 0 ], // Side Y- X-
        [ 2, 8, 7, 1 ], // Side Y+ X-
        [ 0, 6,11, 5 ], // Side Y-
        [ 3, 9, 8, 2 ]  // Side Y+
       ];

    polyhedron(points, faces);
   }

//-------------------------------------
module single_roof_vol(dim)
   {
    dz = 0.001;
    //  p2 +-------------+ p3
    //     |      Y+     |
    //  p1 +-------------+ p4 ->X
    //     |      Y-     |
    //  p0 +-------------+ p5
    p0 = [-dim.x/2, -dim.y/2, 0-dz];
    p1 = [p0.x, 0, dim.z-dz];
    p2 = [p0.x, dim.y/2, p0.z];
    p3 = [dim.x/2, p2.y, p0.z];
    p4 = [p3.x, p1.y, p1.z];
    p5 = [p3.x, p0.y, p0.z];
    points = [p0,  p1,  p2,  p3,  p4,  p5];

    faces =
       [
        [ 0, 5, 3, 2 ], // Under
        [ 0, 1, 4, 5 ], // Over Y+
        [ 1, 2, 3, 4 ], // Over Y-
        [ 5, 4, 3 ], // Front X+
        [ 2, 1, 0 ]  // Front X-
       ];

    polyhedron(points, faces);
   }

// Intersection
difference()
   {
    color("DarkRed") single_roof([13,11,3], 0.3);
    rotate([0,0,90]) single_roof_vol([12,6,3]);
   }

Hi, I'm intersecting two polyedrons (I double checked their faces definiftions), both taken singularly are previewed and rendered ok, but when I difference them the preview fails from certain angles, while the render is ok. Am I missing something or could be a bug? $vpr = [85, 0, 50]; //------------------------------------- module single_roof(dim, sp)    {     // P2  P8    p2 +-------------+ p3       P9  P3     //    \\        |      Y+     |           //     //     \\    p1 +-------------+ p4 ->X   //     //  P1 //P7     |      Y-     |       P10\\ P4     //    //     p0 +-------------+ p5        \\     // P0  P6                               P11  P5     p0 = [-dim.x/2, -dim.y/2, 0];     p1 = [p0.x, 0, dim.z];     p2 = [p0.x, dim.y/2, p0.z];     p3 = [dim.x/2, p2.y, p0.z];     p4 = [p3.x, p1.y, p1.z];     p5 = [p3.x, p0.y, p0.z];     p6 = [p0.x, p0.y, p0.z+sp];     p7 = [p1.x, p1.y, p1.z+sp];     p8 = [p2.x, p2.y, p2.z+sp];     p9 = [p3.x, p3.y, p3.z+sp];     p10 = [p4.x, p4.y, p4.z+sp];     p11 = [p5.x, p5.y, p5.z+sp];     points = [p0, p1, p2, p3, p4,  p5,               p6, p7, p8, p9, p10, p11];     // faces are defined by points indices (CW)     faces =        [         [ 0, 5, 4, 1 ], // Under Y-         [ 6, 7,10,11 ], // Over Y-         [ 1, 4, 3, 2 ], // Under Y+         [ 7, 8, 9,10 ], // Over Y+         [ 5,11,10, 4 ], // Side Y- X+         [ 4,10, 9, 3 ], // Side Y+ X+         [ 1, 7, 6, 0 ], // Side Y- X-         [ 2, 8, 7, 1 ], // Side Y+ X-         [ 0, 6,11, 5 ], // Side Y-         [ 3, 9, 8, 2 ]  // Side Y+        ];     polyhedron(points, faces);    } //------------------------------------- module single_roof_vol(dim)    {     dz = 0.001;     //  p2 +-------------+ p3     //     |      Y+     |     //  p1 +-------------+ p4 ->X     //     |      Y-     |     //  p0 +-------------+ p5     p0 = [-dim.x/2, -dim.y/2, 0-dz];     p1 = [p0.x, 0, dim.z-dz];     p2 = [p0.x, dim.y/2, p0.z];     p3 = [dim.x/2, p2.y, p0.z];     p4 = [p3.x, p1.y, p1.z];     p5 = [p3.x, p0.y, p0.z];     points = [p0,  p1,  p2,  p3,  p4,  p5];     faces =        [         [ 0, 5, 3, 2 ], // Under         [ 0, 1, 4, 5 ], // Over Y+         [ 1, 2, 3, 4 ], // Over Y-         [ 5, 4, 3 ], // Front X+         [ 2, 1, 0 ]  // Front X-        ];     polyhedron(points, faces);    } // Intersection difference()    {     color("DarkRed") single_roof([13,11,3], 0.3);     rotate([0,0,90]) single_roof_vol([12,6,3]);    }
M
MichaelAtOz
Sun, Feb 7, 2021 11:42 AM

MG wrote

Am I missing something or could be a bug?

     convexity

         Integer. The convexity parameter specifies the maximum number

of faces a ray intersecting the object might penetrate. This parameter is
needed only for correct display of the object in OpenCSG preview mode. It
has no effect on the polyhedron rendering. For display problems, setting
it to 10 should work fine for most cases.


OpenSCAD Admin - email* me if you need anything,  or if I've done something stupid...

  • on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

--
Sent from: http://forum.openscad.org/

MG wrote > Am I missing something or could be a bug? https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Primitive_Solids#polyhedron > convexity > > Integer. The convexity parameter specifies the maximum number > of faces a ray intersecting the object might penetrate. This parameter is > needed only for correct display of the object in OpenCSG preview mode. It > has no effect on the polyhedron rendering. For display problems, setting > it to 10 should work fine for most cases. ----- OpenSCAD Admin - email* me if you need anything, or if I've done something stupid... * on the Forum, click on my MichaelAtOz label, there is a link to email me. Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above. -- Sent from: http://forum.openscad.org/
MG
Matteo Gattanini
Sun, Feb 7, 2021 11:45 AM

Ehm, missed that, thanks a lot!

On Sun, Feb 7, 2021, 12:43 MichaelAtOz oz.at.michael@gmail.com wrote:

MG wrote

Am I missing something or could be a bug?

     convexity

         Integer. The convexity parameter specifies the maximum number

of faces a ray intersecting the object might penetrate. This parameter is
needed only for correct display of the object in OpenCSG preview mode. It
has no effect on the polyhedron rendering. For display problems, setting
it to 10 should work fine for most cases.


OpenSCAD Admin - email* me if you need anything,  or if I've done
something stupid...

  • on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the
Public Domain; to the extent possible under law, I have waived all
copyright and related or neighbouring rights to this work. Obviously
inclusion of works of previous authors is not included in the above.

--
Sent from: http://forum.openscad.org/


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

Ehm, missed that, thanks a lot! On Sun, Feb 7, 2021, 12:43 MichaelAtOz <oz.at.michael@gmail.com> wrote: > MG wrote > > Am I missing something or could be a bug? > > > https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Primitive_Solids#polyhedron > > > convexity > > > > Integer. The convexity parameter specifies the maximum number > > of faces a ray intersecting the object might penetrate. This parameter is > > needed only for correct display of the object in OpenCSG preview mode. It > > has no effect on the polyhedron rendering. For display problems, setting > > it to 10 should work fine for most cases. > > > > > > ----- > OpenSCAD Admin - email* me if you need anything, or if I've done > something stupid... > > * on the Forum, click on my MichaelAtOz label, there is a link to email me. > > Unless specifically shown otherwise above, my contribution is in the > Public Domain; to the extent possible under law, I have waived all > copyright and related or neighbouring rights to this work. Obviously > inclusion of works of previous authors is not included in the above. > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >