discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

difference + module operator with strange behaviour

P
Parkinbot
Sun, Apr 9, 2017 8:45 PM

Hi folks,
I use a shortcut for the difference() operator called D(). In some cases,
when I apply it on a set of children that has an empty intersection I get
this:

WARNING: Normalized tree is growing past 4000000 elements. Aborting
normalization.
WARNING: CSG normalization resulted in an empty tree

Must be a bug, because if I do a /translate([20, 0])/  instead of
/translate([-10, 0])/ for the third child, it works even if the intersection
is empty.
If I use /difference()/ instead of /D()/ it always works. Any suggestions?

The problem does not occur with OpenSCAD 2015.03, but with all 2016.xx and
2017.xx I have.
Here is my code:

//block(30);  // works
block(10);  // freaks out
module block(d)
{
D()
{
cube([d, 15, 6], center=true);
translate([10, 0]) cylinder(r=2, h=20,  center=true);
translate([-10, 0]) cylinder(r=2, h=20, center=true);  // works with
translate([20, 0])
}
}

module D()
if($children>1)
difference(){children(0); children([1:$children-1]);}
else children();

--
View this message in context: http://forum.openscad.org/difference-module-operator-with-strange-behaviour-tp21146.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Hi folks, I use a shortcut for the difference() operator called D(). In some cases, when I apply it on a set of children that has an empty intersection I get this: > WARNING: Normalized tree is growing past 4000000 elements. Aborting > normalization. > WARNING: CSG normalization resulted in an empty tree Must be a bug, because if I do a /translate([20, 0])/ instead of /translate([-10, 0])/ for the third child, it works even if the intersection is empty. If I use /difference()/ instead of /D()/ it always works. Any suggestions? The problem does not occur with OpenSCAD 2015.03, but with all 2016.xx and 2017.xx I have. Here is my code: > //block(30); // works > block(10); // freaks out > module block(d) > { > D() > { > cube([d, 15, 6], center=true); > translate([10, 0]) cylinder(r=2, h=20, center=true); > translate([-10, 0]) cylinder(r=2, h=20, center=true); // works with > translate([20, 0]) > } > } > > module D() > if($children>1) > difference(){children(0); children([1:$children-1]);} > else children(); -- View this message in context: http://forum.openscad.org/difference-module-operator-with-strange-behaviour-tp21146.html Sent from the OpenSCAD mailing list archive at Nabble.com.
M
MichaelAtOz
Mon, Apr 10, 2017 12:21 AM

Yeh, looks like a bug.
I changed children([1:$children-1]) to a for(), no change.
They differ in difference() processes three children, D() processes two,
children(0) & union([the two other children]).
Changing code to actually union(), causes the issue
Tho I can't see why that would be a problem...
Making them a group, { children(1); children(2); } does not cause the issue.

I note that putting a '#' in front of either translate() doesn't cause the
issue...

I'll raise a Git Issue.


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

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.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/  time is running out!

View this message in context: http://forum.openscad.org/difference-module-operator-with-strange-behaviour-tp21146p21149.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Yeh, looks like a bug. I changed children([1:$children-1]) to a for(), no change. They differ in difference() processes three children, D() processes two, children(0) & union([the two other children]). Changing code to actually union(), causes the issue Tho I can't see why that would be a problem... Making them a group, { children(1); children(2); } does not cause the issue. I note that putting a '#' in front of either translate() doesn't cause the issue... I'll raise a Git Issue. ----- Admin - PM me if you need anything, or if I've done something stupid... 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. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out! -- View this message in context: http://forum.openscad.org/difference-module-operator-with-strange-behaviour-tp21146p21149.html Sent from the OpenSCAD mailing list archive at Nabble.com.
M
MichaelAtOz
Mon, Apr 10, 2017 12:28 AM

Minimal example.

difference()
{
cube([10, 15, 6], center=true);
//union()
{
translate([10, 0]) cylinder(r=2, h=20,  center=true);
translate([-10, 0]) cylinder(r=2, h=20, center=true);  // works
with translate([20, 0])
}

}

Works, uncomment union(), doesn't.


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

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.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/  time is running out!

View this message in context: http://forum.openscad.org/difference-module-operator-with-strange-behaviour-tp21146p21150.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Minimal example. > difference() > { > cube([10, 15, 6], center=true); > //union() > { > translate([10, 0]) cylinder(r=2, h=20, center=true); > translate([-10, 0]) cylinder(r=2, h=20, center=true); // works > with translate([20, 0]) > } > > } Works, uncomment union(), doesn't. ----- Admin - PM me if you need anything, or if I've done something stupid... 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. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out! -- View this message in context: http://forum.openscad.org/difference-module-operator-with-strange-behaviour-tp21146p21150.html Sent from the OpenSCAD mailing list archive at Nabble.com.
M
MichaelAtOz
Mon, Apr 10, 2017 12:47 AM

Git  issue 1988 https://github.com/openscad/openscad/issues/1988  .


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

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.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/  time is running out!

View this message in context: http://forum.openscad.org/difference-module-operator-with-strange-behaviour-tp21146p21151.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Git issue 1988 <https://github.com/openscad/openscad/issues/1988> . ----- Admin - PM me if you need anything, or if I've done something stupid... 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. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out! -- View this message in context: http://forum.openscad.org/difference-module-operator-with-strange-behaviour-tp21146p21151.html Sent from the OpenSCAD mailing list archive at Nabble.com.