discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

puzzler

J
jon
Tue, Sep 15, 2020 2:27 PM

When I use F5, I see what I expect: a grid.  When I use F6, I see a
totally filled in rectangle, with the interior spaces gone.  If I only
use F6 on the cube at the end, it is fine; if I only use F6 on the
linear_extrude of the Grid, it is fine.

What am I missing?

inches = 25.4;
vt = 1;                // vertical thickness
th = 0.5;            // grid thickness
ht = 1 * inches;    // 6
wd = 1 * inches;    // 9

module Grid() {
*    for (y = [0:3:ht])
        translate([0, y, 0])
            square([wd, th]);
    for (x = [-ht:4:2ht])
        translate([x, 0, 0])
            rotate([0, 0, 45])
                square([wd, th]);
    for (x = [-ht:4:3
ht])
        translate([x, 0, 0])
            rotate([0, 0, 135])
                square([wd, th]);
    }

intersection() {
    cube([wd, ht, vt]);
    linear_extrude(vt)
        Grid();
    }

When I use F5, I see what I expect: a grid.  When I use F6, I see a totally filled in rectangle, with the interior spaces gone.  If I only use F6 on the cube at the end, it is fine; if I only use F6 on the linear_extrude of the Grid, it is fine. What am I missing? inches = 25.4; vt = 1;                // vertical thickness th = 0.5;            // grid thickness ht = 1 * inches;    // 6 wd = 1 * inches;    // 9 module Grid() { *    for (y = [0:3:ht])         translate([0, y, 0])             square([wd, th]);     for (x = [-ht:4:2*ht])         translate([x, 0, 0])             rotate([0, 0, 45])                 square([wd, th]);     for (x = [-ht:4:3*ht])         translate([x, 0, 0])             rotate([0, 0, 135])                 square([wd, th]);     } intersection() {     cube([wd, ht, vt]);     linear_extrude(vt)         Grid();     }
NH
nop head
Tue, Sep 15, 2020 5:42 PM

ERROR: CGAL error in CGALUtils::applyBinaryOperator intersection: CGAL
ERROR: assertion violation! Expr: itl != it->second.end() File:
/mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Nef_3/SNC_external_structure.h
Line: 1152

This works though, and is much faster.

linear_extrude(vt)
intersection() {
square([wd, ht]);

    Grid();
 }

On Tue, 15 Sep 2020 at 15:28, jon jon@jonbondy.com wrote:

When I use F5, I see what I expect: a grid.  When I use F6, I see a
totally filled in rectangle, with the interior spaces gone.  If I only
use F6 on the cube at the end, it is fine; if I only use F6 on the
linear_extrude of the Grid, it is fine.

What am I missing?

inches = 25.4;
vt = 1;                // vertical thickness
th = 0.5;            // grid thickness
ht = 1 * inches;    // 6
wd = 1 * inches;    // 9

module Grid() {

  • for (y = [0:3:ht])
    translate([0, y, 0])
    square([wd, th]);
    for (x = [-ht:4:2ht])
    translate([x, 0, 0])
    rotate([0, 0, 45])
    square([wd, th]);
    for (x = [-ht:4:3
    ht])
    translate([x, 0, 0])
    rotate([0, 0, 135])
    square([wd, th]);
    }

intersection() {
cube([wd, ht, vt]);
linear_extrude(vt)
Grid();
}


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

ERROR: CGAL error in CGALUtils::applyBinaryOperator intersection: CGAL ERROR: assertion violation! Expr: itl != it->second.end() File: /mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Nef_3/SNC_external_structure.h Line: 1152 This works though, and is much faster. linear_extrude(vt) intersection() { square([wd, ht]); Grid(); } On Tue, 15 Sep 2020 at 15:28, jon <jon@jonbondy.com> wrote: > When I use F5, I see what I expect: a grid. When I use F6, I see a > totally filled in rectangle, with the interior spaces gone. If I only > use F6 on the cube at the end, it is fine; if I only use F6 on the > linear_extrude of the Grid, it is fine. > > What am I missing? > > > inches = 25.4; > vt = 1; // vertical thickness > th = 0.5; // grid thickness > ht = 1 * inches; // 6 > wd = 1 * inches; // 9 > > module Grid() { > * for (y = [0:3:ht]) > translate([0, y, 0]) > square([wd, th]); > for (x = [-ht:4:2*ht]) > translate([x, 0, 0]) > rotate([0, 0, 45]) > square([wd, th]); > for (x = [-ht:4:3*ht]) > translate([x, 0, 0]) > rotate([0, 0, 135]) > square([wd, th]); > } > > > intersection() { > cube([wd, ht, vt]); > linear_extrude(vt) > Grid(); > } > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
J
jon
Tue, Sep 15, 2020 5:51 PM

