cgal
cgal copied to clipboard
Add coplanar decimation
Summary of Changes
Add a function in PMP that retriangulates a coplanar patch as well as functions to detect coplanar patches. There are also overloads that are able to handle the simplification of polyhedral complexes. Retriangulation is using CDT2.
TODO:
- [x] split the example in 2, one part should go into test (together with the data provided)
- [x] decide license group
- [ ] decide on the best approximate method, region growing is probably the way to go
- [ ] find better function names
- [ ] small feature
- [ ] fix dependencies
- [ ] update SMS user manual + ref manual
- [ ] update PMP user manual + ref manual
- [ ] demo plugins
This PR depends on PR #5563.
Release Management
- Affected package(s): PMP, Surface Mesh Segmentation
- Feature/Small Feature (if any): TODO
- Link to compiled documentation (obligatory for small feature) wrong link name to be changed
- License and copyright ownership: GF
@danston I'd be interested to discuss region growing on a mesh again to see if I can replace the PCA approach with that.
@danston I moved the segmentation part into the Surface_mesh_segmenation() package, into the function segment_via_plane_fitting().
action failed because of this error:
Differences in Polygon_mesh_processing: Principal_component_analysis are new and not committed.
Looks like this fails to compile w/ Epeck (calling remesh_planar_patches(Surface_mesh<Epeck>())):
In file included from /usr/local/include/CGAL/Exact_predicates_exact_constructions_kernel.h:27:
In file included from /usr/local/include/CGAL/Lazy_kernel.h:18:
/usr/local/include/CGAL/Static_filtered_predicate.h:180:40: error: member reference base type 'const double' is not a structure or union
std::pair<T5,bool> aa5 = convert(a5.approx());
~~^~~~~~~
/usr/local/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:130:12: note: in instantiation of function template specialization 'CGAL::Static_filtered_predicate<CGAL::Simple_cartesian<CGAL::Interval_nt<false>>, CGAL::Filtered_predicate<CGAL::CommonKernelFunctors::Compare_dihedral_angle_3<CGAL::Simple_cartesian<__gmp_expr<mpq_t, mpq_t>>>, CGAL::CommonKernelFunctors::Compare_dihedral_angle_3<CGAL::Simple_cartesian<CGAL::Interval_nt<false>>>, CGAL::Exact_converter<CGAL::Epeck, CGAL::Simple_cartesian<__gmp_expr<mpq_t, mpq_t>>>, CGAL::Approx_converter<CGAL::Epeck, CGAL::Simple_cartesian<CGAL::Interval_nt<false>>>, true>, CGAL::Filtered_predicate<CGAL::CommonKernelFunctors::Compare_dihedral_angle_3<CGAL::Simple_cartesian<CGAL::Mpzf>>, CGAL::CommonKernelFunctors::Compare_dihedral_angle_3<CGAL::Simple_cartesian<CGAL::Interval_nt<false>>>, CGAL::Cartesian_converter<CGAL::Type_equality_wrapper<CGAL::Cartesian_base_no_ref_count<double, CGAL::Epick>, CGAL::Epick>, CGAL::Simple_cartesian<CGAL::Mpzf>, CGAL::NT_converter<double, CGAL::Mpzf>>, CGAL::Cartesian_converter<CGAL::Type_equality_wrapper<CGAL::Cartesian_base_no_ref_count<double, CGAL::Epick>, CGAL::Epick>, CGAL::Simple_cartesian<CGAL::Interval_nt<false>>, CGAL::NT_converter<double, CGAL::Interval_nt<false>>>, true>>::operator()<CGAL::Point_3<CGAL::Epeck>, CGAL::Point_3<CGAL::Epeck>, CGAL::Point_3<CGAL::Epeck>, CGAL::Point_3<CGAL::Epeck>, double>' requested here
return pred(p, q, r, s, coplanar_cos_threshold) == CGAL::LARGER;
^
/usr/local/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:189:12: note: in instantiation of function template specialization 'CGAL::Polygon_mesh_processing::Planar_segmentation::is_edge_between_coplanar_faces<CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epeck>>, CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epeck>>::Property_map<CGAL::SM_Vertex_index, CGAL::Point_3<CGAL::Epeck>>, CGAL::SM_Edge_index>' requested here
if (!is_edge_between_coplanar_faces(e, tm, coplanar_cos_threshold, vpm))
^
/usr/local/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:374:3: note: in instantiation of function template specialization 'CGAL::Polygon_mesh_processing::Planar_segmentation::mark_constrained_edges<CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epeck>>, CGAL::internal::Dynamic<CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epeck>>, CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epeck>>::Property_map<CGAL::SM_Edge_index, bool>>, CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epeck>>::Property_map<CGAL::SM_Vertex_index, CGAL::Point_3<CGAL::Epeck>>>' requested here
mark_constrained_edges(tm, edge_is_constrained, coplanar_cos_threshold, vpm);
^
/usr/local/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:989:26: note: in instantiation of function template specialization 'CGAL::Polygon_mesh_processing::Planar_segmentation::tag_corners_and_constrained_edges<CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epeck>>, CGAL::internal::Dynamic<CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epeck>>, CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epeck>>::Property_map<CGAL::SM_Vertex_index, unsigned long>>, CGAL::internal::Dynamic<CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epeck>>, CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epeck>>::Property_map<CGAL::SM_Edge_index, bool>>, CGAL::internal::Dynamic<CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epeck>>, CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epeck>>::Property_map<CGAL::SM_Face_index, unsigned long>>, CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epeck>>::Property_map<CGAL::SM_Vertex_index, CGAL::Point_3<CGAL::Epeck>>>' requested here
Planar_segmentation::tag_corners_and_constrained_edges(tm, coplanar_cos_threshold, vertex_corner_id, edge_is_constrained, face_cc_ids, vpm);
^
cgalutils-repair.cc:24:34: note: in instantiation of function template specialization 'CGAL::Polygon_mesh_processing::remesh_planar_patches<CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epeck>>, CGAL::Named_function_parameters<bool, CGAL::internal_np::all_default_t>>' requested here
CGAL::Polygon_mesh_processing::remesh_planar_patches(mesh);
^
I
@ochafik Should be fixed now.
@sloriot Wow thanks! This code works amazingly and seems to fixe exponential growth of nested unions in this model.
Are there any caveats to using it? Would be amazing if this could land, even if just in the experimental namespace.
Edit: pasted the problematic part of the model here for reference
In your case, it might be even faster to keep track of the original faces to avoid the re-detection of planar parts. This can be done with the visitor of the corefinement function.
The goal is to have it in 5.5
@sloriot oh I see... "just" need to see which of these sibling faces are still standing at the end of the corefinement? Are there any existing helpers to do the job?
In your case, it might be even faster to keep track of the original faces to avoid the re-detection of planar parts. This can be done with the visitor of the corefinement function.
@sloriot I've taken a stab at this in https://github.com/openscad/openscad/pull/4117, with moderate success (prevents some combinatorial explosions but also explodes in many cases). I'd highly welcome any feedback on it :-)
/build:v0
There was an error while building the doc:
/home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:40: warning: Found unknown command \TODO' /home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:41: warning: Found unknown command \TODO'
/home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:42: warning: Found unknown command \TODO' /home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:40: warning: Found unknown command \TODO'
/home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:41: warning: Found unknown command \TODO' /home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:42: warning: Found unknown command \TODO'
/home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:40: warning: Found unknown command \TODO' /home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:41: warning: Found unknown command \TODO'
/home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:42: warning: Found unknown command \TODO' /home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:40: warning: Found unknown command \TODO'
/home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:41: warning: Found unknown command \TODO' /home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:42: warning: Found unknown command \TODO'
/home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:40: warning: Found unknown command \TODO' /home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:41: warning: Found unknown command \TODO'
/home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:42: warning: Found unknown command `\TODO'
/build:v0
There was an error while building the doc:
/home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:40: warning: Found unknown command \TODO' /home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:41: warning: Found unknown command \TODO'
/home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:42: warning: Found unknown command \TODO' /home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:40: warning: Found unknown command \TODO'
/home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:41: warning: Found unknown command \TODO' /home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:42: warning: Found unknown command \TODO'
/home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:40: warning: Found unknown command \TODO' /home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:41: warning: Found unknown command \TODO'
/home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:42: warning: Found unknown command \TODO' /home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:40: warning: Found unknown command \TODO'
/home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:41: warning: Found unknown command \TODO' /home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:42: warning: Found unknown command \TODO'
/home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:40: warning: Found unknown command \TODO' /home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:41: warning: Found unknown command \TODO'
/home/runner/work/cgal/cgal/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh_planar_patches.h:42: warning: Found unknown command `\TODO'
/build:v0
The documentation is built. It will be available, after a few minutes, here: https://cgal.github.io/5461/v0/Manual/index.html
/build:v1
The documentation is built. It will be available, after a few minutes, here: https://cgal.github.io/5461/v1/Manual/index.html
/force-build:v1
The documentation is built. It will be available, after a few minutes, here: https://cgal.github.io/5461/v1/Manual/index.html
New warnings in CGAL-5.6-Ic-197/Polyhedron_Demo
/force-build:v1
The documentation is built. It will be available, after a few minutes, here: https://cgal.github.io/5461/v1/Manual/index.html
/force-build:v1
The documentation is built. It will be available, after a few minutes, here: https://cgal.github.io/5461/v1/Manual/index.html
@afabri @MaelRL @soesau the user manual is here.
Runtime error here
Successfully tested in CGAL-5.6-Ic-223