Re: How to separate a geometry having distinct objects ?

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

Re: How to separate a geometry having distinct objects ?

mixotricha
That is exactly what I did. 

On Fri, Mar 26, 2021 at 3:25 PM Jordan Brown <[hidden email]> wrote:
It is certainly possible to imagine a 3D design tool, even a programming language like OpenSCAD, that can do things like cut up an object and then manipulate the separate solids that result.

OpenSCAD can't do that without a major overhaul, because it doesn't do any of the geometry processing until after the program has finished running.

The immediate output from an OpenSCAD program is not geometry, not a list of triangles, et cetera.  It is a tree representation of shapes, transformations, and the operations to be done on those shapes.  Look at Design / Display CSG Tree to see.  If you write "intersection() { sphere(); cube(); }", you'll see that that's pretty much what the CSG tree shows.  All of the expressions have been evaluated, all of the loops unrolled, all of the conditionals considered, but *none* of the geometry work has been done.  At that point in the processing, OpenSCAD doesn't *know* anything interesting about the geometry.

It is only when the geometry work is done that it starts to be possible to determine things like bounding boxes, like how many solids result from a particular boolean operation, and so on - and that's too late for the OpenSCAD program to take any action, because it's already done.

Could OpenSCAD have been designed differently, so that it did the geometry as it was processing the program, as Cascade Studio apparently does?  Sure.  But it wasn't, and that's a pretty fundamental design decision and a big job to change.

BTW, this isn't something that's a problem with the OpenSCAD language per se.  Another environment could easily make the same design decision.  Carsten's AngelCAD has the same architecture - in fact, it does the geometry work in a totally separate program.  I don't know about Doug's Curv - Doug?

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]


--
Damien Towning

 

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: How to separate a geometry having distinct objects ?

mixotricha
I wanted to respond to this with look at the OpenSCAD code. It does generate geometry. You are just looking at the interface. Look at the code. Understand what it does. Two primary paths. One generates geometry. The other implements Gold Feather. People are trying to explain to you how things work and what they have learned. 

On Fri, Mar 26, 2021 at 3:25 PM Jordan Brown <[hidden email]> wrote:
It is certainly possible to imagine a 3D design tool, even a programming language like OpenSCAD, that can do things like cut up an object and then manipulate the separate solids that result.

OpenSCAD can't do that without a major overhaul, because it doesn't do any of the geometry processing until after the program has finished running.

The immediate output from an OpenSCAD program is not geometry, not a list of triangles, et cetera.  It is a tree representation of shapes, transformations, and the operations to be done on those shapes.  Look at Design / Display CSG Tree to see.  If you write "intersection() { sphere(); cube(); }", you'll see that that's pretty much what the CSG tree shows.  All of the expressions have been evaluated, all of the loops unrolled, all of the conditionals considered, but *none* of the geometry work has been done.  At that point in the processing, OpenSCAD doesn't *know* anything interesting about the geometry.

It is only when the geometry work is done that it starts to be possible to determine things like bounding boxes, like how many solids result from a particular boolean operation, and so on - and that's too late for the OpenSCAD program to take any action, because it's already done.

Could OpenSCAD have been designed differently, so that it did the geometry as it was processing the program, as Cascade Studio apparently does?  Sure.  But it wasn't, and that's a pretty fundamental design decision and a big job to change.

BTW, this isn't something that's a problem with the OpenSCAD language per se.  Another environment could easily make the same design decision.  Carsten's AngelCAD has the same architecture - in fact, it does the geometry work in a totally separate program.  I don't know about Doug's Curv - Doug?

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]


--
Damien Towning

 

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: How to separate a geometry having distinct objects ?

mixotricha
OpenSCAD is constrained by what its core libraries like CGAL can do in real time in the mesh generating pipe line. Having got around that with stencil buffering tricks in the Gold Feather is basically genius. Assuming you had a clue and went ahead and implemented that part of the pipe line in the browser you could indeed do selections and other actions. But this wont have solved the real geometry pipeline. At which point you will arrive where I am. Which is fixing that. CGAL wants to make geometry that is perfect and water tight. This is a very good thing. That means it needs to use real numbers in the shape of stuff like MFPR. I've traded some of that accuracy for speed by going with Open Cascade. Anything is always going to be a trade off. 

On Sat, Mar 27, 2021 at 7:29 PM Damien Towning <[hidden email]> wrote:
I wanted to respond to this with look at the OpenSCAD code. It does generate geometry. You are just looking at the interface. Look at the code. Understand what it does. Two primary paths. One generates geometry. The other implements Gold Feather. People are trying to explain to you how things work and what they have learned. 

On Fri, Mar 26, 2021 at 3:25 PM Jordan Brown <[hidden email]> wrote:
It is certainly possible to imagine a 3D design tool, even a programming language like OpenSCAD, that can do things like cut up an object and then manipulate the separate solids that result.