Thanks!  in retrospect, your optimization seems obvious.

Is the CGAL error a bug?

:)

On 9/15/2020 1:42 PM, nop head wrote:

ERROR: CGAL error in CGALUtils::applyBinaryOperator intersection: CGAL
ERROR: assertion violation! Expr: itl != it->second.end() File:
/mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Nef_3/SNC_external_structure.h
Line: 1152

This works though, and is much faster.

linear_extrude(vt)     intersection() {         square([wd, ht]);    
    Grid();      }

On Tue, 15 Sep 2020 at 15:28, jon <jon@jonbondy.com
mailto:jon@jonbondy.com> wrote:

 When I use F5, I see what I expect: a grid.  When I use F6, I see a
 totally filled in rectangle, with the interior spaces gone. If I only
 use F6 on the cube at the end, it is fine; if I only use F6 on the
 linear_extrude of the Grid, it is fine.

 What am I missing?


 inches = 25.4;
 vt = 1;                // vertical thickness
 th = 0.5;            // grid thickness
 ht = 1 * inches;    // 6
 wd = 1 * inches;    // 9

 module Grid() {
 *    for (y = [0:3:ht])
          translate([0, y, 0])
              square([wd, th]);
      for (x = [-ht:4:2*ht])
          translate([x, 0, 0])
              rotate([0, 0, 45])
                  square([wd, th]);
      for (x = [-ht:4:3*ht])
          translate([x, 0, 0])
              rotate([0, 0, 135])
                  square([wd, th]);
      }


 intersection() {
      cube([wd, ht, vt]);
      linear_extrude(vt)
          Grid();
      }


 _______________________________________________
 OpenSCAD mailing list
 Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org>
 http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

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

Thanks!  in retrospect, your optimization seems obvious. Is the CGAL error a bug? :) On 9/15/2020 1:42 PM, nop head wrote: > > ERROR: CGAL error in CGALUtils::applyBinaryOperator intersection: CGAL > ERROR: assertion violation! Expr: itl != it->second.end() File: > /mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Nef_3/SNC_external_structure.h > Line: 1152 > > This works though, and is much faster. > > linear_extrude(vt)     intersection() {         square([wd, ht]);     >     Grid();      } > > > On Tue, 15 Sep 2020 at 15:28, jon <jon@jonbondy.com > <mailto:jon@jonbondy.com>> wrote: > > When I use F5, I see what I expect: a grid.  When I use F6, I see a > totally filled in rectangle, with the interior spaces gone. If I only > use F6 on the cube at the end, it is fine; if I only use F6 on the > linear_extrude of the Grid, it is fine. > > What am I missing? > > > inches = 25.4; > vt = 1;                // vertical thickness > th = 0.5;            // grid thickness > ht = 1 * inches;    // 6 > wd = 1 * inches;    // 9 > > module Grid() { > *    for (y = [0:3:ht]) >          translate([0, y, 0]) >              square([wd, th]); >      for (x = [-ht:4:2*ht]) >          translate([x, 0, 0]) >              rotate([0, 0, 45]) >                  square([wd, th]); >      for (x = [-ht:4:3*ht]) >          translate([x, 0, 0]) >              rotate([0, 0, 135]) >                  square([wd, th]); >      } > > > intersection() { >      cube([wd, ht, vt]); >      linear_extrude(vt) >          Grid(); >      } > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org> > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
JB
Jordan Brown
Tue, Sep 15, 2020 5:56 PM

On 9/15/2020 7:27 AM, jon wrote:

When I use F5, I see what I expect: a grid.  When I use F6, I see a
totally filled in rectangle, with the interior spaces gone.  If I only
use F6 on the cube at the end, it is fine; if I only use F6 on the
linear_extrude of the Grid, it is fine.

What am I missing?

Not that it directly helps you, but it looks like you didn't notice this
error in the console pane:

ERROR: CGAL error in CGALUtils::applyBinaryOperator intersection:
CGAL ERROR: assertion violation! Expr: itl != it->second.end() File:
/mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Nef_3/SNC_external_structure.h
Line: 1152 

