hull and union?

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

hull and union?

szabi
Dear all!

I have a case where I want to take the hull on a number of objects. These objects overlap (generated by a for-loop).

We have previously heard, that unions take relatively long, while hull is supposed to be fast.

Now, in this case OpenSCAD first does to union, and then takes the hull, making the whole issue slow.

Would removing the implicit union (as already suggested by several ones before) increase the performance in this case?

Thanks!

--
Szelp, André Szabolcs

+43 (650) 79 22 400

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: hull and union?

szabi
Here comes a concrete example:

j=1; // 1 or 4


hull() {

  for(i=[0:j:j*10]) {

    translate([i,0,0]) sphere(1,$fn=32);

  }

}


With j = 4 (no overlap) this renders in 2 seconds on my computer.

With j = 1 (10 overlaps) this renders in 2 min 16 sec, which is slower by a factor of 60!


(In the above example this very hull could be created by two spheres only, but in my use case they lie on a curve, so I need a number of spheres, and they do overlap).


Another case for removing implicit union?




Szelp, André Szabolcs

+43 (650) 79 22 400


On Thu, Mar 20, 2014 at 4:04 PM, Szelp, A. Sz. <[hidden email]> wrote:
Dear all!

I have a case where I want to take the hull on a number of objects. These objects overlap (generated by a for-loop).

We have previously heard, that unions take relatively long, while hull is supposed to be fast.

Now, in this case OpenSCAD first does to union, and then takes the hull, making the whole issue slow.

Would removing the implicit union (as already suggested by several ones before) increase the performance in this case?

Thanks!

--
Szelp, André Szabolcs

<a href="tel:%2B43%20%28650%29%2079%2022%20400" value="+436507922400" target="_blank">+43 (650) 79 22 400


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: hull and union?

drxenocide
In reply to this post by szabi
From my experience with it, if you have hull(){ union(){ A(); B();} } }, then you could just have hull(){ A(); B();}

For me it reduced computation time by a lot - I noticed a large reduction in facets, but because I was taking a hull(), I assumed those facets were inside what I cared about, therefore they were facets I wasnt going to see anyway.


On Thu, Mar 20, 2014 at 11:04 AM, Szelp, A. Sz. <[hidden email]> wrote:
Dear all!

I have a case where I want to take the hull on a number of objects. These objects overlap (generated by a for-loop).

We have previously heard, that unions take relatively long, while hull is supposed to be fast.

Now, in this case OpenSCAD first does to union, and then takes the hull, making the whole issue slow.

Would removing the implicit union (as already suggested by several ones before) increase the performance in this case?

Thanks!

--
Szelp, André Szabolcs

<a href="tel:%2B43%20%28650%29%2079%2022%20400" value="+436507922400" target="_blank">+43 (650) 79 22 400

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: hull and union?

drxenocide
That was almost exactly the structure of my example. Just do it!


On Thu, Mar 20, 2014 at 11:19 AM, Ari Diacou <[hidden email]> wrote:
From my experience with it, if you have hull(){ union(){ A(); B();} } }, then you could just have hull(){ A(); B();}

For me it reduced computation time by a lot - I noticed a large reduction in facets, but because I was taking a hull(), I assumed those facets were inside what I cared about, therefore they were facets I wasnt going to see anyway.


On Thu, Mar 20, 2014 at 11:04 AM, Szelp, A. Sz. <[hidden email]> wrote:
Dear all!

I have a case where I want to take the hull on a number of objects. These objects overlap (generated by a for-loop).

We have previously heard, that unions take relatively long, while hull is supposed to be fast.

Now, in this case OpenSCAD first does to union, and then takes the hull, making the whole issue slow.

Would removing the implicit union (as already suggested by several ones before) increase the performance in this case?

Thanks!

--
Szelp, André Szabolcs

<a href="tel:%2B43%20%28650%29%2079%2022%20400" value="+436507922400" target="_blank">+43 (650) 79 22 400

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: hull and union?

szabi
In reply to this post by drxenocide
No, you don't understand...

the for loop implicitly does an union. I cannot not-union with overlapping spheres, even though I'd like to (for performance reasons)...

Szelp, André Szabolcs

+43 (650) 79 22 400


On Thu, Mar 20, 2014 at 4:19 PM, Ari Diacou <[hidden email]> wrote:
From my experience with it, if you have hull(){ union(){ A(); B();} } }, then you could just have hull(){ A(); B();}

For me it reduced computation time by a lot - I noticed a large reduction in facets, but because I was taking a hull(), I assumed those facets were inside what I cared about, therefore they were facets I wasnt going to see anyway.


On Thu, Mar 20, 2014 at 11:04 AM, Szelp, A. Sz. <[hidden email]> wrote:
Dear all!

I have a case where I want to take the hull on a number of objects. These objects overlap (generated by a for-loop).

We have previously heard, that unions take relatively long, while hull is supposed to be fast.

Now, in this case OpenSCAD first does to union, and then takes the hull, making the whole issue slow.

Would removing the implicit union (as already suggested by several ones before) increase the performance in this case?

