Openscad: Calling difference() on a imported STL model and a sphere, caused CGAL error.

Created on 9 Oct 2016  Â·  9Comments  Â·  Source: openscad/openscad

Using version 2015.03-3 for OSX.

Use the file "Lid.stl"

Lid.stl.zip

OpenSCAD code is following:

difference()
{
  import("Lid.stl", convexity=10);
  sphere(d = 1);
}

If I use preview function(F5), I get correct output.

But if I use render function(F6), I got error message:

Compiling design (CSG Tree generation)...
Rendering Polygon Mesh using CGAL...
ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion violation! Expr: pe_prev->is_border() || !internal::Plane_constructor::get_plane(pe_prev->facet(),pe_prev->facet()->plane()).is_degenerate() File: /Users/kintel/code/OpenSCAD/openscad-2015.03-3/../libraries/install/include/CGAL/Nef_3/polyhedron_3_to_nef_3.h Line: 251
Geometries in cache: 5
Geometry cache size in bytes: 625672
CGAL Polyhedrons in cache: 6
CGAL cache size in bytes: 0
Total rendering time: 0 hours, 0 minutes, 0 seconds
Rendering finished.

The imported STL file and sphere don't overlap, so it is very strange.

If I comment out the line "sphere(d = 1);", render function can output correctly.

If I use netfabb cloud service to fix the model :

Lid_repaired.stl.zip

difference()
{
  import("Lid_repaired.stl", convexity=10);
  sphere(d = 1);
}

Render function has different error message :

Compiling design (CSG Tree generation)...
Rendering Polygon Mesh using CGAL...
ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion violation! Expr: e->incident_sface() != SFace_const_handle() File: /Users/kintel/code/OpenSCAD/openscad-2015.03-3/../libraries/install/include/CGAL/Nef_S2/SM_const_decorator.h Line: 326
Geometries in cache: 9
Geometry cache size in bytes: 1833576
CGAL Polyhedrons in cache: 10
CGAL cache size in bytes: 0
Total rendering time: 0 hours, 0 minutes, 0 seconds
Rendering finished.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Mesh Repair STL

All 9 comments

Blender still flags lots of zero-faces. Check the FAQ for suggestions.

If I comment out the line "sphere(d = 1);", render function can output
correctly.

That is because without the sphere there are CSG operations for CGAL to do,
so it isn't used, the STL is simply displayed. As soon as you do an
operation on it it needs to be 2 manifold.

On 9 October 2016 at 20:56, Torsten Paul [email protected] wrote:

Blender still flags lots of zero-faces. Check the FAQ
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/FAQ#Why_is_my_imported_STL_file_only_showing_up_with_F5_but_not_F6.3F
for suggestions.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/openscad/openscad/issues/1824#issuecomment-252508606,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAijhbLaLd_yxejDnKuj3IuTPLRI3sFvks5qyUcIgaJpZM4KSF4u
.

Well, I tried Blender 3D Print ToolBox and MeshLab, but after fixing the model by the 2 programs, OpenSCAD still can't do boolean difference on it.
I think maybe it is a limitation of current OpenSCAD design, and this problem can't be fixed easily.

The limitation is that the underlying CSG library enforces 2-manifold geometry and can't handle zero-faces (as it's not possible to determine a face normal in that case). It should always be possible to fix this, but depending on the model, that might need an unreasonable amount of work in rare cases.

Normally MeshLab does the trick when following the steps shown in the FAQ, but I had one case where that also did not work.

This might not be a bug . Its possibly a wonderful feature.

Yes interesting. I've been looking for something like this to put derivative blocking into stl files. Something that allow them to load, display, slice and print but grind to a halt if used as part in a boolean op. Still easy enough to clean up from source files for the persistent user. Thus blocking stl remixing-bots in particular by making them grind for nothing.

Non-manifold STL have a good risk to also break slicing while mesh based derivatives are still simple to generate. Deliberately causing more issues on us also seems not like a fair option.

So is there way to automaticaly fix such non-manifold broken STL? Is it possible for OpenSCAD to do it during import?

In general that's difficult, specifically for zero-faces it should be possible. See #1580.

However - in general - its an open problem in CG to fix(make watertight while preserving surfaces) an arbitrary set of polygons. There are so many examples of situtations which are undecideable without knowing information about the intention - which is absolutely not encoded in the model.

So - no - there isn;t a way to load an arbitrary STL into anything and get out a 'corrected' model. Always requires manual intervention. Blender has a usefuil key sequence for finding holes and fixing them. Meshlab adopts another approach with more flexible but harder to use tools. etc etc etc...

Was this page helpful?
0 / 5 - 0 ratings