openscad / MCAD

OpenSCAD Parametric CAD Library (LGPL 2.1)
http://reprap.org/wiki/MCAD
578 stars 192 forks source link

More efficient and configurable implementation for roundedBox (roundedCube) #66

Closed thehans closed 4 years ago

thehans commented 4 years ago

This PR changes roundedBox to use hull. Using hull makes it much more efficient to compute, and the geometry (rounded cube corners) is more correct without mismatched seams between spheres/cylinders in the corners/edges of the rounded cube.

I also thought it would make most sense to stick to the parameter conventions used by OpenSCAD native modules: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Primitive_Solids#cube so the following changes where made: 1) In addition to size=[x,y,z] the new version optionally accepts a single number for size, which applies to all three dimensions. 2) roundedBox had no center parameter, it was always centered. The new module now provides the option, and defaults to not centered, just as the native cube module does. 3) minor change but parameter name r is more conventional than radius (used by cylinder, sphere etc.) so the new module also uses r.

Since the interface for this module would have changed, I thought it would be best to "deprecate" roundedBox by echoing a "warning" statement and name the new module roundedCube so that old scripts using MCAD can remain backwards compatible.