discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

difference() over intersection_for() crashes

P
Parkinbot
Wed, Jul 17, 2019 10:35 PM

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/

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/
TP
Torsten Paul
Wed, Jul 17, 2019 10:48 PM

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.

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.
M
MichaelAtOz
Wed, Jul 17, 2019 11:20 PM

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,362,363,364,365])
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/

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/
P
Parkinbot
Thu, Jul 18, 2019 12:50 AM

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/

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/