[OpenSCAD] Functional OpenSCAD, working with vertex data

Hans L thehans at gmail.com
Tue Jan 30 11:49:42 EST 2018

Oh, wow.  I guess I had always assumed that hull was a CGAL operation.

You say this belongs in a library, but is there a single library that
has a properly implemented rounded cube?  Everyone's implementation is
different and 99.9% of them are slow and/or poduce ugly geometry.
This is why It should be standardized from the source.

I guess what I'm saying is at the very least MCAD should get updated
with an efficient module like you wrote here, because I think its
currently using what is more-or-less the same implementation as that
example006.scad I mentioned.
Also I should just say that my attention was originally drawn to
example006.scad a while ago when I was looking at improving OpenSCAD's
Travis build times, particularly in the execution time of individual
tests.  And example006.scad was one of the longest running tests.


On Tue, Jan 30, 2018 at 9:42 AM, Parkinbot <rudolf at parkinbot.com> wrote:
> thehans wrote
>> Here is a quick implementation of the rounded cube concept which I
>> made as a module, since this version *does* still require one hull
>> operation.
>> https://gist.github.com/thehans/2c96601af4e5c8c2d232e50252dd37b1
> let me annote that hull() itself is not the problem. To avoid a time
> consuming CGAL round trip, don't use (implicit) unions inside a hull(). If
> you implement rounded_cube() more explicitely, rendering is fast (seconds).
> $fa = 0.1;
> $fs = 0.1;
> rounded_cube_([4, 20, 5], r=1, center=[1,1,1]);
> module rounded_cube_(size, r=0, center=false)
> {
>   sz = size[0]==undef?[size, size, size]:size;
>   ce = center[0]==undef?[center, center, center]:center;
>   r_ = min(abs(r), abs(size.x/2), abs(size.y/2), abs(size.z/2));  // correct
> r
>   translate([ce.x?-sz.x/2:0,ce.y?-sz.y/2:0, ce.z?-sz.z/2:0])
>   if(r)
>     hull()
>     {
>       translate([r_, r_, r_]) sphere(r_);
>       translate([r_, r_, sz.z-r_]) sphere(r_);
>       translate([r_, sz.y-r_, r_]) sphere(r_);
>       translate([r_, sz.y-r_, sz.z-r_]) sphere(r_);
>       translate([sz.x-r_, r_, r_]) sphere(r_);
>       translate([sz.x-r_, r_, sz.z-r_]) sphere(r_);
>       translate([sz.x-r_, sz.y-r_, r_]) sphere(r_);
>       translate([sz.x-r_, sz.y-r_, sz.z-r_]) sphere(r_);
>     }
>   else
>     cube(size);
> }
> in contrast the following call of hull will take minutes.
>   hull()
>   for(x=[r_,size.x-r_], y=[r_,size.y-r_], z=[r_,size.z-r_])
>     translate([x,y,z]) sphere(r_);
> However, rounded_cube_ is currently a typical libary module. I wouldn't add
> it to the core language unless cylinder(), linear_extrude() and maybe hull()
> also get a r parameter.
> --
> Sent from: http://forum.openscad.org/
> _______________________________________________
> OpenSCAD mailing list
> Discuss at lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

More information about the Discuss mailing list