discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

dev build: command line version runs CGAL when generating png file

AM
Adrian Mariano
Mon, Jun 2, 2025 8:17 PM

I have never observed a wildly inaccurate timing reported.  I would guess
if you see a report of a very small number when obviously the time was much
longer that perhaps the model ran twice and the second time was cached.

But to crosscheck the timings, I used the shells "time" command and found:

2021.01: 0.3s
2025.04.29 with CGAL: 9.8s
2025.04.29 with manifold: 1.9s

The timings are in line with expectation.  There is overhead not reported
by the OpenSCAD timing value, so 0.3s is not a surprise.  Other numbers are
slightly higher as well.
Jordan, if I understand correctly, command line access to preview no longer
exists in these recent dev versions.  And CGAL is still the default.  So
unless you specify manifold, CGAL will always run.

On Mon, Jun 2, 2025 at 1:58 PM Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:

On 6/1/2025 4:06 PM, Marius Kintel via Discuss wrote:

You cannot completely disable all CGAL code paths, as certain features (like minkowski) still requires CGAL.

..but this should get you one step closer:

openscad -o test.png  test.scad --backend=manifold

But what's triggering using CGAL?

Generating a PNG should be a preview operation, not a render, and so
(except for a few operations) avoid CGAL entirely.

Offhand, these should trigger CGAL:  render(), rescale(), projection(),
minkowski(), hull().


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

I have never observed a wildly inaccurate timing reported. I would guess if you see a report of a very small number when obviously the time was much longer that perhaps the model ran twice and the second time was cached. But to crosscheck the timings, I used the shells "time" command and found: 2021.01: 0.3s 2025.04.29 with CGAL: 9.8s 2025.04.29 with manifold: 1.9s The timings are in line with expectation. There is overhead not reported by the OpenSCAD timing value, so 0.3s is not a surprise. Other numbers are slightly higher as well. Jordan, if I understand correctly, command line access to preview no longer exists in these recent dev versions. And CGAL is still the default. So unless you specify manifold, CGAL will always run. On Mon, Jun 2, 2025 at 1:58 PM Jordan Brown via Discuss < discuss@lists.openscad.org> wrote: > On 6/1/2025 4:06 PM, Marius Kintel via Discuss wrote: > > You cannot completely disable all CGAL code paths, as certain features (like minkowski) still requires CGAL. > > ..but this should get you one step closer: > > openscad -o test.png test.scad --backend=manifold > > > But what's triggering using CGAL? > > Generating a PNG should be a preview operation, not a render, and so > (except for a few operations) avoid CGAL entirely. > > Offhand, these should trigger CGAL: render(), rescale(), projection(), > minkowski(), hull(). > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
JB
Jordan Brown
Mon, Jun 2, 2025 9:04 PM

On 6/2/2025 1:17 PM, Adrian Mariano via Discuss wrote:

Jordan, if I understand correctly, command line access to preview no
longer exists in these recent dev versions.   And CGAL is still the
default.  So unless you specify manifold, CGAL will always run. 

I would hope not, because there are features that only work in preview -
notably, transparency.

With a test program:

difference() {
    cube(10);
    #sphere(10);
}

I don't see any evidence that a modern OpenSCAD is doing a full render.

openscad -o zzz.new.png zzz.scad

Compiling design (CSG Products normalization)...
Normalized CSG tree has 2 elements
Compiling highlights (1 CSG Trees)...
Geometries in cache: 2
Geometry cache size in bytes: 40384
CGAL Polyhedrons in cache: 0
CGAL cache size in bytes: 0
Total rendering time: 0:00:00.099

versus with the --render=force option:

Geometries in cache: 2
Geometry cache size in bytes: 40384
CGAL Polyhedrons in cache: 1
CGAL cache size in bytes: 175264
Total rendering time: 0:00:00.215
Top level object is a 3D object (Nef polyhedron):
   Simple:     yes
   Vertices:       79
   Halfedges:     378
   Edges:         189
   Halffacets:    224
   Facets:        112
   Volumes:         2

or with --render=force --backend=manifold:

Geometries in cache: 2
Geometry cache size in bytes: 40384
CGAL Polyhedrons in cache: 1
CGAL cache size in bytes: 0
Total rendering time: 0:00:00.103
   Top level object is a 3D object (manifold):
   Status:     NoError
   Genus:      0
   Vertices:       79
   Facets:        154

The preview produces the expected transparent pink sphere, and the two
render options do not.

I tried two different non-manifold models (an incomplete polyhedron with
only one face, and a pair of cubes that touch along an edge), and got
more-or-less expected results:  preview ran fine, CGAL failed on the
incomplete polyhedron and warned on the cubes but produced an OK image,
Manifold failed on the incomplete polyhedron and succeeded on the cubes.

