discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

CGAL error subtracting STL from a cube

J
jon
Sat, Oct 31, 2020 12:27 PM

nophead:

Thanks for the suggestion.  A convexity of 1000 does not fix the CGAL
error.  The STL in question is a 3D scan of my face, and I have a large
beard.  Perhaps convexity needs to be 10,000.  Who knows.

Jon

On 10/31/2020 4:29 AM, nop head wrote:

I think you need to set convexity in the import statement to get it to
preview correctly.

On Sat, 31 Oct 2020 at 03:20, rickan <richard@kandarian.com
mailto:richard@kandarian.com> wrote:

 None of my ideas were relevant.

 But I made two attempts to get what I think you want using
 different methods
 and both look oddly fractured in preview and do not render with
 thin shells.
 The surreal fractures in preview seem identical with both methods and
 independent of thickness. I mean when I change the file the
 preview doesn't
 change except for the thickness if I change that. The fractures do not
 change. But they migrate and morph oddly as if not part of the
 model when
 you alter the POV.

 The errors from render are in the scad file.

 I set it up to generate the shell using scale instead of translate
 and the
 surreal fractures show up in preview even when the shell thickness
 is 50%.
 However! It renders at that thickness! (It did not render at 25%
 and at
 least one thinner value I tried, probably 5%.) I suppose you could
 do a
 binary search for a thickness that is thinner than 50% which
 renders. This
 has me thinking that the stl interferes with itself when the shell
 thickness
 is too thin, i.e. one or more of the craggy features, e.g. in the
 beard
 perforate the shell. That's just a hypothesis. Well, I'm pretty
 sure it
 happens if the shell is thin enough, but I don't know why that
 would be a
 problem.

 I made a third attempt just to subtract the face from a cube and that
 previews and renders fine. I would expect, from my limited
 experience, that
 any difference or intersection with the stl would fail, not just a
 difference or intersection of the stl with itself depending on the
 relative
 scale.

 I did do a 1% translation to avoid the pesky ~0 thickness
 membrane. Maybe
 that's big enough to cause interference between the two surfaces.
 Maybe that
 should be reduced to 0.1%. I kind of doubt that's the problem though.

 HollowFaceRMK.scad
 <http://forum.openscad.org/file/t1112/HollowFaceRMK.scad
 <http://forum.openscad.org/file/t1112/HollowFaceRMK.scad>>

 HollowFaceRMK.png
 <http://forum.openscad.org/file/t1112/HollowFaceRMK.png
 <http://forum.openscad.org/file/t1112/HollowFaceRMK.png>>




 --
 Sent from: http://forum.openscad.org/ <http://forum.openscad.org/>

 _______________________________________________
 OpenSCAD mailing list
 Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org>
 http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
 <http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org>

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

nophead: Thanks for the suggestion.  A convexity of 1000 does not fix the CGAL error.  The STL in question is a 3D scan of my face, and I have a large beard.  Perhaps convexity needs to be 10,000.  Who knows. Jon On 10/31/2020 4:29 AM, nop head wrote: > I think you need to set convexity in the import statement to get it to > preview correctly. > > On Sat, 31 Oct 2020 at 03:20, rickan <richard@kandarian.com > <mailto:richard@kandarian.com>> wrote: > > None of my ideas were relevant. > > But I made two attempts to get what I think you want using > different methods > and both look oddly fractured in preview and do not render with > thin shells. > The surreal fractures in preview seem identical with both methods and > independent of thickness. I mean when I change the file the > preview doesn't > change except for the thickness if I change that. The fractures do not > change. But they migrate and morph oddly as if not part of the > model when > you alter the POV. > > The errors from render are in the scad file. > > I set it up to generate the shell using scale instead of translate > and the > surreal fractures show up in preview even when the shell thickness > is 50%. > However! It renders at that thickness! (It did not render at 25% > and at > least one thinner value I tried, probably 5%.) I suppose you could > do a > binary search for a thickness that is thinner than 50% which > renders. This > has me thinking that the stl interferes with itself when the shell > thickness > is too thin, i.e. one or more of the craggy features, e.g. in the > beard > perforate the shell. That's just a hypothesis. Well, I'm pretty > sure it > happens if the shell is thin enough, but I don't know why that > would be a > problem. > > I made a third attempt just to subtract the face from a cube and that > previews and renders fine. I would expect, from my limited > experience, that > any difference or intersection with the stl would fail, not just a > difference or intersection of the stl with itself depending on the > relative > scale. > > I did do a 1% translation to avoid the pesky ~0 thickness > membrane. Maybe > that's big enough to cause interference between the two surfaces. > Maybe that > should be reduced to 0.1%. I kind of doubt that's the problem though. > > HollowFaceRMK.scad > <http://forum.openscad.org/file/t1112/HollowFaceRMK.scad > <http://forum.openscad.org/file/t1112/HollowFaceRMK.scad>> > > HollowFaceRMK.png > <http://forum.openscad.org/file/t1112/HollowFaceRMK.png > <http://forum.openscad.org/file/t1112/HollowFaceRMK.png>> > > > > > -- > Sent from: http://forum.openscad.org/ <http://forum.openscad.org/> > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org> > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > <http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org> > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
A
adrianv
Sat, Oct 31, 2020 12:37 PM

