discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

STL without render?

B
bsuter
Thu, Jun 2, 2016 12:11 PM

Dear Rudolf, thank you for this info - it may take me some time to
fully understand, I'll try.

A similar problem, doing a union() of a large number of cylinder and sphere
primitives is currently discussed here.
http://www.thingiverse.com/groups/openscad/topic:6515#comment-900694
CGAL rendering is not very efficient when (very) large numbers of shapes
come into play.

In that post you wrote "A single sweep() along a smoothed trajectory
will be faster than a union of cylinders and spheres describing the
same". Could you please explain further what you mean, in OpenSCAD
terms, by "single sweep() along a smoothed trajectory"? This sounds
useful. Certainly each of my branches can be modeled as a sequence of
nodes, where each node has an associated radius. Is there a way to
represent this directly in OpenSCAD? I.e. to specify a trajectory in
3D, and then extrude (ideally a circular cross-section, but a polygon
would work too) along this trajectory, with the extrusion radius
defined at each node?

Essentially this is what I tried to mimic using cylinder primitives
(and spheres at the nodes, to fill in the gaps between cylinder ends).

I've implemented some Matlab class to generically describe arteries with an
interpolation scheme. The output is a winding 'wire' in 3D with free radius
a each point in STL-format.

This part I seem to understand. Arteries are quite similar, in the
present context, to dendritic arbors - tapered cylinders with branch
points. Ultimately all I want is STL. In my own Matlab code I am able
to generate a reasonable 3D figure (by using the cylinder() function
and, after some manipulations, passing the results to the surf()
function). I've toyed with the idea of instead taking the cylinder()
output (basically the vertices at the bottom and top edge of the
cylinder) and using these to generate a tessellated surface in STL
syntax. As long as I use a fixed # of vertices for all cylinders,
connecting the top of one to the base of the next via triangles should
be quite doable.

In lack of an own union or furcation operator
capable to do the intersection triangulation we currently use OpenSCAD and
Blender to compose porperly placed wires into tree structures which we again
cut into puzzle pieces for 3D print.

This part I don't understand ;(

You might be interested for inspiration or even build on at least part of
the code (in a non-commercial way), e.g. to implement this 'little' details
on your own. Send me a PM to get in further touch.

Thank you!

I imagine some tree class, allowing for a (recursive) generic description of
path points with radii that can render its objects to STL. In your case, I
guess, you will add a net class to connect those tree objects formally into
a network to do functional simulation.

Such a class would be quite useful - seemingly to a variety of problem domains.

For functional simulations, the format we already use is quite
suitable (it's called SWC; a list of tuples, each tuple has <ID, type,
x, y, z, r, parent>) and widely used (see neuromorpho database if
curious).

My main goal is (a) virtual reality visualization of many neurons
together, and (b) 3D printing of individual neurons. For the latter,
there's a nice paper, but the code there is implemented within a
simulation environment (NEURON) and does not fit well with my current
pipeline.

McDougal, R. A. and G. M. Shepherd (2015). 3D-printer visualization of
neuron models. Frontiers in neuroinformatics 9.

OpenSCAD or any other CAD-Programm could be used to provide the final
union() operation connecting some number of precompiled trees (neurons) into
a printable unit. I wouldn't advise to do the programming natively in
OpenSCAD.

Rudolf


If you reply to this email, your message will be added to the discussion
below:
http://forum.openscad.org/STL-without-render-tp17503p17524.html
To unsubscribe from STL without render?, click here.
NAML

--
View this message in context: http://forum.openscad.org/STL-without-render-tp17503p17526.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Dear Rudolf, thank you for this info - it may take me some time to fully understand, I'll try. > A similar problem, doing a union() of a large number of cylinder and sphere > primitives is currently discussed here. > http://www.thingiverse.com/groups/openscad/topic:6515#comment-900694 > CGAL rendering is not very efficient when (very) large numbers of shapes > come into play. In that post you wrote "A single sweep() along a smoothed trajectory will be faster than a union of cylinders and spheres describing the same". Could you please explain further what you mean, in OpenSCAD terms, by "single sweep() along a smoothed trajectory"? This sounds useful. Certainly each of my branches can be modeled as a sequence of nodes, where each node has an associated radius. Is there a way to represent this directly in OpenSCAD? I.e. to specify a trajectory in 3D, and then extrude (ideally a circular cross-section, but a polygon would work too) along this trajectory, with the extrusion radius defined at each node? Essentially this is what I tried to mimic using cylinder primitives (and spheres at the nodes, to fill in the gaps between cylinder ends). > I've implemented some Matlab class to generically describe arteries with an > interpolation scheme. The output is a winding 'wire' in 3D with free radius > a each point in STL-format. This part I seem to understand. Arteries are quite similar, in the present context, to dendritic arbors - tapered cylinders with branch points. Ultimately all I want is STL. In my own Matlab code I am able to generate a reasonable 3D figure (by using the cylinder() function and, after some manipulations, passing the results to the surf() function). I've toyed with the idea of instead taking the cylinder() output (basically the vertices at the bottom and top edge of the cylinder) and using these to generate a tessellated surface in STL syntax. As long as I use a fixed # of vertices for all cylinders, connecting the top of one to the base of the next via triangles should be quite doable. > In lack of an own union or furcation operator > capable to do the intersection triangulation we currently use OpenSCAD and > Blender to compose porperly placed wires into tree structures which we again > cut into puzzle pieces for 3D print. This part I don't understand ;( > You might be interested for inspiration or even build on at least part of > the code (in a non-commercial way), e.g. to implement this 'little' details > on your own. Send me a PM to get in further touch. Thank you! > I imagine some tree class, allowing for a (recursive) generic description of > path points with radii that can render its objects to STL. In your case, I > guess, you will add a net class to connect those tree objects formally into > a network to do functional simulation. Such a class would be quite useful - seemingly to a variety of problem domains. For functional simulations, the format we already use is quite suitable (it's called SWC; a list of tuples, each tuple has <ID, type, x, y, z, r, parent>) and widely used (see neuromorpho database if curious). My main goal is (a) virtual reality visualization of many neurons together, and (b) 3D printing of individual neurons. For the latter, there's a nice paper, but the code there is implemented within a simulation environment (NEURON) and does not fit well with my current pipeline. McDougal, R. A. and G. M. Shepherd (2015). 3D-printer visualization of neuron models. Frontiers in neuroinformatics 9. > OpenSCAD or any other CAD-Programm could be used to provide the final > union() operation connecting some number of precompiled trees (neurons) into > a printable unit. I wouldn't advise to do the programming natively in > OpenSCAD. > > > Rudolf > > > > ________________________________ > If you reply to this email, your message will be added to the discussion > below: > http://forum.openscad.org/STL-without-render-tp17503p17524.html > To unsubscribe from STL without render?, click here. > NAML -- View this message in context: http://forum.openscad.org/STL-without-render-tp17503p17526.html Sent from the OpenSCAD mailing list archive at Nabble.com.
P
Parkinbot
Thu, Jun 2, 2016 2:29 PM

bsuter wrote

In that post you wrote "A single sweep() along a smoothed trajectory
will be faster than a union of cylinders and spheres describing the
same". Could you please explain further what you mean, in OpenSCAD
terms, by "single sweep() along a smoothed trajectory"?

