diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h index 36e76aad9b0..e0457c0f3eb 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h @@ -1086,7 +1086,11 @@ volume_connected_components(const TriangleMesh& tm, } } } - if (used_as_a_predicate) return 1; + if (used_as_a_predicate) + { + internal::copy_orientation_bitset(is_cc_outward_oriented, parameters::get_parameter(np, internal_np::is_cc_outward_oriented)); + return 1; + } // merge nested_cc_per_cc and nested_cc_per_cc_shared // (done after the volume creation to assign a CC to a unique volume) @@ -1158,6 +1162,14 @@ volume_connected_components(const TriangleMesh& tm, * \cgalParamBegin{face_index_map} * a property map containing the index of each face of `tm`. * \cgalParamEnd + * \cgalParamBegin{is_cc_outward_oriented} + * a `reference_wrapper` (either from `boost` or the standard library) containing + * a reference to an object of type `std::vector`. + * The size of the vector is exactly the number of connected components. + * For each connected component identified using its id `ccid`, the output of `is_outward_oriented` + * called on the submesh corresponding to this connected component + * is the value at the position `ccid` in the parameter vector. + * \cgalParamEnd * \cgalNamedParamsEnd * * \see `CGAL::Polygon_mesh_processing::orient_to_bound_a_volume()` diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_orient_cc.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_orient_cc.cpp index 4e62117e324..d85fd9122d9 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_orient_cc.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_orient_cc.cpp @@ -2,15 +2,17 @@ #include #include #include - +#include #include #include +//#define TEST_ALL_ORIENTATIONS 1 namespace PMP = CGAL::Polygon_mesh_processing; typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef CGAL::Surface_mesh SMesh; + template bool test_orientation(TriangleMesh& tm, bool is_positive, const NamedParameters& np) { @@ -24,7 +26,7 @@ bool test_orientation(TriangleMesh& tm, bool is_positive, const NamedParameters& using CGAL::parameters::choose_parameter; using CGAL::parameters::get_parameter; - + Vpm vpm = choose_parameter(get_parameter(np, CGAL::internal_np::vertex_point), CGAL::get_const_property_map(boost::vertex_point, tm)); @@ -145,5 +147,67 @@ int main() return 1; } +#ifdef TEST_ALL_ORIENTATIONS //takes around 2 hours + std::cout<<"testing ALL orientations..."< fccmap = + sm1.add_property_map("f:CC").first; + std::vector is_cc_o_or; + PMP::orient_to_bound_a_volume(sm1); + PMP::does_bound_a_volume(sm1, + CGAL::parameters::is_cc_outward_oriented(std::ref(is_cc_o_or))); + + std::size_t nb_ccs = PMP::connected_components(sm1, fccmap); + + std::vector< std::vector > faces_per_cc(nb_ccs); + for(SMesh::Face_index fd : faces(sm1)) + { + std::size_t cc_id = get(fccmap, fd); + faces_per_cc[cc_id].push_back(fd); + } + double total_length = 1<<20; + CGAL::Timer timer; + timer.start(); + for(std::size_t i=1; i>=1; + ++cc; + } + std::vector is_loop_o_o; + PMP::orient_to_bound_a_volume(loop_m); + + if( !PMP::does_bound_a_volume(loop_m, + CGAL::parameters::is_cc_outward_oriented(std::ref(is_loop_o_o))) ) + { + std::cerr << "ERROR for test7\n"; + return 1; + } + if(is_loop_o_o.empty()) + return 1; + if(is_loop_o_o!= is_cc_o_or) + { + std::cerr << "ERROR for test7\n"; + return 1; + } + if(i%1000 == 0){ + timer.stop(); + double remaining = ((1<<20) -i)* timer.time()/1000.0 ; + std::cout<