OpenSCAD can't do that without a major overhaul, because it doesn't do any of the geometry processing until after the program has finished running.

The immediate output from an OpenSCAD program is not geometry, not a list of triangles, et cetera.  It is a tree representation of shapes, transformations, and the operations to be done on those shapes.  Look at Design / Display CSG Tree to see.  If you write "intersection() { sphere(); cube(); }", you'll see that that's pretty much what the CSG tree shows.  All of the expressions have been evaluated, all of the loops unrolled, all of the conditionals considered, but *none* of the geometry work has been done.  At that point in the processing, OpenSCAD doesn't *know* anything interesting about the geometry.

It is only when the geometry work is done that it starts to be possible to determine things like bounding boxes, like how many solids result from a particular boolean operation, and so on - and that's too late for the OpenSCAD program to take any action, because it's already done.

Could OpenSCAD have been designed differently, so that it did the geometry as it was processing the program, as Cascade Studio apparently does?  Sure.  But it wasn't, and that's a pretty fundamental design decision and a big job to change.

BTW, this isn't something that's a problem with the OpenSCAD language per se.  Another environment could easily make the same design decision.  Carsten's AngelCAD has the same architecture - in fact, it does the geometry work in a totally separate program.  I don't know about Doug's Curv - Doug?

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]


--
Damien Towning

 


--
Damien Towning

 

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: How to separate a geometry having distinct objects ?

mixotricha
Further as stated previously somewhere I have basically convinced myself a 'reverse' gold feather exists. That is to go from the stencil buffer back to geometry. I've sort of got this working in limited combinations of stencil buffer examples. 

On Sat, Mar 27, 2021 at 7:40 PM Damien Towning <[hidden email]> wrote:
OpenSCAD is constrained by what its core libraries like CGAL can do in real time in the mesh generating pipe line. Having got around that with stencil buffering tricks in the Gold Feather is basically genius. Assuming you had a clue and went ahead and implemented that part of the pipe line in the browser you could indeed do selections and other actions. But this wont have solved the real geometry pipeline. At which point you will arrive where I am. Which is fixing that. CGAL wants to make geometry that is perfect and water tight. This is a very good thing. That means it needs to use real numbers in the shape of stuff like MFPR. I've traded some of that accuracy for speed by going with Open Cascade. Anything is always going to be a trade off. 

On Sat, Mar 27, 2021 at 7:29 PM Damien Towning <[hidden email]> wrote:
I wanted to respond to this with look at the OpenSCAD code. It does generate geometry. You are just looking at the interface. Look at the code. Understand what it does. Two primary paths. One generates geometry. The other implements Gold Feather. People are trying to explain to you how things work and what they have learned. 

On Fri, Mar 26, 2021 at 3:25 PM Jordan Brown <[hidden email]> wrote:
It is certainly possible to imagine a 3D design tool, even a programming language like OpenSCAD, that can do things like cut up an object and then manipulate the separate solids that result.

OpenSCAD can't do that without a major overhaul, because it doesn't do any of the geometry processing until after the program has finished running.

The immediate output from an OpenSCAD program is not geometry, not a list of triangles, et cetera.  It is a tree representation of shapes, transformations, and the operations to be done on those shapes.  Look at Design / Display CSG Tree to see.  If you write "intersection() { sphere(); cube(); }", you'll see that that's pretty much what the CSG tree shows.  All of the expressions have been evaluated, all of the loops unrolled, all of the conditionals considered, but *none* of the geometry work has been done.  At that point in the processing, OpenSCAD doesn't *know* anything interesting about the geometry.

It is only when the geometry work is done that it starts to be possible to determine things like bounding boxes, like how many solids result from a particular boolean operation, and so on - and that's too late for the OpenSCAD program to take any action, because it's already done.

Could OpenSCAD have been designed differently, so that it did the geometry as it was processing the program, as Cascade Studio apparently does?  Sure.  But it wasn't, and that's a pretty fundamental design decision and a big job to change.

BTW, this isn't something that's a problem with the OpenSCAD language per se.  Another environment could easily make the same design decision.  Carsten's AngelCAD has the same architecture - in fact, it does the geometry work in a totally separate program.  I don't know about Doug's Curv - Doug?

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]


--
Damien Towning

 


--
Damien Towning

 


--
Damien Towning

 

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: How to separate a geometry having distinct objects ?

mixotricha
I lifted this from GitHub. 