On 6/2/2025 1:17 PM, Adrian Mariano via Discuss wrote: > Jordan, if I understand correctly, command line access to preview no > longer exists in these recent dev versions.   And CGAL is still the > default.  So unless you specify manifold, CGAL will always run.  I would hope not, because there are features that only work in preview - notably, transparency. With a test program: difference() { cube(10); #sphere(10); } I don't see any evidence that a modern OpenSCAD is doing a full render. openscad -o zzz.new.png zzz.scad Compiling design (CSG Products normalization)... Normalized CSG tree has 2 elements Compiling highlights (1 CSG Trees)... Geometries in cache: 2 Geometry cache size in bytes: 40384 CGAL Polyhedrons in cache: 0 CGAL cache size in bytes: 0 Total rendering time: 0:00:00.099 versus with the --render=force option: Geometries in cache: 2 Geometry cache size in bytes: 40384 CGAL Polyhedrons in cache: 1 CGAL cache size in bytes: 175264 Total rendering time: 0:00:00.215 Top level object is a 3D object (Nef polyhedron): Simple: yes Vertices: 79 Halfedges: 378 Edges: 189 Halffacets: 224 Facets: 112 Volumes: 2 or with --render=force --backend=manifold: Geometries in cache: 2 Geometry cache size in bytes: 40384 CGAL Polyhedrons in cache: 1 CGAL cache size in bytes: 0 Total rendering time: 0:00:00.103 Top level object is a 3D object (manifold): Status: NoError Genus: 0 Vertices: 79 Facets: 154 The preview produces the expected transparent pink sphere, and the two render options do not. I tried two different non-manifold models (an incomplete polyhedron with only one face, and a pair of cubes that touch along an edge), and got more-or-less expected results:  preview ran fine, CGAL failed on the incomplete polyhedron and warned on the cubes but produced an OK image, Manifold failed on the incomplete polyhedron and succeeded on the cubes.
MK
Marius Kintel
Mon, Jun 2, 2025 9:16 PM

Just to cut through: The design in question uses minkowski, so CGAL will be needed in the default preview case.

-Marius

Just to cut through: The design in question uses minkowski, so CGAL will be needed in the default preview case. -Marius
JB
Jordan Brown
Mon, Jun 2, 2025 9:30 PM

On 6/2/2025 2:16 PM, Marius Kintel wrote:

Just to cut through: The design in question uses minkowski, so CGAL will be needed in the default preview case.

That would certainly explain why CGAL is involved.  I suspect that
Adrian is just wrong about CGAL not being involved in 2021.01, but maybe
(for whatever reason) 2021.01 tolerated the model better than the
current version does.

On 6/2/2025 2:16 PM, Marius Kintel wrote: > Just to cut through: The design in question uses minkowski, so CGAL will be needed in the default preview case. That would certainly explain why CGAL is involved.  I suspect that Adrian is just wrong about CGAL not being involved in 2021.01, but maybe (for whatever reason) 2021.01 tolerated the model better than the current version does.
MK
Marius Kintel
Mon, Jun 2, 2025 9:31 PM

Oh, I think I know what’s going on: I believe your manually built polyhedron probably fails the convexity check in the dev build, triggering a convex decomposition into a lot of tiny parts, which makes the minkowski computation blow up.

That’s a pretty unfortunate regression - I’ll take note of it and see if it can be improved.
If you have more similar examples, especially ones with really bad behavior with --backend=manifold, feel free to post.

-Marius

Oh, I think I know what’s going on: I believe your manually built polyhedron probably fails the convexity check in the dev build, triggering a convex decomposition into a lot of tiny parts, which makes the minkowski computation blow up. That’s a pretty unfortunate regression - I’ll take note of it and see if it can be improved. If you have more similar examples, especially ones with really bad behavior with --backend=manifold, feel free to post. -Marius
AM
Adrian Mariano
Mon, Jun 2, 2025 10:53 PM

By "bad behavior" you mean slow to preview?  There are quite a few cases
that trigger the CGAL error, but they may very well all be happening
because they call cuboid().  Noticing errors is easier.  It's hard to
notice if things are slower than they "should" be when running a batch job
on thousands of files---which doesn't run in the old version so there's no
reference.    But with higher $fn cuboid gets very slow, like 2 minutes
at $fn=96 to preview with CGAL.  And 20 seconds with $fn=0 and
manifold...and the answer is wrong, having a an artifact as noted in the
other message posted.

I ran an old model I wrote that uses minkowski and it previews in 8 minutes
(used to be 20 on the computer I designed on) and in the dev version with
CGAL selected it churned for an hour without result in the dev version
before I gave up.  So that appears to be a regression.  It previews in 9s
with manifold.

I'm a little confused about how this all works now.  If I use manifold but
my model has minkowski, then CGAL is still needed for the minkowski
operation?  It seems like minkowski is faster with manifold, though---how
is that if it's still using CGAL?

It's also a question of why there is a CGAL error in this model posted in
the thread.  Someone else has posted an example of an artifact that appears
which may be connected to the error?  But the artifact seems to appear with
manifold, which doesn't get an error, not with CGAL, which does.  So CGAL
gets an error and is very slow.  Manifold produces an incorrect result
faster, but still much slower than preview in 2021.01.

On Mon, Jun 2, 2025 at 5:32 PM Marius Kintel marius@kintel.net wrote:

Oh, I think I know what’s going on: I believe your manually built
polyhedron probably fails the convexity check in the dev build, triggering
a convex decomposition into a lot of tiny parts, which makes the minkowski
computation blow up.

That’s a pretty unfortunate regression - I’ll take note of it and see if
it can be improved.
If you have more similar examples, especially ones with really bad
behavior with --backend=manifold, feel free to post.

-Marius

By "bad behavior" you mean slow to preview? There are quite a few cases that trigger the CGAL error, but they may very well all be happening because they call cuboid(). Noticing errors is easier. It's hard to notice if things are slower than they "should" be when running a batch job on thousands of files---which doesn't run in the old version so there's no reference. But with higher $fn cuboid gets *very* slow, like 2 minutes at $fn=96 to preview with CGAL. And 20 seconds with $fn=0 and manifold...and the answer is wrong, having a an artifact as noted in the other message posted. I ran an old model I wrote that uses minkowski and it previews in 8 minutes (used to be 20 on the computer I designed on) and in the dev version with CGAL selected it churned for an hour without result in the dev version before I gave up. So that appears to be a regression. It previews in 9s with manifold. I'm a little confused about how this all works now. If I use manifold but my model has minkowski, then CGAL is still needed for the minkowski operation? It seems like minkowski is faster with manifold, though---how is that if it's still using CGAL? It's also a question of why there is a CGAL error in this model posted in the thread. Someone else has posted an example of an artifact that appears which may be connected to the error? But the artifact seems to appear with manifold, which doesn't get an error, not with CGAL, which does. So CGAL gets an error and is very slow. Manifold produces an incorrect result faster, but still much slower than preview in 2021.01. On Mon, Jun 2, 2025 at 5:32 PM Marius Kintel <marius@kintel.net> wrote: > Oh, I think I know what’s going on: I believe your manually built > polyhedron probably fails the convexity check in the dev build, triggering > a convex decomposition into a lot of tiny parts, which makes the minkowski > computation blow up. > > That’s a pretty unfortunate regression - I’ll take note of it and see if > it can be improved. > If you have more similar examples, especially ones with really bad > behavior with --backend=manifold, feel free to post. > > -Marius > >
JB
Jordan Brown
Mon, Jun 2, 2025 10:57 PM

On 6/2/2025 3:53 PM, Adrian Mariano via Discuss wrote:

I'm a little confused about how this all works now.  If I use manifold
but my model has minkowski, then CGAL is still needed for the
minkowski operation?  It seems like minkowski is faster with manifold,
though---how is that if it's still using CGAL? 

Any operation that actually needs to know the faces and vertexes needs
to render.  That means render(), resize(), minkowski(), hull(), and
projection().

Minkowski needs CGAL, because Minkowski hasn't been implemented in
Manifold yet.

On 6/2/2025 3:53 PM, Adrian Mariano via Discuss wrote: > I'm a little confused about how this all works now.  If I use manifold > but my model has minkowski, then CGAL is still needed for the > minkowski operation?  It seems like minkowski is faster with manifold, > though---how is that if it's still using CGAL?  Any operation that actually needs to know the faces and vertexes needs to render.  That means render(), resize(), minkowski(), hull(), and projection(). Minkowski needs CGAL, because Minkowski hasn't been implemented in Manifold yet.
MK
Marius Kintel
Tue, Jun 3, 2025 1:18 AM

On Jun 2, 2025, at 18:53, Adrian Mariano avm4@cornell.edu wrote:

I'm a little confused about how this all works now.  If I use manifold but my model has minkowski, then CGAL is still needed for the minkowski operation?  It seems like minkowski is faster with manifold, though---how is that if it's still using CGAL?

The answer is pretty detailed and nuanced, but it boils down to minkowski sum being a compound operation which involves roughly:

  1. Decompose all operands into convex parts. This is only available in CGAL. This operation can be slow, but even if it’s fast, it can make subsequent operations do a lot more work.
  2. Perform minkowski sums of all convex parts (this is equivalent to convex hulls). This is currently done with CGAL, but we’re planning to move to Manifold. It is reasonably fast, but suffers from generating a possibly high vertex count.
  3. Union all partial sums. This will be done very efficiently with Manifold.

-Marius

On Jun 2, 2025, at 18:53, Adrian Mariano <avm4@cornell.edu> wrote: > > I'm a little confused about how this all works now. If I use manifold but my model has minkowski, then CGAL is still needed for the minkowski operation? It seems like minkowski is faster with manifold, though---how is that if it's still using CGAL? > The answer is pretty detailed and nuanced, but it boils down to minkowski sum being a compound operation which involves roughly: 1. Decompose all operands into convex parts. This is only available in CGAL. This operation can be slow, but even if it’s fast, it can make subsequent operations do a lot more work. 2. Perform minkowski sums of all convex parts (this is equivalent to convex hulls). This is currently done with CGAL, but we’re planning to move to Manifold. It is reasonably fast, but suffers from generating a possibly high vertex count. 3. Union all partial sums. This will be done very efficiently with Manifold. -Marius