Skip to content

Instantly share code, notes, and snippets.

@ochafik
Last active February 22, 2021 15:04
Show Gist options
  • Save ochafik/8d0db8fca505858cfe7a6fc38cff645d to your computer and use it in GitHub Desktop.
Save ochafik/8d0db8fca505858cfe7a6fc38cff645d to your computer and use it in GitHub Desktop.
CGAL corefinement vs. potentially-invalid inputs vs. attempts to fall back to Nef: error cases

Here's now to build the branch from openscad/openscad#3641 (see full build instructions)

git clone --depth 1 http://github.com/ochafik/openscad  --single-branch --branch fast_csg ochafik-openscad
cd ochafik-openscad
rm -fR objects/
qmake openscad.pro \
  CONFIG+=debug \
  CONFIG+=experimental \
  CONFIG+=info \
  QMAKE_CXXFLAGS+=-I../CGAL-5.2/include
make -j4

And here's how to trigger a weird corefinement edge-case (or bug?) that leaves a polyhedron in a state we can't build a nef from:

# See output log below
./openscad -o out.stl testdata/scad/3D/features/mirror-tests.scad --enable=fast-csg

I did try and repair the polyhedron with https://gist.github.com/ochafik/e55c52c50804bcb6f073968a57099e63, to no avail.

ECHO: [fast-csg] corefinement union (12 vs. 12 facets)
ECHO: [fast-csg] corefinement union (12 vs. 12 facets)
ECHO: [fast-csg] corefinement union (12 vs. 12 facets)
ECHO: [fast-csg] corefinement union (12 vs. 12 facets)
ECHO: [fast-csg] corefinement union (20 vs. 20 facets)
ECHO: [fast-csg] corefinement union (24 vs. 20 facets)
CGAL error: assertion violation!
Expression : insert_ok || mesh_to_vertex_to_node_id[&tm][target(h,tm)]==node_id
File : ../CGAL-5.2/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Visitor.h
Line : 303
Explanation:
Refer to the bug-reporting instructions at https://www.cgal.org/bug_report.html
WARNING: [fast-csg] Corefinement corefinement union failed with an error: CGAL ERROR: assertion violation!
Expr: insert_ok || mesh_to_vertex_to_node_id[&tm][target(h,tm)]==node_id
File: ../CGAL-5.2/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Visitor.h
Line: 303
ECHO: [fast-csg] nef union (24 vs. 20 facets)
CGAL error: assertion violation!
Expression : !s2.is_degenerate()
File : ../CGAL-5.2/include/CGAL/Nef_3/SNC_intersection.h
Line : 194
Explanation:
Refer to the bug-reporting instructions at https://www.cgal.org/bug_report.html
ERROR: CGAL error in CGALUtils::applyUnion3DPolyhedron: CGAL ERROR: assertion violation!
Expr: !s2.is_degenerate()
File: ../CGAL-5.2/include/CGAL/Nef_3/SNC_intersection.h
Line: 194
Geometries in cache: 10
Geometry cache size in bytes: 6624
CGAL Polyhedrons in cache: 0
CGAL cache size in bytes: 0
Total rendering time: 0:00:00.137
Current top level object is empty.
@sloriot
Copy link

sloriot commented Feb 22, 2021

I can't compile, I'm having:

src/value.cc:41:10: fatal error: double-conversion/double-conversion.h: No such file or directory
   41 | #include "double-conversion/double-conversion.h"

From the log you provide it seems that the input contains some degenerate faces which Nef and coref seem to complain about. Is it possible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment