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/