The convexity argument is only used for displaying in preview.  It has
NOTHING to do with CGAL errors which are from render.  If you're getting
CGAL errors it means CGAL thinks your geometry is not a manifold or is
somehow malformed, so the only fix is going to be to change the geometry.

jon_bondy wrote

nophead:

Thanks for the suggestion.  A convexity of 1000 does not fix the CGAL
error.  The STL in question is a 3D scan of my face, and I have a large
beard.  Perhaps convexity needs to be 10,000.  Who knows.

Jon

On 10/31/2020 4:29 AM, nop head wrote:

I think you need to set convexity in the import statement to get it to
preview correctly.

On Sat, 31 Oct 2020 at 03:20, rickan <

richard@

> <mailto:

richard@

>> wrote:

 None of my ideas were relevant.

 But I made two attempts to get what I think you want using
 different methods
 and both look oddly fractured in preview and do not render with
 thin shells.
 The surreal fractures in preview seem identical with both methods and
 independent of thickness. I mean when I change the file the
 preview doesn't
 change except for the thickness if I change that. The fractures do

not
change. But they migrate and morph oddly as if not part of the
model when
you alter the POV.

 The errors from render are in the scad file.

 I set it up to generate the shell using scale instead of translate
 and the
 surreal fractures show up in preview even when the shell thickness
 is 50%.
 However! It renders at that thickness! (It did not render at 25%
 and at
 least one thinner value I tried, probably 5%.) I suppose you could
 do a
 binary search for a thickness that is thinner than 50% which
 renders. This
 has me thinking that the stl interferes with itself when the shell
 thickness
 is too thin, i.e. one or more of the craggy features, e.g. in the
 beard
 perforate the shell. That's just a hypothesis. Well, I'm pretty
 sure it
 happens if the shell is thin enough, but I don't know why that
 would be a
 problem.

 I made a third attempt just to subtract the face from a cube and that
 previews and renders fine. I would expect, from my limited
 experience, that
 any difference or intersection with the stl would fail, not just a
 difference or intersection of the stl with itself depending on the
 relative
 scale.

 I did do a 1% translation to avoid the pesky ~0 thickness
 membrane. Maybe
 that's big enough to cause interference between the two surfaces.
 Maybe that
 should be reduced to 0.1%. I kind of doubt that's the problem though.

 HollowFaceRMK.scad
 &lt;http://forum.openscad.org/file/t1112/HollowFaceRMK.scad

>    <http://forum.openscad.org/file/t1112/HollowFaceRMK.scad>>

 HollowFaceRMK.png
 &lt;http://forum.openscad.org/file/t1112/HollowFaceRMK.png

>    <http://forum.openscad.org/file/t1112/HollowFaceRMK.png>>

 --
 Sent from: http://forum.openscad.org/

<http://forum.openscad.org/>

 _______________________________________________
 OpenSCAD mailing list
 

Discuss@.openscad

<mailto:

Discuss@.openscad

>

 http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

<http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org>


OpenSCAD mailing list

Discuss@.openscad

Discuss@.openscad

