[OpenSCAD] Why is this so heavy to OpenScad - PART 2?

MVAckel Mvackel at yahoo.com
Sat Nov 16 08:37:31 EST 2019


After solving the roundedBox() slow performance problem with the
roundedCube() module, I'd tried to go  one step further, making a
roundedCube with 2 radii (and it's more general than the one radius
version).

The problem here is that the hull in roundedCylinder() is also very slow,
making roundedCube2R() taking almost 9 seconds to preview.

Does anybody can suggest a faster approach?




//roundedCylinder(r=20, ra=4, h=50);
roundedCube2R([50,50,50], r1=10, r2=8, center=true);


module roundedCube2R(size, r1, r2, center=true) {
	s = is_list(size) ? size : [size,size,size];
	translate(center ? -s/2 : [0,0,0]) {
			hull() {
				translate([     r1,     r1]) roundedCylinder(r=r1, ra=r2, h=s[2]);
				translate([     r1,s[1]-r1]) roundedCylinder(r=r1, ra=r2, h=s[2]);
				translate([s[0]-r1,     r1]) roundedCylinder(r=r1, ra=r2, h=s[2]);
				translate([s[0]-r1,s[1]-r1]) roundedCylinder(r=r1, ra=r2, h=s[2]);
			}
	}
}
//--------------------------------------------------------------------------

module roundedCylinder(r, ra, h) {
	hull() {
		translate([0,0,ra])   rotate_extrude(convexity = 10) translate([r, 0, 0])
circle(r = ra);
		translate([0,0,h-ra]) rotate_extrude(convexity = 10) translate([r, 0, 0])
circle(r = ra);
	}
}	
//--------------------------------------------------------------------------







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



More information about the Discuss mailing list