discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Animations and memory use

JB
Jordan Brown
Fri, Mar 3, 2023 5:23 AM

Actually, hold on a second.  Jon, can you share your script?

I just wrote a simple script to generate ~10K spheres, and on my antique
system F5 takes about four seconds.  (It claims less than a second, but
there must be something that's not being counted because I count four
seconds.)

That's 10,000 spheres with diameter 20, which for the default $fa/$fs
yields the maximum number of facets, 814.

I'm sure it would take forever to render with F6, because a variant with
only 27 spheres takes two minutes.  But the preview is (relatively) fast.

sep = 30;
d = 20;
n = 100;
echo(n^2);
for (x=[1:n], y=[1:n]){
    translate([x,y]*sep) sphere(d=d);
}
Actually, hold on a second.  Jon, can you share your script? I just wrote a simple script to generate ~10K spheres, and on my antique system F5 takes about four seconds.  (It claims less than a second, but there must be something that's not being counted because I count four seconds.) That's 10,000 spheres with diameter 20, which for the default $fa/$fs yields the maximum number of facets, 814. I'm sure it would take forever to render with F6, because a variant with only 27 spheres takes two minutes.  But the preview is (relatively) fast. sep = 30; d = 20; n = 100; echo(n^2); for (x=[1:n], y=[1:n]){ translate([x,y]*sep) sphere(d=d); }
MM
Michael Möller
Fri, Mar 3, 2023 7:30 AM

That was fun. 0.415 seconds, but then the zoom out to actually see the
spheres ... sorry I can't hear you, the fan is making too much noise!

On my average laptop the task manager just shows CPU time, no graphics
activity. And it is only one core (so I was exaggerating a bit about the
fan)

The best thing here though was being reminded of the nice
vector-multiplication "[x,y]*sep"

On Fri, 3 Mar 2023 at 06:24, Jordan Brown openscad@jordan.maileater.net
wrote:

Actually, hold on a second.  Jon, can you share your script?

I just wrote a simple script to generate ~10K spheres, and on my antique
system F5 takes about four seconds.  (It claims less than a second, but
there must be something that's not being counted because I count four
seconds.)

That's 10,000 spheres with diameter 20, which for the default $fa/$fs
yields the maximum number of facets, 814.

I'm sure it would take forever to render with F6, because a variant with
only 27 spheres takes two minutes.  But the preview is (relatively) fast.

sep = 30;
d = 20;
n = 100;
echo(n^2);
for (x=[1:n], y=[1:n]){
translate([x,y]*sep) sphere(d=d);
}


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

That was fun. 0.415 seconds, but then the zoom out to actually see the spheres ... sorry I can't hear you, the fan is making too much noise! On my average laptop the task manager just shows CPU time, no graphics activity. And it is only one core (so I was exaggerating a bit about the fan) The best thing here though was being reminded of the nice vector-multiplication "[x,y]*sep" On Fri, 3 Mar 2023 at 06:24, Jordan Brown <openscad@jordan.maileater.net> wrote: > Actually, hold on a second. Jon, can you share your script? > > I just wrote a simple script to generate ~10K spheres, and on my antique > system F5 takes about four seconds. (It claims less than a second, but > there must be something that's not being counted because I count four > seconds.) > > That's 10,000 spheres with diameter 20, which for the default $fa/$fs > yields the maximum number of facets, 814. > > I'm sure it would take forever to render with F6, because a variant with > only 27 spheres takes two minutes. But the preview is (relatively) fast. > > sep = 30; > d = 20; > n = 100; > echo(n^2); > for (x=[1:n], y=[1:n]){ > translate([x,y]*sep) sphere(d=d); > } > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
J
jon
Fri, Mar 3, 2023 8:58 AM

Jordan:

I can share the script if you contact me privately.

Jon

On 3/3/2023 12:23 AM, Jordan Brown wrote:

Actually, hold on a second.  Jon, can you share your script?

I just wrote a simple script to generate ~10K spheres, and on my
antique system F5 takes about four seconds.  (It claims less than a
second, but there must be something that's not being counted because I
count four seconds.)

That's 10,000 spheres with diameter 20, which for the default $fa/$fs
yields the maximum number of facets, 814.

I'm sure it would take forever to render with F6, because a variant
with only 27 spheres takes two minutes.  But the preview is
(relatively) fast.

 sep = 30;
 d = 20;
 n = 100;
 echo(n^2);
 for (x=[1:n], y=[1:n]){
      translate([x,y]*sep) sphere(d=d);
 }