The convexity argument is only used for displaying in preview. It has NOTHING to do with CGAL errors which are from render. If you're getting CGAL errors it means CGAL thinks your geometry is not a manifold or is somehow malformed, so the only fix is going to be to change the geometry. jon_bondy wrote > nophead: > > Thanks for the suggestion.  A convexity of 1000 does not fix the CGAL > error.  The STL in question is a 3D scan of my face, and I have a large > beard.  Perhaps convexity needs to be 10,000.  Who knows. > > Jon > > On 10/31/2020 4:29 AM, nop head wrote: >> I think you need to set convexity in the import statement to get it to >> preview correctly. >> >> On Sat, 31 Oct 2020 at 03:20, rickan &lt; > richard@ > > &gt; &lt;mailto: > richard@ > &gt;> wrote: >> >> None of my ideas were relevant. >> >> But I made two attempts to get what I think you want using >> different methods >> and both look oddly fractured in preview and do not render with >> thin shells. >> The surreal fractures in preview seem identical with both methods and >> independent of thickness. I mean when I change the file the >> preview doesn't >> change except for the thickness if I change that. The fractures do >> not >> change. But they migrate and morph oddly as if not part of the >> model when >> you alter the POV. >> >> The errors from render are in the scad file. >> >> I set it up to generate the shell using scale instead of translate >> and the >> surreal fractures show up in preview even when the shell thickness >> is 50%. >> However! It renders at that thickness! (It did not render at 25% >> and at >> least one thinner value I tried, probably 5%.) I suppose you could >> do a >> binary search for a thickness that is thinner than 50% which >> renders. This >> has me thinking that the stl interferes with itself when the shell >> thickness >> is too thin, i.e. one or more of the craggy features, e.g. in the >> beard >> perforate the shell. That's just a hypothesis. Well, I'm pretty >> sure it >> happens if the shell is thin enough, but I don't know why that >> would be a >> problem. >> >> I made a third attempt just to subtract the face from a cube and that >> previews and renders fine. I would expect, from my limited >> experience, that >> any difference or intersection with the stl would fail, not just a >> difference or intersection of the stl with itself depending on the >> relative >> scale. >> >> I did do a 1% translation to avoid the pesky ~0 thickness >> membrane. Maybe >> that's big enough to cause interference between the two surfaces. >> Maybe that >> should be reduced to 0.1%. I kind of doubt that's the problem though. >> >> HollowFaceRMK.scad >> &lt;http://forum.openscad.org/file/t1112/HollowFaceRMK.scad > &gt; &lt;http://forum.openscad.org/file/t1112/HollowFaceRMK.scad&gt;> >> >> HollowFaceRMK.png >> &lt;http://forum.openscad.org/file/t1112/HollowFaceRMK.png > &gt; &lt;http://forum.openscad.org/file/t1112/HollowFaceRMK.png&gt;> >> >> >> >> >> -- >> Sent from: http://forum.openscad.org/ >> &lt;http://forum.openscad.org/&gt; >> >> _______________________________________________ >> OpenSCAD mailing list >> > Discuss@.openscad > &lt;mailto: > Discuss@.openscad > &gt; >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >> &lt;http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org&gt; >> >> >> _______________________________________________ >> OpenSCAD mailing list >> > Discuss@.openscad >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > _______________________________________________ > OpenSCAD mailing list > Discuss@.openscad > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org -- Sent from: http://forum.openscad.org/
R
rickan
Sat, Oct 31, 2020 12:40 PM

Yes!

Setting convexity to 2 removes nearly all the fractures. Setting it higher
seems to remove them all but makes preview extremely laggy on my computer.

Without the distraction of the fractures the holes in the shell become
obvious.

In the attached image of the stl model subtracted from the cube with
viewport settings

$vpt = [-1.97, -9.31, 0.42]; $vpr = 90.00, 0.00, 90.00]; $vpd = 2.30;

There is what looks like a separate blob. It is not separate, however, it is
a hook in the stl which becomes an empty loop in the subtraction. Maybe that
is part of the problem.

HollowFaceIsland.png
http://forum.openscad.org/file/t1112/HollowFaceIsland.png

Maybe there are other nearly invisible features, e.g., long extremely thin
spikes, which are causing problems also.

--
Sent from: http://forum.openscad.org/

Yes! Setting convexity to 2 removes nearly all the fractures. Setting it higher seems to remove them all but makes preview extremely laggy on my computer. Without the distraction of the fractures the holes in the shell become obvious. In the attached image of the stl model subtracted from the cube with viewport settings $vpt = [-1.97, -9.31, 0.42]; $vpr = 90.00, 0.00, 90.00]; $vpd = 2.30; There is what looks like a separate blob. It is not separate, however, it is a hook in the stl which becomes an empty loop in the subtraction. Maybe that is part of the problem. HollowFaceIsland.png <http://forum.openscad.org/file/t1112/HollowFaceIsland.png> Maybe there are other nearly invisible features, e.g., long extremely thin spikes, which are causing problems also. -- Sent from: http://forum.openscad.org/
A
arnholm@arnholm.org
Sat, Oct 31, 2020 12:52 PM

On 2020-10-31 13:37, adrianv wrote:

The convexity argument is only used for displaying in preview.  It has
NOTHING to do with CGAL errors which are from render.  If you're
getting
CGAL errors it means CGAL thinks your geometry is not a manifold or is
somehow malformed, so the only fix is going to be to change the
geometry.