This code is a good starting point and show case:
http://www.thingiverse.com/thing:547620/#files
to get an idea, how sweeps behave. The (implicit) union() is needed for
marriage of different sweep trajectories.

Certainly each of my branches can be modeled as a sequence of
nodes, where each node has an associated radius. Is there a way to
represent this directly in OpenSCAD? I.e. to specify a trajectory in
3D, and then extrude (ideally a circular cross-section, but a polygon
would work too) along this trajectory, with the extrusion radius
defined at each node?

There is no language support for general extrusion along trajectories, and
there is no data structure support (or let's say only weak array support)
for things like trees and so on. But there are libraries like sweep() and
skin() going into this direction. Also see here:
http://www.thingiverse.com/thing:900137

I've implemented some Matlab class to generically describe arteries with
an
interpolation scheme. The output is a winding 'wire' in 3D with free
radius
at each point in STL-format.

this is an example of the outcome:
http://forum.openscad.org/Non-Linear-Transformations-tp14539p14597.html

The class simply does some nspline calculation over a sequence of 4D vectors
(x, y, z, r) describing a skeleton line. Most of the code is for handling
STL-triangulation and output.

In lack of an own union or furcation operator
capable to do the intersection triangulation we currently use OpenSCAD
and
Blender to compose porperly placed wires into tree structures which we
again
cut into puzzle pieces for 3D print.

This part I don't understand ;(

STL triagulation is easy and fast if you don't have to check for
self-intersection (SI). I.e. if the code can assume, no SI will happen, it
can skip all tests and calculations that would be needed to treat SI and
just knit some generic triangulation pattern in a straight forward manner.
Its helps to think about physical knitting to understand what is going on.
For the puzzle part: It might be interesting to print a structure in pieces,
e.g. to compose a construction kit or similar (which can also be used for
moulding).  In your case, it might be advantegous to print the neurons and
the dendrits as destinct pieces and design a connector for piecing parts
together as puzzle.

A union of any non-SI shapes might be SI - and will be SI at defined
locations in the case of furcations and trees. So, if SI is only happening
at furcation points, the intersection can be calculated somehow in a fast
manner, to get a proper triangulation. Have a look, how the union of two
cylinders is mapped into STL (to get a first impression, you can use F10 and
Ctrl+1 which only partly triangulates).
This is the principle. OpenSCAD has this operator in form of union(). So,
one way is to import a bunch of branches (STLs) already correctly placed und
let OpenSCAD do the work dirty work in a general way.
In fact at CSG-level (F5) this is done only virtually by the graphics card.
And when it comes to STL output (F6) CGAL is used, which takes its time.

Knowing that all your branches will not SI, except at furcation points, you
can write your own specialized (and thus fast) union() that remeshes just
the furcation intersection part of the branches.

My main goal is (a) virtual reality visualization of many neurons
together, and (b) 3D printing of individual neurons.

It depends on how often this is repeated. If you model just some two or
three examples, long CGAL rendering times for that what you have, might be
tolerable, as recoding consumes much more time.

For virtual visualization you might want to put in more effort. OpenSCAD has
some nice animation support on the CSG-level. Trygon used it to do some
amazing things.
http://forum.openscad.org/Product-Video-produced-with-OpenSCAD-td15783.html.
Much more of course is offered by Blender.

Rudolf

--
View this message in context: http://forum.openscad.org/STL-without-render-tp17503p17530.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

bsuter wrote > In that post you wrote "A single sweep() along a smoothed trajectory > will be faster than a union of cylinders and spheres describing the > same". Could you please explain further what you mean, in OpenSCAD > terms, by "single sweep() along a smoothed trajectory"? This code is a good starting point and show case: http://www.thingiverse.com/thing:547620/#files to get an idea, how sweeps behave. The (implicit) union() is needed for marriage of different sweep trajectories. > Certainly each of my branches can be modeled as a sequence of > nodes, where each node has an associated radius. Is there a way to > represent this directly in OpenSCAD? I.e. to specify a trajectory in > 3D, and then extrude (ideally a circular cross-section, but a polygon > would work too) along this trajectory, with the extrusion radius > defined at each node? There is no language support for general extrusion along trajectories, and there is no data structure support (or let's say only weak array support) for things like trees and so on. But there are libraries like sweep() and skin() going into this direction. Also see here: http://www.thingiverse.com/thing:900137 >> I've implemented some Matlab class to generically describe arteries with >> an >> interpolation scheme. The output is a winding 'wire' in 3D with free >> radius >> at each point in STL-format. this is an example of the outcome: http://forum.openscad.org/Non-Linear-Transformations-tp14539p14597.html The class simply does some nspline calculation over a sequence of 4D vectors (x, y, z, r) describing a skeleton line. Most of the code is for handling STL-triangulation and output. >> In lack of an own union or furcation operator >> capable to do the intersection triangulation we currently use OpenSCAD >> and >> Blender to compose porperly placed wires into tree structures which we >> again >> cut into puzzle pieces for 3D print. > This part I don't understand ;( STL triagulation is easy and fast if you don't have to check for self-intersection (SI). I.e. if the code can assume, no SI will happen, it can skip all tests and calculations that would be needed to treat SI and just knit some generic triangulation pattern in a straight forward manner. Its helps to think about physical knitting to understand what is going on. For the puzzle part: It might be interesting to print a structure in pieces, e.g. to compose a construction kit or similar (which can also be used for moulding). In your case, it might be advantegous to print the neurons and the dendrits as destinct pieces and design a connector for piecing parts together as puzzle. A union of any non-SI shapes might be SI - and will be SI at defined locations in the case of furcations and trees. So, if SI is only happening at furcation points, the intersection can be calculated somehow in a fast manner, to get a proper triangulation. Have a look, how the union of two cylinders is mapped into STL (to get a first impression, you can use F10 and Ctrl+1 which only partly triangulates). This is the principle. OpenSCAD has this operator in form of union(). So, one way is to import a bunch of branches (STLs) already correctly placed und let OpenSCAD do the work dirty work in a general way. In fact at CSG-level (F5) this is done only virtually by the graphics card. And when it comes to STL output (F6) CGAL is used, which takes its time. Knowing that all your branches will not SI, except at furcation points, you can write your own specialized (and thus fast) union() that remeshes just the furcation intersection part of the branches. > My main goal is (a) virtual reality visualization of many neurons > together, and (b) 3D printing of individual neurons. It depends on how often this is repeated. If you model just some two or three examples, long CGAL rendering times for that what you have, might be tolerable, as recoding consumes much more time. For virtual visualization you might want to put in more effort. OpenSCAD has some nice animation support on the CSG-level. Trygon used it to do some amazing things. http://forum.openscad.org/Product-Video-produced-with-OpenSCAD-td15783.html. Much more of course is offered by Blender. Rudolf -- View this message in context: http://forum.openscad.org/STL-without-render-tp17503p17530.html Sent from the OpenSCAD mailing list archive at Nabble.com.
NH
nop head
Thu, Jun 2, 2016 4:35 PM

Simply replacing the unions with a cylinder by a hull of two spheres will
probably give a decent improvement in speed. Unioning a sphere with a
cylinder can be very slow.

On 2 June 2016 at 15:29, Parkinbot rudolf@parkinbot.com wrote:

bsuter wrote

In that post you wrote "A single sweep() along a smoothed trajectory
will be faster than a union of cylinders and spheres describing the
same". Could you please explain further what you mean, in OpenSCAD
terms, by "single sweep() along a smoothed trajectory"?

This code is a good starting point and show case:
http://www.thingiverse.com/thing:547620/#files
to get an idea, how sweeps behave. The (implicit) union() is needed for
marriage of different sweep trajectories.

Certainly each of my branches can be modeled as a sequence of
nodes, where each node has an associated radius. Is there a way to
represent this directly in OpenSCAD? I.e. to specify a trajectory in
3D, and then extrude (ideally a circular cross-section, but a polygon
would work too) along this trajectory, with the extrusion radius
defined at each node?

There is no language support for general extrusion along trajectories, and
there is no data structure support (or let's say only weak array support)
for things like trees and so on. But there are libraries like sweep() and
skin() going into this direction. Also see here:
http://www.thingiverse.com/thing:900137

I've implemented some Matlab class to generically describe arteries with
an
interpolation scheme. The output is a winding 'wire' in 3D with free
radius
at each point in STL-format.

this is an example of the outcome:
http://forum.openscad.org/Non-Linear-Transformations-tp14539p14597.html

The class simply does some nspline calculation over a sequence of 4D
vectors
(x, y, z, r) describing a skeleton line. Most of the code is for handling
STL-triangulation and output.

In lack of an own union or furcation operator
capable to do the intersection triangulation we currently use OpenSCAD
and
Blender to compose porperly placed wires into tree structures which we
again
cut into puzzle pieces for 3D print.

This part I don't understand ;(

STL triagulation is easy and fast if you don't have to check for
self-intersection (SI). I.e. if the code can assume, no SI will happen, it
can skip all tests and calculations that would be needed to treat SI and
just knit some generic triangulation pattern in a straight forward manner.
Its helps to think about physical knitting to understand what is going on.
For the puzzle part: It might be interesting to print a structure in
pieces,
e.g. to compose a construction kit or similar (which can also be used for
moulding).  In your case, it might be advantegous to print the neurons and
the dendrits as destinct pieces and design a connector for piecing parts
together as puzzle.

A union of any non-SI shapes might be SI - and will be SI at defined
locations in the case of furcations and trees. So, if SI is only happening
at furcation points, the intersection can be calculated somehow in a fast
manner, to get a proper triangulation. Have a look, how the union of two
cylinders is mapped into STL (to get a first impression, you can use F10
and
Ctrl+1 which only partly triangulates).
This is the principle. OpenSCAD has this operator in form of union(). So,
one way is to import a bunch of branches (STLs) already correctly placed
und
let OpenSCAD do the work dirty work in a general way.
In fact at CSG-level (F5) this is done only virtually by the graphics card.
And when it comes to STL output (F6) CGAL is used, which takes its time.

Knowing that all your branches will not SI, except at furcation points, you
can write your own specialized (and thus fast) union() that remeshes just
the furcation intersection part of the branches.

My main goal is (a) virtual reality visualization of many neurons
together, and (b) 3D printing of individual neurons.

It depends on how often this is repeated. If you model just some two or
three examples, long CGAL rendering times for that what you have, might be
tolerable, as recoding consumes much more time.

For virtual visualization you might want to put in more effort. OpenSCAD
has
some nice animation support on the CSG-level. Trygon used it to do some
amazing things.
http://forum.openscad.org/Product-Video-produced-with-OpenSCAD-td15783.html
.
Much more of course is offered by Blender.

Rudolf

--
View this message in context:
http://forum.openscad.org/STL-without-render-tp17503p17530.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Simply replacing the unions with a cylinder by a hull of two spheres will probably give a decent improvement in speed. Unioning a sphere with a cylinder can be very slow. On 2 June 2016 at 15:29, Parkinbot <rudolf@parkinbot.com> wrote: > bsuter wrote > > In that post you wrote "A single sweep() along a smoothed trajectory > > will be faster than a union of cylinders and spheres describing the > > same". Could you please explain further what you mean, in OpenSCAD > > terms, by "single sweep() along a smoothed trajectory"? > > This code is a good starting point and show case: > http://www.thingiverse.com/thing:547620/#files > to get an idea, how sweeps behave. The (implicit) union() is needed for > marriage of different sweep trajectories. > > > > Certainly each of my branches can be modeled as a sequence of > > nodes, where each node has an associated radius. Is there a way to > > represent this directly in OpenSCAD? I.e. to specify a trajectory in > > 3D, and then extrude (ideally a circular cross-section, but a polygon > > would work too) along this trajectory, with the extrusion radius > > defined at each node? > > There is no language support for general extrusion along trajectories, and > there is no data structure support (or let's say only weak array support) > for things like trees and so on. But there are libraries like sweep() and > skin() going into this direction. Also see here: > http://www.thingiverse.com/thing:900137 > > > >> I've implemented some Matlab class to generically describe arteries with > >> an > >> interpolation scheme. The output is a winding 'wire' in 3D with free > >> radius > >> at each point in STL-format. > > this is an example of the outcome: > http://forum.openscad.org/Non-Linear-Transformations-tp14539p14597.html > > The class simply does some nspline calculation over a sequence of 4D > vectors > (x, y, z, r) describing a skeleton line. Most of the code is for handling > STL-triangulation and output. > > > >> In lack of an own union or furcation operator > >> capable to do the intersection triangulation we currently use OpenSCAD > >> and > >> Blender to compose porperly placed wires into tree structures which we > >> again > >> cut into puzzle pieces for 3D print. > > This part I don't understand ;( > > STL triagulation is easy and fast if you don't have to check for > self-intersection (SI). I.e. if the code can assume, no SI will happen, it > can skip all tests and calculations that would be needed to treat SI and > just knit some generic triangulation pattern in a straight forward manner. > Its helps to think about physical knitting to understand what is going on. > For the puzzle part: It might be interesting to print a structure in > pieces, > e.g. to compose a construction kit or similar (which can also be used for > moulding). In your case, it might be advantegous to print the neurons and > the dendrits as destinct pieces and design a connector for piecing parts > together as puzzle. > > A union of any non-SI shapes might be SI - and will be SI at defined > locations in the case of furcations and trees. So, if SI is only happening > at furcation points, the intersection can be calculated somehow in a fast > manner, to get a proper triangulation. Have a look, how the union of two > cylinders is mapped into STL (to get a first impression, you can use F10 > and > Ctrl+1 which only partly triangulates). > This is the principle. OpenSCAD has this operator in form of union(). So, > one way is to import a bunch of branches (STLs) already correctly placed > und > let OpenSCAD do the work dirty work in a general way. > In fact at CSG-level (F5) this is done only virtually by the graphics card. > And when it comes to STL output (F6) CGAL is used, which takes its time. > > Knowing that all your branches will not SI, except at furcation points, you > can write your own specialized (and thus fast) union() that remeshes just > the furcation intersection part of the branches. > > > > My main goal is (a) virtual reality visualization of many neurons > > together, and (b) 3D printing of individual neurons. > > It depends on how often this is repeated. If you model just some two or > three examples, long CGAL rendering times for that what you have, might be > tolerable, as recoding consumes much more time. > > For virtual visualization you might want to put in more effort. OpenSCAD > has > some nice animation support on the CSG-level. Trygon used it to do some > amazing things. > http://forum.openscad.org/Product-Video-produced-with-OpenSCAD-td15783.html > . > Much more of course is offered by Blender. > > Rudolf > > > > > -- > View this message in context: > http://forum.openscad.org/STL-without-render-tp17503p17530.html > Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
B
bsuter
Thu, Jun 2, 2016 5:05 PM

Aha, I think I see what you mean:

  1. What I'm doing now: cylinder from point A to point B, a sphere at
    point B, another cylinder from point B to point C

  2. What you suggest: spheres at points A, B and C; plus hull() of each
    pair of spheres? But would I need to duplicate the sphere at point B,
    since it's part of two hulls?

Did I understand that correctly? I'll try this.

I found another thread that discusses something similar. Interestingly
it starts with someone doing a hull() of two spheres, and hoping for a
faster solution.
http://forum.openscad.org/Rods-between-3D-points-td13104.html

  1. User runsun then suggested: "It will be much faster if you can
    generate points on both end points and use polyhedron.", followed by
    detailed instructions.

In my case, I am able to generate the points framing a circle at each
end of the intended segment, call this pts_base and pts_top. So it
sounds like I could try:
pts = concat(pts_base, pts_top);
faces = faces(shape="rod", nside= len(pts_base), nseg=1);
polyhedron(points=pts, faces=faces("rod", nside=12));

However, this still needs some way to "fill the joint" at the
intersection of two such rods, and from what I've been reading in this
thread, it sounds like maybe it's precisely this problem (which I
"solved" by inserting a sphere at each joint) that is computationally
expensive?

On Thu, Jun 2, 2016 at 6:36 PM, nophead [via OpenSCAD]
ml-node+s1091067n17531h31@n5.nabble.com wrote:

Simply replacing the unions with a cylinder by a hull of two spheres will
probably give a decent improvement in speed. Unioning a sphere with a
cylinder can be very slow.

On 2 June 2016 at 15:29, Parkinbot <[hidden email]> wrote:

bsuter wrote

In that post you wrote "A single sweep() along a smoothed trajectory
will be faster than a union of cylinders and spheres describing the
same". Could you please explain further what you mean, in OpenSCAD
terms, by "single sweep() along a smoothed trajectory"?

This code is a good starting point and show case:
http://www.thingiverse.com/thing:547620/#files
to get an idea, how sweeps behave. The (implicit) union() is needed for
marriage of different sweep trajectories.

Certainly each of my branches can be modeled as a sequence of
nodes, where each node has an associated radius. Is there a way to
represent this directly in OpenSCAD? I.e. to specify a trajectory in
3D, and then extrude (ideally a circular cross-section, but a polygon
would work too) along this trajectory, with the extrusion radius
defined at each node?

There is no language support for general extrusion along trajectories, and
there is no data structure support (or let's say only weak array support)
for things like trees and so on. But there are libraries like sweep() and
skin() going into this direction. Also see here:
http://www.thingiverse.com/thing:900137

I've implemented some Matlab class to generically describe arteries
with
an
interpolation scheme. The output is a winding 'wire' in 3D with free
radius
at each point in STL-format.

this is an example of the outcome:
http://forum.openscad.org/Non-Linear-Transformations-tp14539p14597.html

The class simply does some nspline calculation over a sequence of 4D
vectors
(x, y, z, r) describing a skeleton line. Most of the code is for handling
STL-triangulation and output.

In lack of an own union or furcation operator
capable to do the intersection triangulation we currently use OpenSCAD
and
Blender to compose porperly placed wires into tree structures which we
again
cut into puzzle pieces for 3D print.

This part I don't understand ;(

STL triagulation is easy and fast if you don't have to check for
self-intersection (SI). I.e. if the code can assume, no SI will happen, it
can skip all tests and calculations that would be needed to treat SI and
just knit some generic triangulation pattern in a straight forward manner.
Its helps to think about physical knitting to understand what is going on.
For the puzzle part: It might be interesting to print a structure in
pieces,
e.g. to compose a construction kit or similar (which can also be used for
moulding).  In your case, it might be advantegous to print the neurons and
the dendrits as destinct pieces and design a connector for piecing parts
together as puzzle.

A union of any non-SI shapes might be SI - and will be SI at defined
locations in the case of furcations and trees. So, if SI is only happening
at furcation points, the intersection can be calculated somehow in a fast
manner, to get a proper triangulation. Have a look, how the union of two
cylinders is mapped into STL (to get a first impression, you can use F10
and
Ctrl+1 which only partly triangulates).
This is the principle. OpenSCAD has this operator in form of union(). So,
one way is to import a bunch of branches (STLs) already correctly placed
und
let OpenSCAD do the work dirty work in a general way.
In fact at CSG-level (F5) this is done only virtually by the graphics
card.
And when it comes to STL output (F6) CGAL is used, which takes its time.

Knowing that all your branches will not SI, except at furcation points,
you
can write your own specialized (and thus fast) union() that remeshes just
the furcation intersection part of the branches.

My main goal is (a) virtual reality visualization of many neurons
together, and (b) 3D printing of individual neurons.

It depends on how often this is repeated. If you model just some two or
three examples, long CGAL rendering times for that what you have, might be
tolerable, as recoding consumes much more time.

For virtual visualization you might want to put in more effort. OpenSCAD
has
some nice animation support on the CSG-level. Trygon used it to do some
amazing things.

http://forum.openscad.org/Product-Video-produced-with-OpenSCAD-td15783.html.
Much more of course is offered by Blender.

Rudolf

--
View this message in context:
http://forum.openscad.org/STL-without-render-tp17503p17530.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


If you reply to this email, your message will be added to the discussion
below:
http://forum.openscad.org/STL-without-render-tp17503p17531.html
To unsubscribe from STL without render?, click here.
NAML

--
View this message in context: http://forum.openscad.org/STL-without-render-tp17503p17532.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Aha, I think I see what you mean: 1. What I'm doing now: cylinder from point A to point B, a sphere at point B, another cylinder from point B to point C 2. What you suggest: spheres at points A, B and C; plus hull() of each pair of spheres? But would I need to duplicate the sphere at point B, since it's part of two hulls? Did I understand that correctly? I'll try this. I found another thread that discusses something similar. Interestingly it starts with someone doing a hull() of two spheres, and hoping for a faster solution. http://forum.openscad.org/Rods-between-3D-points-td13104.html 3. User runsun then suggested: "It will be much faster if you can generate points on both end points and use polyhedron.", followed by detailed instructions. In my case, I am able to generate the points framing a circle at each end of the intended segment, call this pts_base and pts_top. So it sounds like I could try: pts = concat(pts_base, pts_top); faces = faces(shape="rod", nside= len(pts_base), nseg=1); polyhedron(points=pts, faces=faces("rod", nside=12)); However, this still needs some way to "fill the joint" at the intersection of two such rods, and from what I've been reading in this thread, it sounds like maybe it's precisely this problem (which I "solved" by inserting a sphere at each joint) that is computationally expensive? On Thu, Jun 2, 2016 at 6:36 PM, nophead [via OpenSCAD] <ml-node+s1091067n17531h31@n5.nabble.com> wrote: > Simply replacing the unions with a cylinder by a hull of two spheres will > probably give a decent improvement in speed. Unioning a sphere with a > cylinder can be very slow. > > On 2 June 2016 at 15:29, Parkinbot <[hidden email]> wrote: >> >> bsuter wrote >> > In that post you wrote "A single sweep() along a smoothed trajectory >> > will be faster than a union of cylinders and spheres describing the >> > same". Could you please explain further what you mean, in OpenSCAD >> > terms, by "single sweep() along a smoothed trajectory"? >> >> This code is a good starting point and show case: >> http://www.thingiverse.com/thing:547620/#files >> to get an idea, how sweeps behave. The (implicit) union() is needed for >> marriage of different sweep trajectories. >> >> >> > Certainly each of my branches can be modeled as a sequence of >> > nodes, where each node has an associated radius. Is there a way to >> > represent this directly in OpenSCAD? I.e. to specify a trajectory in >> > 3D, and then extrude (ideally a circular cross-section, but a polygon >> > would work too) along this trajectory, with the extrusion radius >> > defined at each node? >> >> There is no language support for general extrusion along trajectories, and >> there is no data structure support (or let's say only weak array support) >> for things like trees and so on. But there are libraries like sweep() and >> skin() going into this direction. Also see here: >> http://www.thingiverse.com/thing:900137 >> >> >> >> I've implemented some Matlab class to generically describe arteries >> >> with >> >> an >> >> interpolation scheme. The output is a winding 'wire' in 3D with free >> >> radius >> >> at each point in STL-format. >> >> this is an example of the outcome: >> http://forum.openscad.org/Non-Linear-Transformations-tp14539p14597.html >> >> The class simply does some nspline calculation over a sequence of 4D >> vectors >> (x, y, z, r) describing a skeleton line. Most of the code is for handling >> STL-triangulation and output. >> >> >> >> In lack of an own union or furcation operator >> >> capable to do the intersection triangulation we currently use OpenSCAD >> >> and >> >> Blender to compose porperly placed wires into tree structures which we >> >> again >> >> cut into puzzle pieces for 3D print. >> > This part I don't understand ;( >> >> STL triagulation is easy and fast if you don't have to check for >> self-intersection (SI). I.e. if the code can assume, no SI will happen, it >> can skip all tests and calculations that would be needed to treat SI and >> just knit some generic triangulation pattern in a straight forward manner. >> Its helps to think about physical knitting to understand what is going on. >> For the puzzle part: It might be interesting to print a structure in >> pieces, >> e.g. to compose a construction kit or similar (which can also be used for >> moulding). In your case, it might be advantegous to print the neurons and >> the dendrits as destinct pieces and design a connector for piecing parts >> together as puzzle. >> >> A union of any non-SI shapes might be SI - and will be SI at defined >> locations in the case of furcations and trees. So, if SI is only happening >> at furcation points, the intersection can be calculated somehow in a fast >> manner, to get a proper triangulation. Have a look, how the union of two >> cylinders is mapped into STL (to get a first impression, you can use F10 >> and >> Ctrl+1 which only partly triangulates). >> This is the principle. OpenSCAD has this operator in form of union(). So, >> one way is to import a bunch of branches (STLs) already correctly placed >> und >> let OpenSCAD do the work dirty work in a general way. >> In fact at CSG-level (F5) this is done only virtually by the graphics >> card. >> And when it comes to STL output (F6) CGAL is used, which takes its time. >> >> Knowing that all your branches will not SI, except at furcation points, >> you >> can write your own specialized (and thus fast) union() that remeshes just >> the furcation intersection part of the branches. >> >> >> > My main goal is (a) virtual reality visualization of many neurons >> > together, and (b) 3D printing of individual neurons. >> >> It depends on how often this is repeated. If you model just some two or >> three examples, long CGAL rendering times for that what you have, might be >> tolerable, as recoding consumes much more time. >> >> For virtual visualization you might want to put in more effort. OpenSCAD >> has >> some nice animation support on the CSG-level. Trygon used it to do some >> amazing things. >> >> http://forum.openscad.org/Product-Video-produced-with-OpenSCAD-td15783.html. >> Much more of course is offered by Blender. >> >> Rudolf >> >> >> >> >> -- >> View this message in context: >> http://forum.openscad.org/STL-without-render-tp17503p17530.html >> Sent from the OpenSCAD mailing list archive at Nabble.com. >> >> _______________________________________________ >> OpenSCAD mailing list >> [hidden email] >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > > _______________________________________________ > OpenSCAD mailing list > [hidden email] > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > ________________________________ > If you reply to this email, your message will be added to the discussion > below: > http://forum.openscad.org/STL-without-render-tp17503p17531.html > To unsubscribe from STL without render?, click here. > NAML -- View this message in context: http://forum.openscad.org/STL-without-render-tp17503p17532.html Sent from the OpenSCAD mailing list archive at Nabble.com.
NH
nop head
Thu, Jun 2, 2016 5:20 PM

On 2 June 2016 at 18:05, bsuter ben.suter@gmail.com wrote:

Aha, I think I see what you mean:

  1. What I'm doing now: cylinder from point A to point B, a sphere at
    point B, another cylinder from point B to point C

  2. What you suggest: spheres at points A, B and C; plus hull() of each
    pair of spheres? But would I need to duplicate the sphere at point B,
    since it's part of two hulls?

Yes but duplicating a sphere takes no time at all because it is cached.
Hull is faster than union in later versions of OpenScad but you still need
to union the results so it won't be very fast but perhaps twice the current
speed at a guess.

Did I understand that correctly? I'll try this.

I found another thread that discusses something similar. Interestingly
it starts with someone doing a hull() of two spheres, and hoping for a
faster solution.
http://forum.openscad.org/Rods-between-3D-points-td13104.html

  1. User runsun then suggested: "It will be much faster if you can
    generate points on both end points and use polyhedron.", followed by
    detailed instructions.

In my case, I am able to generate the points framing a circle at each
end of the intended segment, call this pts_base and pts_top. So it
sounds like I could try:
pts = concat(pts_base, pts_top);
faces = faces(shape="rod", nside= len(pts_base), nseg=1);
polyhedron(points=pts, faces=faces("rod", nside=12));

However, this still needs some way to "fill the joint" at the
intersection of two such rods, and from what I've been reading in this
thread, it sounds like maybe it's precisely this problem (which I
"solved" by inserting a sphere at each joint) that is computationally
expensive?

Unioning things that have lots of vertices is very expensive. Generating
polyhedra from points is very fast but you have to be able to fully
describe the shape mathematically. That is not easy where there is a
branch, so best case I think you will need a union per branch or a very
clever recursive function that makes one big polyhedron.

On Thu, Jun 2, 2016 at 6:36 PM, nophead [via OpenSCAD]
<[hidden email] http:///user/SendEmail.jtp?type=node&node=17532&i=0>
wrote:

Simply replacing the unions with a cylinder by a hull of two spheres

will

probably give a decent improvement in speed. Unioning a sphere with a
cylinder can be very slow.

On 2 June 2016 at 15:29, Parkinbot <[hidden email]> wrote:

bsuter wrote

In that post you wrote "A single sweep() along a smoothed trajectory
will be faster than a union of cylinders and spheres describing the
same". Could you please explain further what you mean, in OpenSCAD
terms, by "single sweep() along a smoothed trajectory"?

This code is a good starting point and show case:
http://www.thingiverse.com/thing:547620/#files
to get an idea, how sweeps behave. The (implicit) union() is needed for
marriage of different sweep trajectories.

Certainly each of my branches can be modeled as a sequence of
nodes, where each node has an associated radius. Is there a way to
represent this directly in OpenSCAD? I.e. to specify a trajectory in
3D, and then extrude (ideally a circular cross-section, but a polygon
would work too) along this trajectory, with the extrusion radius
defined at each node?

There is no language support for general extrusion along trajectories,

and

there is no data structure support (or let's say only weak array

support)

for things like trees and so on. But there are libraries like sweep()

and

skin() going into this direction. Also see here:
http://www.thingiverse.com/thing:900137

I've implemented some Matlab class to generically describe arteries
with
an
interpolation scheme. The output is a winding 'wire' in 3D with free
radius
at each point in STL-format.

this is an example of the outcome:
http://forum.openscad.org/Non-Linear-Transformations-tp14539p14597.html

The class simply does some nspline calculation over a sequence of 4D
vectors
(x, y, z, r) describing a skeleton line. Most of the code is for

handling

STL-triangulation and output.

In lack of an own union or furcation operator
capable to do the intersection triangulation we currently use

OpenSCAD

and
Blender to compose porperly placed wires into tree structures which

we

again
cut into puzzle pieces for 3D print.

This part I don't understand ;(

STL triagulation is easy and fast if you don't have to check for
self-intersection (SI). I.e. if the code can assume, no SI will happen,

it

can skip all tests and calculations that would be needed to treat SI

and

just knit some generic triangulation pattern in a straight forward

manner.

Its helps to think about physical knitting to understand what is going

on.

For the puzzle part: It might be interesting to print a structure in
pieces,
e.g. to compose a construction kit or similar (which can also be used

for

moulding).  In your case, it might be advantegous to print the neurons

and

the dendrits as destinct pieces and design a connector for piecing

parts

together as puzzle.

A union of any non-SI shapes might be SI - and will be SI at defined
locations in the case of furcations and trees. So, if SI is only

happening

at furcation points, the intersection can be calculated somehow in a

fast

manner, to get a proper triangulation. Have a look, how the union of

two

cylinders is mapped into STL (to get a first impression, you can use

F10

and
Ctrl+1 which only partly triangulates).
This is the principle. OpenSCAD has this operator in form of union().

So,

one way is to import a bunch of branches (STLs) already correctly

placed

und
let OpenSCAD do the work dirty work in a general way.
In fact at CSG-level (F5) this is done only virtually by the graphics
card.
And when it comes to STL output (F6) CGAL is used, which takes its

time.

Knowing that all your branches will not SI, except at furcation points,
you
can write your own specialized (and thus fast) union() that remeshes

just

the furcation intersection part of the branches.

My main goal is (a) virtual reality visualization of many neurons
together, and (b) 3D printing of individual neurons.

It depends on how often this is repeated. If you model just some two or
three examples, long CGAL rendering times for that what you have, might

be

tolerable, as recoding consumes much more time.

For virtual visualization you might want to put in more effort.

OpenSCAD

has
some nice animation support on the CSG-level. Trygon used it to do some
amazing things.

Much more of course is offered by Blender.

Rudolf

--
View this message in context:
http://forum.openscad.org/STL-without-render-tp17503p17530.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


If you reply to this email, your message will be added to the discussion
below:
http://forum.openscad.org/STL-without-render-tp17503p17531.html
To unsubscribe from STL without render?, click here.
NAML


View this message in context: Re: STL without render?
http://forum.openscad.org/STL-without-render-tp17503p17532.html

Sent from the OpenSCAD mailing list archive http://forum.openscad.org/
at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

On 2 June 2016 at 18:05, bsuter <ben.suter@gmail.com> wrote: > Aha, I think I see what you mean: > 1. What I'm doing now: cylinder from point A to point B, a sphere at > point B, another cylinder from point B to point C > > 2. What you suggest: spheres at points A, B and C; plus hull() of each > pair of spheres? But would I need to duplicate the sphere at point B, > since it's part of two hulls? > Yes but duplicating a sphere takes no time at all because it is cached. Hull is faster than union in later versions of OpenScad but you still need to union the results so it won't be very fast but perhaps twice the current speed at a guess. > > Did I understand that correctly? I'll try this. > > I found another thread that discusses something similar. Interestingly > it starts with someone doing a hull() of two spheres, and hoping for a > faster solution. > http://forum.openscad.org/Rods-between-3D-points-td13104.html > > 3. User runsun then suggested: "It will be much faster if you can > generate points on both end points and use polyhedron.", followed by > detailed instructions. > > In my case, I am able to generate the points framing a circle at each > end of the intended segment, call this pts_base and pts_top. So it > sounds like I could try: > pts = concat(pts_base, pts_top); > faces = faces(shape="rod", nside= len(pts_base), nseg=1); > polyhedron(points=pts, faces=faces("rod", nside=12)); > > However, this still needs some way to "fill the joint" at the > intersection of two such rods, and from what I've been reading in this > thread, it sounds like maybe it's precisely this problem (which I > "solved" by inserting a sphere at each joint) that is computationally > expensive? > Unioning things that have lots of vertices is very expensive. Generating polyhedra from points is very fast but you have to be able to fully describe the shape mathematically. That is not easy where there is a branch, so best case I think you will need a union per branch or a very clever recursive function that makes one big polyhedron. > > > On Thu, Jun 2, 2016 at 6:36 PM, nophead [via OpenSCAD] > <[hidden email] <http:///user/SendEmail.jtp?type=node&node=17532&i=0>> > wrote: > > > Simply replacing the unions with a cylinder by a hull of two spheres > will > > probably give a decent improvement in speed. Unioning a sphere with a > > cylinder can be very slow. > > > > On 2 June 2016 at 15:29, Parkinbot <[hidden email]> wrote: > >> > >> bsuter wrote > >> > In that post you wrote "A single sweep() along a smoothed trajectory > >> > will be faster than a union of cylinders and spheres describing the > >> > same". Could you please explain further what you mean, in OpenSCAD > >> > terms, by "single sweep() along a smoothed trajectory"? > >> > >> This code is a good starting point and show case: > >> http://www.thingiverse.com/thing:547620/#files > >> to get an idea, how sweeps behave. The (implicit) union() is needed for > >> marriage of different sweep trajectories. > >> > >> > >> > Certainly each of my branches can be modeled as a sequence of > >> > nodes, where each node has an associated radius. Is there a way to > >> > represent this directly in OpenSCAD? I.e. to specify a trajectory in > >> > 3D, and then extrude (ideally a circular cross-section, but a polygon > >> > would work too) along this trajectory, with the extrusion radius > >> > defined at each node? > >> > >> There is no language support for general extrusion along trajectories, > and > >> there is no data structure support (or let's say only weak array > support) > >> for things like trees and so on. But there are libraries like sweep() > and > >> skin() going into this direction. Also see here: > >> http://www.thingiverse.com/thing:900137 > >> > >> > >> >> I've implemented some Matlab class to generically describe arteries > >> >> with > >> >> an > >> >> interpolation scheme. The output is a winding 'wire' in 3D with free > >> >> radius > >> >> at each point in STL-format. > >> > >> this is an example of the outcome: > >> http://forum.openscad.org/Non-Linear-Transformations-tp14539p14597.html > >> > >> The class simply does some nspline calculation over a sequence of 4D > >> vectors > >> (x, y, z, r) describing a skeleton line. Most of the code is for > handling > >> STL-triangulation and output. > >> > >> > >> >> In lack of an own union or furcation operator > >> >> capable to do the intersection triangulation we currently use > OpenSCAD > >> >> and > >> >> Blender to compose porperly placed wires into tree structures which > we > >> >> again > >> >> cut into puzzle pieces for 3D print. > >> > This part I don't understand ;( > >> > >> STL triagulation is easy and fast if you don't have to check for > >> self-intersection (SI). I.e. if the code can assume, no SI will happen, > it > >> can skip all tests and calculations that would be needed to treat SI > and > >> just knit some generic triangulation pattern in a straight forward > manner. > >> Its helps to think about physical knitting to understand what is going > on. > >> For the puzzle part: It might be interesting to print a structure in > >> pieces, > >> e.g. to compose a construction kit or similar (which can also be used > for > >> moulding). In your case, it might be advantegous to print the neurons > and > >> the dendrits as destinct pieces and design a connector for piecing > parts > >> together as puzzle. > >> > >> A union of any non-SI shapes might be SI - and will be SI at defined > >> locations in the case of furcations and trees. So, if SI is only > happening > >> at furcation points, the intersection can be calculated somehow in a > fast > >> manner, to get a proper triangulation. Have a look, how the union of > two > >> cylinders is mapped into STL (to get a first impression, you can use > F10 > >> and > >> Ctrl+1 which only partly triangulates). > >> This is the principle. OpenSCAD has this operator in form of union(). > So, > >> one way is to import a bunch of branches (STLs) already correctly > placed > >> und > >> let OpenSCAD do the work dirty work in a general way. > >> In fact at CSG-level (F5) this is done only virtually by the graphics > >> card. > >> And when it comes to STL output (F6) CGAL is used, which takes its > time. > >> > >> Knowing that all your branches will not SI, except at furcation points, > >> you > >> can write your own specialized (and thus fast) union() that remeshes > just > >> the furcation intersection part of the branches. > >> > >> > >> > My main goal is (a) virtual reality visualization of many neurons > >> > together, and (b) 3D printing of individual neurons. > >> > >> It depends on how often this is repeated. If you model just some two or > >> three examples, long CGAL rendering times for that what you have, might > be > >> tolerable, as recoding consumes much more time. > >> > >> For virtual visualization you might want to put in more effort. > OpenSCAD > >> has > >> some nice animation support on the CSG-level. Trygon used it to do some > >> amazing things. > >> > >> > http://forum.openscad.org/Product-Video-produced-with-OpenSCAD-td15783.html. > > >> Much more of course is offered by Blender. > >> > >> Rudolf > >> > >> > >> > >> > >> -- > >> View this message in context: > >> http://forum.openscad.org/STL-without-render-tp17503p17530.html > >> Sent from the OpenSCAD mailing list archive at Nabble.com. > >> > >> _______________________________________________ > >> OpenSCAD mailing list > >> [hidden email] > >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > > > > > > _______________________________________________ > > OpenSCAD mailing list > > [hidden email] > > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > > > > ________________________________ > > If you reply to this email, your message will be added to the discussion > > below: > > http://forum.openscad.org/STL-without-render-tp17503p17531.html > > To unsubscribe from STL without render?, click here. > > NAML > > ------------------------------ > View this message in context: Re: STL without render? > <http://forum.openscad.org/STL-without-render-tp17503p17532.html> > > Sent from the OpenSCAD mailing list archive <http://forum.openscad.org/> > at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
N
Neon22
Thu, Jun 2, 2016 8:22 PM

As pointed out above. Nophead's solution of "hull between spheres at junction
points" is the least effort for speedup. You can set the sphere resolution
low ($fn) for faster preview.

The route best suited to your specific problem is extruding a cross sectiin
along a 'wire' for which there is code linked above. You' d make many
'wires' and then skin them, finally union these together if you needed a
single solid object.

--
View this message in context: http://forum.openscad.org/STL-without-render-tp17503p17535.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

As pointed out above. Nophead's solution of "hull between spheres at junction points" is the least effort for speedup. You can set the sphere resolution low ($fn) for faster preview. The route best suited to your specific problem is extruding a cross sectiin along a 'wire' for which there is code linked above. You' d make many 'wires' and then skin them, finally union these together if you needed a single solid object. -- View this message in context: http://forum.openscad.org/STL-without-render-tp17503p17535.html Sent from the OpenSCAD mailing list archive at Nabble.com.
B
bsuter
Thu, Jun 2, 2016 8:38 PM

As pointed out above. Nophead's solution of "hull between spheres at
junction points" is the least effort for speedup. You can set the sphere
resolution low ($fn) for faster preview.

Thank you - preview is instantaneous (sub-second) for my current
solution (cylinders and spheres), but render takes 2.5 hours per
neuron (and I have many neurons to render). I will try the "hull
between spheres at junction points" and report back.

The route best suited to your specific problem is extruding a cross sectiin
along a 'wire' for which there is code linked above. You' d make many
'wires' and then skin them, finally union these together if you needed a
single solid object.

What I don't yet understand about this solution is how the "joint" or
"junctions" are handled: does the extrusion "turn the bend", so to
speak, or does this solution still require additional spheres (or ?)
at the points where the wire changes direction?

Many thanks!


If you reply to this email, your message will be added to the discussion
below:
http://forum.openscad.org/STL-without-render-tp17503p17535.html
To unsubscribe from STL without render?, click here.
NAML

--
View this message in context: http://forum.openscad.org/STL-without-render-tp17503p17537.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

> As pointed out above. Nophead's solution of "hull between spheres at > junction points" is the least effort for speedup. You can set the sphere > resolution low ($fn) for faster preview. Thank you - preview is instantaneous (sub-second) for my current solution (cylinders and spheres), but render takes 2.5 hours per neuron (and I have many neurons to render). I will try the "hull between spheres at junction points" and report back. > The route best suited to your specific problem is extruding a cross sectiin > along a 'wire' for which there is code linked above. You' d make many > 'wires' and then skin them, finally union these together if you needed a > single solid object. What I don't yet understand about this solution is how the "joint" or "junctions" are handled: does the extrusion "turn the bend", so to speak, or does this solution still require additional spheres (or ?) at the points where the wire changes direction? Many thanks! > > ________________________________ > If you reply to this email, your message will be added to the discussion > below: > http://forum.openscad.org/STL-without-render-tp17503p17535.html > To unsubscribe from STL without render?, click here. > NAML -- View this message in context: http://forum.openscad.org/STL-without-render-tp17503p17537.html Sent from the OpenSCAD mailing list archive at Nabble.com.
P
Parkinbot
Thu, Jun 2, 2016 9:44 PM

the problem is that a general union() will check each edge against each edge
of each other shape. This is a quadratic problem, if no optimization or
short cut scheme is employed. Double number of edges (shapes) four times
longer execution.

--
View this message in context: http://forum.openscad.org/STL-without-render-tp17503p17539.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

the problem is that a general union() will check each edge against each edge of each other shape. This is a quadratic problem, if no optimization or short cut scheme is employed. Double number of edges (shapes) four times longer execution. -- View this message in context: http://forum.openscad.org/STL-without-render-tp17503p17539.html Sent from the OpenSCAD mailing list archive at Nabble.com.
R
Ronaldo
Fri, Jun 3, 2016 1:58 AM

I did some very basic speed tests and even so the results were very
surprising.

A sphere with 250000 facets ($fn=500) takes virtually no time to render
(less than 1sec). But if you render the union of a few disjoint spheres the
time grows very fast:

            total #        total         total #
            facets         time        of spheres ($fn=20)
	   362          0s              1 
	  3100        31s            10
	 31000      550s           100

The union of 10 coincident spheres (r=10, $fn=20) spent 800s!, that is much
more than 10 similar disjoint spheres.

What was a lot surprising for me was the time only one refined cylinder
spent to render.

	# facets           time
	 50000               7s
	100000             29s
	200000           129s
	250000           212s

To confirm that using polyhedron is faster, I wrote the following code that
is able to generate a set (union) of disjoint "spheres"  using only one call
of polyhedron:

n = 20; // $fn
m = n/2;
N = 2000; // number of spheres
radius = 10;

unitary_circle = [ for(i=[0:n]) [ cos(360i/n), sin(360i/n), 0 ] ];
// sphere
sphere_vertices  = radius*[ for( j=[-m/2:m/2], p=unitary_circle )
cos(180j/m) * p + [0, 0, sin(180j/m)] ];
nvert = len(sphere_vertices);

// triangulated faces of the sphere
faces = concat(
[ for(i=[0:n-1])
[ 0, n+i+1, n+i+2 ] ] ,
[ for(j=[1:m-1], i=[0:n-1])
[ (n+1)j+i+1, (n+1)j+i, (n+1)(j+1)+i ] ] ,
[ for(j=[1:m-1], i=[0:n-1])
[ (n+1)j+i+1, (n+1)(j+1)+i, (n+1)
(j+1)+i+1 ] ] ,
[ for(i=[0:n-1])
[ (n+1)(m-1)+i, (n+1)(m+1)-1, (n+1)*(m-1)+i+1] ] ) ;

// vertices of the union of N spheres
unispheres = [ for(k=[1:N], p=sphere_vertices) p+[25*k,0,0] ];

// facets of the union of N spheres
unifaces  = [ for(k=[1:N], f=faces) [for(i=f) i+nvert*(k-1) ] ];

polyhedron( points = unispheres, faces = unifaces);
sphere(10); // a regular sphere

As expected, the set of spheres generated by this code renders a lot faster
than the regular union of OpenSCAD spheres. And the time seems to grow
linearly:

timing of a set of sphere in one polyhedron
# facets      time        # spheres
40000            2s        100
400000          22s        1000

A neuron with just 1600 disjoint $fn=20 spheres will require a lot of time
to render. I don't believe that doing hulls between spheres and the
cylinders would result in a significant gain because those parts need to be
unioned and that is the bottleneck. To get a significant reduction in the
render time you will need to code the generation of vertices and facets to
be sent to polyhedron as the code above do. Doing that for a whole neuron is
a huge task.

The lesson here is: to do CSG operations with B-rep (the internal
representation CGAL uses) works only for small number of primitives. To deal
with a great number of primitives OpenSCAD needs to look for alternative
internal representations.

--
View this message in context: http://forum.openscad.org/STL-without-render-tp17503p17543.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

I did some very basic speed tests and even so the results were very surprising. A sphere with 250000 facets ($fn=500) takes virtually no time to render (less than 1sec). But if you render the union of a few disjoint spheres the time grows very fast: > total # total total # > facets time of spheres ($fn=20) > 362 0s 1 > 3100 31s 10 > 31000 550s 100 The union of 10 coincident spheres (r=10, $fn=20) spent 800s!, that is much more than 10 similar disjoint spheres. What was a lot surprising for me was the time only one refined cylinder spent to render. > # facets time > 50000 7s > 100000 29s > 200000 129s > 250000 212s To confirm that using polyhedron is faster, I wrote the following code that is able to generate a set (union) of disjoint "spheres" using only one call of polyhedron: > n = 20; // $fn > m = n/2; > N = 2000; // number of spheres > radius = 10; > > unitary_circle = [ for(i=[0:n]) [ cos(360*i/n), sin(360*i/n), 0 ] ]; > // sphere > sphere_vertices = radius*[ for( j=[-m/2:m/2], p=unitary_circle ) > cos(180*j/m) * p + [0, 0, sin(180*j/m)] ]; > nvert = len(sphere_vertices); > > // triangulated faces of the sphere > faces = concat( > [ for(i=[0:n-1]) > [ 0, n+i+1, n+i+2 ] ] , > [ for(j=[1:m-1], i=[0:n-1]) > [ (n+1)*j+i+1, (n+1)*j+i, (n+1)*(j+1)+i ] ] , > [ for(j=[1:m-1], i=[0:n-1]) > [ (n+1)*j+i+1, (n+1)*(j+1)+i, (n+1)*(j+1)+i+1 ] ] , > [ for(i=[0:n-1]) > [ (n+1)*(m-1)+i, (n+1)*(m+1)-1, (n+1)*(m-1)+i+1] ] ) ; > > // vertices of the union of N spheres > unispheres = [ for(k=[1:N], p=sphere_vertices) p+[25*k,0,0] ]; > > // facets of the union of N spheres > unifaces = [ for(k=[1:N], f=faces) [for(i=f) i+nvert*(k-1) ] ]; > > polyhedron( points = unispheres, faces = unifaces); > sphere(10); // a regular sphere As expected, the set of spheres generated by this code renders a lot faster than the regular union of OpenSCAD spheres. And the time seems to grow linearly: > timing of a set of sphere in one polyhedron > # facets time # spheres > 40000 2s 100 > 400000 22s 1000 A neuron with just 1600 disjoint $fn=20 spheres will require a lot of time to render. I don't believe that doing hulls between spheres and the cylinders would result in a significant gain because those parts need to be unioned and that is the bottleneck. To get a significant reduction in the render time you will need to code the generation of vertices and facets to be sent to polyhedron as the code above do. Doing that for a whole neuron is a huge task. The lesson here is: to do CSG operations with B-rep (the internal representation CGAL uses) works only for small number of primitives. To deal with a great number of primitives OpenSCAD needs to look for alternative internal representations. -- View this message in context: http://forum.openscad.org/STL-without-render-tp17503p17543.html Sent from the OpenSCAD mailing list archive at Nabble.com.
TP
Torsten Paul
Fri, Jun 3, 2016 6:52 AM

On 06/03/2016 03:58 AM, Ronaldo wrote:

The lesson here is: to do CSG operations with B-rep (the internal
representation CGAL uses) works only for small number of primitives.
To deal with a great number of primitives OpenSCAD needs to look
for alternative internal representations.

Yes, this is all pretty much known, and the discussion about
alternatives is also not new. The Problem is that there's no
real alternative in sight.

The page collecting some info is:
https://github.com/openscad/openscad/wiki/Project%3A-Survey-of-CSG-algorithms

ciao,
Torsten.

On 06/03/2016 03:58 AM, Ronaldo wrote: > The lesson here is: to do CSG operations with B-rep (the internal > representation CGAL uses) works only for small number of primitives. > To deal with a great number of primitives OpenSCAD needs to look > for alternative internal representations. > Yes, this is all pretty much known, and the discussion about alternatives is also not new. The Problem is that there's no real alternative in sight. The page collecting some info is: https://github.com/openscad/openscad/wiki/Project%3A-Survey-of-CSG-algorithms ciao, Torsten.