discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

puzzling performance issue

J
jon
Mon, Aug 15, 2016 9:41 PM

If you do an F5 on this, it takes a little while to compute, but it
manages OK.  But if you change ":5:" to simply ":" on line 26, it never
recovers.  The render takes almost no time, but the display never
completes.  I have to kill OpenSCAD.

I imagine that this is well known/understood.  The thing that surprised
me was that the simple factor of 5 killed it dead.

Jon

$fn = 100;
ht = 21;
id = 12;
od = 30;
th = 1.5;    // wall thickness
cTh = 2;    // thickness of the cord

ir = id/2;
or = od/2;

module torus()
rotate_extrude(convexity = 10)
translate([ir, 0, 0])
difference() {
// outside
square([or - ir, ht]);
// remove interior
translate([th, th, 0])
square([or - ir - 2th, ht - 2th]);
}

translate([0, 0, 1])
difference() {
torus();
// remove a band
for (i = [1:5:360])
translate([0, 0, i > 45 ? 5 : sin(4*i) * 10 + 5])
rotate([0, 0, i])
rotate([90, 0 , 0])
cylinder(h = od, d = cTh);
}

If you do an F5 on this, it takes a little while to compute, but it manages OK. But if you change ":5:" to simply ":" on line 26, it never recovers. The render takes almost no time, but the display never completes. I have to kill OpenSCAD. I imagine that this is well known/understood. The thing that surprised me was that the simple factor of 5 killed it dead. Jon $fn = 100; ht = 21; id = 12; od = 30; th = 1.5; // wall thickness cTh = 2; // thickness of the cord ir = id/2; or = od/2; module torus() rotate_extrude(convexity = 10) translate([ir, 0, 0]) difference() { // outside square([or - ir, ht]); // remove interior translate([th, th, 0]) square([or - ir - 2*th, ht - 2*th]); } translate([0, 0, 1]) difference() { torus(); // remove a band for (i = [1:5:360]) translate([0, 0, i > 45 ? 5 : sin(4*i) * 10 + 5]) rotate([0, 0, i]) rotate([90, 0 , 0]) cylinder(h = od, d = cTh); }
PF
Peter Falke
Mon, Aug 15, 2016 11:36 PM

Just add  translate([0,0,5]) before your cylinder.
This will get rid off all the overlapping cylinders at the origin, and
greatly speed up F6.

2016-08-15 23:41 GMT+02:00 jon jon@jonbondy.com:

If you do an F5 on this, it takes a little while to compute, but it
manages OK.  But if you change ":5:" to simply ":" on line 26, it never
recovers.  The render takes almost no time, but the display never
completes.  I have to kill OpenSCAD.

I imagine that this is well known/understood.  The thing that surprised me
was that the simple factor of 5 killed it dead.

Jon

$fn = 100;
ht = 21;
id = 12;
od = 30;
th = 1.5;    // wall thickness
cTh = 2;    // thickness of the cord

ir = id/2;
or = od/2;

module torus()
rotate_extrude(convexity = 10)
translate([ir, 0, 0])
difference() {
// outside
square([or - ir, ht]);
// remove interior
translate([th, th, 0])
square([or - ir - 2th, ht - 2th]);
}

translate([0, 0, 1])
difference() {
torus();
// remove a band
for (i = [1:5:360])
translate([0, 0, i > 45 ? 5 : sin(4*i) * 10 + 5])
rotate([0, 0, i])
rotate([90, 0 , 0])
cylinder(h = od, d = cTh);
}


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

Just add translate([0,0,5]) before your cylinder. This will get rid off all the overlapping cylinders at the origin, and greatly speed up F6. 2016-08-15 23:41 GMT+02:00 jon <jon@jonbondy.com>: > If you do an F5 on this, it takes a little while to compute, but it > manages OK. But if you change ":5:" to simply ":" on line 26, it never > recovers. The render takes almost no time, but the display never > completes. I have to kill OpenSCAD. > > I imagine that this is well known/understood. The thing that surprised me > was that the simple factor of 5 killed it dead. > > Jon > > > > $fn = 100; > ht = 21; > id = 12; > od = 30; > th = 1.5; // wall thickness > cTh = 2; // thickness of the cord > > ir = id/2; > or = od/2; > > module torus() > rotate_extrude(convexity = 10) > translate([ir, 0, 0]) > difference() { > // outside > square([or - ir, ht]); > // remove interior > translate([th, th, 0]) > square([or - ir - 2*th, ht - 2*th]); > } > > translate([0, 0, 1]) > difference() { > torus(); > // remove a band > for (i = [1:5:360]) > translate([0, 0, i > 45 ? 5 : sin(4*i) * 10 + 5]) > rotate([0, 0, i]) > rotate([90, 0 , 0]) > cylinder(h = od, d = cTh); > } > > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
MK
Marius Kintel
Wed, Aug 17, 2016 9:37 PM

I imagine that this is well known/understood.  The thing that surprised me was that the simple factor of 5 killed it dead.

In preview mode, your framerate will be very slow, due to how previews are rendered.
My laptop takes ~5-6 seconds per frame. If you have a low end GPU, this can be painful.

-Marius

> > I imagine that this is well known/understood. The thing that surprised me was that the simple factor of 5 killed it dead. > In preview mode, your framerate will be very slow, due to how previews are rendered. My laptop takes ~5-6 seconds per frame. If you have a low end GPU, this can be painful. -Marius