Jordan: I can share the script if you contact me privately. Jon On 3/3/2023 12:23 AM, Jordan Brown wrote: > Actually, hold on a second.  Jon, can you share your script? > > I just wrote a simple script to generate ~10K spheres, and on my > antique system F5 takes about four seconds.  (It claims less than a > second, but there must be something that's not being counted because I > count four seconds.) > > That's 10,000 spheres with diameter 20, which for the default $fa/$fs > yields the maximum number of facets, 814. > > I'm sure it would take forever to render with F6, because a variant > with only 27 spheres takes two minutes.  But the preview is > (relatively) fast. > > sep = 30; > d = 20; > n = 100; > echo(n^2); > for (x=[1:n], y=[1:n]){ > translate([x,y]*sep) sphere(d=d); > } >
J
jon
Fri, Mar 3, 2023 9:00 AM

Sphere diameter is 1, so they look like this:

On 3/2/2023 11:53 PM, Jordan Brown wrote:

How large are your spheres?

Sphere diameter is 1, so they look like this: On 3/2/2023 11:53 PM, Jordan Brown wrote: > How large are your spheres? >
J
jon
Fri, Mar 3, 2023 9:28 AM

Just flailing around here...

My 3D model consists of 100 sub-models, each of which contains 100 small
spheres (hence the 10,000).  When I created an STL to represent the
sub-model, and imported that 100 times, the F5 time was reduced from
about 5 minutes to about 3 seconds.   When I then tried F6, it failed at
about 1 GB (which is better than 32 GB) in under 3 minutes (which is
better than never), but with these error messages:

Parsing design (AST generation)...

Compiling design (CSG Tree generation)...

Rendering Polygon Mesh using CGAL...

ERROR: The given mesh is not closed! Unable to convert to
CGAL_Nef_Polyhedron.  

ERROR: The given mesh is not closed! Unable to convert to
CGAL_Nef_Polyhedron.  

ERROR: The given mesh is not closed! Unable to convert to
CGAL_Nef_Polyhedron.  

ERROR: The given mesh is not closed! Unable to convert to
CGAL_Nef_Polyhedron.  

ERROR: The given mesh is not closed! Unable to convert to
CGAL_Nef_Polyhedron.  

Geometries in cache: 48

Geometry cache size in bytes: 103923016

CGAL Polyhedrons in cache: 6

CGAL cache size in bytes: 83126640

Total rendering time: 0:02:24.235

    Top level object is a 3D object:

    Simple:        yes

    Vertices:    15218

    Halfedges:   49894

    Edges:       24947

    Halffacets:  19556

    Facets:       9778

    Volumes:         2

Rendering finished.

The spheres are strung along a path, using BOSL2's path_copies(), and
the path is also shown using stroke().  With the above, all I see is the
stroke().  All of the STL geometry is gone.  If I remove the stroke()s
entirely, then there is no geometry at all.

I'm sure I've been able to import STL files in the past and they
survived F6, so this is puzzling.

Jon

On 3/3/2023 12:23 AM, Jordan Brown wrote:

Actually, hold on a second.  Jon, can you share your script?

I just wrote a simple script to generate ~10K spheres, and on my
antique system F5 takes about four seconds.  (It claims less than a
second, but there must be something that's not being counted because I
count four seconds.)

That's 10,000 spheres with diameter 20, which for the default $fa/$fs
yields the maximum number of facets, 814.

I'm sure it would take forever to render with F6, because a variant
with only 27 spheres takes two minutes.  But the preview is
(relatively) fast.

 sep = 30;
 d = 20;
 n = 100;
 echo(n^2);
 for (x=[1:n], y=[1:n]){
      translate([x,y]*sep) sphere(d=d);
 }
Just flailing around here... My 3D model consists of 100 sub-models, each of which contains 100 small spheres (hence the 10,000).  When I created an STL to represent the sub-model, and imported that 100 times, the F5 time was reduced from about 5 minutes to about 3 seconds.   When I then tried F6, it failed at about 1 GB (which is better than 32 GB) in under 3 minutes (which is better than never), but with these error messages: Parsing design (AST generation)... Compiling design (CSG Tree generation)... Rendering Polygon Mesh using CGAL... ERROR: The given mesh is not closed! Unable to convert to CGAL_Nef_Polyhedron. ERROR: The given mesh is not closed! Unable to convert to CGAL_Nef_Polyhedron. ERROR: The given mesh is not closed! Unable to convert to CGAL_Nef_Polyhedron. ERROR: The given mesh is not closed! Unable to convert to CGAL_Nef_Polyhedron. ERROR: The given mesh is not closed! Unable to convert to CGAL_Nef_Polyhedron. Geometries in cache: 48 Geometry cache size in bytes: 103923016 CGAL Polyhedrons in cache: 6 CGAL cache size in bytes: 83126640 Total rendering time: 0:02:24.235 Top level object is a 3D object: Simple: yes Vertices: 15218 Halfedges: 49894 Edges: 24947 Halffacets: 19556 Facets: 9778 Volumes: 2 Rendering finished. The spheres are strung along a path, using BOSL2's path_copies(), and the path is also shown using stroke().  With the above, all I see is the stroke().  All of the STL geometry is gone.  If I remove the stroke()s entirely, then there is no geometry at all. I'm sure I've been able to import STL files in the past and they survived F6, so this is puzzling. Jon On 3/3/2023 12:23 AM, Jordan Brown wrote: > Actually, hold on a second.  Jon, can you share your script? > > I just wrote a simple script to generate ~10K spheres, and on my > antique system F5 takes about four seconds.  (It claims less than a > second, but there must be something that's not being counted because I > count four seconds.) > > That's 10,000 spheres with diameter 20, which for the default $fa/$fs > yields the maximum number of facets, 814. > > I'm sure it would take forever to render with F6, because a variant > with only 27 spheres takes two minutes.  But the preview is > (relatively) fast. > > sep = 30; > d = 20; > n = 100; > echo(n^2); > for (x=[1:n], y=[1:n]){ > translate([x,y]*sep) sphere(d=d); > } >
JB
Jordan Brown
Fri, Mar 3, 2023 4:00 PM