OpenSCAD uses CGAL's CSG operations on Nef polyhedrons, not the brep functionality. CGAL's way of doing CSG is extremely slow, but comes with pretty good guarantees to produce manifold objects, making it well suited for 3D printing. I'm not familiar enough with CGAL or breps to tell whether it would be possible to rewrite (parts of) OpenSCAD to use other techniques for calculating the resulting surfaces. There has been a bit of talk about OpenCascade, but nobody has yet come up with a convincing proof of concept. OpenJsCad is a good approach to deal with CSG in a different way, but in the end all such approaches I've seen suffer from numerical instabilities once objects get too complex.
FWIW, the CGAL support in OpenSCAD is pretty much isolated to a single visitor class transforming a CSG tree into polygons, so it's not unsurpassable to experiment with alternatives.

On Sat, Mar 27, 2021 at 7:43 PM Damien Towning <[hidden email]> wrote:
Further as stated previously somewhere I have basically convinced myself a 'reverse' gold feather exists. That is to go from the stencil buffer back to geometry. I've sort of got this working in limited combinations of stencil buffer examples. 

On Sat, Mar 27, 2021 at 7:40 PM Damien Towning <[hidden email]> wrote:
OpenSCAD is constrained by what its core libraries like CGAL can do in real time in the mesh generating pipe line. Having got around that with stencil buffering tricks in the Gold Feather is basically genius. Assuming you had a clue and went ahead and implemented that part of the pipe line in the browser you could indeed do selections and other actions. But this wont have solved the real geometry pipeline. At which point you will arrive where I am. Which is fixing that. CGAL wants to make geometry that is perfect and water tight. This is a very good thing. That means it needs to use real numbers in the shape of stuff like MFPR. I've traded some of that accuracy for speed by going with Open Cascade. Anything is always going to be a trade off. 

On Sat, Mar 27, 2021 at 7:29 PM Damien Towning <[hidden email]> wrote:
I wanted to respond to this with look at the OpenSCAD code. It does generate geometry. You are just looking at the interface. Look at the code. Understand what it does. Two primary paths. One generates geometry. The other implements Gold Feather. People are trying to explain to you how things work and what they have learned. 

On Fri, Mar 26, 2021 at 3:25 PM Jordan Brown <[hidden email]> wrote:
It is certainly possible to imagine a 3D design tool, even a programming language like OpenSCAD, that can do things like cut up an object and then manipulate the separate solids that result.

OpenSCAD can't do that without a major overhaul, because it doesn't do any of the geometry processing until after the program has finished running.

The immediate output from an OpenSCAD program is not geometry, not a list of triangles, et cetera.  It is a tree representation of shapes, transformations, and the operations to be done on those shapes.  Look at Design / Display CSG Tree to see.  If you write "intersection() { sphere(); cube(); }", you'll see that that's pretty much what the CSG tree shows.  All of the expressions have been evaluated, all of the loops unrolled, all of the conditionals considered, but *none* of the geometry work has been done.  At that point in the processing, OpenSCAD doesn't *know* anything interesting about the geometry.

It is only when the geometry work is done that it starts to be possible to determine things like bounding boxes, like how many solids result from a particular boolean operation, and so on - and that's too late for the OpenSCAD program to take any action, because it's already done.

Could OpenSCAD have been designed differently, so that it did the geometry as it was processing the program, as Cascade Studio apparently does?  Sure.  But it wasn't, and that's a pretty fundamental design decision and a big job to change.

BTW, this isn't something that's a problem with the OpenSCAD language per se.  Another environment could easily make the same design decision.  Carsten's AngelCAD has the same architecture - in fact, it does the geometry work in a totally separate program.  I don't know about Doug's Curv - Doug?

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]


--
Damien Towning

 


--
Damien Towning

 


--
Damien Towning

 


--
Damien Towning

 

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: How to separate a geometry having distinct objects ?

mixotricha
Sorry if I sounded grumpy. I've done it. I've written a 'bare-bones' implementation using Open Cascade. It works in parallel. It optimises the OpenSCAD. It does these things. I had it up for a year or so. Took it down again because building house. Also had complete rethink. I guess it is up to each of us to all go relearn the same lessons. 

On Sat, Mar 27, 2021 at 8:08 PM Damien Towning <[hidden email]> wrote:
I lifted this from GitHub. 

OpenSCAD uses CGAL's CSG operations on Nef polyhedrons, not the brep functionality. CGAL's way of doing CSG is extremely slow, but comes with pretty good guarantees to produce manifold objects, making it well suited for 3D printing. I'm not familiar enough with CGAL or breps to tell whether it would be possible to rewrite (parts of) OpenSCAD to use other techniques for calculating the resulting surfaces. There has been a bit of talk about OpenCascade, but nobody has yet come up with a convincing proof of concept. OpenJsCad is a good approach to deal with CSG in a different way, but in the end all such approaches I've seen suffer from numerical instabilities once objects get too complex.
FWIW, the CGAL support in OpenSCAD is pretty much isolated to a single visitor class transforming a CSG tree into polygons, so it's not unsurpassable to experiment with alternatives.

