diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h index 93ad6b960ae..ac134c7edce 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/corefinement.h @@ -30,12 +30,103 @@ namespace CGAL { namespace Polygon_mesh_processing { +namespace internal { + +template +bool recursive_does_bound_a_volume(const TriangleMesh& tm, + Vpm& vpm, + Fid_map& fid_map, + const std::vector& xtrm_vertices, + boost::dynamic_bitset<>& cc_handled, + const std::vector& face_cc, + std::size_t xtrm_cc_id, + bool is_parent_outward_oriented) +{ + typedef boost::graph_traits GT; + typedef typename GT::face_descriptor face_descriptor; + typedef Side_of_triangle_mesh Side_of_tm; +// first check that the orientation of the current cc is consistant with its +// parent cc containing it + bool new_is_parent_outward_oriented = internal::is_outward_oriented( + xtrm_vertices[xtrm_cc_id], tm, parameters::vertex_point_map(vpm)); + if (new_is_parent_outward_oriented==is_parent_outward_oriented) + return false; + cc_handled.set(xtrm_cc_id); + + std::size_t nb_cc = cc_handled.size(); + +// get all cc that are inside xtrm_cc_id + std::vector cc_faces; + BOOST_FOREACH(face_descriptor fd, faces(tm)) + { + if(face_cc[get(fid_map, fd)]==xtrm_cc_id) + cc_faces.push_back(fd); + } + + typename Side_of_tm::AABB_tree aabb_tree(cc_faces.begin(), cc_faces.end(), + tm, vpm); + Side_of_tm side_of_cc(aabb_tree); + + std::vector cc_inside; + for(std::size_t id=0; id new_cc_handled(nb_cc,0); + new_cc_handled.set(); + new_cc_handled.reset(new_xtrm_cc_id); + cc_handled.set(new_xtrm_cc_id); + + std::size_t nb_candidates = cc_inside.size(); + for (std::size_t i=1;i( + tm, vpm, fid_map, xtrm_vertices, new_cc_handled, face_cc, + new_xtrm_cc_id, new_is_parent_outward_oriented) ) return false; + } + +// now explore remaining cc included in the same cc as xtrm_cc_id + boost::dynamic_bitset<> cc_not_handled = ~cc_handled; + std::size_t new_xtrm_cc_id = cc_not_handled.find_first(); + if (new_xtrm_cc_id == cc_not_handled.npos) return true; + + for (std::size_t candidate = cc_not_handled.find_next(new_xtrm_cc_id); + candidate < cc_not_handled.npos; + candidate = cc_not_handled.find_next(candidate)) + { + if(get(vpm,xtrm_vertices[candidate]) < get(vpm,xtrm_vertices[new_xtrm_cc_id])) + new_xtrm_cc_id = candidate; + } + + return internal::recursive_does_bound_a_volume( + tm, vpm, fid_map, xtrm_vertices, cc_handled, face_cc, + new_xtrm_cc_id, is_parent_outward_oriented); +} + +} //end of namespace internal + /** \ingroup PMP_corefinement_grp * * indicates if `tm` bounds a volume. * See \ref coref_def_subsec for details. * - * @tparam TriangleMesh a model of `FaceListGraph` and `HalfedgeListGraph` + * @tparam TriangleMesh a model of `MutableFaceGraph`, `HalfedgeListGraph` and `FaceListGraph`. + * If `TriangleMesh` has an internal property map for `CGAL::face_index_t`, + * as a named parameter, then it must initialized. * @tparam NamedParameters a sequence of \ref namedparameters * * @param tm a triangulated surface mesh @@ -43,18 +134,85 @@ namespace Polygon_mesh_processing { * * \cgalNamedParamsBegin * \cgalParamBegin{vertex_point_map} - * the property map with the points associated to the vertices of `tm1` (`tm2`). + * the property map with the points associated to the vertices of `tm`. * If this parameter is omitted, an internal property map for * `CGAL::vertex_point_t` should be available in `TriangleMesh` * \cgalParamEnd + * \cgalParamBegin{face_index_map} + * a property map containing the index of each face of `tm1` (`tm2`) + * \cgalParamEnd * \cgalNamedParamsEnd * - * \todo in the implementation degenerated faces should be skipped */ template -bool does_bound_a_volume(const TriangleMesh& tm, const NamedParameters& np); +bool does_bound_a_volume(const TriangleMesh& tm, const NamedParameters& np) +{ + typedef boost::graph_traits GT; + typedef typename GT::vertex_descriptor vertex_descriptor; + typedef typename GetVertexPointMap::const_type Vpm; + typedef typename GetFaceIndexMap::const_type Fid_map; + typedef typename Kernel_traits< + typename boost::property_traits::value_type >::Kernel Kernel; + + if (!is_closed(tm)) return false; + if (!is_triangle_mesh(tm)) return false; + + Vpm vpm = choose_param(get_param(np, vertex_point), + get_const_property_map(vertex_point, tm)); + + Fid_map fid_map = choose_param(get_param(np, face_index), + get_const_property_map(face_index, tm)); + + std::vector face_cc(num_faces(tm), std::size_t(-1)); + + // set the connected component id of each face + std::size_t nb_cc = connected_components(tm, + Corefinement::bind_maps(fid_map,make_property_map(face_cc)), + parameters::face_index_map(fid_map)); + + if (nb_cc == 1) + return true; + + boost::dynamic_bitset<> cc_handled(nb_cc, 0); + + // extract the less-xyz vertex of each connected component + std::vector xtrm_vertices(nb_cc, GT::null_vertex()); + BOOST_FOREACH(vertex_descriptor vd, vertices(tm)) + { + std::size_t cc_id = face_cc[get(fid_map, face(halfedge(vd, tm), tm))]; + if (xtrm_vertices[cc_id]==GT::null_vertex()) + xtrm_vertices[cc_id]=vd; + else + if (get(vpm, vd)(xtrm_vertices[xtrm_cc_id], tm, np); + + return internal::recursive_does_bound_a_volume(tm, vpm, fid_map, + xtrm_vertices, + cc_handled, + face_cc, + xtrm_cc_id, + is_parent_outward_oriented); +} /// \cond SKIP_IN_MANUAL +template +bool does_bound_a_volume(const TriangleMesh& tm) +{ + return does_bound_a_volume(tm, parameters::all_default()); +} + #define CGAL_COREF_SET_OUTPUT_VERTEX_POINT_MAP(i) \ if (desired_output[i]!=boost::none) \ { \ diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt index bb2a6a66bf1..491ce4f65de 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt @@ -79,6 +79,7 @@ if (EIGEN3_FOUND) create_single_source_cgal_program("test_corefinement_and_constraints.cpp") create_single_source_cgal_program("test_corefinement_bool_op.cpp") create_single_source_cgal_program("test_corefine.cpp") + create_single_source_cgal_program("test_does_bound_a_volume.cpp") create_single_source_cgal_program("polyhedron_clipping.cpp") if(NOT (${EIGEN3_VERSION} VERSION_LESS 3.2.0)) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/nested_cubes.off b/Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/nested_cubes.off new file mode 100644 index 00000000000..07026e414b4 --- /dev/null +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/nested_cubes.off @@ -0,0 +1,404 @@ +OFF +160 240 0 + +0.10320419669151307 0.79904278516769411 0.52098208069801333 +0.10320419669151307 0.79904278516769411 0.22098208069801331 +0.10320419669151307 0.49904278516769407 0.52098208069801333 +0.10320419669151307 0.49904278516769407 0.22098208069801331 +0.40320419669151308 0.49904278516769407 0.52098208069801333 +0.40320419669151308 0.79904278516769411 0.22098208069801331 +0.40320419669151308 0.79904278516769411 0.52098208069801333 +0.40320419669151308 0.49904278516769407 0.22098208069801331 +0.57863039970397945 0.8809532999992371 0.37629838585853576 +0.57863039970397945 0.8809532999992371 0.27629838585853578 +0.57863039970397945 0.78095329999923702 0.37629838585853576 +0.57863039970397945 0.78095329999923702 0.27629838585853578 +0.67863039970397954 0.78095329999923702 0.37629838585853576 +0.67863039970397954 0.8809532999992371 0.27629838585853578 +0.67863039970397954 0.8809532999992371 0.37629838585853576 +0.67863039970397954 0.78095329999923702 0.27629838585853578 +0.56791503429412837 0.49280046224594115 0.7018417596817017 +0.56791503429412837 0.49280046224594115 0.60184175968170162 +0.56791503429412837 0.39280046224594117 0.7018417596817017 +0.56791503429412837 0.39280046224594117 0.60184175968170162 +0.66791503429412846 0.39280046224594117 0.7018417596817017 +0.66791503429412846 0.49280046224594115 0.60184175968170162 +0.66791503429412846 0.49280046224594115 0.7018417596817017 +0.66791503429412846 0.39280046224594117 0.60184175968170162 +0 1 1 +0 1 0 +0 0 1 +0 0 0 +1 0 1 +1 1 0 +1 1 1 +1 0 0 +0.06909611225128176 0.96300069093704221 0.80988616347312925 +0.06909611225128176 0.96300069093704221 0.10988616347312929 +0.06909611225128176 0.26300069093704226 0.80988616347312925 +0.06909611225128176 0.26300069093704226 0.10988616347312929 +0.76909611225128172 0.26300069093704226 0.80988616347312925 +0.76909611225128172 0.96300069093704221 0.10988616347312929 +0.76909611225128172 0.96300069093704221 0.80988616347312925 +0.76909611225128172 0.26300069093704226 0.10988616347312929 +0.2678844451904297 0.17584145367145537 0.26026618778705596 +0.2678844451904297 0.17584145367145537 0.16026618778705598 +0.2678844451904297 0.075841453671455381 0.26026618778705596 +0.2678844451904297 0.075841453671455381 0.16026618778705598 +0.36788444519042968 0.075841453671455381 0.26026618778705596 +0.36788444519042968 0.17584145367145537 0.16026618778705598 +0.36788444519042968 0.17584145367145537 0.26026618778705596 +0.36788444519042968 0.075841453671455381 0.16026618778705598 +0.53309006690978999 0.1619653433561325 0.57721101045608525 +0.53309006690978999 0.1619653433561325 0.47721101045608522 +0.53309006690978999 0.061965343356132505 0.57721101045608525 +0.53309006690978999 0.061965343356132505 0.47721101045608522 +0.63309006690979008 0.061965343356132505 0.57721101045608525 +0.63309006690979008 0.1619653433561325 0.47721101045608522 +0.63309006690979008 0.1619653433561325 0.57721101045608525 +0.63309006690979008 0.061965343356132505 0.47721101045608522 +0.15149673521518708 0.74308388233184819 0.35533644556999205 +0.15149673521518708 0.74308388233184819 0.25533644556999208 +0.15149673521518708 0.6430838823318481 0.35533644556999205 +0.15149673521518708 0.6430838823318481 0.25533644556999208 +0.25149673521518706 0.6430838823318481 0.35533644556999205 +0.25149673521518706 0.74308388233184819 0.25533644556999208 +0.25149673521518706 0.74308388233184819 0.35533644556999205 +0.25149673521518706 0.6430838823318481 0.25533644556999208 +0.24913252592086793 0.63105385303497319 0.47872929573059081 +0.24913252592086793 0.63105385303497319 0.37872929573059083 +0.24913252592086793 0.5310538530349731 0.47872929573059081 +0.24913252592086793 0.5310538530349731 0.37872929573059083 +0.34913252592086791 0.5310538530349731 0.47872929573059081 +0.34913252592086791 0.63105385303497319 0.37872929573059083 +0.34913252592086791 0.63105385303497319 0.47872929573059081 +0.34913252592086791 0.5310538530349731 0.37872929573059083 +0.2678844451904297 0.77532844543457036 0.49450137019157409 +0.2678844451904297 0.77532844543457036 0.39450137019157411 +0.2678844451904297 0.67532844543457027 0.49450137019157409 +0.2678844451904297 0.67532844543457027 0.39450137019157411 +0.36788444519042968 0.67532844543457027 0.49450137019157409 +0.36788444519042968 0.77532844543457036 0.39450137019157411 +0.36788444519042968 0.77532844543457036 0.49450137019157409 +0.36788444519042968 0.67532844543457027 0.39450137019157411 +-0.32699817997861602 1.4168234017308903 0.47901791930198667 +-0.32699817997861602 1.4168234017308903 0.77901791930198672 +-0.32699817997861602 1.11682340173089 0.47901791930198667 +-0.32699817997861602 1.11682340173089 0.77901791930198672 +-0.62699817997861607 1.11682340173089 0.47901791930198667 +-0.62699817997861607 1.4168234017308903 0.77901791930198672 +-0.62699817997861607 1.4168234017308903 0.47901791930198667 +-0.62699817997861607 1.11682340173089 0.77901791930198672 +-0.80242438299108243 1.4987339165624332 0.62370161414146419 +-0.80242438299108243 1.4987339165624332 0.72370161414146428 +-0.80242438299108243 1.3987339165624331 0.62370161414146419 +-0.80242438299108243 1.3987339165624331 0.72370161414146428 +-0.90242438299108252 1.3987339165624331 0.62370161414146419 +-0.90242438299108252 1.4987339165624332 0.72370161414146428 +-0.90242438299108252 1.4987339165624332 0.62370161414146419 +-0.90242438299108252 1.3987339165624331 0.72370161414146428 +-0.79170901758123136 1.1105810788091373 0.2981582403182983 +-0.79170901758123136 1.1105810788091373 0.39815824031829838 +-0.79170901758123136 1.0105810788091372 0.2981582403182983 +-0.79170901758123136 1.0105810788091372 0.39815824031829838 +-0.89170901758123144 1.0105810788091372 0.2981582403182983 +-0.89170901758123144 1.1105810788091373 0.39815824031829838 +-0.89170901758123144 1.1105810788091373 0.2981582403182983 +-0.89170901758123144 1.0105810788091372 0.39815824031829838 +-0.22379398328710298 1.617780616563196 0 +-0.22379398328710298 1.617780616563196 1 +-0.22379398328710298 0.61778061656319605 0 +-0.22379398328710298 0.61778061656319605 1 +-1.223793983287103 0.61778061656319605 0 +-1.223793983287103 1.617780616563196 1 +-1.223793983287103 1.617780616563196 0 +-1.223793983287103 0.61778061656319605 1 +-0.29289009553838474 1.5807813075002382 0.19011383652687075 +-0.29289009553838474 1.5807813075002382 0.89011383652687071 +-0.29289009553838474 0.88078130750023831 0.19011383652687075 +-0.29289009553838474 0.88078130750023831 0.89011383652687071 +-0.9928900955383847 0.88078130750023831 0.19011383652687075 +-0.9928900955383847 1.5807813075002382 0.89011383652687071 +-0.9928900955383847 1.5807813075002382 0.19011383652687075 +-0.9928900955383847 0.88078130750023831 0.89011383652687071 +-0.49167842847753268 0.79362207023465148 0.73973381221294399 +-0.49167842847753274 0.79362207023465148 0.83973381221294408 +-0.49167842847753268 0.69362207023465139 0.73973381221294399 +-0.49167842847753274 0.69362207023465139 0.83973381221294408 +-0.59167842847753271 0.69362207023465139 0.73973381221294399 +-0.59167842847753271 0.79362207023465148 0.83973381221294408 +-0.59167842847753271 0.79362207023465148 0.73973381221294399 +-0.59167842847753271 0.69362207023465139 0.83973381221294408 +-0.75688405019689298 0.7797459599193286 0.42278898954391475 +-0.75688405019689298 0.7797459599193286 0.52278898954391473 +-0.75688405019689298 0.67974595991932851 0.42278898954391475 +-0.75688405019689298 0.67974595991932851 0.52278898954391473 +-0.85688405019689307 0.67974595991932851 0.42278898954391475 +-0.85688405019689307 0.7797459599193286 0.52278898954391473 +-0.85688405019689307 0.7797459599193286 0.42278898954391475 +-0.85688405019689307 0.67974595991932851 0.52278898954391473 +-0.37529071850229007 1.3608644988950442 0.644663554430008 +-0.37529071850229007 1.3608644988950442 0.74466355443000798 +-0.37529071850229007 1.2608644988950442 0.644663554430008 +-0.37529071850229007 1.2608644988950442 0.74466355443000798 +-0.47529071850229004 1.2608644988950442 0.64466355443000789 +-0.47529071850229004 1.3608644988950442 0.74466355443000798 +-0.47529071850229004 1.3608644988950442 0.64466355443000789 +-0.47529071850229004 1.2608644988950442 0.74466355443000798 +-0.47292650920797091 1.2488344695981692 0.52127070426940925 +-0.47292650920797091 1.2488344695981692 0.62127070426940922 +-0.47292650920797091 1.1488344695981692 0.52127070426940925 +-0.47292650920797091 1.1488344695981692 0.62127070426940922 +-0.57292650920797095 1.1488344695981692 0.52127070426940925 +-0.57292650920797095 1.2488344695981692 0.62127070426940922 +-0.57292650920797095 1.2488344695981692 0.52127070426940925 +-0.57292650920797095 1.1488344695981692 0.62127070426940922 +-0.49167842847753268 1.3931090619977664 0.50549862980842597 +-0.49167842847753268 1.3931090619977664 0.60549862980842595 +-0.49167842847753268 1.2931090619977663 0.50549862980842597 +-0.49167842847753268 1.2931090619977663 0.60549862980842595 +-0.59167842847753271 1.2931090619977663 0.50549862980842597 +-0.59167842847753271 1.3931090619977664 0.60549862980842595 +-0.59167842847753271 1.3931090619977664 0.50549862980842597 +-0.59167842847753271 1.2931090619977663 0.60549862980842595 +3 0 1 2 +3 2 1 3 +3 4 5 6 +3 4 7 5 +3 4 3 7 +3 4 2 3 +3 6 1 0 +3 6 5 1 +3 2 6 0 +3 2 4 6 +3 3 1 5 +3 3 5 7 +3 8 9 10 +3 10 9 11 +3 12 13 14 +3 12 15 13 +3 12 11 15 +3 12 10 11 +3 14 9 8 +3 14 13 9 +3 10 14 8 +3 10 12 14 +3 11 9 13 +3 11 13 15 +3 16 17 18 +3 18 17 19 +3 20 21 22 +3 20 23 21 +3 20 19 23 +3 20 18 19 +3 22 17 16 +3 22 21 17 +3 18 22 16 +3 18 20 22 +3 19 17 21 +3 19 21 23 +3 24 25 26 +3 26 25 27 +3 28 29 30 +3 28 31 29 +3 28 27 31 +3 28 26 27 +3 30 25 24 +3 30 29 25 +3 26 30 24 +3 26 28 30 +3 27 25 29 +3 27 29 31 +3 34 33 32 +3 35 33 34 +3 38 37 36 +3 37 39 36 +3 39 35 36 +3 35 34 36 +3 32 33 38 +3 33 37 38 +3 32 38 34 +3 38 36 34 +3 37 33 35 +3 39 37 35 +3 42 41 40 +3 43 41 42 +3 46 45 44 +3 45 47 44 +3 47 43 44 +3 43 42 44 +3 40 41 46 +3 41 45 46 +3 40 46 42 +3 46 44 42 +3 45 41 43 +3 47 45 43 +3 50 49 48 +3 51 49 50 +3 54 53 52 +3 53 55 52 +3 55 51 52 +3 51 50 52 +3 48 49 54 +3 49 53 54 +3 48 54 50 +3 54 52 50 +3 53 49 51 +3 55 53 51 +3 58 57 56 +3 59 57 58 +3 62 61 60 +3 61 63 60 +3 63 59 60 +3 59 58 60 +3 56 57 62 +3 57 61 62 +3 56 62 58 +3 62 60 58 +3 61 57 59 +3 63 61 59 +3 66 65 64 +3 67 65 66 +3 70 69 68 +3 69 71 68 +3 71 67 68 +3 67 66 68 +3 64 65 70 +3 65 69 70 +3 64 70 66 +3 70 68 66 +3 69 65 67 +3 71 69 67 +3 74 73 72 +3 75 73 74 +3 78 77 76 +3 77 79 76 +3 79 75 76 +3 75 74 76 +3 72 73 78 +3 73 77 78 +3 72 78 74 +3 78 76 74 +3 77 73 75 +3 79 77 75 +3 80 81 82 +3 82 81 83 +3 84 85 86 +3 84 87 85 +3 84 83 87 +3 84 82 83 +3 86 81 80 +3 86 85 81 +3 82 86 80 +3 82 84 86 +3 83 81 85 +3 83 85 87 +3 88 89 90 +3 90 89 91 +3 92 93 94 +3 92 95 93 +3 92 91 95 +3 92 90 91 +3 94 89 88 +3 94 93 89 +3 90 94 88 +3 90 92 94 +3 91 89 93 +3 91 93 95 +3 96 97 98 +3 98 97 99 +3 100 101 102 +3 100 103 101 +3 100 99 103 +3 100 98 99 +3 102 97 96 +3 102 101 97 +3 98 102 96 +3 98 100 102 +3 99 97 101 +3 99 101 103 +3 104 105 106 +3 106 105 107 +3 108 109 110 +3 108 111 109 +3 108 107 111 +3 108 106 107 +3 110 105 104 +3 110 109 105 +3 106 110 104 +3 106 108 110 +3 107 105 109 +3 107 109 111 +3 114 113 112 +3 115 113 114 +3 118 117 116 +3 117 119 116 +3 119 115 116 +3 115 114 116 +3 112 113 118 +3 113 117 118 +3 112 118 114 +3 118 116 114 +3 117 113 115 +3 119 117 115 +3 122 121 120 +3 123 121 122 +3 126 125 124 +3 125 127 124 +3 127 123 124 +3 123 122 124 +3 120 121 126 +3 121 125 126 +3 120 126 122 +3 126 124 122 +3 125 121 123 +3 127 125 123 +3 130 129 128 +3 131 129 130 +3 134 133 132 +3 133 135 132 +3 135 131 132 +3 131 130 132 +3 128 129 134 +3 129 133 134 +3 128 134 130 +3 134 132 130 +3 133 129 131 +3 135 133 131 +3 138 137 136 +3 139 137 138 +3 142 141 140 +3 141 143 140 +3 143 139 140 +3 139 138 140 +3 136 137 142 +3 137 141 142 +3 136 142 138 +3 142 140 138 +3 141 137 139 +3 143 141 139 +3 146 145 144 +3 147 145 146 +3 150 149 148 +3 149 151 148 +3 151 147 148 +3 147 146 148 +3 144 145 150 +3 145 149 150 +3 144 150 146 +3 150 148 146 +3 149 145 147 +3 151 149 147 +3 154 153 152 +3 155 153 154 +3 158 157 156 +3 157 159 156 +3 159 155 156 +3 155 154 156 +3 152 153 158 +3 153 157 158 +3 152 158 154 +3 158 156 154 +3 157 153 155 +3 159 157 155 + diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/nested_cubes_invalid_volume.off b/Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/nested_cubes_invalid_volume.off new file mode 100644 index 00000000000..e860b794a1f --- /dev/null +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/nested_cubes_invalid_volume.off @@ -0,0 +1,404 @@ +OFF +160 240 0 + +0.10320419669151307 0.49904278516769407 0.22098208069801331 +0.40320419669151308 0.79904278516769411 0.22098208069801331 +0.40320419669151308 0.49904278516769407 0.22098208069801331 +0.10320419669151307 0.79904278516769411 0.22098208069801331 +0.10320419669151307 0.49904278516769407 0.52098208069801333 +0.40320419669151308 0.49904278516769407 0.52098208069801333 +0.40320419669151308 0.79904278516769411 0.52098208069801333 +0.10320419669151307 0.79904278516769411 0.52098208069801333 +0.57863039970397945 0.78095329999923702 0.27629838585853578 +0.67863039970397954 0.8809532999992371 0.27629838585853578 +0.67863039970397954 0.78095329999923702 0.27629838585853578 +0.57863039970397945 0.8809532999992371 0.27629838585853578 +0.57863039970397945 0.78095329999923702 0.37629838585853576 +0.67863039970397954 0.78095329999923702 0.37629838585853576 +0.67863039970397954 0.8809532999992371 0.37629838585853576 +0.57863039970397945 0.8809532999992371 0.37629838585853576 +0.56791503429412837 0.39280046224594117 0.60184175968170162 +0.66791503429412846 0.49280046224594115 0.60184175968170162 +0.66791503429412846 0.39280046224594117 0.60184175968170162 +0.56791503429412837 0.49280046224594115 0.60184175968170162 +0.56791503429412837 0.39280046224594117 0.7018417596817017 +0.66791503429412846 0.39280046224594117 0.7018417596817017 +0.66791503429412846 0.49280046224594115 0.7018417596817017 +0.56791503429412837 0.49280046224594115 0.7018417596817017 +0 0 0 +1 1 0 +1 0 0 +0 1 0 +0 0 1 +1 0 1 +1 1 1 +0 1 1 +0.76909611225128172 0.26300069093704226 0.10988616347312929 +0.76909611225128172 0.96300069093704221 0.10988616347312929 +0.06909611225128176 0.26300069093704226 0.10988616347312929 +0.06909611225128176 0.96300069093704221 0.10988616347312929 +0.76909611225128172 0.96300069093704221 0.80988616347312925 +0.76909611225128172 0.26300069093704226 0.80988616347312925 +0.06909611225128176 0.26300069093704226 0.80988616347312925 +0.06909611225128176 0.96300069093704221 0.80988616347312925 +0.36788444519042968 0.075841453671455381 0.16026618778705598 +0.36788444519042968 0.17584145367145537 0.16026618778705598 +0.2678844451904297 0.075841453671455381 0.16026618778705598 +0.2678844451904297 0.17584145367145537 0.16026618778705598 +0.36788444519042968 0.17584145367145537 0.26026618778705596 +0.36788444519042968 0.075841453671455381 0.26026618778705596 +0.2678844451904297 0.075841453671455381 0.26026618778705596 +0.2678844451904297 0.17584145367145537 0.26026618778705596 +0.63309006690979008 0.061965343356132505 0.47721101045608522 +0.63309006690979008 0.1619653433561325 0.47721101045608522 +0.53309006690978999 0.061965343356132505 0.47721101045608522 +0.53309006690978999 0.1619653433561325 0.47721101045608522 +0.63309006690979008 0.1619653433561325 0.57721101045608525 +0.63309006690979008 0.061965343356132505 0.57721101045608525 +0.53309006690978999 0.061965343356132505 0.57721101045608525 +0.53309006690978999 0.1619653433561325 0.57721101045608525 +0.25149673521518706 0.6430838823318481 0.25533644556999208 +0.25149673521518706 0.74308388233184819 0.25533644556999208 +0.15149673521518708 0.6430838823318481 0.25533644556999208 +0.15149673521518708 0.74308388233184819 0.25533644556999208 +0.25149673521518706 0.74308388233184819 0.35533644556999205 +0.25149673521518706 0.6430838823318481 0.35533644556999205 +0.15149673521518708 0.6430838823318481 0.35533644556999205 +0.15149673521518708 0.74308388233184819 0.35533644556999205 +0.34913252592086791 0.5310538530349731 0.37872929573059083 +0.34913252592086791 0.63105385303497319 0.37872929573059083 +0.24913252592086793 0.5310538530349731 0.37872929573059083 +0.24913252592086793 0.63105385303497319 0.37872929573059083 +0.34913252592086791 0.63105385303497319 0.47872929573059081 +0.34913252592086791 0.5310538530349731 0.47872929573059081 +0.24913252592086793 0.5310538530349731 0.47872929573059081 +0.24913252592086793 0.63105385303497319 0.47872929573059081 +0.36788444519042968 0.67532844543457027 0.39450137019157411 +0.36788444519042968 0.77532844543457036 0.39450137019157411 +0.2678844451904297 0.67532844543457027 0.39450137019157411 +0.2678844451904297 0.77532844543457036 0.39450137019157411 +0.36788444519042968 0.77532844543457036 0.49450137019157409 +0.36788444519042968 0.67532844543457027 0.49450137019157409 +0.2678844451904297 0.67532844543457027 0.49450137019157409 +0.2678844451904297 0.77532844543457036 0.49450137019157409 +-0.32699817997861602 1.11682340173089 0.77901791930198672 +-0.62699817997861607 1.4168234017308903 0.77901791930198672 +-0.62699817997861607 1.11682340173089 0.77901791930198672 +-0.32699817997861602 1.4168234017308903 0.77901791930198672 +-0.32699817997861602 1.11682340173089 0.47901791930198667 +-0.62699817997861607 1.11682340173089 0.47901791930198667 +-0.62699817997861607 1.4168234017308903 0.47901791930198667 +-0.32699817997861602 1.4168234017308903 0.47901791930198667 +-0.80242438299108243 1.3987339165624331 0.72370161414146428 +-0.90242438299108252 1.4987339165624332 0.72370161414146428 +-0.90242438299108252 1.3987339165624331 0.72370161414146428 +-0.80242438299108243 1.4987339165624332 0.72370161414146428 +-0.80242438299108243 1.3987339165624331 0.62370161414146419 +-0.90242438299108252 1.3987339165624331 0.62370161414146419 +-0.90242438299108252 1.4987339165624332 0.62370161414146419 +-0.80242438299108243 1.4987339165624332 0.62370161414146419 +-0.79170901758123136 1.0105810788091372 0.39815824031829838 +-0.89170901758123144 1.1105810788091373 0.39815824031829838 +-0.89170901758123144 1.0105810788091372 0.39815824031829838 +-0.79170901758123136 1.1105810788091373 0.39815824031829838 +-0.79170901758123136 1.0105810788091372 0.2981582403182983 +-0.89170901758123144 1.0105810788091372 0.2981582403182983 +-0.89170901758123144 1.1105810788091373 0.2981582403182983 +-0.79170901758123136 1.1105810788091373 0.2981582403182983 +-0.22379398328710298 0.61778061656319605 1 +-1.223793983287103 1.617780616563196 1 +-1.223793983287103 0.61778061656319605 1 +-0.22379398328710298 1.617780616563196 1 +-0.22379398328710298 0.61778061656319605 0 +-1.223793983287103 0.61778061656319605 0 +-1.223793983287103 1.617780616563196 0 +-0.22379398328710298 1.617780616563196 0 +-0.9928900955383847 0.88078130750023831 0.89011383652687071 +-0.9928900955383847 1.5807813075002382 0.89011383652687071 +-0.29289009553838474 0.88078130750023831 0.89011383652687071 +-0.29289009553838474 1.5807813075002382 0.89011383652687071 +-0.9928900955383847 1.5807813075002382 0.19011383652687075 +-0.9928900955383847 0.88078130750023831 0.19011383652687075 +-0.29289009553838474 0.88078130750023831 0.19011383652687075 +-0.29289009553838474 1.5807813075002382 0.19011383652687075 +-0.59167842847753271 0.69362207023465139 0.83973381221294408 +-0.59167842847753271 0.79362207023465148 0.83973381221294408 +-0.49167842847753274 0.69362207023465139 0.83973381221294408 +-0.49167842847753274 0.79362207023465148 0.83973381221294408 +-0.59167842847753271 0.79362207023465148 0.73973381221294399 +-0.59167842847753271 0.69362207023465139 0.73973381221294399 +-0.49167842847753268 0.69362207023465139 0.73973381221294399 +-0.49167842847753268 0.79362207023465148 0.73973381221294399 +-0.85688405019689307 0.67974595991932851 0.52278898954391473 +-0.85688405019689307 0.7797459599193286 0.52278898954391473 +-0.75688405019689298 0.67974595991932851 0.52278898954391473 +-0.75688405019689298 0.7797459599193286 0.52278898954391473 +-0.85688405019689307 0.7797459599193286 0.42278898954391475 +-0.85688405019689307 0.67974595991932851 0.42278898954391475 +-0.75688405019689298 0.67974595991932851 0.42278898954391475 +-0.75688405019689298 0.7797459599193286 0.42278898954391475 +-0.47529071850229004 1.2608644988950442 0.74466355443000798 +-0.47529071850229004 1.3608644988950442 0.74466355443000798 +-0.37529071850229007 1.2608644988950442 0.74466355443000798 +-0.37529071850229007 1.3608644988950442 0.74466355443000798 +-0.47529071850229004 1.3608644988950442 0.64466355443000789 +-0.47529071850229004 1.2608644988950442 0.64466355443000789 +-0.37529071850229007 1.2608644988950442 0.644663554430008 +-0.37529071850229007 1.3608644988950442 0.644663554430008 +-0.57292650920797095 1.1488344695981692 0.62127070426940922 +-0.57292650920797095 1.2488344695981692 0.62127070426940922 +-0.47292650920797091 1.1488344695981692 0.62127070426940922 +-0.47292650920797091 1.2488344695981692 0.62127070426940922 +-0.57292650920797095 1.2488344695981692 0.52127070426940925 +-0.57292650920797095 1.1488344695981692 0.52127070426940925 +-0.47292650920797091 1.1488344695981692 0.52127070426940925 +-0.47292650920797091 1.2488344695981692 0.52127070426940925 +-0.59167842847753271 1.2931090619977663 0.60549862980842595 +-0.59167842847753271 1.3931090619977664 0.60549862980842595 +-0.49167842847753268 1.2931090619977663 0.60549862980842595 +-0.49167842847753268 1.3931090619977664 0.60549862980842595 +-0.59167842847753271 1.3931090619977664 0.50549862980842597 +-0.59167842847753271 1.2931090619977663 0.50549862980842597 +-0.49167842847753268 1.2931090619977663 0.50549862980842597 +-0.49167842847753268 1.3931090619977664 0.50549862980842597 +3 0 1 2 +3 0 3 1 +3 4 5 6 +3 4 6 7 +3 6 1 3 +3 6 3 7 +3 5 4 0 +3 5 0 2 +3 5 2 1 +3 5 1 6 +3 4 3 0 +3 7 3 4 +3 8 9 10 +3 8 11 9 +3 12 13 14 +3 12 14 15 +3 14 9 11 +3 14 11 15 +3 13 12 8 +3 13 8 10 +3 13 10 9 +3 13 9 14 +3 12 11 8 +3 15 11 12 +3 16 17 18 +3 16 19 17 +3 20 21 22 +3 20 22 23 +3 22 17 19 +3 22 19 23 +3 21 20 16 +3 21 16 18 +3 21 18 17 +3 21 17 22 +3 20 19 16 +3 23 19 20 +3 24 25 26 +3 24 27 25 +3 28 29 30 +3 28 30 31 +3 30 25 27 +3 30 27 31 +3 29 28 24 +3 29 24 26 +3 29 26 25 +3 29 25 30 +3 28 27 24 +3 31 27 28 +3 32 33 34 +3 33 35 34 +3 36 37 38 +3 39 36 38 +3 35 33 36 +3 39 35 36 +3 34 38 37 +3 32 34 37 +3 33 32 37 +3 36 33 37 +3 34 35 38 +3 38 35 39 +3 40 41 42 +3 41 43 42 +3 44 45 46 +3 47 44 46 +3 43 41 44 +3 47 43 44 +3 42 46 45 +3 40 42 45 +3 41 40 45 +3 44 41 45 +3 42 43 46 +3 46 43 47 +3 48 49 50 +3 49 51 50 +3 52 53 54 +3 55 52 54 +3 51 49 52 +3 55 51 52 +3 50 54 53 +3 48 50 53 +3 49 48 53 +3 52 49 53 +3 50 51 54 +3 54 51 55 +3 56 57 58 +3 57 59 58 +3 60 61 62 +3 63 60 62 +3 59 57 60 +3 63 59 60 +3 58 62 61 +3 56 58 61 +3 57 56 61 +3 60 57 61 +3 58 59 62 +3 62 59 63 +3 64 65 66 +3 65 67 66 +3 68 69 70 +3 71 68 70 +3 67 65 68 +3 71 67 68 +3 66 70 69 +3 64 66 69 +3 65 64 69 +3 68 65 69 +3 66 67 70 +3 70 67 71 +3 74 73 72 +3 74 75 73 +3 78 77 76 +3 78 76 79 +3 76 73 75 +3 76 75 79 +3 77 78 74 +3 77 74 72 +3 77 72 73 +3 77 73 76 +3 78 75 74 +3 79 75 78 +3 80 81 82 +3 80 83 81 +3 84 85 86 +3 84 86 87 +3 86 81 83 +3 86 83 87 +3 85 84 80 +3 85 80 82 +3 85 82 81 +3 85 81 86 +3 84 83 80 +3 87 83 84 +3 88 89 90 +3 88 91 89 +3 92 93 94 +3 92 94 95 +3 94 89 91 +3 94 91 95 +3 93 92 88 +3 93 88 90 +3 93 90 89 +3 93 89 94 +3 92 91 88 +3 95 91 92 +3 96 97 98 +3 96 99 97 +3 100 101 102 +3 100 102 103 +3 102 97 99 +3 102 99 103 +3 101 100 96 +3 101 96 98 +3 101 98 97 +3 101 97 102 +3 100 99 96 +3 103 99 100 +3 104 105 106 +3 104 107 105 +3 108 109 110 +3 108 110 111 +3 110 105 107 +3 110 107 111 +3 109 108 104 +3 109 104 106 +3 109 106 105 +3 109 105 110 +3 108 107 104 +3 111 107 108 +3 112 113 114 +3 113 115 114 +3 116 117 118 +3 119 116 118 +3 115 113 116 +3 119 115 116 +3 114 118 117 +3 112 114 117 +3 113 112 117 +3 116 113 117 +3 114 115 118 +3 118 115 119 +3 120 121 122 +3 121 123 122 +3 124 125 126 +3 127 124 126 +3 123 121 124 +3 127 123 124 +3 122 126 125 +3 120 122 125 +3 121 120 125 +3 124 121 125 +3 122 123 126 +3 126 123 127 +3 128 129 130 +3 129 131 130 +3 132 133 134 +3 135 132 134 +3 131 129 132 +3 135 131 132 +3 130 134 133 +3 128 130 133 +3 129 128 133 +3 132 129 133 +3 130 131 134 +3 134 131 135 +3 136 137 138 +3 137 139 138 +3 140 141 142 +3 143 140 142 +3 139 137 140 +3 143 139 140 +3 138 142 141 +3 136 138 141 +3 137 136 141 +3 140 137 141 +3 138 139 142 +3 142 139 143 +3 144 145 146 +3 145 147 146 +3 148 149 150 +3 151 148 150 +3 147 145 148 +3 151 147 148 +3 146 150 149 +3 144 146 149 +3 145 144 149 +3 148 145 149 +3 146 147 150 +3 150 147 151 +3 152 153 154 +3 153 155 154 +3 156 157 158 +3 159 156 158 +3 155 153 156 +3 159 155 156 +3 154 158 157 +3 152 154 157 +3 153 152 157 +3 156 153 157 +3 154 155 158 +3 158 155 159 + diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_does_bound_a_volume.cmd b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_does_bound_a_volume.cmd new file mode 100644 index 00000000000..731284364cc --- /dev/null +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_does_bound_a_volume.cmd @@ -0,0 +1,2 @@ +data-coref/nested_cubes.off 1 +data-coref/nested_cubes_invalid_volume.off 0 diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_does_bound_a_volume.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_does_bound_a_volume.cpp new file mode 100644 index 00000000000..262468b48a4 --- /dev/null +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_does_bound_a_volume.cpp @@ -0,0 +1,35 @@ +#include +#include +#include + +#include +#include + +typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; +typedef CGAL::Surface_mesh Surface_mesh; + +int main(int argc, char** argv) +{ + if (argc==1) + { + std::cerr << "Nothing tested\n"; + return 1; + } + + for(int i=0;i<(argc-1)/2; ++i) + { + std::cout << "Handling " << argv[2*i+1] + << " expected res is " << argv[2*(i+1)] << "\n"; + + std::ifstream input(argv[2*i+1]); + assert(input); + Surface_mesh sm; + input >> sm; + bool res = atoi(argv[2*(i+1)]); + assert(!"Result is not as expected (input orientation)" || + CGAL::Polygon_mesh_processing::does_bound_a_volume(sm)==res); + CGAL::Polygon_mesh_processing::reverse_face_orientations(sm); + assert(!"Result is not as expected (reversed orientation)" || + CGAL::Polygon_mesh_processing::does_bound_a_volume(sm)==res); + } +}