<JordanBrown>
That is, the general form of a node would be an object with three members: op, the operation name, arguments, the object describing the arguments to the operation, and children, an array containing child nodes.
<JordanBrown>
I'd like to figure out how to make it a little less verbose, but I haven't really tried yet.
<JordanBrown>
If you had o = { cube(10); };
<JordanBrown>
then maybe the result would be
<JordanBrown>
{ op = "cube"; args= {size=[10,10,10]; center=false;}}
<JordanBrown>
or maybe it would always have an explicit union node at the top
<JordanBrown>
or maybe the top would be an array that would be an implicit union.
<JordanBrown>
I think not the last, because I think you'd want to be able to construct one of these and use a previously-created one as one of the children.
<JordanBrown>
sq = { square(10); };
<JordanBrown>
le = { op = "linear_extrude"; args = {...}; children=[sq] };
<JordanBrown>
Hypothesizing an add() operation that adds the specified CSG-tree-object to the current CSG tree (which might or might not be the CSG tree that is the final model), you might also say:
<JordanBrown>
le = { linear_extrude() add(sq); };
<JordanBrown>
I should note that some of this I've thought about over time, and some of it is design-on-the-fly right now.
<JordanBrown>
Does that all sort of make sense?
<teepee>
no, what is that supposed to do?
ur5us has quit [Ping timeout: 244 seconds]
<JordanBrown>
It allows you to use a bunch of geometry construction operations to build up a data structure that you could introspect.
<teepee>
and how is: cube(10); wrong?
<JordanBrown>
cube(10) doesn't yield a data item.
<JordanBrown>
cube(10) always adds to the model.
<JordanBrown>
(Today, that is.)
<JordanBrown>
And then as a second step, you could call render(o) on one of them, and it would yield some sort of structure that would described the rendered output. Perhaps it would be triangle soup, but preferably it would be something that describes vertexes and faces and maybe colors.
<JordanBrown>
So render({cube(10);}) would yield a data structure that describes eight vertexes and six faces.
Furor is now known as Colere
Colere has quit [Remote host closed the connection]
<JordanBrown>
Note, for instance, that one of the questions we get asked is "how do I have a module return not just geometry but also some information about the geometry?".
<JordanBrown>
{ size = [10,10,10]; cube(size); } would be a data item that has both some information about the cube and the cube itself.
<JordanBrown>
And, remembering that a lot of this is design-on-the-fly rather than fully thought out, I don't yet know how the object returned would include *both* the values *and* the geometry. Perhaps there is a reserved element for containing the geometry, so that that example would have o.size and
<JordanBrown>
o.geometry.
<JordanBrown>
where o.geometry is a CSG tree as described above.
<InPhase>
JordanBrown: So that notion is actually somewhat limiting on future development.
<InPhase>
JordanBrown: Part of the lazy union work was based on the notion that we could go ahead and rearrange geometries with equivalent output transformations and get some optimization that way. Also the CSG product that we get displayed is doing the same sort of thing, rearranging content from its original syntactic form. I'm not sure if we want to preserve a CSG tree for reflection perusal to that detail.
<InPhase>
I kind of like the notion that a geometry is an output produced by a black box, and there's a wall there where you can see the output, but the black box can be refactored.
<InPhase>
Currently the exception to that is children() which provides a one-layer deep syntactic perusal, but it fails immediately at for loops. However we're already on path to fix that, as for example you could replace a geometric for loop with a list comprehension for loop with N geometries in it when you want to explicitly expose that list of components.
<InPhase>
So we don't really need to add in syntax and semantics for browsing an entire syntactically matched CSG tree when we're empowering the code writer to expose structures of geometry with a clean implementer-chosen API like this, where they can structure the exposed elements into lists or as render() generated object values.
teepee has quit [Ping timeout: 258 seconds]
teepee has joined #openscad
TheAssassin has quit [Remote host closed the connection]
fling has quit [Remote host closed the connection]
TheAssassin has joined #openscad
fling has joined #openscad
othx has quit [Read error: Connection reset by peer]
othx has joined #openscad
teepee_ has joined #openscad
teepee has quit [Ping timeout: 258 seconds]
teepee_ is now known as teepee
epony has quit [Remote host closed the connection]
snaked has quit [Ping timeout: 268 seconds]
qeed_ has joined #openscad
qeed has quit [Ping timeout: 268 seconds]
rvt has quit [Ping timeout: 268 seconds]
rvt has joined #openscad
aisa has joined #openscad
lastrodamo has quit [Quit: Leaving]
<aisa>
hi all! first time openscad user here -- I'm trying to model a ring, like one cut from a pipe, but I want the cut to be sine wave that goes around the circumference, if that makes sense
<aisa>
I've looked into building a polyhedron with a for loop, but that seems to be rather tedius
<J1A8412>
hi aisa
<aisa>
any idea if there's an easier way to do this?
<aisa>
J1A8412: hi :-)
<J1A8412>
there are some libs that can help you .. or you like to learn
<aisa>
both :-)
<J1A8412>
a beginners approach would be a chained hull
<aisa>
yeah, I thought hull might do the trick
<aisa>
I'm not exactly sure though, what objects I should input
<J1A8412>
or lets start without the hull .. just arranging cylinders around and move them sinoidal up and down
<J1A8412>
if you want a round finish you may need to use spheres
<aisa>
I wrote something that basically does this, but with union()
<aisa>
it produces a non-smooth surface though
<aisa>
using hull, however, seems to remove the hole from the ring
<J1A8412>
that looks promising so just try to apply the hull from the last to the next cylinder
<J1A8412>
your i advances by 1 so the hull is made with the transformation i+1
<aisa>
one sec, shouldn't be too hard
<J1A8412>
when using a hull you can reduce n to like 100
<J1A8412>
if you want waves that are phase shifted (180) on both sides so your ring getting smaller and wider you either use the spheres in my example and create a second sphere in the hull .. or in yours you can alter the cylinder height with a centered cylinder (without the translate)
<aisa>
got it
<aisa>
I just realized that I don't really want a sine wave, but a zig-zag
<aisa>
using the hull method in this case produces some "artifacts" that wouldn't appear in the sine case
<aisa>
I see. I need a non-rounded version, however :x
<aisa>
but then the hull approach stops working
<J1A8412>
just replace the sphere with a cube(center=true);
<J1A8412>
or cylinder if only top sides should be flat
<aisa>
that isn't producing the result I'm looking for
<J1A8412>
.. a different approach would be using a tube and cutting with a zigzag polyhedron or just overlapping cylinders with $fn=3 or 4 that are rotated [90]
<aisa>
I think for the hull approach I need objects that are placed edge-up, instead of face-up
<J1A8412>
if you create a module Object(){cube()}; which replaces the sphere() you can easier try different objects by replacing them just within the module
<J1A8412>
that was a cube (size = [d,.1,.1],center=true); instead of the sphere();
<aisa>
very handy :-)
<aisa>
so what if I wanted to make an analytical version of this? or this is generally not how it's done?
<J1A8412>
not sure what you mean
<aisa>
like my idea with a polyhedron that is essentially constructed by a formula
<aisa>
this would yield ideal results
<aisa>
the hull approach only produces ideal results in the limit
<J1A8412>
no it doesn't .. the hull is just a way to let the polyhedron be constructed for you
<aisa>
but the hull approach has still mitered edges on top
<J1A8412>
but if you like to build this .. you use the same loop but generate points
<aisa>
unless the cube is rotated edge-up, I assume
<J1A8412>
you can use 2 dimensional objects instead so there would be only one edge
<aisa>
can hull produce 3d objects from 2d objects?
<J1A8412>
or rotate and scale a cube so it is like a diamond shape
<J1A8412>
no but you can construct a 2D 3D polyhedron Ü
<J1A8412>
however for using points you need to generate affine transformations
<J1A8412>
or at least to get the points around a center you need to use [cos(a)*r,sin(a)*r, z] in the loop (where z would be your zig zag steps)
<aisa>
yeah. that's what my initial code is basically doing
<J1A8412>
so you create outside points and inside points .. then you need to create the faces and feed that into the polyhedron
<aisa>
creating faces seems tedious >:D
<J1A8412>
much more work .. if you do F12 can show you wrong aligned faces as they turn magenta
<aisa>
I see
<aisa>
I think I'll try hull with correctly rotated tetrahedrons
<aisa>
that should produce the same result as constructing the polyhedron manually
<J1A8412>
the faces will be constructed in a way hull does .. so you use 2 points from "now" and 1 point from the next step .. (or 2 for quads)
<aisa>
presummably the polyhedron would be faster than hull, right?
<J1A8412>
just use the hull with cylinder (2,d1=d,d2=0);
<J1A8412>
yes and no .. if only the polyhedron is used in render then the render is instantly but the calculation for points take longer than the internal math would need.
<J1A8412>
but if you are using less than 500 zig-zags it will not matter
<J1A8412>
the rounded wave (not zig-zag) version with 120 steps Total rendering time: 0:00:00.054
<J1A8412>
so you really need to use this very very often to get the time for making the polyhedron back
<J1A8412>
but it will be a good learning experience for other projects
<aisa>
I see
foul_owl has quit [Ping timeout: 244 seconds]
<aisa>
openscad has definitely a learning curve, but very much worth it :-)
* J1A8412
agrees
<J1A8412>
it is math which is logical thinking of abstracts .. and programming is sort of math on steroids
<J1A8412>
if your render time is much longer you can use the nightly versions (2022) and activate fast CSG in preferences features
<J1A8412>
even with super detailed spheres the preview took 15seconds .. but the render just .176
<aisa>
will do
<aisa>
also, thanks for your help! :-)
<J1A8412>
you are welcome .. and if you build the polyhedron .. just build a tube and then move every %2 point down
foul_owl has joined #openscad
<aisa>
https://bpa.st/JDXA this is what I came up with, in case you're interested, J1A8412
<aisa>
thanks again!
<J1A8412>
looks great
<aisa>
indeed :-)
<J1A8412>
having the long side at the base might not be ideal
ghee has quit [Quit: EOF]
<J1A8412>
if you use a smaller version for the base the edge will not over lap with the next and make a blunt end https://pasteboard.co/o6RfkEW3OrrZ.png
epony has joined #openscad
<aisa>
hm. I don't follow
<J1A8412>
your object has a 10 edge that is radial at the top but at the base tangential
gunnbr has joined #openscad
<J1A8412>
if you change the two last points z value to both [… , … , height/2]
othx has quit [Ping timeout: 248 seconds]
gunnbr__ has quit [Ping timeout: 252 seconds]
othx has joined #openscad
<J1A8412>
or something height*.7 .. bit strange to construct a polyhedron and then rotate and translate it
<aisa>
I've just added a 180deg rotation to the base object, now it's like being cut by a plane
<aisa>
which is basically what I wanted :-)
<aisa>
but yeah, using a hull definitely makes much more sense than constructing a polyhedron
<InPhase>
The output is as identical to yours as I could get from visual comparison.
<J1A84>
InPhase .. i think you are not aware that this would be very confusing for someone that is not familiar with your lib - Ü
<InPhase>
And I left a stray echo in there.
<InPhase>
J1A84: Of course. But that's to be motivation to get familiar with it. :)
<J1A84>
guerilla marketing for libraries Ü
<InPhase>
It is after all built for exactly this sort of use case. :)
<J1A84>
yes it is
<InPhase>
This model is almost identical to one of the demo cases. I started by copying and pasting from it. :)
<J1A84>
however i think a hull with a linear_extruded(.1,scale=0)polygon rotated around the center would also be a good option
<InPhase>
aisa: After removing the echo I left on line 14 (oops), the interesting difference is that yours completes the render in 30 seconds, and my version of the same design completes the render in 0.1 seconds.
<InPhase>
That and well the compactness.
<J1A84>
aisas version renders Total rendering time: 0:00:00.182 .. what did you do the other 29.878 seconds ?
<InPhase>
design / flush cache
<J1A84>
Total rendering time: 0:00:00.257
<InPhase>
I get 3.5 seconds on the master branch with fast-csg, but nothing sub-second.
<J1A84>
hm must be lazy U then Ü
<InPhase>
Well, that makes it much faster.
<J1A84>
oh great with a union i get lo ERROR: [fast-csg-remesh] Failed to collect path around patch faces, invalid mesh!
<InPhase>
What did you do with a union to trigger that?
<J1A84>
put i union() in front of the loop
<InPhase>
Oh. :(
<J1A84>
probably because there is no overlap
<InPhase>
I'm generally wary of the hull and loop strategy because of those overlap issues.
<InPhase>
I spent a lot of time doing those in my prior OpenSCAD life and kept hitting issues.
<InPhase>
You're looking at the inside of the high part.
<InPhase>
I habitually zoom in at the edges on models that flicker at me, so I spotted it right away. Although obviously it's sub-printing resolution in scale, so inconsequential as long as everything is manifold.
<J1A84>
you have changed something on the code .. else this is not there
<J1A84>
maybe you have using a different advance without correcting j for that
<InPhase>
I copied and pasted your 67GQ?
<InPhase>
Oh wait, I also changed :5: to :1:
<InPhase>
But it's still there in the 5 just not as pronounced.
<J1A84>
it can't be
<J1A84>
use j =i+1;
<InPhase>
Where'd it go. I saw them a second ago.
<J1A84>
it is mathematically not possible as there are no overlaps if j is i+advance .. and 360 is reached
<InPhase>
Okay, now I don't see them. I guess that was an artifact of me not noticing the other 5, so it ended up with a 5x overlap. :)
<InPhase>
My bad. :)
<InPhase>
I walked away from the desk in the middle, and forgot I swapped it from 5 to 1.
fling has quit [Ping timeout: 258 seconds]
<InPhase>
Looks clean now with both 5's as 1's.
<J1A84>
but the code wasn't made for resolution change . was just a poc .. else i would loop the steps not angle
<J1A84>
should also only loop to 360-advance so there is no overlap
<J1A84>
( what is what learned from you some years ago)
peepsalot has quit [Read error: Connection reset by peer]
peepsalot has joined #openscad
qeed_ has quit [Read error: Connection reset by peer]
qeed_ has joined #openscad
qeed_ has quit [Quit: qeed_]
qeed has joined #openscad
snaked has quit [Remote host closed the connection]
snaked has joined #openscad
califax has quit [Remote host closed the connection]
califax has joined #openscad
lastrodamo has joined #openscad
<linext>
is it possible to run the web assembly port on a windows server running apache?