On 3/3/2023 1:28 AM, jon wrote:

I'm sure I've been able to import STL files in the past and they
survived F6, so this is puzzling.

Whether you can import an STL and operate on it is very dependent on the
particular STL.  OpenSCAD's use of CGAL is very picky about the
polyhedra it is willing to accept, and many STLs (including ones
generated by OpenSCAD!) have subtle problems that it considers unacceptable.

I'm not an expert on diagnosing STL issues; perhaps one of the people
who is can elaborate on the classes of problems that you can encounter.

On 3/3/2023 1:28 AM, jon wrote: > I'm sure I've been able to import STL files in the past and they > survived F6, so this is puzzling. Whether you can import an STL and operate on it is very dependent on the particular STL.  OpenSCAD's use of CGAL is very picky about the polyhedra it is willing to accept, and many STLs (including ones generated by OpenSCAD!) have subtle problems that it considers unacceptable. I'm not an expert on diagnosing STL issues; perhaps one of the people who is can elaborate on the classes of problems that you can encounter.
NH
nop head
Fri, Mar 3, 2023 4:36 PM

There only three possible problems l am aware of. There can be holes,
degenerate triangles or self intersections. The first two are easy to fix
but the last one hard.

On Fri, 3 Mar 2023, 16:01 Jordan Brown, openscad@jordan.maileater.net
wrote:

On 3/3/2023 1:28 AM, jon wrote:

I'm sure I've been able to import STL files in the past and they survived
F6, so this is puzzling.

Whether you can import an STL and operate on it is very dependent on the
particular STL.  OpenSCAD's use of CGAL is very picky about the polyhedra
it is willing to accept, and many STLs (including ones generated by
OpenSCAD!) have subtle problems that it considers unacceptable.

I'm not an expert on diagnosing STL issues; perhaps one of the people who
is can elaborate on the classes of problems that you can encounter.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

There only three possible problems l am aware of. There can be holes, degenerate triangles or self intersections. The first two are easy to fix but the last one hard. On Fri, 3 Mar 2023, 16:01 Jordan Brown, <openscad@jordan.maileater.net> wrote: > On 3/3/2023 1:28 AM, jon wrote: > > I'm sure I've been able to import STL files in the past and they survived > F6, so this is puzzling. > > > Whether you can import an STL and operate on it is very dependent on the > particular STL. OpenSCAD's use of CGAL is very picky about the polyhedra > it is willing to accept, and many STLs (including ones generated by > OpenSCAD!) have subtle problems that it considers unacceptable. > > I'm not an expert on diagnosing STL issues; perhaps one of the people who > is can elaborate on the classes of problems that you can encounter. > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
J
jon
Fri, Mar 3, 2023 5:25 PM

Well, I did Repair it using NetFabb, just in case

On 3/3/2023 11:00 AM, Jordan Brown wrote:

On 3/3/2023 1:28 AM, jon wrote:

