[OpenSCAD] Functional OpenSCAD, working with vertex data

Antonio Bueno atnbueno at gmail.com
Tue Jan 30 14:35:57 EST 2018


Any insight in why the first hull() (the one with explicit union()) is
faster (16s*) than the second one (26s)?

(*) These times are with version 2018.01.06, Windows 10 x64, i5-4570S @
2.90GHz and 32 GB of RAM


size=30;
radius=1;
$fn=60;
// 16s if $fn=60
hull() {
union() translate([size/2, size/2]) {
translate([0, 0, -size/2]) sphere(radius);
translate([0, 0, size/2]) sphere(radius);
cylinder(radius, h=size, center=true);
}
rotate(90) union() translate([size/2, size/2]) {
translate([0, 0, -size/2]) sphere(radius);
translate([0, 0, size/2]) sphere(radius);
cylinder(radius, h=size, center=true);
}
rotate(180) union() translate([size/2, size/2]) {
translate([0, 0, -size/2]) sphere(radius);
translate([0, 0, size/2]) sphere(radius);
cylinder(radius, h=size, center=true);
}
rotate(270) union() translate([size/2, size/2]) {
translate([0, 0, -size/2]) sphere(radius);
translate([0, 0, size/2]) sphere(radius);
cylinder(radius, h=size, center=true);
}
}

// 26s if $fn=60
hull() {
translate([size/2, size/2]) {
translate([0, 0, -size/2]) sphere(radius);
translate([0, 0, size/2]) sphere(radius);
cylinder(radius, h=size, center=true);
}
rotate(90) translate([size/2, size/2]) {
translate([0, 0, -size/2]) sphere(radius);
translate([0, 0, size/2]) sphere(radius);
cylinder(radius, h=size, center=true);
}
rotate(180) translate([size/2, size/2]) {
translate([0, 0, -size/2]) sphere(radius);
translate([0, 0, size/2]) sphere(radius);
cylinder(radius, h=size, center=true);
}
rotate(270) translate([size/2, size/2]) {
translate([0, 0, -size/2]) sphere(radius);
translate([0, 0, size/2]) sphere(radius);
cylinder(radius, h=size, center=true);
}
}

(I know there are faster methods to do that, but they are a couple of
samples from an speed test I did some time ago and illustrate well my doubt)

2018-01-30 20:05 GMT+01:00 Carsten Arnholm <arnholm at arnholm.org>:

> On 30. jan. 2018 17:49, Jordan Brown wrote:
>
>> Not knowing how hull( ) works, I wouldn't have expected there to be a
>> difference.
>>
>> Good information, thanks.
>>
>
> The problem is not hull(), but implicit union. Hull only needs the points
> in the input mesh(es). Applying [implicit] union() before applying hull()
> to the result is like unknowingly driving with the hand brake engaged. You
> perform a potentially costly computation (union()) only to immediately
> throw away the result.
>
> One idea would be to provide an option to switch off implicit union, and
> such issues will go away.
>
> Carsten Arnholm
>
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss at lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>



-- 
Saludos,
Antonio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20180130/e78d11ad/attachment-0002.html>


More information about the Discuss mailing list