Indeed, the convexity parameter has nothing at all to do with geometric
calculations. In my opinion that parameter should not even exist, but
that's another story.

Where is the STL that you are struggling with?

Carsten Arnholm

On 2020-10-31 13:37, adrianv wrote: > The convexity argument is only used for displaying in preview. It has > NOTHING to do with CGAL errors which are from render. If you're > getting > CGAL errors it means CGAL thinks your geometry is not a manifold or is > somehow malformed, so the only fix is going to be to change the > geometry. Indeed, the convexity parameter has nothing at all to do with geometric calculations. In my opinion that parameter should not even exist, but that's another story. Where is the STL that you are struggling with? Carsten Arnholm
J
jon
Sat, Oct 31, 2020 2:13 PM

Thanks, everyone, for helping out.

The STL is huge (>10MB) so I am sending it to individuals who
volunteer.  I will send a copy to Carsten; if anyone else is curious,
please let me know

Jon

On 10/31/2020 8:52 AM, arnholm@arnholm.org wrote:

On 2020-10-31 13:37, adrianv wrote:

The convexity argument is only used for displaying in preview.  It has
NOTHING to do with CGAL errors which are from render.  If you're getting
CGAL errors it means CGAL thinks your geometry is not a manifold or is
somehow malformed, so the only fix is going to be to change the
geometry.

Indeed, the convexity parameter has nothing at all to do with
geometric calculations. In my opinion that parameter should not even
exist, but that's another story.

Where is the STL that you are struggling with?

Carsten Arnholm


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

Thanks, everyone, for helping out. The STL is huge (>10MB) so I am sending it to individuals who volunteer.  I will send a copy to Carsten; if anyone else is curious, please let me know Jon On 10/31/2020 8:52 AM, arnholm@arnholm.org wrote: > On 2020-10-31 13:37, adrianv wrote: >> The convexity argument is only used for displaying in preview.  It has >> NOTHING to do with CGAL errors which are from render.  If you're getting >> CGAL errors it means CGAL thinks your geometry is not a manifold or is >> somehow malformed, so the only fix is going to be to change the >> geometry. > > Indeed, the convexity parameter has nothing at all to do with > geometric calculations. In my opinion that parameter should not even > exist, but that's another story. > > Where is the STL that you are struggling with? > > Carsten Arnholm > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
CA
Carsten Arnholm
Sat, Oct 31, 2020 4:15 PM

On 31.10.2020 15:13, jon wrote:

Thanks, everyone, for helping out.

The STL is huge (>10MB) so I am sending it to individuals who
volunteer.  I will send a copy to Carsten; if anyone else is curious,
please let me know

I got your file, thanks.

I ran it through polyfix which reported a number of issues (see below),
and saved it in AMF format, as that is supported in OpenSCAD since
2019.05. I then ran it through your .scad code using OpenSCAD version
2020.10.11.nightly (git b416aa2) under Ubuntu.

However, it failed:
ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion
violation! Expr: e->incident_sface() != SFace_const_handle() File:
/usr/include/CGAL/Nef_S2/SM_const_decorator.h Line: 329, location unknown

So instead I ran your STL through polyfix again and saved it as OBJ, as
that is much more compact than AMF (but OBJ is not supported in OpenSCAD):

$ polyfix "Jon-mesh-export-3 - MM Repair.stl" -out=Jon_Face_polyfix.obj

Parameters:
input_file = Jon-mesh-export-3 - MM Repair.stl
out = Jon_Face_polyfix.obj

polyhedron 0 ================= volume=1992, dtol=0.01, atol=1e-06,
maxiter=10
iteration 0: vertices=898980 faces=299660

          warning: nonmanifold edges: uc(1)=898980
          merged 749167 vertices
          removed 12 collapsed or zero area faces
          removed 7 duplicate faces
          removed 2 nonmanifold faces
          total changes=749188
          warning: nonmanifold edges: uc(1)=5 uc(3)=4 uc(4)=1

iteration 1: vertices=149813 faces=299639
warning: nonmanifold edges: uc(1)=5 uc(3)=4 uc(4)=1
split 3 faces
removed 1 duplicate face
removed 3 nonmanifold faces
removed 6 zero area faces
total changes=13
warning: nonmanifold edges: uc(4)=1

iteration 2: vertices=149813 faces=299634
warning: nonmanifold edges: uc(4)=1
removed 1 unused vertex
total changes=1
warning: nonmanifold edges: uc(4)=1