On Sat, Mar 27, 2021 at 7:43 PM Damien Towning <[hidden email]> wrote:
Further as stated previously somewhere I have basically convinced myself a 'reverse' gold feather exists. That is to go from the stencil buffer back to geometry. I've sort of got this working in limited combinations of stencil buffer examples. 

On Sat, Mar 27, 2021 at 7:40 PM Damien Towning <[hidden email]> wrote:
OpenSCAD is constrained by what its core libraries like CGAL can do in real time in the mesh generating pipe line. Having got around that with stencil buffering tricks in the Gold Feather is basically genius. Assuming you had a clue and went ahead and implemented that part of the pipe line in the browser you could indeed do selections and other actions. But this wont have solved the real geometry pipeline. At which point you will arrive where I am. Which is fixing that. CGAL wants to make geometry that is perfect and water tight. This is a very good thing. That means it needs to use real numbers in the shape of stuff like MFPR. I've traded some of that accuracy for speed by going with Open Cascade. Anything is always going to be a trade off. 

On Sat, Mar 27, 2021 at 7:29 PM Damien Towning <[hidden email]> wrote:
I wanted to respond to this with look at the OpenSCAD code. It does generate geometry. You are just looking at the interface. Look at the code. Understand what it does. Two primary paths. One generates geometry. The other implements Gold Feather. People are trying to explain to you how things work and what they have learned. 

On Fri, Mar 26, 2021 at 3:25 PM Jordan Brown <[hidden email]> wrote:
It is certainly possible to imagine a 3D design tool, even a programming language like OpenSCAD, that can do things like cut up an object and then manipulate the separate solids that result.

OpenSCAD can't do that without a major overhaul, because it doesn't do any of the geometry processing until after the program has finished running.

The immediate output from an OpenSCAD program is not geometry, not a list of triangles, et cetera.  It is a tree representation of shapes, transformations, and the operations to be done on those shapes.  Look at Design / Display CSG Tree to see.  If you write "intersection() { sphere(); cube(); }", you'll see that that's pretty much what the CSG tree shows.  All of the expressions have been evaluated, all of the loops unrolled, all of the conditionals considered, but *none* of the geometry work has been done.  At that point in the processing, OpenSCAD doesn't *know* anything interesting about the geometry.

It is only when the geometry work is done that it starts to be possible to determine things like bounding boxes, like how many solids result from a particular boolean operation, and so on - and that's too late for the OpenSCAD program to take any action, because it's already done.

Could OpenSCAD have been designed differently, so that it did the geometry as it was processing the program, as Cascade Studio apparently does?  Sure.  But it wasn't, and that's a pretty fundamental design decision and a big job to change.

BTW, this isn't something that's a problem with the OpenSCAD language per se.  Another environment could easily make the same design decision.  Carsten's AngelCAD has the same architecture - in fact, it does the geometry work in a totally separate program.  I don't know about Doug's Curv - Doug?

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]


--
Damien Towning

 


--
Damien Towning

 


--
Damien Towning

 


--
Damien Towning

 


--
Damien Towning

 

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: How to separate a geometry having distinct objects ?

cacb
On 2021-03-27 10:10, Damien Towning wrote:
> Sorry if I sounded grumpy. I've done it. I've written a 'bare-bones'
> implementation using Open Cascade. It works in parallel. It optimises
> the OpenSCAD. It does these things. I had it up for a year or so. Took
> it down again because building house. Also had complete rethink. I
> guess it is up to each of us to all go relearn the same lessons.

Do you have a good reference to a C++ API for Open Cascade to do CSG
modelling? By that I mean the 3d primitives like cube, cylinder etc. and
the booleans union, difference, intersection. Maybe even your bare-bones
implementation using Open Cascade?

Many years ago, in the mid 1990s, for a short while I was looking at
what was then called CAS.CADE, I even visited Matra Datavision outside
Paris on a couple of occasions as we tried to use CAS.CADE (a very
expensive product then) in our company. The effort failed for several
reasons, one was their insistence of using something called CDL (Cascade
Definition Language), but we wanted a C++ API. We suggested to Matra
they made a C++ API, an idea they didn't like at that point. Now, many
years later Open Cascade is open source... We ended up using ACIS from
Spatial Technology back then.

I believe the core of Open Cascade is very solid indeed, most probably
the API and documentation has improved a lot since I last visited it.
When I started looking at Constructive Solid Geometry a few years ago I
saw Cascade and Carve as to possible routes to achieve that. Carve is
used in https://github.com/arnholm/xcsg , the boolean computation engine
of AngelCAD because I found some good examples for how to do it. An
interesting thought would be to implement xcsg using Open Cascade, but
for that to happen I guess some sample Open Cascade would be needed.

Carsten Arnholm
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: How to separate a geometry having distinct objects ?

MichaelAtOz
Administrator
Note I moved this to a new thread as it is heading in a different direction.
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain;
to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.


Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain;
to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.