I'm sure I've been able to import STL files in the past and they
survived F6, so this is puzzling.

Whether you can import an STL and operate on it is very dependent on
the particular STL.  OpenSCAD's use of CGAL is very picky about the
polyhedra it is willing to accept, and many STLs (including ones
generated by OpenSCAD!) have subtle problems that it considers
unacceptable.

I'm not an expert on diagnosing STL issues; perhaps one of the people
who is can elaborate on the classes of problems that you can encounter.

Well, I did Repair it using NetFabb, just in case On 3/3/2023 11:00 AM, Jordan Brown wrote: > On 3/3/2023 1:28 AM, jon wrote: >> I'm sure I've been able to import STL files in the past and they >> survived F6, so this is puzzling. > > Whether you can import an STL and operate on it is very dependent on > the particular STL.  OpenSCAD's use of CGAL is very picky about the > polyhedra it is willing to accept, and many STLs (including ones > generated by OpenSCAD!) have subtle problems that it considers > unacceptable. > > I'm not an expert on diagnosing STL issues; perhaps one of the people > who is can elaborate on the classes of problems that you can encounter. >
J
jon
Sat, Mar 4, 2023 5:24 PM

I sent my source code to Adrian, and he resolved my issues:

So nobody could ever have figured out how to help you based on your description on the forum.  The main time suck is drawing the spiral lines, not the spheres.  So first of all, you're using stroke(). Stroke works well in 2d but is quite slow in 3d, because it produces a cylinder for every segment and sphere for every dot and you end up with a massive union.  It also produces kind of mediocre output.  It can do some handy things like arrows and variable with, but in 3d you're always better off with path_sweep if it meets your needs.

That's point one.  Point 2 is that it makes a big difference if you run path_sweep once and save the VNF.  I guess the computation of the sweep is slow?  (Slower than I would have expected.)

Doing those things got the preview time down to 12s for me.  Note that I get it to 10s if I avoid using path_copies, which computes normal vectors and reorients the child.  I don't know if that's an important part of your design or not.  If it's not, you can speed it up a bit more.  Based on what you said my computer seems to be 2x as fast as yours, because it originally took a bit under 2 minutes.  I'm using 2022.12.07 for this testing.

Using the old code, F6 ran last night on a dedicated machine with 32 GB of RAM.  It took almost 7 hours of compute time, and 25 GB of RAM.  I asked it to save the STL and after a while, the 143 MB result was saved

Jon

On 3/3/2023 4:28 AM, jon wrote:

Just flailing around here...

My 3D model consists of 100 sub-models, each of which contains 100
small spheres (hence the 10,000).  When I created an STL to represent
the sub-model, and imported that 100 times, the F5 time was reduced
from about 5 minutes to about 3 seconds.   When I then tried F6, it
failed at about 1 GB (which is better than 32 GB) in under 3 minutes
(which is better than never), but with these error messages:

 Parsing design (AST generation)...

 Compiling design (CSG Tree generation)...

 Rendering Polygon Mesh using CGAL...

 ERROR: The given mesh is not closed! Unable to convert to
 CGAL_Nef_Polyhedron.  

 ERROR: The given mesh is not closed! Unable to convert to
 CGAL_Nef_Polyhedron.  

 ERROR: The given mesh is not closed! Unable to convert to
 CGAL_Nef_Polyhedron.  

 ERROR: The given mesh is not closed! Unable to convert to
 CGAL_Nef_Polyhedron.  

 ERROR: The given mesh is not closed! Unable to convert to
 CGAL_Nef_Polyhedron.  

 Geometries in cache: 48

 Geometry cache size in bytes: 103923016

 CGAL Polyhedrons in cache: 6

 CGAL cache size in bytes: 83126640

 Total rendering time: 0:02:24.235

     Top level object is a 3D object:

     Simple:        yes

     Vertices:    15218

     Halfedges:   49894

     Edges:       24947

     Halffacets:  19556

     Facets:       9778

     Volumes:         2

 Rendering finished.

The spheres are strung along a path, using BOSL2's path_copies(), and
the path is also shown using stroke().  With the above, all I see is
the stroke().  All of the STL geometry is gone.  If I remove the
stroke()s entirely, then there is no geometry at all.

I'm sure I've been able to import STL files in the past and they
survived F6, so this is puzzling.

Jon

On 3/3/2023 12:23 AM, Jordan Brown wrote:

Actually, hold on a second.  Jon, can you share your script?

