[OpenSCAD] Functional OpenSCAD, working with vertex data
jon
jon at jonbondy.com
Tue Jan 30 10:51:19 EST 2018
Sorry to be clueless, but why is it faster to enumerate the explicit
locations of the spheres vs having them in a loop?
Jon
On 1/30/2018 10:42 AM, Parkinbot 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
>
>
--
Sent from my desktop computer.
I do not receive emails while away from my desk,
nor do I receive texts on my main phone number
(which is a land line).
If you know that I am on the road, please text me.
If you know that I am home, please email me.
More information about the Discuss
mailing list