From 7bd7caa53cbc0532a694f0627f0b90602bf8616b Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 14 Jan 2019 16:49:04 +0100 Subject: [PATCH 1/8] Replace vectors of points and polygons by ranges and write a test file. --- .../convert_nef_polyhedron_to_polygon_mesh.h | 70 ++++++++++--------- Nef_3/test/Nef_3/test_nef_to_soup.cpp | 48 +++++++++++++ 2 files changed, 84 insertions(+), 34 deletions(-) create mode 100644 Nef_3/test/Nef_3/test_nef_to_soup.cpp diff --git a/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h b/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h index 7393881de00..60cfd12edf2 100644 --- a/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h +++ b/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h @@ -42,15 +42,17 @@ namespace CGAL{ namespace nef_to_pm{ // Visitor used to collect and index vertices of a shell -template +template struct Shell_vertex_index_visitor { - typedef boost::unordered_map Vertex_index_map; - std::vector& points; + typedef boost::unordered_map< + typename Nef_polyhedron::Vertex_const_handle, std::size_t> Vertex_index_map; + typedef typename PointRange::value_type Point_3; + PointRange& points; Vertex_index_map vertex_indices; const Converter& converter; - Shell_vertex_index_visitor(std::vector& points, const Converter& converter) + Shell_vertex_index_visitor(PointRange& points, const Converter& converter) :points(points), converter(converter) {} @@ -80,16 +82,17 @@ struct FaceInfo2 }; //Visitor used to collect polygons -template +template struct Shell_polygons_visitor { typedef boost::unordered_map Vertex_index_map; + typedef typename PolygonRange::value_type Polygon; Vertex_index_map& vertex_indices; - std::vector< std::vector >& polygons; + PolygonRange& polygons; bool triangulate_all_faces; Shell_polygons_visitor(Vertex_index_map& vertex_indices, - std::vector< std::vector >& polygons, + PolygonRange& polygons, bool triangulate_all_faces) : vertex_indices( vertex_indices ) , polygons(polygons) @@ -146,22 +149,22 @@ struct Shell_polygons_visitor { if (is_marked) { - polygons.push_back( std::vector() ); + polygons.push_back( Polygon() ); polygons.back().push_back(vertex_indices[v[0]]); polygons.back().push_back(vertex_indices[v[1]]); polygons.back().push_back(vertex_indices[v[2]]); - polygons.push_back( std::vector() ); + polygons.push_back( Polygon() ); polygons.back().push_back(vertex_indices[v[2]]); polygons.back().push_back(vertex_indices[v[0]]); polygons.back().push_back(vertex_indices[v[3]]); } else { - polygons.push_back( std::vector() ); + polygons.push_back( Polygon() ); polygons.back().push_back(vertex_indices[v[1]]); polygons.back().push_back(vertex_indices[v[0]]); polygons.back().push_back(vertex_indices[v[2]]); - polygons.push_back( std::vector() ); + polygons.push_back( Polygon() ); polygons.back().push_back(vertex_indices[v[0]]); polygons.back().push_back(vertex_indices[v[2]]); polygons.back().push_back(vertex_indices[v[3]]); @@ -171,22 +174,22 @@ struct Shell_polygons_visitor { if (is_marked) { - polygons.push_back( std::vector() ); + polygons.push_back( Polygon() ); polygons.back().push_back(vertex_indices[v[0]]); polygons.back().push_back(vertex_indices[v[1]]); polygons.back().push_back(vertex_indices[v[3]]); - polygons.push_back( std::vector() ); + polygons.push_back( Polygon() ); polygons.back().push_back(vertex_indices[v[3]]); polygons.back().push_back(vertex_indices[v[1]]); polygons.back().push_back(vertex_indices[v[2]]); } else { - polygons.push_back( std::vector() ); + polygons.push_back( Polygon() ); polygons.back().push_back(vertex_indices[v[0]]); polygons.back().push_back(vertex_indices[v[3]]); polygons.back().push_back(vertex_indices[v[1]]); - polygons.push_back( std::vector() ); + polygons.push_back( Polygon() ); polygons.back().push_back(vertex_indices[v[1]]); polygons.back().push_back(vertex_indices[v[3]]); polygons.back().push_back(vertex_indices[v[2]]); @@ -197,7 +200,7 @@ struct Shell_polygons_visitor case 3: { // create a new polygon - polygons.push_back( std::vector() ); + polygons.push_back( Polygon() ); fc = f->facet_cycles_begin(); se = typename Nef_polyhedron::SHalfedge_const_handle(fc); CGAL_assertion(se!=0); @@ -320,21 +323,21 @@ struct Shell_polygons_visitor {} }; -template +template void collect_polygon_mesh_info( - std::vector& points, - std::vector< std::vector >& polygons, + PointRange& points, + PolygonRange& polygons, Nef_polyhedron& nef, typename Nef_polyhedron::Shell_entry_const_iterator shell, const Converter& converter, bool triangulate_all_faces) { // collect points and set vertex indices - Shell_vertex_index_visitor vertex_index_visitor(points, converter); + Shell_vertex_index_visitor vertex_index_visitor(points, converter); nef.visit_shell_objects(typename Nef_polyhedron::SFace_const_handle(shell), vertex_index_visitor); // collect polygons - Shell_polygons_visitor polygon_visitor( + Shell_polygons_visitor polygon_visitor( vertex_index_visitor.vertex_indices, polygons, triangulate_all_faces); @@ -343,16 +346,15 @@ void collect_polygon_mesh_info( } //end of namespace nef_to_pm -template +template void convert_nef_polyhedron_to_polygon_soup(const Nef_polyhedron& nef, - std::vector& points, - std::vector< std::vector >& polygons, + PointRange& points, + PolygonRange& polygons, bool triangulate_all_faces = false) { typedef typename Nef_polyhedron::Point_3 Point_3; typedef typename Kernel_traits::Kernel Nef_Kernel; typedef Cartesian_converter Converter; - typedef typename Output_kernel::Point_3 Out_point; typename Nef_polyhedron::Volume_const_iterator vol_it = nef.volumes_begin(), vol_end = nef.volumes_end(); if ( Nef_polyhedron::Infi_box::extended_kernel() ) ++vol_it; // skip Infi_box @@ -361,22 +363,22 @@ void convert_nef_polyhedron_to_polygon_soup(const Nef_polyhedron& nef, Converter to_output; for (;vol_it!=vol_end;++vol_it) - nef_to_pm::collect_polygon_mesh_info(points, - polygons, - nef, - vol_it->shells_begin(), - to_output, - triangulate_all_faces); + nef_to_pm::collect_polygon_mesh_info(points, + polygons, + nef, + vol_it->shells_begin(), + to_output, + triangulate_all_faces); } -template +template void convert_nef_polyhedron_to_polygon_mesh(const Nef_polyhedron& nef, Polygon_mesh& pm, bool triangulate_all_faces = false) { typedef typename boost::property_traits::type>::value_type PM_Point; typedef typename Kernel_traits::Kernel PM_Kernel; - std::vector points; - std::vector< std::vector > polygons; + PointRange points; + PolygonRange polygons; convert_nef_polyhedron_to_polygon_soup(nef, points, polygons, triangulate_all_faces); Polygon_mesh_processing::polygon_soup_to_polygon_mesh(points, polygons, pm); } diff --git a/Nef_3/test/Nef_3/test_nef_to_soup.cpp b/Nef_3/test/Nef_3/test_nef_to_soup.cpp new file mode 100644 index 00000000000..f117c20d54a --- /dev/null +++ b/Nef_3/test/Nef_3/test_nef_to_soup.cpp @@ -0,0 +1,48 @@ +#include +#include +#include + +#include +#include +#include + +#include + +typedef CGAL::Exact_predicates_exact_constructions_kernel EPEC; +typedef CGAL::Exact_predicates_inexact_constructions_kernel EPIC; + +int main() +{ + typedef CGAL::Nef_polyhedron_3< EPEC > Nef_polyhedron; + typedef CGAL::Polyhedron_3< EPEC > Polyhedron; + typedef typename EPIC::Point_3 Point; + typedef std::list > PolygonRange; + typedef std::list PointRange; + + typename EPEC::RT n, d; + std::istringstream str_n("6369051672525773"); + str_n >> n; + std::istringstream str_d("4503599627370496"); + str_d >> d; + + EPEC::Point_3 p(n, 0, 0, d); + EPEC::Point_3 q(0, n, 0, d); + EPEC::Point_3 r(0, 0, n, d); + EPEC::Point_3 s(0, 0, 0, 1); + + std::cout << " build...\n"; + Polyhedron P; + P.make_tetrahedron( p, q, r, s); + Nef_polyhedron nef( P ); + PointRange points; + PolygonRange polygons; + std::cout << " convert...\n"; + CGAL::convert_nef_polyhedron_to_polygon_soup< + EPIC, + Nef_polyhedron, + PolygonRange, + PointRange>(nef, points, polygons); + CGAL_assertion(points.size() == 4); + CGAL_assertion(polygons.size() == 4); + return 0; +} From b939551b3844362e9a58e934636746a5ab2d667a Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 15 Jan 2019 12:17:49 +0100 Subject: [PATCH 2/8] Don't hardcode vector but use a random access container in polygon_soup_to_polygon_mesh. --- Nef_3/test/Nef_3/test_nef_to_soup.cpp | 13 +++++--- .../polygon_soup_to_polygon_mesh.h | 33 +++++++++++-------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/Nef_3/test/Nef_3/test_nef_to_soup.cpp b/Nef_3/test/Nef_3/test_nef_to_soup.cpp index f117c20d54a..4793a892ea9 100644 --- a/Nef_3/test/Nef_3/test_nef_to_soup.cpp +++ b/Nef_3/test/Nef_3/test_nef_to_soup.cpp @@ -15,6 +15,7 @@ int main() { typedef CGAL::Nef_polyhedron_3< EPEC > Nef_polyhedron; typedef CGAL::Polyhedron_3< EPEC > Polyhedron; + typedef CGAL::Polyhedron_3< EPIC > PolygonMesh; typedef typename EPIC::Point_3 Point; typedef std::list > PolygonRange; typedef std::list PointRange; @@ -38,11 +39,15 @@ int main() PolygonRange polygons; std::cout << " convert...\n"; CGAL::convert_nef_polyhedron_to_polygon_soup< - EPIC, - Nef_polyhedron, - PolygonRange, - PointRange>(nef, points, polygons); + EPIC>(nef, points, polygons); CGAL_assertion(points.size() == 4); CGAL_assertion(polygons.size() == 4); + PolygonMesh pm; + CGAL::convert_nef_polyhedron_to_polygon_mesh< + Nef_polyhedron, + PolygonMesh, + std::vector >, + std::vector >(nef, pm); + return 0; } diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h index d3f70c87401..b2568833f51 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h @@ -44,12 +44,12 @@ namespace Polygon_mesh_processing namespace internal { template + , typename PointRange + , typename PolygonRange> class Polygon_soup_to_polygon_mesh { - const std::vector& _points; - const std::vector& _polygons; + const PointRange& _points; + const PolygonRange& _polygons; typedef typename boost::property_map::type Vpmap; typedef typename boost::property_traits::value_type Point_3; @@ -57,15 +57,17 @@ class Polygon_soup_to_polygon_mesh typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename boost::graph_traits::face_descriptor face_descriptor; + typedef typename PolygonRange::value_type Polygon; + typedef typename PointRange::value_type Point; public: /** * The constructor for modifier object. * @param points points of the soup of polygons. - * @param polygons each element in the vector describes a polygon using the index of the points in the vector. + * @param polygons each element in the range describes a polygon using the index of the points in the range. */ - Polygon_soup_to_polygon_mesh(const std::vector& points, - const std::vector& polygons) + Polygon_soup_to_polygon_mesh(const PointRange& points, + const PolygonRange& polygons) : _points(points), _polygons(polygons) { } @@ -195,9 +197,12 @@ public: * @pre the input polygon soup describes a consistently oriented * polygon mesh. * - * @tparam PolygonMesh a model of `MutableFaceGraph` with an internal point property map - * @tparam Point a point type that has an operator `[]` to access coordinates - * @tparam Polygon a `std::vector` containing the indices + * @tparam PolygonMesh a model of `MutableFaceGraph` with an internal point + * property map + * @tparam PointRange a `RandomAccessContainer` with a value_type that has an + * operator `[]` to access coordinates + * @tparam PolygonRange a `RandomAccessContainer` of `RandomAccessContainer` + * of `std::size_t` containing the indices * of the points of the face * * @param points points of the soup of polygons @@ -211,16 +216,16 @@ public: * \sa `CGAL::Polygon_mesh_processing::is_polygon_soup_a_polygon_mesh()` * */ - template + template void polygon_soup_to_polygon_mesh( - const std::vector& points, - const std::vector& polygons, + const PointRange& points, + const PolygonRange& polygons, PolygonMesh& out) { CGAL_precondition_msg(is_polygon_soup_a_polygon_mesh(polygons), "Input soup needs to be a polygon mesh!"); - internal::Polygon_soup_to_polygon_mesh + internal::Polygon_soup_to_polygon_mesh converter(points, polygons); converter(out); } From ce72dd895f38f9504784859dd3e3e8d10b48abc5 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 15 Jan 2019 12:38:04 +0100 Subject: [PATCH 3/8] First draft of the doc --- .../convert_nef_polyhedron_to_polygon_mesh.h | 26 +++++++++++++++++++ .../convert_nef_polyhedron_to_polygon_mesh.h | 6 ++--- Nef_3/test/Nef_3/test_nef_to_soup.cpp | 4 +-- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/Nef_3/doc/Nef_3/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h b/Nef_3/doc/Nef_3/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h index 7f074eb22fb..d7a903f5288 100644 --- a/Nef_3/doc/Nef_3/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h +++ b/Nef_3/doc/Nef_3/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h @@ -5,9 +5,35 @@ namespace CGAL { /// Note that contrary to `Nef_polyhedron_3::convert_to_polyhedron()`, the output is not triangulated /// (but faces with more than one connected component of the boundary). /// The polygon mesh can be triangulated by setting `triangulate_all_faces` to `true` or by calling the function `triangulate_faces()`. +/// @tparam Nef_polyhedron an object of type `Nef_polyhedron_3`. +/// @tparam Polygon_mesh a model of `MutableFaceGraph`. +/// +/// @param nef the input. +/// @param pm the output. +/// @param triangulate_all_faces the bool for triangulating the faces. +/// /// \pre `Polygon_mesh` must have an internal point property map with value type being `Nef_polyhedron_3::Point_3`. /// \pre `nef.simple()` template void convert_nef_polyhedron_to_polygon_mesh(const Nef_polyhedron& nef, Polygon_mesh& pm, bool triangulate_all_faces = false); + + /// \ingroup PkgNef3IOFunctions + /// Converts an objet of type `Nef_polyhedron_3` into a polygon soup. + /// The polygons can be triangulated by setting `triangulate_all_faces` to `true`. + /// @tparam Output_kernel the Kernel from which the point type of points come from. + /// @tparam Nef_polyhedron an object of type `Nef_polyhedron_3`. + /// @tparam Polygon_mesh a model of `MutableFaceGraph`. + /// @tparam PolygonRange a container of collections of indices of the points in their range. + /// @tparam PointRange a container of `Output_kernel::Point_3`. + /// + /// @param nef the input. + /// @param pm the output. + /// @param triangulate_all_faces the bool for triangulating the faces. + /// \pre `nef.simple()` + template + void convert_nef_polyhedron_to_polygon_soup(const Nef_polyhedron& nef, + PointRange& points, + PolygonRange& polygons, + bool triangulate_all_faces = false); } diff --git a/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h b/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h index 60cfd12edf2..c1053f88014 100644 --- a/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h +++ b/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h @@ -371,14 +371,14 @@ void convert_nef_polyhedron_to_polygon_soup(const Nef_polyhedron& nef, triangulate_all_faces); } -template +template void convert_nef_polyhedron_to_polygon_mesh(const Nef_polyhedron& nef, Polygon_mesh& pm, bool triangulate_all_faces = false) { typedef typename boost::property_traits::type>::value_type PM_Point; typedef typename Kernel_traits::Kernel PM_Kernel; - PointRange points; - PolygonRange polygons; + std::vector points; + std::vector > polygons; convert_nef_polyhedron_to_polygon_soup(nef, points, polygons, triangulate_all_faces); Polygon_mesh_processing::polygon_soup_to_polygon_mesh(points, polygons, pm); } diff --git a/Nef_3/test/Nef_3/test_nef_to_soup.cpp b/Nef_3/test/Nef_3/test_nef_to_soup.cpp index 4793a892ea9..42121f341af 100644 --- a/Nef_3/test/Nef_3/test_nef_to_soup.cpp +++ b/Nef_3/test/Nef_3/test_nef_to_soup.cpp @@ -45,9 +45,7 @@ int main() PolygonMesh pm; CGAL::convert_nef_polyhedron_to_polygon_mesh< Nef_polyhedron, - PolygonMesh, - std::vector >, - std::vector >(nef, pm); + PolygonMesh>(nef, pm); return 0; } From 7a7098d00956eca7b05e5dc52b95e3116a84b345 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 16 Jan 2019 11:23:30 +0100 Subject: [PATCH 4/8] Fix doc --- .../graph/convert_nef_polyhedron_to_polygon_mesh.h | 12 ++++++------ .../polygon_soup_to_polygon_mesh.h | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Nef_3/doc/Nef_3/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h b/Nef_3/doc/Nef_3/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h index d7a903f5288..1a8e5a46cee 100644 --- a/Nef_3/doc/Nef_3/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h +++ b/Nef_3/doc/Nef_3/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h @@ -10,7 +10,7 @@ namespace CGAL { /// /// @param nef the input. /// @param pm the output. -/// @param triangulate_all_faces the bool for triangulating the faces. +/// @param triangulate_all_faces indicates whether all the faces must be triangulated. /// /// \pre `Polygon_mesh` must have an internal point property map with value type being `Nef_polyhedron_3::Point_3`. /// \pre `nef.simple()` @@ -23,14 +23,14 @@ namespace CGAL { /// The polygons can be triangulated by setting `triangulate_all_faces` to `true`. /// @tparam Output_kernel the Kernel from which the point type of points come from. /// @tparam Nef_polyhedron an object of type `Nef_polyhedron_3`. - /// @tparam Polygon_mesh a model of `MutableFaceGraph`. - /// @tparam PolygonRange a container of collections of indices of the points in their range. - /// @tparam PointRange a container of `Output_kernel::Point_3`. + /// @tparam PointRange a model of the concepts `RandomAccessContainer` and + /// `BackInsertionSequence` whose `value_type` is the point type + /// @tparam PolygonRange a model of the concept `RandomAccessContainer` whose + /// `value_type` is a model of the concept `RandomAccessContainer` whose `value_type` is `std::size_t`. /// /// @param nef the input. /// @param pm the output. - /// @param triangulate_all_faces the bool for triangulating the faces. - /// \pre `nef.simple()` + /// @param triangulate_all_faces indicates whether all polygons must be triangulated. template void convert_nef_polyhedron_to_polygon_soup(const Nef_polyhedron& nef, PointRange& points, diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h index b2568833f51..53fb2ac2945 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h @@ -199,11 +199,11 @@ public: * * @tparam PolygonMesh a model of `MutableFaceGraph` with an internal point * property map - * @tparam PointRange a `RandomAccessContainer` with a value_type that has an - * operator `[]` to access coordinates - * @tparam PolygonRange a `RandomAccessContainer` of `RandomAccessContainer` - * of `std::size_t` containing the indices - * of the points of the face + * @tparam PointRange a model of the concepts `RandomAccessContainer` and + * `BackInsertionSequence` whose value type is the point type + * @tparam PolygonRange a model of the concept `RandomAccessContainer` whose + * `value_type` is a model of the concept `RandomAccessContainer` whose `value_type` is `std::size_t`. + * * @param points points of the soup of polygons * @param polygons each element in the vector describes a polygon using the index of the points in `points` From 18d9e721246439774ba0d94d5e0ea51a357a430f Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 22 Jan 2019 11:19:38 +0100 Subject: [PATCH 5/8] Fix doc and update CHANGES.md --- Installation/CHANGES.md | 8 ++++++++ .../boost/graph/convert_nef_polyhedron_to_polygon_mesh.h | 3 ++- Nef_3/doc/Nef_3/PackageDescription.txt | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index 9f2c4f38d50..731f7b96aa1 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -1,5 +1,13 @@ Release History =============== +Release 4.15 +------------ + +Release date: September 2019 + +###3D Boolean Operations on Nef Polyhedra +- Added a function to convert a Nef_polyhedron to a polygon soup: + - `CGAL::convert_nef_to_polygon_soup()` Release 4.14 ------------ diff --git a/Nef_3/doc/Nef_3/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h b/Nef_3/doc/Nef_3/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h index 1a8e5a46cee..06a883da670 100644 --- a/Nef_3/doc/Nef_3/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h +++ b/Nef_3/doc/Nef_3/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h @@ -29,7 +29,8 @@ namespace CGAL { /// `value_type` is a model of the concept `RandomAccessContainer` whose `value_type` is `std::size_t`. /// /// @param nef the input. - /// @param pm the output. + /// @param points the output points of the soup + /// @param polygons the output polygons of the soup. /// @param triangulate_all_faces indicates whether all polygons must be triangulated. template void convert_nef_polyhedron_to_polygon_soup(const Nef_polyhedron& nef, diff --git a/Nef_3/doc/Nef_3/PackageDescription.txt b/Nef_3/doc/Nef_3/PackageDescription.txt index c54ab4aa33d..83597337294 100644 --- a/Nef_3/doc/Nef_3/PackageDescription.txt +++ b/Nef_3/doc/Nef_3/PackageDescription.txt @@ -60,6 +60,7 @@ a simple OpenGL visualization for debugging and illustrations. ## Functions ## - `CGAL::OFF_to_nef_3()` - `CGAL::convert_nef_polyhedron_to_polygon_mesh()` +- `CGAL::convert_nef_polyhedron_to_polygon_soup()` - \link PkgNef3IOFunctions `CGAL::operator<<()` \endlink - \link PkgNef3IOFunctions `CGAL::operator>>()` \endlink From e2f2c63e76c43196f370d15e2eaffe92212c128c Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 23 Jan 2019 11:25:00 +0100 Subject: [PATCH 6/8] Modifications after review --- Installation/CHANGES.md | 2 +- .../convert_nef_polyhedron_to_polygon_mesh.h | 22 ++++++++++++++----- .../convert_nef_polyhedron_to_polygon_mesh.h | 9 +++++--- Nef_3/test/Nef_3/test_nef_to_soup.cpp | 3 +-- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index 731f7b96aa1..2a2b8c742d8 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -6,7 +6,7 @@ Release 4.15 Release date: September 2019 ###3D Boolean Operations on Nef Polyhedra -- Added a function to convert a Nef_polyhedron to a polygon soup: +- Added a function to convert a Nef_polyhedron_3 to a polygon soup: - `CGAL::convert_nef_to_polygon_soup()` Release 4.14 diff --git a/Nef_3/doc/Nef_3/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h b/Nef_3/doc/Nef_3/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h index 06a883da670..8aee57294ea 100644 --- a/Nef_3/doc/Nef_3/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h +++ b/Nef_3/doc/Nef_3/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h @@ -6,7 +6,12 @@ namespace CGAL { /// (but faces with more than one connected component of the boundary). /// The polygon mesh can be triangulated by setting `triangulate_all_faces` to `true` or by calling the function `triangulate_faces()`. /// @tparam Nef_polyhedron an object of type `Nef_polyhedron_3`. -/// @tparam Polygon_mesh a model of `MutableFaceGraph`. +/// @tparam Polygon_mesh a model of `MutableFaceGraph` with an internal property map for `CGAL::vertex_point_t`. +/// +/// The points from `nef` to `pm` are converted using +/// `CGAL::Cartesian_converter`. +/// `NefKernel` and `TargetKernel` are deduced using `CGAL::Kernel_traits` +/// from the point type of `nef` and the value type of the vertex_point_map of `tm`. /// /// @param nef the input. /// @param pm the output. @@ -21,18 +26,25 @@ namespace CGAL { /// \ingroup PkgNef3IOFunctions /// Converts an objet of type `Nef_polyhedron_3` into a polygon soup. /// The polygons can be triangulated by setting `triangulate_all_faces` to `true`. - /// @tparam Output_kernel the Kernel from which the point type of points come from. /// @tparam Nef_polyhedron an object of type `Nef_polyhedron_3`. /// @tparam PointRange a model of the concepts `RandomAccessContainer` and /// `BackInsertionSequence` whose `value_type` is the point type - /// @tparam PolygonRange a model of the concept `RandomAccessContainer` whose - /// `value_type` is a model of the concept `RandomAccessContainer` whose `value_type` is `std::size_t`. + /// @tparam PolygonRange a model of the concepts `RandomAccessContainer` and + /// `BackInsertionSequence` whose `value_type` is a model of the concepts + /// `RandomAccessContainer` and `BackInsertionSequence` whose + /// `value_type` is `std::size_t`. + /// It must + /// + /// The points from `nef` to `points` are converted using + /// `CGAL::Cartesian_converter`. + /// `NefKernel` and `OutputKernel` are deduced using `CGAL::Kernel_traits` + /// from the point types. /// /// @param nef the input. /// @param points the output points of the soup /// @param polygons the output polygons of the soup. /// @param triangulate_all_faces indicates whether all polygons must be triangulated. - template + template void convert_nef_polyhedron_to_polygon_soup(const Nef_polyhedron& nef, PointRange& points, PolygonRange& polygons, diff --git a/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h b/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h index c1053f88014..b379e7af7df 100644 --- a/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h +++ b/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h @@ -291,7 +291,7 @@ struct Shell_polygons_visitor queue.pop_back(); if (e.first->info().visited) continue; e.first->info().visited=true; - polygons.resize(polygons.size()+1); + polygons.push_back(Polygon()); if (is_marked) for (int i=2; i>=0; --i) polygons.back().push_back(e.first->vertex(i)->info()); @@ -346,7 +346,7 @@ void collect_polygon_mesh_info( } //end of namespace nef_to_pm -template +template < class Nef_polyhedron, typename PolygonRange, typename PointRange> void convert_nef_polyhedron_to_polygon_soup(const Nef_polyhedron& nef, PointRange& points, PolygonRange& polygons, @@ -354,6 +354,9 @@ void convert_nef_polyhedron_to_polygon_soup(const Nef_polyhedron& nef, { typedef typename Nef_polyhedron::Point_3 Point_3; typedef typename Kernel_traits::Kernel Nef_Kernel; + typedef typename PointRange::value_type Out_Point; + typedef typename Kernel_traits::Kernel Output_kernel; + typedef Cartesian_converter Converter; typename Nef_polyhedron::Volume_const_iterator vol_it = nef.volumes_begin(), vol_end = nef.volumes_end(); @@ -379,7 +382,7 @@ void convert_nef_polyhedron_to_polygon_mesh(const Nef_polyhedron& nef, Polygon_m std::vector points; std::vector > polygons; - convert_nef_polyhedron_to_polygon_soup(nef, points, polygons, triangulate_all_faces); + convert_nef_polyhedron_to_polygon_soup(nef, points, polygons, triangulate_all_faces); Polygon_mesh_processing::polygon_soup_to_polygon_mesh(points, polygons, pm); } diff --git a/Nef_3/test/Nef_3/test_nef_to_soup.cpp b/Nef_3/test/Nef_3/test_nef_to_soup.cpp index 42121f341af..c81a85cd526 100644 --- a/Nef_3/test/Nef_3/test_nef_to_soup.cpp +++ b/Nef_3/test/Nef_3/test_nef_to_soup.cpp @@ -38,8 +38,7 @@ int main() PointRange points; PolygonRange polygons; std::cout << " convert...\n"; - CGAL::convert_nef_polyhedron_to_polygon_soup< - EPIC>(nef, points, polygons); + CGAL::convert_nef_polyhedron_to_polygon_soup(nef, points, polygons); CGAL_assertion(points.size() == 4); CGAL_assertion(polygons.size() == 4); PolygonMesh pm; From 2feb6c892bd7d996facf023750cab31b3e9b8a5a Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Thu, 24 Jan 2019 11:57:38 +0100 Subject: [PATCH 7/8] Remove the RandomAccessContainer constraint --- .../convert_nef_polyhedron_to_polygon_mesh.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Nef_3/doc/Nef_3/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h b/Nef_3/doc/Nef_3/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h index 8aee57294ea..0db3c62a408 100644 --- a/Nef_3/doc/Nef_3/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h +++ b/Nef_3/doc/Nef_3/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h @@ -27,22 +27,21 @@ namespace CGAL { /// Converts an objet of type `Nef_polyhedron_3` into a polygon soup. /// The polygons can be triangulated by setting `triangulate_all_faces` to `true`. /// @tparam Nef_polyhedron an object of type `Nef_polyhedron_3`. - /// @tparam PointRange a model of the concepts `RandomAccessContainer` and - /// `BackInsertionSequence` whose `value_type` is the point type - /// @tparam PolygonRange a model of the concepts `RandomAccessContainer` and - /// `BackInsertionSequence` whose `value_type` is a model of the concepts - /// `RandomAccessContainer` and `BackInsertionSequence` whose + /// @tparam PointRange a model of the concept `BackInsertionSequence` + /// whose `value_type` is the point type + /// @tparam PolygonRange a model of the concept + /// `BackInsertionSequence` whose `value_type` is a model of the concept + /// `BackInsertionSequence` whose /// `value_type` is `std::size_t`. - /// It must - /// + /// /// The points from `nef` to `points` are converted using /// `CGAL::Cartesian_converter`. /// `NefKernel` and `OutputKernel` are deduced using `CGAL::Kernel_traits` /// from the point types. - /// + /// /// @param nef the input. /// @param points the output points of the soup - /// @param polygons the output polygons of the soup. + /// @param polygons the output polygons of the soup. /// @param triangulate_all_faces indicates whether all polygons must be triangulated. template void convert_nef_polyhedron_to_polygon_soup(const Nef_polyhedron& nef, From 28ec0d926da0b1fc60ce1fea3e8003ec0f4229f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 12 Apr 2019 17:52:31 +0200 Subject: [PATCH 8/8] remove unused typedef --- .../CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h b/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h index b379e7af7df..950bcbeedb8 100644 --- a/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h +++ b/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h @@ -378,7 +378,6 @@ template void convert_nef_polyhedron_to_polygon_mesh(const Nef_polyhedron& nef, Polygon_mesh& pm, bool triangulate_all_faces = false) { typedef typename boost::property_traits::type>::value_type PM_Point; - typedef typename Kernel_traits::Kernel PM_Kernel; std::vector points; std::vector > polygons;