difference() over intersection_for() crashes

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

difference() over intersection_for() crashes

Parkinbot
why does this innocent piece of code crash?

R1 = 25;
d = 10;
n = 10;
r = 8;

difference()
{
   sphere(R1);
   for(i=[0:n-1])
     rotate([0, 0, i*360/n ]) translate([R1, 0, 0]) tri();  
}
module tri()
{
  rotate([0, 90, 0])
  intersection_for(i=[0:120:359])
  rotate(i) translate([d/3, 0, 0]) cylinder(r=d, h = r, center = true);
}




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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
tp3
Reply | Threaded
Open this post in threaded view
|

Re: difference() over intersection_for() crashes

tp3
On 18.07.19 00:35, Parkinbot wrote:
> why does this innocent piece of code crash?

It does not crash for me, but gives warning.
WARNING: Normalized tree is growing past 2000000 elements. Aborting normalization.

I guess it crashes because it runs out of stack space
when calculating the CSG tree which is exploding due
to the intersections like mentioned there:
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/FAQ#Why_is_the_preview_so_slow?

Adding a render() at the top of tri() makes it produce
instant result.

ciao,
  Torsten.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
-- Torsten
Reply | Threaded
Open this post in threaded view
|

Re: difference() over intersection_for() crashes

MichaelAtOz
Administrator
No crash for me.
Initially it looked like a hang, but it came back eventually, with VEEERY
slow preview motion updates.
I have preference/Turn off rendering at = 100000000 so I didn't get the
warning.

When debugging I changed the loop to angle based

   for(a=[0,36,36*2,36*3,36*4,36*5])
    rotate([0, 0, a ])

As I added more 36*n's, preview performance went down quickly.



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

* 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.

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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Admin - email* me if you need anything,
or if I've done something stupid...
* 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.


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() over intersection_for() crashes

Parkinbot
In reply to this post by tp3
It is not a real crash, but the session hangs.  

I changed the code of tri(), and used a 2D intersection followed by a
linear_extrude. This gives an instant result.




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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org