Hello, this is my first post here as I'm using OpenSCAD again after years.
I'm trying to code a 2 axis slicer and there is a step that seems
impossible to do, but maybe is it because I'm not aware enough of
functional programming techniques.
Here is what I do :
Then, there is the step that I cannot do : access each of the gathered
intersections, and split each of them in half (top and bottom).
Next steps will be :
This is something I'm doing with OpenJSCAD for years now and I needed to
write my own 3d split code to be able to do so. The main problem is that
sometimes an intersection returns two or more separated object into the
same geometry and my process need to split each of them separately in order
to make correct cross pieces.
Is it possible to split a geometry having separated objects so that each
can be processed separately ?
my code : (I need inter() to have several children instead of only 1)
w= 0.6;
inter();
translate([20,0,0])tranchesX();
translate([-20,0,0])tranchesY();
translate([0,0,30])volume();
module tranchesX() { for(i = [2:3:12])trancheX(i); }
module tranchesY() { for(i = [0:4:20-1])trancheY(i); }
module inter(){
intersection(){
union(){tranchesX();}
union(){tranchesY();}
}
}
module trancheY(dec) {
intersection() {
translate([-1, dec, -1])cube([14, w, 22]);
volume();
}
}
module trancheX(dec) {
intersection() {
translate([dec, -1, -1])cube([w, 12, 22]);
volume();
}
}
module volume() {
difference(){
cube([12,10,20]);
scale([1,2,1])translate([6,2.5,6])sphere(r=5);
}
}
On 23.01.2021 10:04, Gilbert Duval wrote:
The main problem is that
sometimes an intersection returns two or more separated object into the
same geometry and my process need to split each of them separately in
order to make correct cross pieces.
Is it possible to split a geometry having separated objects so that each
can be processed separately ?
Hello Gilbert,
You cannot automatically split it into separate objects using OpenSCAD,
but you can save the output from OpenSCAD and automatically split it
into separate objects using polyfix ( polyfix is a console application,
it comes with AngelCAD https://github.com/arnholm/angelcad/releases/ )
Using your example, let us call it 'separate.scad', you can save it to
e.g. 'separate.stl' containing everything. Then you run polyfix with the
-lumps option to extract separated objects (lump=separate object):
$ polyfix -lumps separate.stl -out=*.off
( You must select an output format different from STL, because polyfix
does not support -lumps in combination with STL output )
In this case the result is 32 files, each containing a separated object
from your original:
separate_0.off
.
.
.
separate_30.off
separate_31.off
Carsten Arnholm
As Carsten said, there's no way to "split" geometry.
If, for instance, you wanted to take a sphere, cut the top half from the
bottom half, and separate the two halves, the only way to do it is to
create two spheres, cut away the top half of one, and cut away the
bottom half of the other.
Now, because OpenSCAD is after all a programming environment, that
doesn't mean that you have to type out both models.
Start with this module:
big = 1000;
module cut(d) {
// First: top half
translate([0,0,d/2]) intersection() {
children();
translate([-big,-big,0]) cube([big*2,big*2,big]);
}
// Second: bottom half
translate([0,0,-d/2]) intersection() {
children();
translate([-big,-big,-big]) cube([big*2,big*2,big]);
}
}
and here's how you use it:
cut(10) sphere(10);
and here's what you get:
The same principle applies to any other kind of cut: for each
"segment", generate the model and cut away what you don't want in that
segment.
I got the impression that he wanted to have a way to perform an intersection
and automatically get all the connected components of the intersection as
separate children. This can't be done by your method because you don't know
what the connected components are in advance. And there's no limit to how
many components there are.
I don't understand what he's trying to do and why he needs the connected
components to be separate.
JordanBrown wrote
As Carsten said, there's no way to "split" geometry.
If, for instance, you wanted to take a sphere, cut the top half from the
bottom half, and separate the two halves, the only way to do it is to
create two spheres, cut away the top half of one, and cut away the
bottom half of the other.
Now, because OpenSCAD is after all a programming environment, that
doesn't mean that you have to type out both models.
Start with this module:
big = 1000;
module cut(d) {
// First: top half
translate([0,0,d/2]) intersection() {
children();
translate([-big,-big,0]) cube([big*2,big*2,big]);
}
// Second: bottom half
translate([0,0,-d/2]) intersection() {
children();
translate([-big,-big,-big]) cube([big*2,big*2,big]);
}
}
and here's how you use it:
cut(10) sphere(10);
and here's what you get:
The same principle applies to any other kind of cut: for each
"segment", generate the model and cut away what you don't want in that
segment.
OpenSCAD mailing list
Discuss@.openscad
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
oobpgooekkgmbfan.png (4K)
<http://forum.openscad.org/attachment/31692/0/oobpgooekkgmbfan.png>
--
Sent from: http://forum.openscad.org/
On 1/23/2021 7:33 AM, adrianv wrote:
I got the impression that he wanted to have a way to perform an intersection
and automatically get all the connected components of the intersection as
separate children. This can't be done by your method because you don't know
what the connected components are in advance. And there's no limit to how
many components there are.
Right. If, for instance, the model was a human body, and you wanted to
cut it at the knees and end up with two separate legs, your cut
processing would have to "just know" that there are two legs and to cut
between them. There's no way to derive that from an arbitrary model.
I want to produce this kind of output :
http://forum.openscad.org/file/t3103/Capture_d%E2%80%99%C3%A9cran_de_2020-12-01_15-28-26.png
Making the x and y slices was easy, their intersection also. But then I was
unable to access those intersections one by one (because I need to split
each of them in one top half and one bottom half).
With OpenJSCAD I needed to write my own Split3d to split them, but such
function needs to read a polyhedron vertices and sort them and there's
nothing to do that in OpenSCAD.
here what I have for the moment :
http://forum.openscad.org/file/t3103/Capture_d%E2%80%99%C3%A9cran_de_2021-01-23_09-23-41.png
--
Sent from: http://forum.openscad.org/
I don't really understand the issue. If you write a module that creates a
slice using an intersection, why can't you use that slice as a new object
any number of times in any way you want?
On Sun, 24 Jan 2021 at 09:36, gilboonet gilbertfd@gmail.com wrote:
I want to produce this kind of output :
<
http://forum.openscad.org/file/t3103/Capture_d%E2%80%99%C3%A9cran_de_2020-12-01_15-28-26.png>
Making the x and y slices was easy, their intersection also. But then I was
unable to access those intersections one by one (because I need to split
each of them in one top half and one bottom half).
With OpenJSCAD I needed to write my own Split3d to split them, but such
function needs to read a polyhedron vertices and sort them and there's
nothing to do that in OpenSCAD.
here what I have for the moment :
<
http://forum.openscad.org/file/t3103/Capture_d%E2%80%99%C3%A9cran_de_2021-01-23_09-23-41.png>
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Yes, it can be done by specifying manually each time an intersection contains
more than one piece, but it would make the script very unpractical as it is
intended to be used from customizer to create skeleton of whatever volume
the user want.
Here is the original OpenJSCAD script : see here
https://raw.githubusercontent.com/gilboonet/gilboonet.github.io/master/sq_edit/slice_2axis_example.js
http://forum.openscad.org/file/t3103/Capture_d%E2%80%99%C3%A9cran_de_2021-01-24_13-13-26.png
--
Sent from: http://forum.openscad.org/
I still don't understand. You start with a solid object and slice it two
ways to get some sticks and then you want to cut those in half?
You could write a nested for loop that produces the intersection of x slice
i and y slice j and then do whatever you want with the stick result based
on i and j.
On Sun, 24 Jan 2021 at 12:24, gilboonet gilbertfd@gmail.com wrote:
Yes, it can be done by specifying manually each time an intersection
contains
more than one piece, but it would make the script very unpractical as it is
intended to be used from customizer to create skeleton of whatever volume
the user want.
Here is the original OpenJSCAD script : see here
<
https://raw.githubusercontent.com/gilboonet/gilboonet.github.io/master/sq_edit/slice_2axis_example.js>
<
http://forum.openscad.org/file/t3103/Capture_d%E2%80%99%C3%A9cran_de_2021-01-24_13-13-26.png>
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Here is a part of my process
http://forum.openscad.org/file/t3103/Capture_d%E2%80%99%C3%A9cran_de_2021-01-24_13-59-06.png
I design a volume (save it as 3d file)
Then make its skeleton, here with 3 X slices and 3 Y slices
The skeleton is made by interlocking those slices.
When an intersection returns more than one geometry, each of those
geometries must be considered as one intersection
The interlocking is made by splitting each intersection in 2 (top and
bottom)
And subtract all top to X slices and all bottom to Y slices.
This way one's have slices that interlock perfectly
I'm making a collection of designs to be built from cardboard and I'm using
part vanilla js and jscad 2 scripts to generate my plans. I was wondering
whether it could be possible to do the same with OpenSCAD.
--
Sent from: http://forum.openscad.org/
I understand your problem now. When a slice is broken by holes in the
original shape you want to be able to access the individual pieces
resulting from a single intersection. No you can't do that in OpenSCAD.
Perhaps there could be a new module that splits disjoint geometry into
separate children.
On Sun, 24 Jan 2021 at 13:25, gilboonet gilbertfd@gmail.com wrote:
Here is a part of my process
<
http://forum.openscad.org/file/t3103/Capture_d%E2%80%99%C3%A9cran_de_2021-01-24_13-59-06.png>
I design a volume (save it as 3d file)
Then make its skeleton, here with 3 X slices and 3 Y slices
The skeleton is made by interlocking those slices.
When an intersection returns more than one geometry, each of those
geometries must be considered as one intersection
The interlocking is made by splitting each intersection in 2 (top and
bottom)
And subtract all top to X slices and all bottom to Y slices.
This way one's have slices that interlock perfectly
I'm making a collection of designs to be built from cardboard and I'm using
part vanilla js and jscad 2 scripts to generate my plans. I was wondering
whether it could be possible to do the same with OpenSCAD.
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
I wrote a jscad function that does such splitting, it may be possible to use
it to add this functionnality to OpenSCAD, here it is :
/
function sortNb (E){ // returns E numerically sorted and deduplicated
return E.sort(function(a, b) {return a-b}).filter(
function(item, pos, ary) {return !pos || item != ary[pos - 1]});
}
function scission3d (geom){
var i, Pl, j, i1, j1, ok, ti, tj, z,
zz = [], P, RScission, til, tjl, tii1, zzl, zzdl;
// construit table de correspondance entre Polygones (P)
// build polygons lookup table
//P = geom.toPolygons();
P = geom.polygons;
RScission = [];
Pl = P.length;
for (i = 0; i < Pl; i++){
ti = P[i].vertices;
z = [];
for (j = 0; j < Pl; j++){
tj = P[j].vertices;
ok = false;
for (i1 = 0; i1 < ti.length; i1++){
tii1 = ti[i1];
for(j1 = 0; j1 < tj.length; j1++)
if (!ok)ok = vec3.distance(tii1, tj[j1]) < 0.01;
}
if (ok)z.push(parseInt(j));
}
z = sortNb(z);
zz.push({e:0, d:z});
}
// regroupe les correspondances des polygones se touchant
// boucle ne s'arrêtant que quand deux passages retournent le même nb de
polygones
// merge lookup data from linked polygons as long as possible
ok = false;
nElOk = 0;
do {
lnElOk = nElOk;
nElOk = 0;
for (i = 0; i < zz.length; i++){
if (zz[i].e >= 0) {
nElOk++;
for (j = 0; j < zz[i].d.length; j++){
a = zz[i].d[j];
if (zz[a].e >= 0)
if (i != a) {
zz[i].d = sortNb(zz[i].d.concat(zz[a].d));
zz[a].e = -1;
}
}
}
}
ok = lnElOk == nElOk;
}while (!ok);
// construit le tableau des CSG à retourner
// build array of CSG to return
for (i = 0, zzl = zz.length; i < zzl; i++) {
if (zz[i].e >= 0) {
z = [];
for (j = 0, zzdl = zz[i].d.length; j < zzdl; j++){
z.push(P[zz[i].d[j]]);
}
if(z.length > 0) {
RScission.push(geom3.create(z));
}
}
}
return RScission;
}
/
--
Sent from: http://forum.openscad.org/
On 2021-01-24 14:35, nop head wrote:
I understand your problem now. When a slice is broken by holes in the
original shape you want to be able to access the individual pieces
resulting from a single intersection. No you can't do that in
OpenSCAD.
That is what I said in my initial reply. There is no way to do it in
OpenSCAD, the only way is to do it outside OpenSCAD. As noted, polyfix
will do it easily, but there is no way OpenSCAD can detect the number of
individual pieces generated because it can't evaluate the contents of a
file folder.
Carsten Arnholm
On 2021-01-24 15:04, gilboonet wrote:
I wrote a jscad function that does such splitting,
What you wrote is possibly similar to what polyfix does, except it never
evaluates the vertex coordinates, it relies exclusively on the
polyhedron topology (which may have been reconstructed if the source was
STL).
However, this or that algorithm is not likely to find its way into
OpenSCAD because the language does not allow returning the result of
such algorithms, so you will never be able to access it from OpenSCAD
code.
Carsten Arnholm
This is an example where having a function render which returns polyhedron
would be very useful.
On Sun, 24 Jan 2021, 10:45 , arnholm@arnholm.org wrote:
On 2021-01-24 15:04, gilboonet wrote:
I wrote a jscad function that does such splitting,
What you wrote is possibly similar to what polyfix does, except it never
evaluates the vertex coordinates, it relies exclusively on the
polyhedron topology (which may have been reconstructed if the source was
STL).
However, this or that algorithm is not likely to find its way into
OpenSCAD because the language does not allow returning the result of
such algorithms, so you will never be able to access it from OpenSCAD
code.
Carsten Arnholm
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
The "transform3d" idea proposed in the "Passing function literals to builtin
modules" would make this possible.
So maybe it's less impossible than Carsten thinks.
acwest wrote
This is an example where having a function render which returns polyhedron
would be very useful.
On Sun, 24 Jan 2021, 10:45 , <
arnholm@
> wrote:
On 2021-01-24 15:04, gilboonet wrote:
I wrote a jscad function that does such splitting,
What you wrote is possibly similar to what polyfix does, except it never
evaluates the vertex coordinates, it relies exclusively on the
polyhedron topology (which may have been reconstructed if the source was
STL).
However, this or that algorithm is not likely to find its way into
OpenSCAD because the language does not allow returning the result of
such algorithms, so you will never be able to access it from OpenSCAD
code.
Carsten Arnholm
OpenSCAD mailing list
Discuss@.openscad
Discuss@.openscad
--
Sent from: http://forum.openscad.org/
If it becomes possible for a function to return polyhedron, I think I could
port my splitter and I have another script that I will be happy to port to
OpenSCAD, an unfolder that I use to make furniture clothe and that is
companion of the 2 axis slicer (I use both to make my designs plans).
The two are used here :
http://forum.openscad.org/file/t3103/Capture_d%E2%80%99%C3%A9cran_de_2021-01-10_10-45-39.png
acwest wrote
This is an example where having a function render which returns polyhedron
would be very useful.
--
Sent from: http://forum.openscad.org/
Hello, I recently discovered Cascade Studio and with it I was able to make
those separation I needed. Maybe the way Open Cascade manage geometries
could be useful if you want to extend OpenSCAD possibilities to do the same.
Cascade Studio is a young project but it is already very powerful in the
hands of a basic user like me, I'm certain that 3d specialists will be able
to make marvels with it. One really net of its possibilities is that it is
super easy to share code, you simply share the url like this
https://zalo.github.io/CascadeStudio/?code=bY%2FBSsQwEIbvfYo5pnZWkrLZS%2FVSRdmLF0svoYfSTTHQJiVJQRDf3WmkuIoQCPnzzcc%2Fk45QC7iH2r0zyTGdvMqmLS8pb3xvw9RHzZREibzDhB45HhNKbIJbYh%2FNOGqv7aBZLRBUXXb7d%2FNbdZBYcjyIXXfiKPD0YxvWSANnG7UPeojGWQaqRWiS8ErEkadOLeX%2FxM0uXHofAylVV2Wj82zLDL15RdcdPOv4ss6vbjKXcLYPbl7cai%2BMauQEFEUOHxl8S26XNbwxGkj0k3fzNY5gtiUA%2FpSRHG6AmULk1Cp5lNl2%2BfwC&gui=q1ZKzs8tyM9LzSvxS8xNVbJSSk4sTk5MSQ3LTC1X0lHyTS3OCEotVrIy0DOE84IS89KBSqMN9AwMdYxidZScE5MzUu2VrEqKSlN1lIISUzJLgVqMDWBsmAYjAx0Tg9haAA%3D%3D
http://forum.openscad.org/file/t3103/Capture_d%E2%80%99%C3%A9cran_de_2021-03-25_21-08-28.png
--
Sent from: http://forum.openscad.org/
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?
Thank you for your reply JordanBrown, indeed I'm now doing those things with
two designs tools, OpenJSCAD and Cascade Studio, and I'm pretty sure it is
also possible with CadQuery and Blender Python. I tried to do it with
FreeCAD Python, but it is still too buggy. Maybe ScriptCAD can do it too.
This is a design tool that one of OpenJSCAD creators, René K Müller, made,
and it computes a scene in two stages, first computing, then rendering. I
did such thing with one my OpenJSCAD script that I use to unwrap 3d models
that I use to make faceted statues or furniture clothe. First I run the
OpenJSCAD script that unflatten a polyhedron and save polygon data (points,
faces and neighboring), then I can use a nodeJS script on those data, one to
render a multi-page PDF of the unflatten net as it is, another to render it
as a puzzle (interlocking edges). I hope that someday OpenSCAD will enable
such processes, but maybe it is not something users are intended to do with
it.
--
Sent from: http://forum.openscad.org/
I don't have either a solution to the task of finding the connected
component of a model. Even if all mesh data needed to reproduce the model
with a polyhedron call was available, the process of finding the components
with the language would be rather inefficient because there is no effective
way to mark vertices during a tour through the mesh.
Jordan Brown openscad@jordan.maileater.net wrote:
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
because it's already done.
As a side comment without arguing against that, with some ingenuity its is
possible to generate fully parametric models like the one bellow:
[image: fob.PNG]
The design would be simple to be done from the bounding box data of the
inscription and so we are tempted to give up before realizing that the data
is not essential, the bounding box itself is enough.
// inscription data
text = "Any text here";
size = 10;
// fob data
margins = [7, 4];
border = 2;
thickness = 2;
depth = 1;
fob(margins, border, thickness)
union() {
text(text,size=size,valign="center");
translate([-size7/16,0])
rotate(18)
circle(size5/16,$fn=5);
}
module fob(margins, border, thickness) {
module simple_fob(dimens) {
minkowski() {
translate([0,0,.01])
cube([dimens[0], dimens[1],.02], center=true);
bbox()
linear_extrude(dimens[2], convexity=10)
children();
}
}
difference() {
simple_fob([margins[0]+border,margins[1]+border, thickness])
children();
difference() {
translate([0,0,thickness-depth])
simple_fob([margins[0],margins[1], thickness])
children();
linear_extrude(thickness, convexity=10)
children();
}
}
}
The code relies on an operator (a module that handles children() ), bbox(),
to generate the bounding box geometry that is a simple cube. That operator
may be coded in OpenSCAD as it can be seen in the now overlooked OpenSCAD
Manual section, Tips and Tricks
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Tips_and_Tricks#Computing_a_bounding_box.
Although the code makes use of minkowski(), an operator usually considered
slow, its operation involves only cubic shapes and it is fast. In my
machine, the render (F6) of this model takes a few seconds.
The bbox() operator may be also helpful for defining a clipping box fitted
to a design as discussed here elsewhere.
I find this response Jordan really informative/intriguing, really well written, and I really want to know more about how this division and sequence of processing occurs in OpenSCAD. You have flagged the top level reasons for why OpenSCAD can't "post process" objects, but I still don't understand the process how it works. Is a fuller explanation of your response available somewhere? Is there an OpenSCAD page that illuminates this?
Forgive my ignorance, but given the frequency of questions relating to these "limitations" on this forum I suspect I am not alone, but I think a lot of frustration with OpenSCAD could be quickly defused with a more in depth explanation along these lines that people like me could be referred to?
How can all the processing be completed, then the geometry completed after that?
Cheers, RobW
On 26 March 2021 11:46:55 am AEDT, Jordan Brown openscad@jordan.maileater.net 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?
On 3/26/2021 4:27 AM, Rob Ward wrote:
How can all the processing be completed, then the geometry completed
after that?
The simplest explanation is to set up a model, F5 it, and then look at
Design / View CSG Tree.
(Side note: It would be nice if, once you have the CSG Tree Dump window
up, it was updated on subsequent runs.)
Consider this program:
difference() {
cube(20, center=true);
for (x = [-5:10:5], z=[-5:10:5]) {
if (x > 0 || z > 0) {
translate([x, 0, z])
rotate([90,0,0])
cylinder(h=21, d=5, center=true);
}
}
}
which generates this object:
The output from the processing of the OpenSCAD language is this, from
Design / Display CSG Tree:
difference() {
cube(size = [20, 20, 20], center = true);
group() {
group() {
multmatrix([[1, 0, 0, -5], [0, 1, 0, 0], [0, 0, 1, 5], [0, 0, 0, 1]]) {
multmatrix([[1, 0, 0, 0], [0, 0, -1, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) {
cylinder($fn = 0, $fa = 12, $fs = 2, h = 21, r1 = 2.5, r2 = 2.5, center = true);
}
}
}
group() {
multmatrix([[1, 0, 0, 5], [0, 1, 0, 0], [0, 0, 1, -5], [0, 0, 0, 1]]) {
multmatrix([[1, 0, 0, 0], [0, 0, -1, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) {
cylinder($fn = 0, $fa = 12, $fs = 2, h = 21, r1 = 2.5, r2 = 2.5, center = true);
}
}
}
group() {
multmatrix([[1, 0, 0, 5], [0, 1, 0, 0], [0, 0, 1, 5], [0, 0, 0, 1]]) {
multmatrix([[1, 0, 0, 0], [0, 0, -1, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) {
cylinder($fn = 0, $fa = 12, $fs = 2, h = 21, r1 = 2.5, r2 = 2.5, center = true);
}
}
}
}
}
Note how all of the "program" stuff is gone. There are no variables,
there are no loops, there is no "if". There's just shapes (a cube and
three cylinders), transformations (the matrix multiplications), and
boolean operations (the difference).
Note: I assume that this is a textual representation of an
in-memory data structure, rather than text that's actually generated
in the middle of the pipeline. But I don't know.
This is the data that comes out of executing the program, that then goes
into the geometry engines.
For Carsten's AngelCAD environment it's more distinct - an AngelCAD
execution generates an XML file with basically the same data as above,
and then a separate program interprets and displays it.
Does that sort of make sense?
That is exactly what I did.
On Fri, Mar 26, 2021 at 3:25 PM Jordan Brown openscad@jordan.maileater.net
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 discuss-leave@lists.openscad.org
--
Damien Towning
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 openscad@jordan.maileater.net
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 discuss-leave@lists.openscad.org
--
Damien Towning
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 connolly.damien@gmail.com
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 <
openscad@jordan.maileater.net> 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 discuss-leave@lists.openscad.org
--
Damien Towning
--
Damien Towning
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 connolly.damien@gmail.com
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 connolly.damien@gmail.com
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 <
openscad@jordan.maileater.net> 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 discuss-leave@lists.openscad.org
--
Damien Towning
--
Damien Towning
--
Damien Towning
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 connolly.damien@gmail.com
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 connolly.damien@gmail.com
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 connolly.damien@gmail.com
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 <
openscad@jordan.maileater.net> 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 discuss-leave@lists.openscad.org
--
Damien Towning
--
Damien Towning
--
Damien Towning
--
Damien Towning
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 connolly.damien@gmail.com
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 connolly.damien@gmail.com
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 connolly.damien@gmail.com
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 <
connolly.damien@gmail.com> 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 <
openscad@jordan.maileater.net> 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 discuss-leave@lists.openscad.org
--
Damien Towning
--
Damien Towning
--
Damien Towning
--
Damien Towning
--
Damien Towning
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