From 60464325348dd966652464d02aede004b0e1e2d6 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 3 Dec 2020 07:58:33 +0000 Subject: [PATCH] Add a mesh in envelope test --- .../Polygon_mesh_processing/CMakeLists.txt | 1 + .../polyhedral_envelope_mesh_containment.cpp | 38 +++++++++++++++++++ .../include/CGAL/Polyhedral_envelope.h | 2 + 3 files changed, 41 insertions(+) create mode 100644 Polygon_mesh_processing/examples/Polygon_mesh_processing/polyhedral_envelope_mesh_containment.cpp diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt index da047d10634..5601ede5b0a 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt @@ -55,6 +55,7 @@ endif() create_single_source_cgal_program( "polyhedral_envelope.cpp" ) create_single_source_cgal_program( "polyhedral_envelope_of_triangle_soup.cpp" ) +create_single_source_cgal_program( "polyhedral_envelope_mesh_containment.cpp" ) create_single_source_cgal_program( "self_intersections_example.cpp" ) create_single_source_cgal_program( "stitch_borders_example.cpp" ) create_single_source_cgal_program( "compute_normals_example_Polyhedron.cpp" CXX_FEATURES cxx_range_for ) diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/polyhedral_envelope_mesh_containment.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/polyhedral_envelope_mesh_containment.cpp new file mode 100644 index 00000000000..2a52468cff8 --- /dev/null +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/polyhedral_envelope_mesh_containment.cpp @@ -0,0 +1,38 @@ +#include +#include +#include + +#include + +int main(int argc, char* argv[]) +{ + typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; + typedef Kernel::Point_3 Point_3; + typedef CGAL::Surface_mesh Surface_mesh; + typedef boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef boost::graph_traits::halfedge_descriptor halfedge_descriptor; + + typedef CGAL::Polyhedral_envelope Envelope; + + std::ifstream in((argc>1) ? argv[1] : "data/patch.off"); + std::ifstream in2((argc>2) ? argv[2] : "data/tentative.off"); + Surface_mesh tmesh, test; + + in >> tmesh; + in2 >> test; + + double eps = (argc>3) ? std::stod(std::string(argv[3])) : 0.2; + + Envelope envelope(tmesh, eps); + + for(auto fd : faces(test)){ + halfedge_descriptor hd = halfedge(fd, test); + Point_3 p = test.point(target(hd,test)); + Point_3 q = test.point(target(next(hd,test),test)); + Point_3 r = test.point(source(hd,test)); + if(envelope(p,q,r)){ + std::cout << "inside polyhedral envelope" << std::endl; + } + } + return 0; +} diff --git a/Polygon_mesh_processing/include/CGAL/Polyhedral_envelope.h b/Polygon_mesh_processing/include/CGAL/Polyhedral_envelope.h index 0d619eafed5..c9a0a5e43f7 100644 --- a/Polygon_mesh_processing/include/CGAL/Polyhedral_envelope.h +++ b/Polygon_mesh_processing/include/CGAL/Polyhedral_envelope.h @@ -58,6 +58,8 @@ #include +#define CGAL_ENVELOPE_DEBUG 1 + #include #include