diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map.h b/Combinatorial_map/include/CGAL/Combinatorial_map.h index fd68a82745c..3dd3f5f1792 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map.h @@ -3599,11 +3599,15 @@ namespace CGAL { * @param dh1 initial dart for this map * @param map2 the second combinatorial map * @param dh2 initial dart for map2 - * @param testAttributes Boolean to test the equality of attributes and - * dart info (true) or not (false) + * @param testDartInfo Boolean to test the equality of dart info (true) + * or not (false) + * @param testAttributes Boolean to test the equality of attributes (true) + * or not (false) + * @param testPoint Boolean to test the equality of points (true) + * or not (false) (used for LCC) * @return true iff the cc of map is isomorphic to the cc of map2 starting - * from dh1 and dh2; by testing the equality of attributes if - * testAttributes is true + * from dh1 and dh2; by testing the equality of dartinfo and/or + * attributes and/or points. */ template @@ -3612,7 +3616,9 @@ namespace CGAL { & map2, typename Combinatorial_map_base ::Dart_const_handle dh2, - bool testAttributes=true) const + bool testDartInfo=true, + bool testAttributes=true, + bool testPoint=true) const { typedef Combinatorial_map_base Map2; @@ -3661,19 +3667,19 @@ namespace CGAL { mark(current, m1); map2.mark(other, m2); - if (testAttributes) - { - // We first test info of darts + // We first test info of darts #if !defined(CGAL_CMAP_DART_DEPRECATED) || defined(CGAL_NO_DEPRECATED_CODE) - if (match) - match=internal::Test_is_same_dart_info_functor:: - run(*this, map2, current, other); + if (match && testDartInfo) + match=internal::Test_is_same_dart_info_functor:: + run(*this, map2, current, other); #endif - // We need to test in both direction because - // Foreach_enabled_attributes only test non void attributes - // of Self. Functor Test_is_same_attribute_functor will modify - // the value of match to false if attributes do not match + // We need to test in both direction because + // Foreach_enabled_attributes only test non void attributes + // of Self. Functor Test_is_same_attribute_functor will modify + // the value of match to false if attributes do not match + if (testAttributes) + { if (match) Helper::template Foreach_enabled_attributes < internal::Test_is_same_attribute_functor >:: @@ -3684,6 +3690,14 @@ namespace CGAL { run(map2, *this, other, current, match); } + if (match && testPoint) + { + // Only point of 0-attribute are tested. TODO test point of all + // attributes ? + match=internal::Test_is_same_attribute_point_functor + ::run(*this, map2, current, other); + } + // We test if the injection is valid with its neighboors. // We go out as soon as it is not satisfied. for (i = 0; match && i <= dimension; ++i) @@ -3793,8 +3807,12 @@ namespace CGAL { /** Test if this cmap is isomorphic to map2. * @pre cmap is connected. * @param map2 the second combinatorial map + * @param testDartInfo Boolean to test the equality of dart info (true) + * or not (false) * @param testAttributes Boolean to test the equality of attributes (true) * or not (false) + * @param testPoint Boolean to test the equality of points (true) + * or not (false) (used for LCC) * @return true iff this map is isomorphic to map2, testing the equality * of attributes if testAttributes is true */ @@ -3802,17 +3820,18 @@ namespace CGAL { class Storage2> bool is_isomorphic_to(const Combinatorial_map_base & map2, - bool testAttributes=true) const + bool testDartInfo=true, + bool testAttributes=true, + bool testPoint=true) const { - // if ( dimension!=map2.dimension ) return false; - Dart_const_handle d1=darts().begin(); for (typename Combinatorial_map_base:: Dart_range::const_iterator it(map2.darts().begin()), itend(map2.darts().end()); it!=itend; ++it) { - if (are_cc_isomorphic(d1, map2, it, testAttributes)) + if (are_cc_isomorphic(d1, map2, it, testDartInfo, testAttributes, + testPoint)) { return true; } diff --git a/Combinatorial_map/include/CGAL/internal/Combinatorial_map_internal_functors.h b/Combinatorial_map/include/CGAL/internal/Combinatorial_map_internal_functors.h index bcf7db60347..a4ad551e93a 100644 --- a/Combinatorial_map/include/CGAL/internal/Combinatorial_map_internal_functors.h +++ b/Combinatorial_map/include/CGAL/internal/Combinatorial_map_internal_functors.h @@ -68,7 +68,10 @@ * darts have the same info. * * internal::Test_is_same_attribute_functor to test if two - * i-attributes of two darts are isomorphic. + * i-attributes of two darts are isomorphic (ie they have the same info). + * + * inernal::Test_is_same_attribute_point_functor to test if + * the point of two i-attributes are equal. * * internal::Reverse_orientation_of_map_functor to reverse the * orientation of a whole combinatorial map @@ -661,9 +664,12 @@ struct Is_same_point }; // Case of two non void type, with two points -template -struct Is_same_attribute_point_functor +template::type>::value, + bool Withpoint2=Is_attribute_has_point + ::type>::value> +struct Test_is_same_attribute_point_functor { static bool run(const Map1& m1, const Map2& m2, typename Map1::Dart_const_handle dh1, @@ -679,16 +685,16 @@ struct Is_same_attribute_point_functor return false; return - Is_same_point::run + Is_same_point::type, + typename Map2::template Attribute_type::type>::run (m1.template get_attribute(m1.template attribute(dh1)), m2.template get_attribute(m2.template attribute(dh2))); } }; // Case of two non void type, first without point -template -struct Is_same_attribute_point_functor +template +struct Test_is_same_attribute_point_functor { static bool run(const Map1&, const Map2&, typename Map1::Dart_const_handle, @@ -697,9 +703,8 @@ struct Is_same_attribute_point_functor }; // Case of two non void type, second without point -template -struct Is_same_attribute_point_functor +template +struct Test_is_same_attribute_point_functor { static bool run(const Map1&, const Map2&, typename Map1::Dart_const_handle, @@ -708,9 +713,8 @@ struct Is_same_attribute_point_functor }; // Case of two non void type, both without point -template -struct Is_same_attribute_point_functor +template +struct Test_is_same_attribute_point_functor { static bool run(const Map1&, const Map2&, typename Map1::Dart_const_handle, @@ -733,17 +737,6 @@ struct Test_is_same_attribute_functor res = Is_same_attribute_info_functor ::run(m1, m2, dh1, dh2); } - if (res) - { - res = Is_same_attribute_point_functor - ::type, - typename Map2::template Attribute_type::type, - Is_attribute_has_point::type>::value, - Is_attribute_has_point::type>::value, i>::run(m1, m2, dh1, dh2); - } } }; // **************************************************************************** diff --git a/Generalized_map/include/CGAL/Generalized_map.h b/Generalized_map/include/CGAL/Generalized_map.h index 93597753867..2b56b4a3004 100644 --- a/Generalized_map/include/CGAL/Generalized_map.h +++ b/Generalized_map/include/CGAL/Generalized_map.h @@ -2779,11 +2779,15 @@ namespace CGAL { * @param dh1 initial dart for this map * @param map2 the second generalized map * @param dh2 initial dart for map2 + * @param testDartInfo Boolean to test the equality of dart info (true) + * or not (false) * @param testAttributes Boolean to test the equality of attributes (true) * or not (false) + * @param testPoint Boolean to test the equality of points (true) + * or not (false) (used for LCC) * @return true iff the cc of map is isomorphic to the cc of map2 starting - * from dh1 and dh2; by testing the equality of attributes if - * testAttributes is true + * from dh1 and dh2; by testing the equality of dartinfo and/or + * attributes and/or points. */ template @@ -2792,7 +2796,9 @@ namespace CGAL { & map2, typename Generalized_map_base ::Dart_const_handle dh2, - bool testAttributes=true) const + bool testDartInfo=true, + bool testAttributes=true, + bool testPoint=true) const { typedef Generalized_map_base Map2; @@ -2841,17 +2847,17 @@ namespace CGAL { mark(current, m1); map2.mark(other, m2); + // We first test info of darts + if (match && testDartInfo) + match=internal::Test_is_same_dart_info_functor:: + run(*this, map2, current, other); + + // We need to test in both direction because + // Foreach_enabled_attributes only test non void attributes + // of Self. Functor Test_is_same_attribute_functor will modify + // the value of match to false if attributes do not match if (testAttributes) { - // We first test info of darts - if (match) - match=internal::Test_is_same_dart_info_functor:: - run(*this, map2, current, other); - - // We need to test in both direction because - // Foreach_enabled_attributes only test non void attributes - // of Self. Functor Test_is_same_attribute_functor will modify - // the value of match to false if attributes do not match if (match) Helper::template Foreach_enabled_attributes < internal::Test_is_same_attribute_functor >:: @@ -2862,6 +2868,14 @@ namespace CGAL { run(map2, *this, other, current, match); } + if (match && testPoint) + { + // Only point of 0-attribute are tested. TODO test point of all + // attributes ? + match=internal::Test_is_same_attribute_point_functor + ::run(*this, map2, current, other); + } + // We test if the injection is valid with its neighboors. // We go out as soon as it is not satisfied. for (i = 0; match && i <= dimension; ++i) @@ -2970,8 +2984,12 @@ namespace CGAL { /** Test if this gmap is isomorphic to map2. * @pre gmap is connected. * @param map2 the second generalized map + * @param testDartInfo Boolean to test the equality of dart info (true) + * or not (false) * @param testAttributes Boolean to test the equality of attributes (true) * or not (false) + * @param testPoint Boolean to test the equality of points (true) + * or not (false) (used for LCC) * @return true iff this map is isomorphic to map2, testing the equality * of attributes if testAttributes is true */ @@ -2979,7 +2997,9 @@ namespace CGAL { class Storage2> bool is_isomorphic_to(const Generalized_map_base & map2, - bool testAttributes=true) + bool testDartInfo=true, + bool testAttributes=true, + bool testPoint=true) const { // if ( dimension!=map2.dimension ) return false; @@ -2989,7 +3009,8 @@ namespace CGAL { Dart_range::const_iterator it(map2.darts().begin()), itend(map2.darts().end()); it!=itend; ++it) { - if (are_cc_isomorphic(d1, map2, it, testAttributes)) + if (are_cc_isomorphic(d1, map2, it, testDartInfo, testAttributes, + testPoint)) { return true; } diff --git a/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_3_test.h b/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_3_test.h index eb64d6625af..84bbcd00e6f 100644 --- a/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_3_test.h +++ b/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_3_test.h @@ -827,7 +827,7 @@ bool test_LCC_3() if ( !check_number_of_cells_3(lcc2, 26002, 78000, 52000, 1, 1) ) return false; - if (!lcc.is_isomorphic_to(lcc2)) + if (!lcc.is_isomorphic_to(lcc2, false, false, true)) // dartinfo, attrib, point { assert(false); return false; diff --git a/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_copy_test.cpp b/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_copy_test.cpp index 5cf0fee13da..019c5d98b8c 100644 --- a/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_copy_test.cpp +++ b/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_copy_test.cpp @@ -632,36 +632,45 @@ bool testCopy() // 2D Map2 map1p(map1); assert(map1p.is_valid()); if ( map1.is_isomorphic_to(map1p) ) { assert(false); return false; } - if ( !map1.is_isomorphic_to(map1p, false) ) { assert(false); return false; } + if ( !map1.is_isomorphic_to(map1p, false, false, true) ) + { assert(false); return false; } Map3 map1t(map1); assert(map1t.is_valid()); if ( map1.is_isomorphic_to(map1t) ) { assert(false); return false; } - if ( !map1.is_isomorphic_to(map1t, false) ) { assert(false); return false; } + if ( !map1.is_isomorphic_to(map1t, false, false, false) ) + { assert(false); return false; } if ( map1p.is_isomorphic_to(map1t) ) { assert(false); return false; } - if ( !map1p.is_isomorphic_to(map1t, false) ) { assert(false); return false; } + if ( !map1p.is_isomorphic_to(map1t, false, false, false) ) + { assert(false); return false; } Map1 map2p(map2); assert(map2p.is_valid()); if ( map2.is_isomorphic_to(map2p) ) { assert(false); return false; } - if ( !map2.is_isomorphic_to(map2p, false) ) { assert(false); return false; } + if ( !map2.is_isomorphic_to(map2p, false, false, true) ) + { assert(false); return false; } Map3 map2t(map2); assert(map2t.is_valid()); if ( map2.is_isomorphic_to(map2t) ) { assert(false); return false; } - if ( !map2.is_isomorphic_to(map2t, false) ) { assert(false); return false; } + if ( !map2.is_isomorphic_to(map2t, false, false, false) ) + { assert(false); return false; } if ( map2p.is_isomorphic_to(map2t) ) { assert(false); return false; } - if ( !map2p.is_isomorphic_to(map2t, false) ) { assert(false); return false; } + if ( !map2p.is_isomorphic_to(map2t, false, false, false) ) + { assert(false); return false; } Map1 map3p(map3); assert(map3p.is_valid()); if ( map3.is_isomorphic_to(map3p) ) { assert(false); return false; } - if ( !map3.is_isomorphic_to(map3p, false) ) { assert(false); return false; } + if ( !map3.is_isomorphic_to(map3p, false, false, false) ) + { assert(false); return false; } Map2 map3t(map3); assert(map3t.is_valid()); if ( map3.is_isomorphic_to(map3t) ) { assert(false); return false; } - if ( !map3.is_isomorphic_to(map3t, false) ) { assert(false); return false; } + if ( !map3.is_isomorphic_to(map3t, false, false, false) ) + { assert(false); return false; } if ( map3p.is_isomorphic_to(map3t) ) { assert(false); return false; } - if ( !map3p.is_isomorphic_to(map3t, false) ) { assert(false); return false; } + if ( !map3p.is_isomorphic_to(map3t, false, false, false) ) + { assert(false); return false; } assert( map1.is_isomorphic_to(map1p)==map1p.is_isomorphic_to(map1) ); assert( map1.is_isomorphic_to(map1t)==map1t.is_isomorphic_to(map1) ); @@ -673,11 +682,13 @@ bool testCopy() // 3D Map4 map5a(map5); assert(map5a.is_valid()); if ( map5.is_isomorphic_to(map5a) ) { assert(false); return false; } - if ( !map5.is_isomorphic_to(map5a, false) ) { assert(false); return false; } + if ( !map5.is_isomorphic_to(map5a, false, false, true) ) + { assert(false); return false; } Map6 map5b(map5); assert(map5b.is_valid()); if ( map5.is_isomorphic_to(map5b) ) { assert(false); return false; } - if ( !map5.is_isomorphic_to(map5b, false) ) { assert(false); return false; } + if ( !map5.is_isomorphic_to(map5b, false, false, false) ) + { assert(false); return false; } assert( map5b.template number_of_attributes<0>()== map5.template number_of_attributes<0>() && map5b.template number_of_attributes<1>()==0 && @@ -688,7 +699,10 @@ bool testCopy() Map7 map5c(map5); assert(map5c.is_valid()); if ( map5.is_isomorphic_to(map5c) ) { assert(false); return false; } - if ( !map5.is_isomorphic_to(map5c, false) ) { assert(false); return false; } + if ( !map5.is_isomorphic_to(map5c, false, false, false) ) + { assert(false); return false; } + if ( !map5b.is_isomorphic_to(map5c, false, false, true) ) + { assert(false); return false; } assert( map5c.template number_of_attributes<0>()== map5.template number_of_attributes<0>() && map5c.template number_of_attributes<2>()== @@ -701,7 +715,8 @@ bool testCopy() // 4D Map8 map9a(map9); assert(map9a.is_valid()); if ( map9.is_isomorphic_to(map9a) ) { assert(false); return false; } - if ( !map9.is_isomorphic_to(map9a, false) ) { assert(false); return false; } + if ( !map9.is_isomorphic_to(map9a, false, false, true) ) + { assert(false); return false; } assert( map9a.template number_of_attributes<0>()== map9.template number_of_attributes<0>() && map9a.template number_of_attributes<2>()== @@ -711,7 +726,8 @@ bool testCopy() Map9 map8a(map8); assert(map8a.is_valid()); if ( map8.is_isomorphic_to(map8a) ) { assert(false); return false; } - if ( !map8.is_isomorphic_to(map8a, false) ) { assert(false); return false; } + if ( !map8.is_isomorphic_to(map8a, false, false, true) ) + { assert(false); return false; } assert( map8a.template number_of_attributes<0>()== map8.template number_of_attributes<0>() && map8a.template number_of_attributes<1>()==0 && @@ -727,7 +743,8 @@ bool testCopy() { Map5 map2a(map2); assert(map2a.is_valid()); if ( map2a.is_isomorphic_to(map2) ) { assert(false); return false; } - if ( !map2a.is_isomorphic_to(map2, false) ) { assert(false); return false; } + if ( !map2a.is_isomorphic_to(map2, false, false, true) ) + { assert(false); return false; } assert( map2a.template number_of_attributes<0>()== map2.template number_of_attributes<0>() && map2a.template number_of_attributes<2>()==0 && @@ -795,7 +812,8 @@ bool testCopy() Map9 map5b(map5, myconverters2); assert(map5b.is_valid()); if ( map5b.is_isomorphic_to(map5) ) { assert(false); return false; } - if ( !map5b.is_isomorphic_to(map5, false) ) { assert(false); return false; } + if ( !map5b.is_isomorphic_to(map5, false, false, false) ) + { assert(false); return false; } assert( map5b.template number_of_attributes<0>()== map5.template number_of_attributes<0>() && map5b.template number_of_attributes<2>()==