I just wrote a simple script to generate ~10K spheres, and on my
antique system F5 takes about four seconds.  (It claims less than a
second, but there must be something that's not being counted because
I count four seconds.)

That's 10,000 spheres with diameter 20, which for the default $fa/$fs
yields the maximum number of facets, 814.

I'm sure it would take forever to render with F6, because a variant
with only 27 spheres takes two minutes.  But the preview is
(relatively) fast.

 sep = 30;
 d = 20;
 n = 100;
 echo(n^2);
 for (x=[1:n], y=[1:n]){
      translate([x,y]*sep) sphere(d=d);
 }

OpenSCAD mailing list
To unsubscribe send an email todiscuss-leave@lists.openscad.org

I sent my source code to Adrian, and he resolved my issues: So nobody could ever have figured out how to help you based on your description on the forum. The main time suck is drawing the spiral lines, not the spheres. So first of all, you're using stroke(). Stroke works well in 2d but is quite slow in 3d, because it produces a cylinder for every segment and sphere for every dot and you end up with a massive union. It also produces kind of mediocre output. It can do some handy things like arrows and variable with, but in 3d you're always better off with path_sweep if it meets your needs. That's point one. Point 2 is that it makes a big difference if you run path_sweep once and save the VNF. I guess the computation of the sweep is slow? (Slower than I would have expected.) Doing those things got the preview time down to 12s for me. Note that I get it to 10s if I avoid using path_copies, which computes normal vectors and reorients the child. I don't know if that's an important part of your design or not. If it's not, you can speed it up a bit more. Based on what you said my computer seems to be 2x as fast as yours, because it originally took a bit under 2 minutes. I'm using 2022.12.07 for this testing. Using the old code, F6 ran last night on a dedicated machine with 32 GB of RAM.  It took almost 7 hours of compute time, and 25 GB of RAM.  I asked it to save the STL and after a while, the 143 MB result was saved Jon On 3/3/2023 4:28 AM, jon wrote: > > Just flailing around here... > > My 3D model consists of 100 sub-models, each of which contains 100 > small spheres (hence the 10,000).  When I created an STL to represent > the sub-model, and imported that 100 times, the F5 time was reduced > from about 5 minutes to about 3 seconds.   When I then tried F6, it > failed at about 1 GB (which is better than 32 GB) in under 3 minutes > (which is better than never), but with these error messages: > > Parsing design (AST generation)... > > Compiling design (CSG Tree generation)... > > Rendering Polygon Mesh using CGAL... > > ERROR: The given mesh is not closed! Unable to convert to > CGAL_Nef_Polyhedron. > > ERROR: The given mesh is not closed! Unable to convert to > CGAL_Nef_Polyhedron. > > ERROR: The given mesh is not closed! Unable to convert to > CGAL_Nef_Polyhedron. > > ERROR: The given mesh is not closed! Unable to convert to > CGAL_Nef_Polyhedron. > > ERROR: The given mesh is not closed! Unable to convert to > CGAL_Nef_Polyhedron. > > Geometries in cache: 48 > > Geometry cache size in bytes: 103923016 > > CGAL Polyhedrons in cache: 6 > > CGAL cache size in bytes: 83126640 > > Total rendering time: 0:02:24.235 > > Top level object is a 3D object: > > Simple: yes > > Vertices: 15218 > > Halfedges: 49894 > > Edges: 24947 > > Halffacets: 19556 > > Facets: 9778 > > Volumes: 2 > > Rendering finished. > > The spheres are strung along a path, using BOSL2's path_copies(), and > the path is also shown using stroke().  With the above, all I see is > the stroke().  All of the STL geometry is gone.  If I remove the > stroke()s entirely, then there is no geometry at all. > > I'm sure I've been able to import STL files in the past and they > survived F6, so this is puzzling. > > Jon > > > On 3/3/2023 12:23 AM, Jordan Brown wrote: >> Actually, hold on a second.  Jon, can you share your script? >> >> I just wrote a simple script to generate ~10K spheres, and on my >> antique system F5 takes about four seconds.  (It claims less than a >> second, but there must be something that's not being counted because >> I count four seconds.) >> >> That's 10,000 spheres with diameter 20, which for the default $fa/$fs >> yields the maximum number of facets, 814. >> >> I'm sure it would take forever to render with F6, because a variant >> with only 27 spheres takes two minutes.  But the preview is >> (relatively) fast. >> >> sep = 30; >> d = 20; >> n = 100; >> echo(n^2); >> for (x=[1:n], y=[1:n]){ >> translate([x,y]*sep) sphere(d=d); >> } >> > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org