discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Functional OpenSCAD, working with vertex data

P
Parkinbot
Tue, Jan 30, 2018 6:34 PM

thehans wrote

I wonder if we could alleviate most of the slowdown of implicit union
by having group nodes do a simple bounding box check before passing to
CGAL, if no bounding boxes overlap then just skip it?

This issue has also been discussed many times, in the context of
multithreading and also in the context with a lazy_union() operator.

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

thehans wrote > I wonder if we could alleviate most of the slowdown of implicit union > by having group nodes do a simple bounding box check before passing to > CGAL, if no bounding boxes overlap then just skip it? This issue has also been discussed many times, in the context of multithreading and also in the context with a lazy_union() operator. -- Sent from: http://forum.openscad.org/
P
Parkinbot
Tue, Jan 30, 2018 7:00 PM

Parkinbot wrote

See my implementation of a rounded_cylinder() and how it deals with
conflicts between diameters and radii. It is pretty fast, but I have no
way
to figure out, whether it is semantically equivalent with cylinder,
therefore I can't call cylinder() with all its parameters in case r_ is 0.

Sorry, here is my latest implementation:

$fa=.2;
$fs=.2;

module CyR(r = 10, h=10, r_=1, d = undef, r1=undef, r2=undef, d1 = undef, d2
= undef, center=false)
{
r1 = r1==undef?d1==undef?d==undef?r:d/2:d1/2:r1;
r2 = r2==undef?d2==undef?d==undef?r:d/2:d2/2:r2;
r_=min(abs(h/4), abs(r1), abs(r2), abs(r_));
h=abs(h);
translate([0,0,center?-h/2:0])
rotate_extrude()
intersection()
{
offset(r_)offset(-r_) polygon([[-2r_,0], [r1, 0], [r2, h], [0,h],
[-2
r_,h]] );
square(max(r1,r2), h);
}
}

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

Parkinbot wrote > > See my implementation of a rounded_cylinder() and how it deals with > conflicts between diameters and radii. It is pretty fast, but I have no > way > to figure out, whether it is semantically equivalent with cylinder, > therefore I can't call cylinder() with all its parameters in case r_ is 0. Sorry, here is my latest implementation: $fa=.2; $fs=.2; module CyR(r = 10, h=10, r_=1, d = undef, r1=undef, r2=undef, d1 = undef, d2 = undef, center=false) { r1 = r1==undef?d1==undef?d==undef?r:d/2:d1/2:r1; r2 = r2==undef?d2==undef?d==undef?r:d/2:d2/2:r2; r_=min(abs(h/4), abs(r1), abs(r2), abs(r_)); h=abs(h); translate([0,0,center?-h/2:0]) rotate_extrude() intersection() { offset(r_)offset(-r_) polygon([[-2*r_,0], [r1, 0], [r2, h], [0,h], [-2*r_,h]] ); square(max(r1,r2), h); } } -- Sent from: http://forum.openscad.org/
CA
Carsten Arnholm
Tue, Jan 30, 2018 7:05 PM

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

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
J
jon
Tue, Jan 30, 2018 7:25 PM

I would welcome a switch that turned off implicit union, if the result
was better performance.  I understand that I would need to alter my
source code, and that I might need to modify library source code.

Jon

On 1/30/2018 2:05 PM, Carsten Arnholm wrote:

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@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.

I would welcome a switch that turned off implicit union, if the result was better performance.  I understand that I would need to alter my source code, and that I might need to modify library source code. Jon On 1/30/2018 2:05 PM, Carsten Arnholm wrote: > 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@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.
HL
Hans L
Tue, Jan 30, 2018 7:35 PM

By the way, here is a relevant issue that looks like had a lot of work
done towards it but never completely finalized.

Lazy union (aka. no implicit union):
https://github.com/openscad/openscad/issues/350

On Tue, Jan 30, 2018 at 1:25 PM, jon jon@jonbondy.com wrote:

I would welcome a switch that turned off implicit union, if the result was
better performance.  I understand that I would need to alter my source code,
and that I might need to modify library source code.

Jon

On 1/30/2018 2:05 PM, Carsten Arnholm wrote:

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@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.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

By the way, here is a relevant issue that looks like had a lot of work done towards it but never completely finalized. Lazy union (aka. no implicit union): https://github.com/openscad/openscad/issues/350 On Tue, Jan 30, 2018 at 1:25 PM, jon <jon@jonbondy.com> wrote: > I would welcome a switch that turned off implicit union, if the result was > better performance. I understand that I would need to alter my source code, > and that I might need to modify library source code. > > Jon > > > > On 1/30/2018 2:05 PM, Carsten Arnholm wrote: >> >> 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@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. > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
AB
Antonio Bueno
Tue, Jan 30, 2018 7:35 PM

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@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@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

--
Saludos,
Antonio

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@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@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > -- Saludos, Antonio
CA
Carsten Arnholm
Tue, Jan 30, 2018 8:07 PM

