Allow isomorphism to test dartinfo and/or point and/or attribute independently; use this in LCC test.

This commit is contained in:
Guillaume Damiand 2016-10-27 09:07:08 -04:00
parent 80ffced770
commit 588ba4f527
5 changed files with 126 additions and 75 deletions

View File

@ -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 <unsigned int d2, typename Refs2, typename Items2, class Alloc2,
class Storage2>
@ -3612,7 +3616,9 @@ namespace CGAL {
<d2,Refs2,Items2,Alloc2, Storage2>& map2,
typename Combinatorial_map_base
<d2,Refs2,Items2,Alloc2, Storage2>::Dart_const_handle dh2,
bool testAttributes=true) const
bool testDartInfo=true,
bool testAttributes=true,
bool testPoint=true) const
{
typedef Combinatorial_map_base<d2,Refs2,Items2,Alloc2, Storage2> 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<Self, Map2>::
run(*this, map2, current, other);
if (match && testDartInfo)
match=internal::Test_is_same_dart_info_functor<Self, Map2>::
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<Self, Map2> >::
@ -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
<Self, Map2, 0>::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
<d2,Refs2,Items2,Alloc2, Storage2>& 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<d2,Refs2,Items2,Alloc2, Storage2>::
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;
}

View File

@ -68,7 +68,10 @@
* darts have the same info.
*
* internal::Test_is_same_attribute_functor<Map1, Map2> 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<Map1, Map2, i> to test if
* the point of two i-attributes are equal.
*
* internal::Reverse_orientation_of_map_functor<CMap> to reverse the
* orientation of a whole combinatorial map
@ -661,9 +664,12 @@ struct Is_same_point<Attr1, Attr2, Point, Point, Dynamic_dimension_tag >
};
// Case of two non void type, with two points
template<typename Map1, typename Map2,
typename T1, typename T2, bool Withpoint1, bool Withpoint2, int i>
struct Is_same_attribute_point_functor
template<typename Map1, typename Map2, int i,
bool Withpoint1=Is_attribute_has_point
<typename Map1::template Attribute_type<i>::type>::value,
bool Withpoint2=Is_attribute_has_point
<typename Map2::template Attribute_type<i>::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<T1,T2>::run
Is_same_point<typename Map1::template Attribute_type<i>::type,
typename Map2::template Attribute_type<i>::type>::run
(m1.template get_attribute<i>(m1.template attribute<i>(dh1)),
m2.template get_attribute<i>(m2.template attribute<i>(dh2)));
}
};
// Case of two non void type, first without point
template<typename Map1, typename Map2,
typename T1, typename T2, int i>
struct Is_same_attribute_point_functor<Map1, Map2, T1, T2, false, true, i>
template<typename Map1, typename Map2, int i>
struct Test_is_same_attribute_point_functor<Map1, Map2, i, false, true>
{
static bool run(const Map1&, const Map2&,
typename Map1::Dart_const_handle,
@ -697,9 +703,8 @@ struct Is_same_attribute_point_functor<Map1, Map2, T1, T2, false, true, i>
};
// Case of two non void type, second without point
template<typename Map1, typename Map2,
typename T1, typename T2, int i>
struct Is_same_attribute_point_functor<Map1, Map2, T1, T2, true, false, i>
template<typename Map1, typename Map2, int i>
struct Test_is_same_attribute_point_functor<Map1, Map2, i, true, false>
{
static bool run(const Map1&, const Map2&,
typename Map1::Dart_const_handle,
@ -708,9 +713,8 @@ struct Is_same_attribute_point_functor<Map1, Map2, T1, T2, true, false, i>
};
// Case of two non void type, both without point
template<typename Map1, typename Map2,
typename T1, typename T2, int i>
struct Is_same_attribute_point_functor<Map1, Map2, T1, T2, false, false, i>
template<typename Map1, typename Map2, int i>
struct Test_is_same_attribute_point_functor<Map1, Map2, i, false, false>
{
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
<Map1, Map2, i>::run(m1, m2, dh1, dh2);
}
if (res)
{
res = Is_same_attribute_point_functor
<Map1, Map2,
typename Map1::template Attribute_type<i>::type,
typename Map2::template Attribute_type<i>::type,
Is_attribute_has_point<typename Map1::template
Attribute_type<i>::type>::value,
Is_attribute_has_point<typename Map2::template
Attribute_type<i>::type>::value, i>::run(m1, m2, dh1, dh2);
}
}
};
// ****************************************************************************

View File

@ -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 <unsigned int d2, typename Refs2, typename Items2, class Alloc2,
class Storage2>
@ -2792,7 +2796,9 @@ namespace CGAL {
<d2,Refs2,Items2,Alloc2, Storage2>& map2,
typename Generalized_map_base
<d2,Refs2,Items2,Alloc2, Storage2>::Dart_const_handle dh2,
bool testAttributes=true) const
bool testDartInfo=true,
bool testAttributes=true,
bool testPoint=true) const
{
typedef Generalized_map_base<d2,Refs2,Items2,Alloc2, Storage2> 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<Self, Map2>::
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<Self, Map2>::
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<Self, Map2> >::
@ -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
<Self, Map2, 0>::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
<d2,Refs2,Items2,Alloc2, Storage2>& 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;
}

View File

@ -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;

View File

@ -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>()==