iteration 3: vertices=149812 faces=299634
warning: nonmanifold edges: uc(4)=1
total changes=0
warning: nonmanifold edges: uc(4)=1

Summary:
polyhedron 0: vertices=149812 faces=299634 : warning:
nonmanifold edges: uc(4)=1

Writing: Jon_Face_polyfix_1.obj

... polyfix finished, time used: 0d 00h 02m 36s

The summary says the result contains one edge with use-count=4, so it is
not perfectly repaired, but it might still work in AngelCAD. I wrote a
few lines of code to make the hollow face, but dropped the cube as it
did not seem to intersect with the Face (?).

See attached image of result.

If you allow I will upload the AngelCAD code and the resulting STL (26.1
MB) to a github gist, so you can be viewed and you can download it. Is
that ok?

Regards
Carsten Arnholm

On 31.10.2020 15:13, jon wrote: > Thanks, everyone, for helping out. > > The STL is huge (>10MB) so I am sending it to individuals who > volunteer.  I will send a copy to Carsten; if anyone else is curious, > please let me know I got your file, thanks. I ran it through polyfix which reported a number of issues (see below), and saved it in AMF format, as that is supported in OpenSCAD since 2019.05. I then ran it through your .scad code using OpenSCAD version 2020.10.11.nightly (git b416aa2) under Ubuntu. However, it failed: ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion violation! Expr: e->incident_sface() != SFace_const_handle() File: /usr/include/CGAL/Nef_S2/SM_const_decorator.h Line: 329, location unknown So instead I ran your STL through polyfix again and saved it as OBJ, as that is much more compact than AMF (but OBJ is not supported in OpenSCAD): $ polyfix "Jon-mesh-export-3 - MM Repair.stl" -out=Jon_Face_polyfix.obj Parameters: input_file = Jon-mesh-export-3 - MM Repair.stl out = Jon_Face_polyfix.obj polyhedron 0 ================= volume=1992, dtol=0.01, atol=1e-06, maxiter=10 iteration 0: vertices=898980 faces=299660 warning: nonmanifold edges: uc(1)=898980 merged 749167 vertices removed 12 collapsed or zero area faces removed 7 duplicate faces removed 2 nonmanifold faces total changes=749188 warning: nonmanifold edges: uc(1)=5 uc(3)=4 uc(4)=1 iteration 1: vertices=149813 faces=299639 warning: nonmanifold edges: uc(1)=5 uc(3)=4 uc(4)=1 split 3 faces removed 1 duplicate face removed 3 nonmanifold faces removed 6 zero area faces total changes=13 warning: nonmanifold edges: uc(4)=1 iteration 2: vertices=149813 faces=299634 warning: nonmanifold edges: uc(4)=1 removed 1 unused vertex total changes=1 warning: nonmanifold edges: uc(4)=1 iteration 3: vertices=149812 faces=299634 warning: nonmanifold edges: uc(4)=1 total changes=0 warning: nonmanifold edges: uc(4)=1 Summary: polyhedron 0: vertices=149812 faces=299634 : warning: nonmanifold edges: uc(4)=1 Writing: Jon_Face_polyfix_1.obj ... polyfix finished, time used: 0d 00h 02m 36s The summary says the result contains one edge with use-count=4, so it is not perfectly repaired, but it might still work in AngelCAD. I wrote a few lines of code to make the hollow face, but dropped the cube as it did not seem to intersect with the Face (?). See attached image of result. If you allow I will upload the AngelCAD code and the resulting STL (26.1 MB) to a github gist, so you can be viewed and you can download it. Is that ok? Regards Carsten Arnholm
CA
Carsten Arnholm
Sat, Oct 31, 2020 7:53 PM

On 31.10.2020 15:13, jon wrote:

Thanks, everyone, for helping out.

The script and files are here:
https://github.com/arnholm/hollow_face

You can get the file in 2 ways

Method 1: Go to the page above and find the green button that says
"Code" and select the "Download Zip" to get all files, including the STL
and OBJ files.

Method 2: Clone the repository using git to get all files.

$ git clone https://github.com/arnholm/hollow_face

Carsten Arnholm

> On 31.10.2020 15:13, jon wrote: >> Thanks, everyone, for helping out. The script and files are here: https://github.com/arnholm/hollow_face You can get the file in 2 ways Method 1: Go to the page above and find the green button that says "Code" and select the "Download Zip" to get all files, including the STL and OBJ files. Method 2: Clone the repository using git to get all files. $ git clone https://github.com/arnholm/hollow_face Carsten Arnholm