On 30. jan. 2018 20:35, Antonio Bueno wrote:

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

Implicit or explicit union takes time. You are doing both in this case.

Why not simplify. Shorter, easier code. And faster.

size=30;
radius=1;
$fn=60;
hull() {
translate([-size/2, -size/2, -size/2]) sphere(radius);
translate([+size/2, -size/2, -size/2]) sphere(radius);
translate([+size/2, +size/2, -size/2]) sphere(radius);
translate([-size/2, +size/2, -size/2]) sphere(radius);

 translate([-size/2, -size/2, +size/2]) sphere(radius);
 translate([+size/2, -size/2, +size/2]) sphere(radius);
 translate([+size/2, +size/2, +size/2]) sphere(radius);
 translate([-size/2, +size/2, +size/2]) sphere(radius);

}

Carsten Arnholm

On 30. jan. 2018 20:35, Antonio Bueno wrote: > Any insight in why the first hull() (the one with explicit union()) is > faster (16s*) than the second one (26s)? Implicit or explicit union takes time. You are doing both in this case. Why not simplify. Shorter, easier code. And faster. size=30; radius=1; $fn=60; hull() { translate([-size/2, -size/2, -size/2]) sphere(radius); translate([+size/2, -size/2, -size/2]) sphere(radius); translate([+size/2, +size/2, -size/2]) sphere(radius); translate([-size/2, +size/2, -size/2]) sphere(radius); translate([-size/2, -size/2, +size/2]) sphere(radius); translate([+size/2, -size/2, +size/2]) sphere(radius); translate([+size/2, +size/2, +size/2]) sphere(radius); translate([-size/2, +size/2, +size/2]) sphere(radius); } Carsten Arnholm
HL
Hans L
Tue, Jan 30, 2018 8:12 PM

Its basically just easier for CGAL to handle a bunch of smaller unions
than one big one.

On Tue, Jan 30, 2018 at 2:07 PM, Carsten Arnholm arnholm@arnholm.org wrote:

On 30. jan. 2018 20:35, Antonio Bueno wrote:

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

Implicit or explicit union takes time. You are doing both in this case.

Why not simplify. Shorter, easier code. And faster.

size=30;
radius=1;
$fn=60;
hull() {
translate([-size/2, -size/2, -size/2]) sphere(radius);
translate([+size/2, -size/2, -size/2]) sphere(radius);
translate([+size/2, +size/2, -size/2]) sphere(radius);
translate([-size/2, +size/2, -size/2]) sphere(radius);

 translate([-size/2, -size/2, +size/2]) sphere(radius);
 translate([+size/2, -size/2, +size/2]) sphere(radius);
 translate([+size/2, +size/2, +size/2]) sphere(radius);
 translate([-size/2, +size/2, +size/2]) sphere(radius);

}

Carsten Arnholm


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Its basically just easier for CGAL to handle a bunch of smaller unions than one big one. On Tue, Jan 30, 2018 at 2:07 PM, Carsten Arnholm <arnholm@arnholm.org> wrote: > On 30. jan. 2018 20:35, Antonio Bueno wrote: >> >> Any insight in why the first hull() (the one with explicit union()) is >> faster (16s*) than the second one (26s)? > > > Implicit or explicit union takes time. You are doing both in this case. > > Why not simplify. Shorter, easier code. And faster. > > size=30; > radius=1; > $fn=60; > hull() { > translate([-size/2, -size/2, -size/2]) sphere(radius); > translate([+size/2, -size/2, -size/2]) sphere(radius); > translate([+size/2, +size/2, -size/2]) sphere(radius); > translate([-size/2, +size/2, -size/2]) sphere(radius); > > translate([-size/2, -size/2, +size/2]) sphere(radius); > translate([+size/2, -size/2, +size/2]) sphere(radius); > translate([+size/2, +size/2, +size/2]) sphere(radius); > translate([-size/2, +size/2, +size/2]) sphere(radius); > > } > > Carsten Arnholm > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
N
NateTG
Wed, Jan 31, 2018 2:40 PM

Its basically just easier for CGAL to handle a bunch of smaller unions

than one big one.

If that's true, then can OpenSCAD get a performance improvement with divide
and conquer?

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

> Its basically just easier for CGAL to handle a bunch of smaller unions than one big one. If that's true, then can OpenSCAD get a performance improvement with divide and conquer? -- Sent from: http://forum.openscad.org/
N
NateTG
Thu, Feb 8, 2018 2:33 AM

As an attempt to attack the problem of booleans, I wrote an octree voxelizer

  • that would make the boolean operations trivial, but it seems too slow to
    be viable.

octree.scad http://forum.openscad.org/file/t2140/octree.scad

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

As an attempt to attack the problem of booleans, I wrote an octree voxelizer - that would make the boolean operations trivial, but it seems too slow to be viable. octree.scad <http://forum.openscad.org/file/t2140/octree.scad> -- Sent from: http://forum.openscad.org/