Thanks!

--
Szelp, André Szabolcs

<a href="tel:%2B43%20%28650%29%2079%2022%20400" value="+436507922400" target="_blank">+43 (650) 79 22 400

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: hull and union?

Kevin Crowley
This look like an issue that the new but now yet incorporated extrude functions would be useful.


On Thu, Mar 20, 2014 at 10:24 AM, Szelp, A. Sz. <[hidden email]> wrote:
No, you don't understand...

the for loop implicitly does an union. I cannot not-union with overlapping spheres, even though I'd like to (for performance reasons)...

Szelp, André Szabolcs

<a href="tel:%2B43%20%28650%29%2079%2022%20400" value="+436507922400" target="_blank">+43 (650) 79 22 400


On Thu, Mar 20, 2014 at 4:19 PM, Ari Diacou <[hidden email]> wrote:
From my experience with it, if you have hull(){ union(){ A(); B();} } }, then you could just have hull(){ A(); B();}

For me it reduced computation time by a lot - I noticed a large reduction in facets, but because I was taking a hull(), I assumed those facets were inside what I cared about, therefore they were facets I wasnt going to see anyway.


On Thu, Mar 20, 2014 at 11:04 AM, Szelp, A. Sz. <[hidden email]> wrote:
Dear all!

I have a case where I want to take the hull on a number of objects. These objects overlap (generated by a for-loop).

We have previously heard, that unions take relatively long, while hull is supposed to be fast.

Now, in this case OpenSCAD first does to union, and then takes the hull, making the whole issue slow.

Would removing the implicit union (as already suggested by several ones before) increase the performance in this case?

Thanks!

--
Szelp, André Szabolcs

<a href="tel:%2B43%20%28650%29%2079%2022%20400" value="+436507922400" target="_blank">+43 (650) 79 22 400

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: hull and union?

szabi
Yeah, in my particular instance the "new" parametrized extrude would work perfectly, though not in every situation I could imagine.

Still there are use cases where you'd want to take the hull of overlapping objects (and only need the hull). With the current behaviour (i.e. implicit union of objects of equal level in the tree) this is sub-optimal in terms of performance.

Take it as an input for the case of no implicit unions.

Szelp, André Szabolcs

+43 (650) 79 22 400


On Thu, Mar 20, 2014 at 4:30 PM, Kevin Crowley <[hidden email]> wrote:
This look like an issue that the new but now yet incorporated extrude functions would be useful.


On Thu, Mar 20, 2014 at 10:24 AM, Szelp, A. Sz. <[hidden email]> wrote:
No, you don't understand...

the for loop implicitly does an union. I cannot not-union with overlapping spheres, even though I'd like to (for performance reasons)...

Szelp, André Szabolcs

<a href="tel:%2B43%20%28650%29%2079%2022%20400" value="+436507922400" target="_blank">+43 (650) 79 22 400


On Thu, Mar 20, 2014 at 4:19 PM, Ari Diacou <[hidden email]> wrote:
From my experience with it, if you have hull(){ union(){ A(); B();} } }, then you could just have hull(){ A(); B();}

For me it reduced computation time by a lot - I noticed a large reduction in facets, but because I was taking a hull(), I assumed those facets were inside what I cared about, therefore they were facets I wasnt going to see anyway.


On Thu, Mar 20, 2014 at 11:04 AM, Szelp, A. Sz. <[hidden email]> wrote:
Dear all!

I have a case where I want to take the hull on a number of objects. These objects overlap (generated by a for-loop).

We have previously heard, that unions take relatively long, while hull is supposed to be fast.

Now, in this case OpenSCAD first does to union, and then takes the hull, making the whole issue slow.

Would removing the implicit union (as already suggested by several ones before) increase the performance in this case?

Thanks!

--
Szelp, André Szabolcs

<a href="tel:%2B43%20%28650%29%2079%2022%20400" value="+436507922400" target="_blank">+43 (650) 79 22 400

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: hull and union?

nophead
You might be able to remove the implicit union by replacing the for loop with a recursive module like I did here: http://forum.openscad.org/union-problem-td7111.html#a7129



On 20 March 2014 15:45, Szelp, A. Sz. <[hidden email]> wrote:
Yeah, in my particular instance the "new" parametrized extrude would work perfectly, though not in every situation I could imagine.

Still there are use cases where you'd want to take the hull of overlapping objects (and only need the hull). With the current behaviour (i.e. implicit union of objects of equal level in the tree) this is sub-optimal in terms of performance.

Take it as an input for the case of no implicit unions.

Szelp, André Szabolcs

<a href="tel:%2B43%20%28650%29%2079%2022%20400" value="+436507922400" target="_blank">+43 (650) 79 22 400


On Thu, Mar 20, 2014 at 4:30 PM, Kevin Crowley <[hidden email]> wrote:
This look like an issue that the new but now yet incorporated extrude functions would be useful.


On Thu, Mar 20, 2014 at 10:24 AM, Szelp, A. Sz. <[hidden email]> wrote:
No, you don't understand...

