difference + module operator with strange behaviour

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

difference + module operator with strange behaviour

Parkinbot
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();
Reply | Threaded
Open this post in threaded view
|

Re: difference + module operator with strange behaviour

MichaelAtOz
Administrator
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!
Reply | Threaded
Open this post in threaded view
|

Re: difference + module operator with strange behaviour

MichaelAtOz
Administrator
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!
Reply | Threaded
Open this post in threaded view
|

Re: difference + module operator with strange behaviour

MichaelAtOz
Administrator
Git issue 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!