As I try to simplify it, I also get:

ERROR: CGAL error in CGALUtils::applyBinaryOperator intersection:
CGAL ERROR: assertion violation! Expr: cet->get_index() ==
ce->twin()->get_index() File:
/mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Nef_3/SNC_external_structure.h
Line: 1219 

And:

ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion
violation! Expr: e->incident_sface() != SFace_const_handle() File:
/mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Nef_S2/SM_const_decorator.h
Line: 329

I've also seen variations that just crash the program, and that yield

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

Here's the simplest example that I've been able to come up with:

union() {
    translate([-10,-10]) cube(1);
    linear_extrude(1) {
        translate([1.1, 0]) {
            rotate([0, 0, 45])
                square([25, 1.1]);
        }
        translate([1.1, 0]) {
            rotate([0, 0, 135])
                square([25.4, 1]);
        }
    }
}

Messing with the values - even the apparently irrelevant values like the
X dimensions of the squares - changes the behavior.

I think CGAL is upset that the two squares just barely touch each
other.  (Or, possibly, that after the various rounding and quantization
effects they touch each other along only one edge.)

A workaround is to nudge one set of squares just a little so that they
no longer perfectly align with the other, e.g.:

inches = 25.4;
vt = 1;                // vertical thickness
th = 0.5;            // grid thickness
ht = 1 * inches;    // 6
wd = 1 * inches;    // 9

module Grid() {
*    for (y = [0:3:ht])
        translate([0, y, 0])
            square([wd, th]);
    for (x = [-ht:4:2*ht])
        translate([x, 0.001, 0])       // <<<< nudge
            rotate([0, 0, 45])
                square([wd, th]);
    for (x = [-ht:4:3*ht])
        translate([x, 0, 0])
            rotate([0, 0, 135])
                square([wd, th]);
    }


intersection() {
    cube([wd, ht, vt]);
    linear_extrude(vt)
        Grid();
    } 
On 9/15/2020 7:27 AM, jon wrote: > When I use F5, I see what I expect: a grid.  When I use F6, I see a > totally filled in rectangle, with the interior spaces gone.  If I only > use F6 on the cube at the end, it is fine; if I only use F6 on the > linear_extrude of the Grid, it is fine. > > What am I missing? Not that it directly helps you, but it looks like you didn't notice this error in the console pane: ERROR: CGAL error in CGALUtils::applyBinaryOperator intersection: CGAL ERROR: assertion violation! Expr: itl != it->second.end() File: /mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Nef_3/SNC_external_structure.h Line: 1152 As I try to simplify it, I also get: ERROR: CGAL error in CGALUtils::applyBinaryOperator intersection: CGAL ERROR: assertion violation! Expr: cet->get_index() == ce->twin()->get_index() File: /mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Nef_3/SNC_external_structure.h Line: 1219 And: ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion violation! Expr: e->incident_sface() != SFace_const_handle() File: /mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Nef_S2/SM_const_decorator.h Line: 329 I've also seen variations that just crash the program, and that yield UI-WARNING: Object may not be a valid 2-manifold and may need repair! Here's the simplest example that I've been able to come up with: union() { translate([-10,-10]) cube(1); linear_extrude(1) { translate([1.1, 0]) { rotate([0, 0, 45]) square([25, 1.1]); } translate([1.1, 0]) { rotate([0, 0, 135]) square([25.4, 1]); } } } Messing with the values - even the apparently irrelevant values like the X dimensions of the squares - changes the behavior. I think CGAL is upset that the two squares just barely touch each other.  (Or, possibly, that after the various rounding and quantization effects they touch each other along only one edge.) A workaround is to nudge one set of squares just a little so that they no longer perfectly align with the other, e.g.: inches = 25.4; vt = 1; // vertical thickness th = 0.5; // grid thickness ht = 1 * inches; // 6 wd = 1 * inches; // 9 module Grid() { * for (y = [0:3:ht]) translate([0, y, 0]) square([wd, th]); for (x = [-ht:4:2*ht]) translate([x, 0.001, 0]) // <<<< nudge rotate([0, 0, 45]) square([wd, th]); for (x = [-ht:4:3*ht]) translate([x, 0, 0]) rotate([0, 0, 135]) square([wd, th]); } intersection() { cube([wd, ht, vt]); linear_extrude(vt) Grid(); }