the for loop implicitly does an union. I cannot not-union with overlapping spheres, even though I'd like to (for performance reasons)...

Szelp, André Szabolcs

<a href="tel:%2B43%20%28650%29%2079%2022%20400" value="+436507922400" target="_blank">+43 (650) 79 22 400


On Thu, Mar 20, 2014 at 4:19 PM, Ari Diacou <[hidden email]> wrote:
From my experience with it, if you have hull(){ union(){ A(); B();} } }, then you could just have hull(){ A(); B();}

For me it reduced computation time by a lot - I noticed a large reduction in facets, but because I was taking a hull(), I assumed those facets were inside what I cared about, therefore they were facets I wasnt going to see anyway.


On Thu, Mar 20, 2014 at 11:04 AM, Szelp, A. Sz. <[hidden email]> wrote:
Dear all!

I have a case where I want to take the hull on a number of objects. These objects overlap (generated by a for-loop).

We have previously heard, that unions take relatively long, while hull is supposed to be fast.

Now, in this case OpenSCAD first does to union, and then takes the hull, making the whole issue slow.

Would removing the implicit union (as already suggested by several ones before) increase the performance in this case?

Thanks!

--
Szelp, André Szabolcs

<a href="tel:%2B43%20%28650%29%2079%2022%20400" value="+436507922400" target="_blank">+43 (650) 79 22 400

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: hull and union?

drxenocide
Sorry about before, I didnt get the subtlety. What if you removed the parts of the spheres that touched, like with an intersection or difference function? So instead of 10 intersecting spheres, the hull was around 10 "lemon wedges"...


On Thu, Mar 20, 2014 at 11:55 AM, nop head <[hidden email]> wrote:
You might be able to remove the implicit union by replacing the for loop with a recursive module like I did here: http://forum.openscad.org/union-problem-td7111.html#a7129



On 20 March 2014 15:45, Szelp, A. Sz. <[hidden email]> wrote:
Yeah, in my particular instance the "new" parametrized extrude would work perfectly, though not in every situation I could imagine.

Still there are use cases where you'd want to take the hull of overlapping objects (and only need the hull). With the current behaviour (i.e. implicit union of objects of equal level in the tree) this is sub-optimal in terms of performance.

Take it as an input for the case of no implicit unions.

Szelp, André Szabolcs

<a href="tel:%2B43%20%28650%29%2079%2022%20400" value="+436507922400" target="_blank">+43 (650) 79 22 400


On Thu, Mar 20, 2014 at 4:30 PM, Kevin Crowley <[hidden email]> wrote:
This look like an issue that the new but now yet incorporated extrude functions would be useful.


On Thu, Mar 20, 2014 at 10:24 AM, Szelp, A. Sz. <[hidden email]> wrote:
No, you don't understand...

the for loop implicitly does an union. I cannot not-union with overlapping spheres, even though I'd like to (for performance reasons)...

Szelp, André Szabolcs

<a href="tel:%2B43%20%28650%29%2079%2022%20400" value="+436507922400" target="_blank">+43 (650) 79 22 400


On Thu, Mar 20, 2014 at 4:19 PM, Ari Diacou <[hidden email]> wrote:
From my experience with it, if you have hull(){ union(){ A(); B();} } }, then you could just have hull(){ A(); B();}

For me it reduced computation time by a lot - I noticed a large reduction in facets, but because I was taking a hull(), I assumed those facets were inside what I cared about, therefore they were facets I wasnt going to see anyway.


On Thu, Mar 20, 2014 at 11:04 AM, Szelp, A. Sz. <[hidden email]> wrote:
Dear all!

I have a case where I want to take the hull on a number of objects. These objects overlap (generated by a for-loop).

We have previously heard, that unions take relatively long, while hull is supposed to be fast.

Now, in this case OpenSCAD first does to union, and then takes the hull, making the whole issue slow.

Would removing the implicit union (as already suggested by several ones before) increase the performance in this case?

Thanks!

--
Szelp, André Szabolcs

<a href="tel:%2B43%20%28650%29%2079%2022%20400" value="+436507922400" target="_blank">+43 (650) 79 22 400

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: hull and union?

Alan Cox
In reply to this post by szabi
> Take it as an input for the case of no implicit unions.

Or presumably for deferring implicit union until you have to do it in
order to generate the same language behaviour as before ?

It seems a lot of union() operators could actually be optimised by a bit
of tree manipulation.

Alan
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: hull and union?

doug.moen
I like Alan's suggestion of lazy implicit union. Allow people to write code in the most obvious way, and make that just run faster. Plus, preserving backwards compatibility, of course.


On 20 March 2014 13:45, Alan Cox <[hidden email]> wrote:
> Take it as an input for the case of no implicit unions.

Or presumably for deferring implicit union until you have to do it in
order to generate the same language behaviour as before ?

It seems a lot of union() operators could actually be optimised by a bit
of tree manipulation.

Alan
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: hull and union?

kintel
Administrator
Hi,

This is discussed a bit in https://github.com/openscad/openscad/issues/350

 -Marius

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566