Continue on operations, group and degroup...

This commit is contained in:
Guillaume Damiand 2013-02-13 17:57:49 +01:00
parent 550518a13f
commit 173f8bc073
14 changed files with 704 additions and 515 deletions

View File

@ -86,6 +86,9 @@ namespace CGAL {
template <class T, class Alloc_>
friend class Compact_container;
template<typename CMap, unsigned int i, typename T>
friend struct internal::Decrease_attribute_functor_run;
public:
typedef Tag_false Supports_cell_dart;
@ -182,6 +185,9 @@ namespace CGAL {
template <class T, class Alloc_>
friend class Compact_container;
template<typename CMap, unsigned int i, typename T>
friend struct internal::Decrease_attribute_functor_run;
public:
typedef Tag_true Supports_cell_dart;

View File

@ -644,7 +644,7 @@ namespace CGAL {
*/
unsigned int close(unsigned int i)
{
CGAL_assertion(2<=i && i<=dimension);
CGAL_assertion( 2<=i && i<=dimension );
unsigned int res = 0;
Dart_handle d, d2;
@ -655,20 +655,30 @@ namespace CGAL {
{
d = create_dart();
++res;
link_beta(it, d, i);
// Here we cannot use link_beta as i is not a constant
// TODO something to solve this problem ?
basic_link_beta_for_involution(it, d, i);
// we copy all the non void attribute
Helper::template Foreach_enabled_attributes_except
<internal::Group_attribute_functor_of_dart<Self, dimension+1>,
dimension+1>:: run(this,it,d);
// we need to remove i-attrib, how to do that ?
// Special cases for 0 and 1
if ( !it->is_free(1) && !it->beta(1)->is_free(i) )
if ( !it->template is_free<1>() &&
!it->template beta<1>()->is_free(i) )
link_beta<1>(it->beta(1)->beta(i),d);
if ( !it->is_free(0) && !it->beta(0)->is_free(i) )
link_beta<0>(it->beta(0)->beta(i),d);
if ( !it->template is_free<0>() &&
!it->template beta<0>()->is_free(i) )
link_beta<0>(it->template beta<0>()->beta(i),d);
// General case for 2...dimension
for ( unsigned int j=2; j<=dimension; ++j)
{
if ( j+1!=i && j!=i && j!=i+1 &&
!it->is_free(j) && !it->beta(j)->is_free(i) )
{
link_beta(it->beta(j)->beta(i), d, j);
basic_link_beta_for_involution(it->beta(j)->beta(i), d, j);
}
}
@ -677,8 +687,8 @@ namespace CGAL {
{ d2 = d2->beta(i-1)->beta(i); }
if (d2 != null_dart_handle)
{
if (i==2) link_beta<1>(d2, d);
else link_beta(d2, d, i-1);
if (i==2) basic_link_beta<1>(d2, d);
else basic_link_beta_for_involution(d2, d, i-1);
}
}
}
@ -806,7 +816,7 @@ namespace CGAL {
* @param os the ostream.
* @return the ostream.
*/
std::ostream& display_darts(std::ostream & os) const
std::ostream& display_darts(std::ostream & os, bool attribs=false) const
{
unsigned int nb = 0;
for ( typename Dart_range::const_iterator it=darts().begin();
@ -816,7 +826,12 @@ namespace CGAL {
for ( unsigned int i=0; i<=dimension; ++i)
{
os << &(*it->beta(i)) << ",\t";
if (it->is_free(i))os << "\t";
if (it->is_free(i)) os << "\t";
}
if ( attribs )
{
Helper::template Foreach_enabled_attributes
<internal::Display_attribute_functor<Self> >::run(this, it);
}
os << std::endl;
++nb;
@ -1131,6 +1146,8 @@ namespace CGAL {
* \em adart1 is 0-linked to \em adart2 and \em adart2 is 1-linked
* with \em adart1. The NULL attributes of \em adart1 are updated to
* non NULL attributes associated to \em adart2, and vice-versa.
* If both darts have an attribute, the attribute of adart1 is
* associated to adart2.
* We can obtain a non-valid map with darts belonging to a same cell
* and having different attributes.
* @param adart1 a first dart.
@ -1140,17 +1157,19 @@ namespace CGAL {
{
CGAL_assertion(adart1 != NULL && adart2 != NULL);
CGAL_assertion(adart1 != null_dart_handle && adart2 != null_dart_handle);
adart1->basic_link_beta<0>(adart2);
adart2->basic_link_beta<1>(adart1);
Helper::template Foreach_enabled_attributes_except
<internal::Group_attribute_functor_of_dart<Self, 0>, 1>::
run(this,adart1,adart2);
adart1->basic_link_beta<0>(adart2);
adart2->basic_link_beta<1>(adart1);
}
/** Double link two darts, and update the NULL attributes.
* \em adart1 is 1-linked to \em adart2 and \em adart2 is 0-linked
* with \em adart1. The NULL attributes of \em adart1 are updated to
* non NULL attributes associated to \em adart2, and vice-versa.
* If both darts have an attribute, the attribute of adart1 is
* associated to adart2.
* We can obtain a non-valid map with darts belonging to a same cell
* and having different attributes.
* @param adart1 a first dart.
@ -1160,17 +1179,19 @@ namespace CGAL {
{
CGAL_assertion(adart1 != NULL && adart2 != NULL);
CGAL_assertion(adart1 != null_dart_handle && adart2 != null_dart_handle);
adart1->basic_link_beta<1>(adart2);
adart2->basic_link_beta<0>(adart1);
Helper::template Foreach_enabled_attributes_except
<internal::Group_attribute_functor_of_dart<Self, 1>, 1>::
run(this,adart1,adart2);
adart1->basic_link_beta<1>(adart2);
adart2->basic_link_beta<0>(adart1);
}
/** Double link two darts, and update the NULL attributes.
* \em adart1 is i-linked to \em adart2 and \em adart2 is i^-1-linked
* with \em adart1. The NULL attributes of \em adart1 are updated to
* non NULL attributes associated to \em adart2, and vice-versa.
* If both darts have an attribute, the attribute of adart1 is
* associated to adart2.
* We can obtain a non-valid map with darts belonging to a same cell
* and having different attributes.
* @param adart1 a first dart.
@ -1184,17 +1205,19 @@ namespace CGAL {
CGAL_assertion(adart1 != NULL && adart2 != NULL && adart1!=adart2 );
CGAL_assertion(adart1 != null_dart_handle && adart2 != null_dart_handle);
CGAL_assertion( 2<=i && i<=dimension );
Helper::template Foreach_enabled_attributes_except
<internal::Group_attribute_functor_of_dart<Self, i>, i>::
run(this,adart1,adart2);
adart1->template basic_link_beta<i>(adart2);
adart2->template basic_link_beta<i>(adart1);
Helper::template Foreach_enabled_attributes_except
<internal::Group_attribute_functor_of_dart<Self>, i>::
run(this,adart1,adart2);
}
/** Double link two darts, and update the NULL attributes.
* \em adart1 is i-linked to \em adart2 and \em adart2 is i^-1-linked
* with \em adart1. The NULL attributes of \em adart1 are updated to
* non NULL attributes associated to \em adart2, and vice-versa.
* If both darts have an attribute, the attribute of adart1 is
* associated to adart2.
* We can obtain a non-valid map with darts belonging to a same cell
* and having different attributes.
* @param adart1 a first dart.
@ -1211,8 +1234,9 @@ namespace CGAL {
/** Double link a dart with betai to a second dart.
* \em adart1 is i-linked to \em adart2 and \em adart2 is i^-1-linked
* with \em adart1. The NULL attributes of \em adart1 are updated to
* non NULL attributes associated to \em adart2, and vice-versa, only .
* if update_attributes==true.
* non NULL attributes associated to \em adart2, and vice-versa,
* if both darts have an attribute, the attribute of adart1 is
* associated to adart2 (only if update_attributes==true).
* @param adart1 a first dart.
* @param adart2 a second dart.
* @param update_attributes a boolean to update the enabled attributes.
@ -1324,28 +1348,39 @@ namespace CGAL {
{
CGAL_assertion( (is_sewable<1>(adart1,adart2)) );
int m = get_new_mark();
std::deque<Dart_handle> dartv;
for ( CMap_dart_iterator_basic_of_cell<Self,0> it(*this,adart1,m);
it.cont(); ++it)
if ( adart1==adart2 )
{
mark(it,m);
dartv.push_back(it);
for ( CMap_dart_iterator_of_involution<Self,1> it(*this, adart1);
it.cont(); ++it )
{
basic_link_beta_1(it, it);
}
}
CMap_dart_iterator_of_involution<Self,1> I1(*this, adart1);
CMap_dart_iterator_of_involution_inv<Self,1> I2(*this, adart2);
for ( ; I1.cont(); ++I1, ++I2 )
else
{
if ( is_marked(I1,m) ) basic_link_beta_1(I1, I2);
else basic_link_beta_0(I1, I2);
}
int m = get_new_mark();
std::deque<Dart_handle> dartv;
for ( CMap_dart_iterator_basic_of_cell<Self,0> it(*this,adart1,m);
it.cont(); ++it)
{
mark(it,m);
dartv.push_back(it);
}
for ( typename std::deque<Dart_handle>::iterator it=dartv.begin();
it!=dartv.end(); ++it)
{ unmark(*it,m); }
CGAL_assertion( is_whole_map_unmarked(m) );
free_mark(m);
CMap_dart_iterator_of_involution<Self,1> I1(*this, adart1);
CMap_dart_iterator_of_involution_inv<Self,1> I2(*this, adart2);
for ( ; I1.cont(); ++I1, ++I2 )
{
if ( is_marked(I1,m) ) basic_link_beta_1(I1, I2);
else basic_link_beta_0(I1, I2);
}
for ( typename std::deque<Dart_handle>::iterator it=dartv.begin();
it!=dartv.end(); ++it)
{ unmark(*it,m); }
CGAL_assertion( is_whole_map_unmarked(m) );
free_mark(m);
}
}
/** Topological sew by beta0 two given darts plus all the required darts
@ -1407,6 +1442,16 @@ namespace CGAL {
{
CGAL_assertion( (is_sewable<0>(adart1,adart2)) );
if ( adart1==adart2 )
{
for ( CMap_dart_iterator_of_involution<Self,1> it(*this, adart1);
it.cont(); ++it )
{
basic_link_beta_1(it, it);
}
return;
}
int m = get_new_mark();
std::deque<Dart_handle> dartv;
for ( CMap_dart_iterator_basic_of_cell<Self,0> it(*this,adart1,m);
@ -1474,6 +1519,17 @@ namespace CGAL {
void sew_1(Dart_handle adart1, Dart_handle adart2)
{
CGAL_assertion( (is_sewable<1>(adart1,adart2)) );
if ( adart1==adart2 )
{
for ( CMap_dart_iterator_of_involution<Self,1> it(*this, adart1);
it.cont(); ++it )
{
basic_link_beta_1(it, it);
}
return;
}
int m = get_new_mark();
std::deque<Dart_handle> dartv;
for ( CMap_dart_iterator_basic_of_cell<Self,0> it(*this,adart1,m);
@ -1495,6 +1551,7 @@ namespace CGAL {
// (by calling when required the onmerge functors).
for ( ; I1.cont(); ++I1, ++I2 )
{
CGAL_assertion( I2.cont() );
if ( is_marked(I1,m) )
Helper::template Foreach_enabled_attributes_except
<internal::Group_attribute_functor<Self, 1>, 1>::
@ -1553,7 +1610,7 @@ namespace CGAL {
for ( ; I1.cont(); ++I1, ++I2 )
{
Helper::template Foreach_enabled_attributes_except
<internal::Group_attribute_functor<Self>, i>::
<internal::Group_attribute_functor<Self, i>, i>::
run(this, I1, I2);
// TODO avant group_all_attributes_except(I1,I2,i);
}
@ -1810,7 +1867,6 @@ namespace CGAL {
modified_darts.push_back(it);
modified_darts.push_back(it->template beta<i>());
unlink_beta_for_involution<i>(it);
++it;
}
// We test the split of all the incident cells for all the non
@ -1987,24 +2043,8 @@ namespace CGAL {
return mmask_marks[(size_type)amark];
}
/* Decrease the cell attribute reference counting of the given dart.
* The cell is removed if there is no more darts linked with it.
*/
template<unsigned int i>
void decrease_attribute_ref_counting(Dart_handle adart)
{
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
"decrease_attribute_ref_counting<i> but "
"i-attributes are disabled");
if ( adart->template attribute<i>()!=NULL )
{
adart->template attribute<i>()->dec_nb_refs();
if ( adart->template attribute<i>()->get_nb_refs()==0 )
erase_attribute<i>(adart->template attribute<i>());
}
}
public:
// TODO REMOVE ?
/** Update the dart of the given i-cell attribute onto a non marked dart.
* @param ah the attribute to update.
* @param amark the mark.
@ -2085,8 +2125,8 @@ namespace CGAL {
if ( a!=NULL && a->get_nb_refs()!=nb )
{
std::cout<<"ERROR: the number of reference of an attribute is not correct "
<<nb<<" != "<<a->get_nb_refs()<<" for dart "
std::cout<<"ERROR: the number of reference of an attribute is not correct. "
<<"Count: "<<nb<<" != Store in the attribute:"<<a->get_nb_refs()<<" for dart "
<<&*adart<<std::endl;
valid = false;
}
@ -2955,76 +2995,8 @@ namespace CGAL {
{ return one_dart_per_cell<i,Self::dimension>(); }
//--------------------------------------------------------------------------
/** Set the i th attribute of the given dart.
* @param adart a dart.
* @param ah the attribute to set.
*/
template<unsigned int i>
void set_attribute_of_dart(Dart_handle adart,
typename Attribute_handle<i>::type ah)
{
CGAL_static_assertion(i<=dimension);
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
"set_attribute_of_dart<i> but "
"i-attributes are disabled");
CGAL_assertion( adart!=NULL && adart!=null_dart_handle && ah!=NULL );
if ( adart->template attribute<i>()==ah ) return;
decrease_attribute_ref_counting<i>(adart);
adart->template set_attribute<i>(ah);
// TODO remove the set_dart ?
// ah->set_dart(adart);
}
public:
/** Set the i-attribute of all the darts of a given i-cell.
* @param adart a starting dart.
* @param ah an handle to the i-attribute to set.
*/
template<unsigned int i>
void set_attribute(Dart_handle adart,
typename Attribute_handle<i>::type ah)
{
CGAL_static_assertion(i<=dimension);
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
"set_attribute<i> but i-attributes are disabled");
CGAL_assertion( adart!=NULL && adart!=null_dart_handle && ah!=NULL );
for ( typename Dart_of_cell_range<i>::iterator it(*this, adart);
it.cont(); ++it)
{
if ( it->template attribute<i>()!=ah )
{
decrease_attribute_ref_counting<i>(it);
it->template set_attribute<i>(ah);
}
}
ah->set_dart(adart);
}
/** Set the i-attribute of all the darts of a given range.
* @param adart a starting dart.
* @param ah an handle to the i-attribute to set.
*/
template<unsigned int i, typename Range>
void set_attribute(Dart_handle adart,
typename Attribute_handle<i>::type ah)
{
CGAL_static_assertion(i<=dimension);
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
"set_attribute<i> but i-attributes are disabled");
CGAL_assertion( adart!=NULL && adart!=null_dart_handle && ah!=NULL );
for ( typename Range::iterator it(*this, adart); it.cont(); ++it)
{
if ( it->template attribute<i>()!=ah )
{
decrease_attribute_ref_counting<i>(it);
it->template set_attribute<i>(ah);
}
}
ah->set_dart(adart);
}
/** Compute the dual of a Combinatorial_map.
* @param amap the cmap in which we build the dual of this map.
* @param adart a dart of the initial map, NULL by default.
@ -3038,7 +3010,7 @@ namespace CGAL {
{
CGAL_assertion( is_without_boundary(dimension) );
std::map< Dart_handle, Dart_handle > dual;
CGAL::Unique_hash_map< Dart_handle, Dart_handle > dual;
Dart_handle d, d2, res = NULL;
// We clear amap. TODO return a new amap ? (but we need to make
@ -3058,29 +3030,31 @@ namespace CGAL {
// dual(G)=(B, b(n-1)obn, b(n-2)obn,...,b1obn, bn)
// We suppose darts are run in the same order for both maps.
typename Dart_range::iterator it2=amap.darts().begin();
for ( typename Dart_range::iterator it=darts().begin(); it!=darts().end();
++it, ++it2)
for ( typename Dart_range::iterator it=darts().begin();
it!=darts().end(); ++it, ++it2)
{
d = it2; // The supposition on the order allows to avoid d=dual[it];
CGAL_assertion(it2 == dual[it]);
CGAL_assertion( it2==dual[it] );
// First case outside the loop since we need to use link_beta1
if ( d->is_free(1) &&
it->beta(dimension)->beta(dimension-1)!=null_dart_handle )
amap.link_beta<1>(d,
dual[it->beta(dimension)->beta(dimension-1)]);
if ( d->template is_free<1>() && it->template beta<dimension>()->
template beta<dimension-1>()!=null_dart_handle )
amap.basic_link_beta_1(d, dual[it->template beta<dimension>()->
template beta<dimension-1>()]);
// and during the loop we use link_beta(d1,d2,i)
for ( unsigned int i=dimension-2; i>=1; --i)
{
if ( d->is_free(dimension-i) &&
it->beta(dimension)->beta(i)!=null_dart_handle )
amap.link_beta(d, dual[it->beta(dimension)->beta(i)], dimension-i);
it->template beta<dimension>()->beta(i)!=null_dart_handle )
amap.basic_link_beta(d, dual[it->template beta<dimension>()->
beta(i)], dimension-i);
}
if ( d->is_free(dimension) )
if ( d->template is_free<dimension>() )
{
CGAL_assertion ( !it->is_free(dimension) );
amap.link_beta(d, dual[it->beta(dimension)],dimension);
CGAL_assertion ( !it->template is_free<dimension>() );
amap.basic_link_beta(d, dual[it->template beta<dimension>()],
dimension);
}
}

View File

@ -13,19 +13,21 @@ namespace CGAL {
*/
template<class CMap>
typename CMap::Dart_handle
insert_cell_0_in_cell_1(CMap& amap, typename CMap::Dart_handle adart)
insert_cell_0_in_cell_1( CMap& amap, typename CMap::Dart_handle adart,
typename CMap::template
Attribute_handle<0>::type ah=NULL )
{
CGAL_assertion(adart != NULL && adart!=CMap::null_dart_handle);
typename CMap::Dart_handle d1, d2;
int mark = amap.get_new_mark();
int mark=amap.get_new_mark();
// 1) We store all the darts of the edge.
std::deque<typename CMap::Dart_handle> vect;
int m=amap.get_new_mark();
{
for ( typename CMap::template Dart_of_cell_range<1>::iterator it=
amap.template darts_of_cell<1>(adart).begin();
it != amap.template darts_of_cell<1>(adart).end(); ++it )
for ( typename CMap::template Dart_of_cell_basic_range<1>::iterator
it=amap.template darts_of_cell_basic<1>(adart, m).begin();
it != amap.template darts_of_cell_basic<1>(adart, m).end(); ++it )
vect.push_back(it);
}
@ -49,21 +51,23 @@ insert_cell_0_in_cell_1(CMap& amap, typename CMap::Dart_handle adart)
}
amap.link_beta_1(*it, d1);
// TODO remove this group, and use link_beta instead ?
//amap.group_all_dart_attributes_except(*it, d1, 1);
internal::Set_i_attribute_of_dart_functor<CMap, 0>::run(&amap, d1, ah);
amap.mark(*it, mark);
}
for (it = vect.begin(); it != vect.end(); ++it)
{ amap.unmark(*it, mark); }
{
amap.unmark(*it, m);
amap.unmark(*it, mark);
}
amap.free_mark(m);
amap.free_mark(mark);
internal::Degroup_attribute_functor_run<CMap, 1>::
run(&amap, adart, adart->beta(1));
// CGAL_expensive_postcondition( amap.is_valid() );
CGAL_assertion( amap.is_valid() );
return adart->beta(1);
}
@ -74,22 +78,21 @@ insert_cell_0_in_cell_1(CMap& amap, typename CMap::Dart_handle adart)
* @param adart a dart of the facet to triangulate.
* @return A dart incident to the new vertex.
*/
// TODO revoir toute la gestion des attributs
// (utilisation correcte des link avec/sans la maj)
template < class CMap >
typename CMap::Dart_handle
insert_cell_0_in_cell_2(CMap& amap, typename CMap::Dart_handle adart)
insert_cell_0_in_cell_2( CMap& amap, typename CMap::Dart_handle adart,
typename CMap::Helper::template
Attribute_handle<0>::type ah=NULL )
{
CGAL_assertion(adart != NULL && adart!=CMap::null_dart_handle);
typename CMap::Dart_handle first = adart, prev = NULL, cur = NULL;
typename CMap::Dart_handle n1 = NULL, n2 = NULL;
typename CMap::Dart_handle nn1 = NULL, nn2 = NULL;
// If the facet is open, we search the dart 0-free
while (!first->is_free(0) && first->beta(0) != adart)
first = first->beta(0);
while ( !first->template is_free<0>() && first->template beta<0>()!=adart )
first = first->template beta<0>();
// Stack of couple of dart and dimension for which
// we must call on_split functor
@ -102,52 +105,38 @@ insert_cell_0_in_cell_2(CMap& amap, typename CMap::Dart_handle adart)
std::stack<typename CMap::Dart_handle> tounmark;
// Now we run through the facet
for (CGAL::CMap_dart_iterator_basic_of_orbit<CMap,1> it(amap,first);
it.cont();)
for ( CGAL::CMap_dart_iterator_basic_of_orbit<CMap,1> it(amap, first);
it.cont(); )
{
cur = it;
++it;
amap.mark(cur, treated);
tounmark.push(cur);
if ( cur!=first )
if (!cur->template is_free<0>())
{
// TODO
//if ( amap.template degroup_attribute_of_dart<2>(first, cur) )
{
// TODO Functor takiing a range, an attrib_handle, and that set
// all the darts of the range to this handle
/* for (typename CMap::template Dart_of_involution_range<1>::iterator
it=template darts_of_involution<1>(dh2).begin(),
itend=template darts_of_involution<1>(dh2).end(); it!=itend;
++it)
{
}
tosplit.push(internal::Couple_dart_and_dim
<typename CMap::Dart_handle>
(first,cur,2));*/
}
}
if (!cur->is_free(0))
{
n1 = amap.create_dart();
n1=amap.create_dart();
amap.link_beta_0(cur, n1);
}
else n1 = NULL;
if (!cur->is_free(1))
if (!cur->template is_free<1>())
{
n2 = amap.create_dart();
amap.link_beta_1(cur, n2);
}
else n2 = NULL;
if (n1 != NULL && n2 != NULL)
amap.link_beta_0(n1, n2);
if ( n1!=NULL )
{
if ( n2!=NULL )
amap.basic_link_beta_0(n1, n2);
if (n1 != NULL && prev != NULL)
amap.template link_beta_for_involution<2>(prev, n1);
if ( prev!=NULL )
amap.template basic_link_beta_for_involution<2>(prev, n1);
internal::Set_i_attribute_of_dart_functor<CMap, 0>::run(&amap, n1, ah);
}
for (unsigned int dim=3; dim<=CMap::dimension; ++dim)
{
@ -168,6 +157,8 @@ insert_cell_0_in_cell_2(CMap& amap, typename CMap::Dart_handle adart)
nn2=amap.create_dart();
amap.link_beta_0(cur->beta(dim), nn2);
amap.basic_link_beta_for_involution(n2, nn2, dim);
internal::Set_i_attribute_of_dart_functor<CMap, 0>::
run(&amap, nn2, ah);
}
else nn2=NULL;
@ -175,7 +166,8 @@ insert_cell_0_in_cell_2(CMap& amap, typename CMap::Dart_handle adart)
amap.basic_link_beta_1(nn1, nn2);
if (nn1 != NULL && prev != NULL)
amap.basic_link_beta_for_involution(nn1, prev->beta(dim), 2);
amap.template basic_link_beta_for_involution<2>
(nn1, prev->beta(dim));
amap.mark(cur->beta(dim), treated);
tounmark.push(cur->beta(dim));
@ -183,9 +175,11 @@ insert_cell_0_in_cell_2(CMap& amap, typename CMap::Dart_handle adart)
else
{
if ( n1!=NULL )
amap.basic_link_beta_for_involution(n1, cur->beta(dim)->beta(1), dim);
amap.basic_link_beta_for_involution
(n1, cur->beta(dim)->template beta<1>(), dim);
if ( n2!=NULL )
amap.basic_link_beta_for_involution(n2, cur->beta(dim)->beta(0), dim);
amap.basic_link_beta_for_involution
(n2, cur->beta(dim)->template beta<0>(), dim);
}
}
}
@ -195,35 +189,35 @@ insert_cell_0_in_cell_2(CMap& amap, typename CMap::Dart_handle adart)
if (n2 != NULL)
{
amap.template link_beta_for_involution<2>(first->beta(0), n2);
amap.template basic_link_beta_for_involution<2>(first->template beta<0>(),
n2);
for (unsigned int dim=3; dim<=CMap::dimension; ++dim)
{
if ( !adart->is_free(dim) )
{
amap.basic_link_beta_for_involution(first->beta(0)->beta(dim),
n2->beta(dim), 2);
amap.template basic_link_beta_for_involution<2>
(first->template beta<0>()->beta(dim), n2->beta(dim));
}
}
}
// Now we unmark all marked darts
// Now we unmark all marked darts, and we degroup the new faces with the
// initial one (if 2-attributes are non void).
while ( !tounmark.empty() )
{
amap.unmark(tounmark.top(), treated);
if ( tounmark.top()!=adart )
internal::Degroup_attribute_functor_run<CMap, 2>::
run(&amap, adart, tounmark.top());
tounmark.pop();
}
CGAL_assertion(amap.is_whole_map_unmarked(treated));
amap.free_mark(treated);
/* TODO while ( !tosplit.empty() )
{
internal::Couple_dart_and_dim<typename CMap::Dart_handle> c=tosplit.top();
tosplit.pop();
internal::Call_split_functor<CMap, 2>::run(c.d1, c.d2);
} */
CGAL_expensive_postcondition( amap.is_valid() );
CGAL_assertion( amap.is_valid() );
return n1;
}
@ -234,7 +228,10 @@ insert_cell_0_in_cell_2(CMap& amap, typename CMap::Dart_handle adart)
*/
template<class CMap>
typename CMap::Dart_handle
insert_dangling_cell_1_in_cell_2(CMap& amap, typename CMap::Dart_handle adart1)
insert_dangling_cell_1_in_cell_2( CMap& amap,
typename CMap::Dart_handle adart1,
typename CMap::Helper::template
Attribute_handle<0>::type ah=NULL )
{
CGAL_assertion(adart1!=NULL && adart1!=CMap::null_dart_handle);
@ -255,7 +252,7 @@ insert_dangling_cell_1_in_cell_2(CMap& amap, typename CMap::Dart_handle adart1)
int treated = amap.get_new_mark();
CGAL::CMap_dart_iterator_of_involution<CMap,1> it1(amap,adart1);
CGAL::CMap_dart_iterator_of_involution<CMap,1> it1(amap, adart1);
for ( ; it1.cont(); ++it1)
{
@ -267,22 +264,24 @@ insert_dangling_cell_1_in_cell_2(CMap& amap, typename CMap::Dart_handle adart1)
if ( !it1->is_free(s1) )
{
if ( s1==0 ) amap.template link_beta<1>(it1->template beta<0>(), d2);
else amap.template link_beta<0>(it1->template beta<1>(), d2);
if ( s1==0 )
amap.template link_beta_1(it1->template beta<0>(), d2);
else
amap.template link_beta_0(it1->template beta<1>(), d2);
}
if (s1==0)
{
amap.template link_beta<0>(it1, d1);
amap.template link_beta<0>(d1,d2);
amap.link_beta_0(it1, d1);
amap.link_beta_0(d1, d2);
}
else
{
amap.template link_beta<1>(it1, d1);
amap.template link_beta<1>(d1,d2);
amap.link_beta_1(it1, d1);
amap.link_beta_1(d1, d2);
}
amap.template link_beta_for_involution<2>(d1, d2);
amap.template basic_link_beta_for_involution<2>(d1, d2);
for ( unsigned int dim=3; dim<=CMap::dimension; ++dim)
{
@ -295,7 +294,7 @@ insert_dangling_cell_1_in_cell_2(CMap& amap, typename CMap::Dart_handle adart1)
(it1->beta(dim)->beta_inv(s1)->beta(2), d2, dim);
}
}
internal::Set_i_attribute_of_dart_functor<CMap, 0>::run(&amap, d1, ah);
amap.mark(it1,treated);
}
@ -311,9 +310,9 @@ insert_dangling_cell_1_in_cell_2(CMap& amap, typename CMap::Dart_handle adart1)
CGAL_assertion( amap.is_whole_map_unmarked(mark1) );
amap.free_mark(mark1);
// CGAL_expensive_postcondition( amap.is_valid() );
CGAL_assertion( amap.is_valid() );
return adart1->beta(0);
return adart1->template beta<0>();
}
/** Test if an edge can be inserted onto a 2-cell between two given darts.
@ -390,13 +389,13 @@ insert_cell_1_in_cell_2(CMap& amap,
if ( !it1->is_free(s1) )
{
if ( s1==0 ) amap.basic_link_beta_1(it1->template beta<0>(), d2);
else amap.link_beta_0(it1->template beta<1>(), d2);
else amap.basic_link_beta_0(it1->template beta<1>(), d2);
}
if ( !it2->is_free(s1) )
{
if ( s1==0 ) amap.basic_link_beta_1(it2->template beta<0>(), d1);
else amap.link_beta_0(it2->template beta<1>(), d1);
else amap.basic_link_beta_0(it2->template beta<1>(), d1);
}
if ( s1==0 )
@ -406,10 +405,10 @@ insert_cell_1_in_cell_2(CMap& amap,
}
else
{
amap.basic_link_beta_1(it1, d1);
amap.basic_link_beta_1(it2, d2);
amap.link_beta_1(it1, d1);
amap.link_beta_1(it2, d2);
}
amap.link_beta_for_involution(d2, d1, 2);
amap.template basic_link_beta_for_involution<2>(d2, d1);
for ( unsigned int dim=3; dim<=CMap::dimension; ++dim)
{
@ -454,7 +453,7 @@ insert_cell_1_in_cell_2(CMap& amap,
CGAL_assertion( amap.is_whole_map_unmarked(mark1) );
amap.free_mark(mark1);
// CGAL_expensive_postcondition( amap.is_valid() );
CGAL_assertion( amap.is_valid() );
return adart1->template beta<0>();
}
@ -471,7 +470,7 @@ bool is_insertable_cell_2_in_cell_3(const CMap& amap,
InputIterator afirst,
InputIterator alast)
{
CGAL_static_assertion( CMap::dimension>= 3 );
CGAL_assertion( CMap::dimension>= 3 );
// The path must have at least one dart.
if (afirst==alast) return false;
@ -523,9 +522,9 @@ insert_cell_2_in_cell_3(CMap& amap, InputIterator afirst, InputIterator alast)
bool withBeta3 = false;
{
for (InputIterator it(afirst); it!=alast; ++it)
for (InputIterator it(afirst); !withBeta3 && it!=alast; ++it)
{
if (!(*it)->is_free(2)) withBeta3 = true;
if (!(*it)->template is_free<2>()) withBeta3 = true;
}
}
@ -533,35 +532,34 @@ insert_cell_2_in_cell_3(CMap& amap, InputIterator afirst, InputIterator alast)
for (InputIterator it(afirst); it!=alast; ++it)
{
d = amap.create_dart();
if (withBeta3)
{
if ( withBeta3 )
dd = amap.create_dart();
amap.template basic_link_beta_for_involution<3>(d, dd);
}
if (prec != NULL)
{
amap.template link_beta<0>(prec, d);
amap.basic_link_beta_0(prec, d);
if (withBeta3)
amap.template link_beta<1>(prec->template beta<3>(), dd);
amap.basic_link_beta_1(prec->template beta<3>(), dd);
}
else first = d;
if (!(*it)->is_free(2))
amap.template link_beta_for_involution<2>
if ( !(*it)->template is_free<2>() )
amap.template basic_link_beta_for_involution<2>
((*it)->template beta<2>(), dd);
amap.template link_beta_for_involution<2>(*it, d);
if ( withBeta3 )
amap.template link_beta_for_involution<3>(d, dd);
prec = d;
}
}
amap.template link_beta<0>(prec, first);
if (withBeta3)
amap.basic_link_beta_0(prec, first);
if ( withBeta3 )
{
amap.template link_beta<1>(prec->template beta<3>(),
first->template beta<3>());
amap.basic_link_beta_1(prec->template beta<3>(),
first->template beta<3>());
}
// Make copies of the new facet for dimension >=4
@ -575,11 +573,11 @@ insert_cell_2_in_cell_3(CMap& amap, InputIterator afirst, InputIterator alast)
it.cont(); ++it )
{
d = amap.create_dart();
amap.link_beta_for_involution(it->template beta<2>(), d, dim);
amap.basic_link_beta_for_involution(it->template beta<2>(), d, dim);
if ( withBeta3 )
{
dd = amap.create_dart();
amap.link_beta_for_involution
amap.basic_link_beta_for_involution
(it->template beta<2>()->template beta<3>(), dd, dim);
amap.template basic_link_beta_for_involution<3>(d, dd);
}
@ -588,20 +586,31 @@ insert_cell_2_in_cell_3(CMap& amap, InputIterator afirst, InputIterator alast)
amap.link_beta_0(prec, d);
if ( withBeta3 )
{
amap.link_beta_1(prec->template beta<3>(), dd);
amap.basic_link_beta_1(prec->template beta<3>(), dd);
}
}
else first2 = prec;
for ( unsigned dim2=2; dim2<=CMap::dimension; ++dim2 )
// We consider dim2=2 out of the loop to use link_beta instead of
// basic _link_beta (to modify non void attributes only once).
if ( !it->template is_free<2>() &&
it->template beta<2>()->is_free(dim) )
amap.template link_beta_for_involution<2>
(it->template beta<2>()->beta(dim), d);
if ( withBeta3 &&
!it->template beta<3>()->template is_free<2>() &&
it->template beta<3>()->template beta<2>()->is_free(dim) )
amap.template link_beta_for_involution<2>
(it->template beta<3>()->template beta<2>()->beta(dim), dd);
for ( unsigned dim2=3; dim2<=CMap::dimension; ++dim2 )
{
if ( dim2+1!=dim && dim2!=dim && dim2!=dim+1 )
{
if ( !it->is_free(dim2) &&
it->beta(dim2)->is_free(dim) )
if ( !it->is_free(dim2) && it->beta(dim2)->is_free(dim) )
amap.basic_link_beta_for_involution(it->beta(dim2)->beta(dim),
d, dim2);
if ( withBeta3 && !it->beta(3)->is_free(dim2) &&
if ( withBeta3 && !it->template beta<3>()->is_free(dim2) &&
it->template beta<3>()->beta(dim2)->is_free(dim) )
amap.basic_link_beta_for_involution
(it->template beta<3>()->beta(dim2)->beta(dim), dd, dim2);
@ -609,21 +618,24 @@ insert_cell_2_in_cell_3(CMap& amap, InputIterator afirst, InputIterator alast)
}
prec = d;
}
amap.template link_beta<0>( prec, first2 );
amap.basic_link_beta_0( prec, first2 );
if ( withBeta3 )
{
amap.template link_beta<1>( prec->template beta<3>(),
first2->template beta<3>() );
amap.basic_link_beta_1( prec->template beta<3>(),
first2->template beta<3>() );
}
}
}
// Degroup the attributes
if ( withBeta3 )
{ // Here we cannot use Degroup_attribute_functor_run as new darts do not
// have their 3-attribute
internal::Degroup_attribute_functor_run<CMap, 3>::
run(&amap, first, first->template beta<3>());
}
// CGAL_expensive_postcondition( amap.is_valid() );
CGAL_assertion( amap.is_valid() );
return first;
}

View File

@ -109,6 +109,14 @@ namespace CGAL {
amap.update_dart_of_all_attributes(*it, mark);
std::deque<typename CMap::Dart_handle> modified_darts;
std::deque<typename CMap::Dart_handle> modified_darts2;
// If i==1, we modify beta1, thus in modified_darts we store all
// the darts having beta0 modified, and in modified_darts2 all the
// darts having beta1 modified. Otherwise we store all the darts in
// modified_darts.
std::deque<typename CMap::Dart_handle> &first_modified_darts=
(i==1?modified_darts2:modified_darts);
// For each dart of the i-cell, we modify i-links of neighbors.
for ( it=to_erase.begin(); it!=to_erase.end(); ++it )
@ -140,7 +148,7 @@ namespace CGAL {
amap.template basic_link_beta<i>(d1, d2);
amap.mark(d1, mark_modified_darts);
amap.mark(d2, mark_modified_darts);
modified_darts.push_back(d1);
first_modified_darts.push_back(d1);
modified_darts.push_back(d2);
// TODO push only one out of two dart ?
/*if ( i==1 )
@ -157,7 +165,7 @@ namespace CGAL {
d1->template unlink_beta<i>();
CGAL_assertion( !amap.is_marked(d1, mark_modified_darts) );
amap.mark(d1, mark_modified_darts);
modified_darts.push_back(d1);
first_modified_darts.push_back(d1);
}
}
}
@ -189,9 +197,15 @@ namespace CGAL {
// We test the split of all the incident cells for all the non
// void attributes.
CMap::Helper::template Foreach_enabled_attributes_except
<internal::Test_split_attribute_functor<CMap,i>, i>::
run(&amap, modified_darts, mark_modified_darts);
if ( i==1 )
CMap::Helper::template Foreach_enabled_attributes_except
<internal::Test_split_attribute_functor<CMap,i>, i>::
run(&amap, modified_darts, modified_darts2,
mark_modified_darts);
else
CMap::Helper::template Foreach_enabled_attributes_except
<internal::Test_split_attribute_functor<CMap,i>, i>::
run(&amap, modified_darts, mark_modified_darts);
// We remove all the darts of the i-cell.
for ( it=to_erase.begin(); it!=to_erase.end(); ++it )
@ -206,6 +220,14 @@ namespace CGAL {
iterator it=modified_darts.begin();
it!=modified_darts.end(); ++it )
amap.unmark(*it, mark_modified_darts);
if ( i==1 )
{
for ( typename std::deque<typename CMap::Dart_handle>::
iterator it=modified_darts2.begin();
it!=modified_darts2.end(); ++it )
amap.unmark(*it, mark_modified_darts);
}
}
CGAL_assertion ( amap.is_whole_map_unmarked(mark_modified_darts) );
@ -523,7 +545,7 @@ namespace CGAL {
{
if ( !d1->template is_free<i>() )
{
d1->unlink_beta(i);
d1->template unlink_beta<i>();
CGAL_assertion( !amap.is_marked(d1, mark_modified_darts) );
amap.mark(d1, mark_modified_darts);
modified_darts.push_back(d1);
@ -534,7 +556,7 @@ namespace CGAL {
{
if ( !d2->is_free(i) )
{
d2->unlink_beta(i);
d2->template unlink_beta<i>();
CGAL_assertion( !amap.is_marked(d2, mark_modified_darts) );
amap.mark(d2, mark_modified_darts);
modified_darts.push_back(d2);
@ -547,7 +569,7 @@ namespace CGAL {
d1 = (*it)->beta(i);
if ( !d1->is_free(i) )
{
d1->unlink_beta(i);
d1->template unlink_beta<i>();
CGAL_assertion( !amap.is_marked(d1, mark_modified_darts) );
amap.mark(d1, mark_modified_darts);
modified_darts.push_back(d1);
@ -618,8 +640,9 @@ namespace CGAL {
it.cont(); ++it )
{
to_erase.push_back(it);
if ( dg1==NULL && it->other_extremity()!=NULL )
{ dg1=it; dg2=it->other_extremity(); }
if ( dg1==NULL && !it->template is_free<0>() &&
!it->template is_free<1>() )
{ dg1=it->template beta<0>(); dg2=it->template beta<1>(); }
amap.mark(it, mark);
++res;
}
@ -632,21 +655,21 @@ namespace CGAL {
// We group the two vertices incident if they exist.
if ( dg1!=NULL )
internal::Group_attribute_functor_run<CMap, 0>::
internal::Group_attribute_functor_run<CMap, 0, 1>::
run(&amap, dg1, dg2);
// 4) For each dart of the cell, we modify link of neighbors.
for ( it=to_erase.begin(); it!=to_erase.end(); ++it )
{
if ( !(*it)->is_free(0) )
if ( !(*it)->template is_free<0>() )
{
if ( !(*it)->is_free(1) )
if ( !(*it)->template is_free<1>() )
{
if ( (*it)->beta(1)!=*it )
if ( (*it)->template beta<1>()!=*it )
{
/* modified_darts.push_back((*it)->beta(0));
/*modified_darts2.push_back((*it)->template beta<0>());
if ( (*it)->beta(0)!=(*it)->beta(1) )*/
modified_darts2.push_back((*it)->template beta<1>());
modified_darts.push_back((*it)->template beta<1>());
amap.basic_link_beta_1((*it)->template beta<0>(),
(*it)->template beta<1>());
}
@ -654,16 +677,16 @@ namespace CGAL {
else
{
// TODO todegroup.push(Dart_pair((*it)->beta(0), *it));
modified_darts.push_back((*it)->template beta<0>());
modified_darts2.push_back((*it)->template beta<0>());
(*it)->template beta<0>()->template unlink_beta<1>();
}
}
else
{
if ( !(*it)->is_free(1) )
if ( !(*it)->template is_free<1>() )
{
// TODO todegroup.push(Dart_pair((*it)->beta(1), *it));
modified_darts2.push_back((*it)->template beta<1>());
modified_darts.push_back((*it)->template beta<1>());
(*it)->template beta<1>()->template unlink_beta<0>();
}
}

View File

@ -216,51 +216,6 @@ namespace CGAL {
(mattribute_handles);
}
protected:
/** Default constructor: initialise marks and beta of this dart.
* @param amarks the marks.
*/
Dart(const std::bitset<NB_MARKS>& amarks) : mmarks(amarks)
{
for (unsigned int i = 0; i <= dimension; ++i)
mbeta[i] = Refs::null_dart_handle;
Helper::template Foreach_enabled_attributes<Init_attribute_functor>::
run(this);
}
/** Return the mark value of a given mark number.
* @param amark the mark number.
* @return the value for this number.
*/
bool get_mark(int amark) const
{
CGAL_assertion(amark>=0 && (size_type)amark<NB_MARKS);
return mmarks[(size_type)amark];
}
/** Set the mark of a given mark number to a given value.
* @param amark the mark number.
* @param AValue the value.
*/
void set_mark(int amark, bool avalue) const
{
CGAL_assertion(amark>=0 && (size_type)amark<NB_MARKS);
mmarks.set((size_type)amark, avalue);
}
/** Return all the marks of this dart.
* @return the marks.
*/
std::bitset<NB_MARKS> get_marks() const
{ return mmarks; }
/** Set simultaneously all the marks of this dart to a given value.
* @param amarks the value of the marks.
*/
void set_marks(const std::bitset<NB_MARKS>& amarks) const
{ mmarks = amarks; }
/** Link this dart with a given dart for a given dimension.
* @param adart the dart to link with.
* @param i the dimension.
@ -306,6 +261,50 @@ namespace CGAL {
}
protected:
/** Default constructor: initialise marks and beta of this dart.
* @param amarks the marks.
*/
Dart(const std::bitset<NB_MARKS>& amarks) : mmarks(amarks)
{
for (unsigned int i = 0; i <= dimension; ++i)
mbeta[i] = Refs::null_dart_handle;
Helper::template Foreach_enabled_attributes<Init_attribute_functor>::
run(this);
}
/** Return the mark value of a given mark number.
* @param amark the mark number.
* @return the value for this number.
*/
bool get_mark(int amark) const
{
CGAL_assertion(amark>=0 && (size_type)amark<NB_MARKS);
return mmarks[(size_type)amark];
}
/** Set the mark of a given mark number to a given value.
* @param amark the mark number.
* @param AValue the value.
*/
void set_mark(int amark, bool avalue) const
{
CGAL_assertion(amark>=0 && (size_type)amark<NB_MARKS);
mmarks.set((size_type)amark, avalue);
}
/** Return all the marks of this dart.
* @return the marks.
*/
std::bitset<NB_MARKS> get_marks() const
{ return mmarks; }
/** Set simultaneously all the marks of this dart to a given value.
* @param amarks the value of the marks.
*/
void set_marks(const std::bitset<NB_MARKS>& amarks) const
{ mmarks = amarks; }
/// Functor used to initialize all attributes to NULL.
struct Init_attribute_functor
{

View File

@ -57,6 +57,12 @@
* Beta_functor_static<Dart, i...> to call several beta on the given dart.
* Indices are given as template arguments.
*
* Set_i_attribute_of_dart_functor<CMap, i> to set the i-attribute of a given
* dart.
* Set_i_attribute_functor<CMap, i> to set the i-attribute of a given
* i-cell.
*
* Group_attribute_functor_of_dart<CMap> to group the <i>-attributes of two
* given darts (except for j-dim). Only the attributes of the two given
* darts are possibly modified.
@ -208,6 +214,21 @@ namespace CGAL
}
};
// **************************************************************************
/// Functor used to display the adress of the i-cell attribute
template<typename CMap>
struct Display_attribute_functor
{
template <unsigned int i>
static void run(const CMap* amap,
typename CMap::Dart_const_handle adart)
{
if ( adart->template attribute<i>()==NULL )
std::cout<<"NULL";
else
std::cout<<&*(adart->template attribute<i>());
}
};
// **************************************************************************
/// Functor for counting i-cell
template<typename CMap>
struct Count_cell_functor
@ -257,6 +278,30 @@ namespace CGAL
}
};
// **************************************************************************
/// Decrease the cell attribute reference counting of the given dart.
/// The attribute is removed if there is no more darts linked with it.
template<typename CMap, unsigned int i, typename T=
typename CMap::Helper::template Attribute_type<i>::type>
struct Decrease_attribute_functor_run
{
static void run(CMap* amap, typename CMap::Dart_handle adart)
{
if ( adart->template attribute<i>()!=NULL )
{
adart->template attribute<i>()->dec_nb_refs();
if ( adart->template attribute<i>()->get_nb_refs()==0 )
amap->template erase_attribute<i>(adart->template attribute<i>());
}
}
};
/// Specialization for void attributes.
template<typename CMap, unsigned int i>
struct Decrease_attribute_functor_run<CMap,i,CGAL::Void>
{
static void run(CMap*, typename CMap::Dart_handle)
{}
};
// **************************************************************************
/// Functor used to call decrease_attribute_ref_counting<i>
/// on each i-cell attribute enabled
template<typename CMap>
@ -264,14 +309,78 @@ namespace CGAL
{
template <unsigned int i>
static void run(CMap* amap, typename CMap::Dart_handle adart)
{ amap->template decrease_attribute_ref_counting<i>(adart); }
{ Decrease_attribute_functor_run<CMap,i>::run(amap, adart); }
};
// **************************************************************************
/// Functor used to set the i-attribute of a given dart.
template<typename CMap, unsigned int i, typename T=
typename CMap::Helper::template Attribute_type<i>::type>
struct Set_i_attribute_of_dart_functor
{
static void run( CMap* amap, typename CMap::Dart_handle dh,
typename CMap::Helper::template Attribute_handle<i>::type
ah )
{
CGAL_static_assertion(i<=CMap::dimension);
CGAL_assertion( dh!=NULL && dh!=CMap::null_dart_handle );
if ( dh->template attribute<i>()==ah ) return;
Decrease_attribute_functor_run<CMap, i>::run(amap, dh);
dh->template set_attribute<i>(ah);
}
};
/// Specialization for void attributes.
template<typename CMap, unsigned int i>
struct Set_i_attribute_of_dart_functor<CMap,i,CGAL::Void>
{
static void run( CMap*, typename CMap::Dart_handle,
typename CMap::Helper::template Attribute_handle<i>::type)
{}
};
// **************************************************************************
/// Functor used to set the i-attribute of a given i-cell.
/// We can use any range as Range type, by default we use
/// Dart_of_cell_range<i>
template<typename CMap, unsigned int i,
typename Range=typename CMap::template Dart_of_cell_range<i>,
typename T=typename CMap::Helper::template Attribute_type<i>::type>
struct Set_i_attribute_functor
{
static void run( CMap* amap, typename CMap::Dart_handle dh,
typename CMap::Helper::template Attribute_handle<i>::type
ah )
{
CGAL_static_assertion(i<=CMap::dimension);
CGAL_assertion( dh!=NULL && dh!=CMap::null_dart_handle && ah!=NULL );
for ( typename Range::iterator it(*amap, dh); it.cont(); ++it)
{
if ( it->template attribute<i>()!=ah )
{
Decrease_attribute_functor_run<CMap, i>::run(amap, it);
it->template set_attribute<i>(ah);
}
}
ah->set_dart(dh);
}
};
/// Specialization for void attributes.
template<typename CMap, unsigned int i>
struct Set_i_attribute_functor<CMap,i,CGAL::Void>
{
static void run( CMap*, typename CMap::Dart_handle,
typename CMap::Helper::template Attribute_handle<i>::type)
{}
};
// **************************************************************************
/// Functor used for link_beta to update the i-attributes of
/// adart2 on the attributes of this dart, except if i=j.
/// (j is the dimension of the beta modified between adart1 and adart2,
/// so that after the modification we will have beta_j(adart1)==adart2)
/// Only attributes of dh1 or dh2 can be modified.
/// dh2 on the attributes of dh1 dart, except if i=j.
/// (j is the dimension of the beta modified between dh1 and dh2,
/// so that after the modification we will have beta_j(dh1)==dh2)
/// Only attributes of dh1 or dh2 can be modified. If one dart as its
/// attribute equal to null, it takes the attributes of the second dart.
/// If both attributes are non null, dh2 takes the attribute of dh1.
template<typename CMap, unsigned int i, unsigned int j=CMap::dimension+1,
typename T=
typename CMap::Helper::template Attribute_type<i>::type>
@ -283,7 +392,7 @@ namespace CGAL
typename CMap::Dart_handle dh2)
{
CGAL_static_assertion( 1<=i && i<=CMap::dimension );
CGAL_static_assertion( i!=j );
CGAL_static_assertion( i!=j && (i!=1 || j!=0) );
CGAL_static_assertion_msg(CMap::Helper::template
Dimension_index<i>::value>=0,
"Group_attribute_functor_of_dart_run<i> but "
@ -300,11 +409,13 @@ namespace CGAL
// If the two attributes are equal, nothing to do.
if ( a1==a2 ) return;
if ( a1==NULL ) amap->template set_attribute_of_dart<i>(dh1, a2);
else amap->template set_attribute_of_dart<i>(dh2, a1);
if ( a1==NULL )
Set_i_attribute_of_dart_functor<CMap, i>::run(amap, dh1, a2);
else
Set_i_attribute_of_dart_functor<CMap, i>::run(amap, dh2, a1);
}
};
// Specialization for i=0 and 2<=j.
// Specialization for i=0 and 2<=j. We modify 0-attribute for beta_j j>=2.
template<typename CMap, unsigned int j, typename T>
struct Group_attribute_functor_of_dart_run<CMap, 0, j, T>
{
@ -332,7 +443,7 @@ namespace CGAL
if ( a1==NULL && a2!=NULL )
{
amap->template set_attribute_of_dart<0>(dh1, a2);
Set_i_attribute_of_dart_functor<CMap, 0>::run(amap, dh1, a2);
}
}
@ -341,16 +452,14 @@ namespace CGAL
if ( od!=NULL )
{
a1=od->template attribute<0>();
a2=dh2->template attribute<0>();
if ( a1!=NULL )
{
amap->template set_attribute_of_dart<0>(dh2, a1);
Set_i_attribute_of_dart_functor<CMap, 0>::run(amap, dh2, a1);
}
}
}
};
// Specialization for i=0 and j=0.
// Specialization for i=0 and j=0. We modify 0-attribute for beta_0.
template<typename CMap, typename T>
struct Group_attribute_functor_of_dart_run<CMap, 0, 0, T>
{
@ -375,12 +484,12 @@ namespace CGAL
if ( a1==NULL && a2!=NULL )
{
amap->template set_attribute_of_dart<0>(dh1, a2);
Set_i_attribute_of_dart_functor<CMap, 0>::run(amap, dh1, a2);
}
}
}
};
// Specialization for i=0 and j=1.
// Specialization for i=0 and j=1. We modify 0-attribute for beta_1.
template<typename CMap, typename T>
struct Group_attribute_functor_of_dart_run<CMap, 0, 1, T>
{
@ -400,12 +509,10 @@ namespace CGAL
{
typename CMap::Helper::template Attribute_handle<0>::type
a1=od->template attribute<0>();
typename CMap::Helper::template Attribute_handle<0>::type
a2=dh2->template attribute<0>();
if ( a1!=NULL )
{
amap->template set_attribute_of_dart<0>(dh2, a1);
Set_i_attribute_of_dart_functor<CMap, 0>::run(amap, dh2, a1);
}
}
}
@ -502,10 +609,11 @@ namespace CGAL
Call_merge_functor<CMap, i>::run(a1, a2);
}
}
amap->template set_attribute<i>(toSet, a1);
Set_i_attribute_functor<CMap, i>::run(amap, toSet, a1);
}
};
// Specialization for i=0 and 2<=j.
// Specialization for i=0 and 2<=j. We update 0-attributes for beta_j j>=2.
// We need to update both extremities of the edge dh1.
template<typename CMap, unsigned int j, typename T>
struct Group_attribute_functor_run<CMap, 0, j, T>
{
@ -542,8 +650,7 @@ namespace CGAL
Call_merge_functor<CMap, 0>::run(a1, a2);
}
}
// TODO set_attribute templated by a range
amap->template set_attribute<0>(toSet, a1);
Set_i_attribute_functor<CMap, 0>::run(amap, toSet, a1);
}
}
// Second extremity
@ -564,13 +671,13 @@ namespace CGAL
Call_merge_functor<CMap, 0>::run(a1, a2);
}
}
// TODO set_attribute templated by a range
amap->template set_attribute<0>(toSet, a1);
Set_i_attribute_functor<CMap, 0>::run(amap, toSet, a1);
}
}
}
};
// Specialization for i=0 and j=0.
// Specialization for i=0 and j=0. We update 0-attributes for beta_0.
// We need to update the first extremity of the edge dh1.
template<typename CMap, typename T>
struct Group_attribute_functor_run<CMap, 0, 0, T>
{
@ -605,13 +712,13 @@ namespace CGAL
Call_merge_functor<CMap, 0>::run(a1, a2);
}
}
// TODO set_attribute templated by a range
amap->template set_attribute<0>(toSet, a1);
Set_i_attribute_functor<CMap, 0>::run(amap, toSet, a1);
}
}
}
};
// Specialization for i=0 and j=1.
// Specialization for i=0 and j=1. We update 0-attributes for beta_1.
// We need to update the second extremity of the edge dh1.
template<typename CMap, typename T>
struct Group_attribute_functor_run<CMap, 0, 1, T>
{
@ -646,8 +753,7 @@ namespace CGAL
Call_merge_functor<CMap, 0>::run(a1, a2);
}
}
// TODO set_attribute templated by a range
amap->template set_attribute<0>(toSet, a1);
Set_i_attribute_functor<CMap, 0>::run(amap, toSet, a1);
}
}
}
@ -792,8 +898,12 @@ namespace CGAL
typename CMap::Helper::template Attribute_handle<i>::type
a1=adart1->template attribute<i>();
// If the two attributes are different, nothing to do.
if ( a1!=adart2->template attribute<i>() || a1==NULL ) return;
// If there is no first attribute, nothing to degroup.
if ( a1==NULL ) return;
// If the second attribute is non null and equal to a1, nothing to do.
if ( a1!=adart2->template attribute<i>() &&
adart2->template attribute<i>()!=NULL ) return;
CGAL_assertion( (!belong_to_same_cell<CMap,i,CMap::dimension>
(*amap, adart1, adart2)) );
@ -801,7 +911,7 @@ namespace CGAL
typename CMap::Helper::template Attribute_handle<i>::type
a2 = amap->template create_attribute<i>(*a1);
amap->template set_attribute<i>(adart2, a2);
Set_i_attribute_functor<CMap, i>::run(amap, adart2, a2);
Call_split_functor<CMap, i>::run(a1, a2);
}
};
@ -863,7 +973,7 @@ namespace CGAL
for ( CMap_dart_iterator_basic_of_cell<CMap, i>
itj(*amap, adart, mark); itj.cont(); ++itj )
{
amap->template set_attribute_of_dart<i>(itj, a2);
Set_i_attribute_of_dart_functor<CMap, i>::run(amap, itj, a2);
amap->mark(itj, mark);
}
Call_split_functor<CMap, i>::run(a1, a2);
@ -941,11 +1051,6 @@ namespace CGAL
&modified_darts2,
int mark_modified_darts=-1)
{
// Normalement on utilise la version avec modified_darts2
// que dans le cas j=0
CGAL_assertion(false);
// TODO remove cette function run
CGAL_static_assertion( 1<=i && i<=CMap::dimension );
CGAL_assertion( i!=j );
CGAL_assertion( amap!=NULL );
@ -1059,11 +1164,6 @@ namespace CGAL
&modified_darts2,
int mark_modified_darts=-1)
{
// Normalement on utilise la version avec modified_darts2
// que dans le cas j=0
CGAL_assertion(false);
// TODO remove cette function run
CGAL_assertion( j!=0 && j!=1 );
CGAL_assertion( amap!=NULL );
CGAL_static_assertion_msg(CMap::Helper::template
@ -1135,9 +1235,15 @@ namespace CGAL
}
};
// Specialization for i=0 and j=0.
// For j==0 or j==1, we use only the version with two list of darts,
// modified_darts are darts modified for beta0, and
// modified_darts2 are darts modified for beta1.
template<typename CMap, typename T>
struct Test_split_attribute_functor_run<CMap, 0, 0, T>
{
static void run( CMap*, const std::deque<typename CMap::Dart_handle>&,
int =-1)
{ CGAL_assertion(false); }
static void run( CMap* amap,
const std::deque<typename CMap::Dart_handle>
&modified_darts,
@ -1205,11 +1311,14 @@ namespace CGAL
struct Test_split_attribute_functor_run<CMap, 0, 1, T>
{
static void run( CMap*, const std::deque<typename CMap::Dart_handle>&,
int=-1)
{ CGAL_assertion(false); }
static void run( CMap*, const std::deque<typename CMap::Dart_handle>&,
const std::deque<typename CMap::Dart_handle>&, int=-1)
int =-1)
{ CGAL_assertion(false); }
static void run( CMap* amap, const std::deque<typename CMap::Dart_handle>&
modified_darts,
const std::deque<typename CMap::Dart_handle>&
modified_darts2, int mark_modified_darts=-1)
{ Test_split_attribute_functor_run<CMap, 0, 0, T>::
run(amap, modified_darts, modified_darts2, mark_modified_darts); }
};
// Specialization for void attributes.
template<typename CMap, unsigned int i, unsigned int j>
@ -1246,7 +1355,6 @@ namespace CGAL
{}
};
// **************************************************************************
/// Functor used for unsew to test if i-attributes are split after an
/// operation, except for j-attributes.
/// We define run<i> to allows to use this functor with

View File

@ -0,0 +1,4 @@
#ifndef CGAL_COMBINATORIAL_MAP_GROUP_FUNCTORS_H
#define CGAL_COMBINATORIAL_MAP_GROUP_FUNCTORS_H
#endif // CGAL_COMBINATORIAL_MAP_GROUP_FUNCTORS_H

View File

@ -126,6 +126,16 @@ struct Is_sewable_functor<CMap, 0, dim>
}
};
// Specialization for i=1 and 3<dim.
template<typename CMap, unsigned int dim>
struct Is_sewable_functor<CMap, 1, dim>
{
static bool run( const CMap* amap,
typename CMap::Dart_const_handle adart1,
typename CMap::Dart_const_handle adart2 )
{ return Is_sewable_functor<CMap,0>::run(amap, adart2, adart1); }
};
// Specialization for i=0 and dim=1.
template<typename CMap>
struct Is_sewable_functor<CMap, 0, 1>

View File

@ -279,6 +279,13 @@ namespace CGAL
static void run(T...){}
};
template <class Functor,int n,class Type>
struct Conditionnal_run_except<Functor,n,n,Type>
{
template <class ... T>
static void run(T...){}
};
template <class Functor,int n>
struct Conditionnal_run_except<Functor,n,n,Void>
{
@ -377,7 +384,6 @@ namespace CGAL
template <class CMap>
struct Combinatorial_map_helper
{
// defines as type Compact_container<T>
template <class T>
struct Add_compact_container{
@ -418,19 +424,19 @@ namespace CGAL
// Number of enabled attributes
static const unsigned int nb_attribs =
Number_of_different_type_in_tuple<Void,Enabled_attributes>::value;
Number_of_different_type_in_tuple<Void,Enabled_attributes>::value;
// Given a dimension of the cell, return the index of
// corresponding attribute
template <int d>
struct Dimension_index
{ static const int value=
Nb_type_different_in_tuple_up_to_k<Void,d,Attributes>::value; };
Nb_type_different_in_tuple_up_to_k<Void,d,Attributes>::value; };
// All these type contains as many entries than the number of
// enabled attributes
typedef typename Tuple_converter
< Add_compact_container, Enabled_attributes >::type Attribute_containers;
< Add_compact_container, Enabled_attributes >::type Attribute_containers;
typedef typename Tuple_converter< Add_compact_container_iterator,
Enabled_attributes >::type
@ -450,106 +456,99 @@ namespace CGAL
struct Attribute_type
{ typedef typename CGAL::cpp11::tuple_element<d,Attributes>::type type; };
template<int d>
struct Attribute_type<d,0>
{ typedef Void type; };
template<int d>
struct Attribute_type<d,0>
{ typedef Void type; };
// Helper class allowing to retreive the d-cell-handle attribute
template<int d, class Type=typename
CGAL::cpp11::tuple_element<d,Attributes>::type>
struct Attribute_handle
{
typedef typename CGAL::cpp11::tuple_element
<Dimension_index<d>::value,Attribute_handles>::type type;
};
// Helper class allowing to retreive the d-cell-handle attribute
template<int d, class Type=typename Attribute_type<d>::type>
struct Attribute_handle
{
typedef typename CGAL::cpp11::tuple_element
<Dimension_index<d>::value,Attribute_handles>::type type;
};
template<int d>
struct Attribute_handle<d,Void>
{ typedef Void type; };
template<int d>
struct Attribute_handle<d, CGAL::Void>
{ typedef CGAL::Void* type; };
// Helper class allowing to retreive the d-cell-const handle attribute
template<int d,
class Type=typename CGAL::cpp11::tuple_element<d,Attributes>::type>
struct Attribute_const_handle
{
typedef typename CGAL::cpp11::tuple_element
<Dimension_index<d>::value, Attribute_const_handles>::type type;
};
// Helper class allowing to retreive the d-cell-const handle attribute
template<int d, class Type=typename Attribute_type<d>::type>
struct Attribute_const_handle
{
typedef typename CGAL::cpp11::tuple_element
<Dimension_index<d>::value, Attribute_const_handles>::type type;
};
template<int d>
struct Attribute_const_handle<d,Void>
{ typedef Void type; };
template<int d>
struct Attribute_const_handle<d, CGAL::Void>
{ typedef CGAL::Void* type; };
// Helper class allowing to retreive the d-cell-iterator attribute
template<int d,
class Type=typename CGAL::cpp11::tuple_element<d,Attributes>::type>
struct Attribute_iterator
{
typedef typename CGAL::cpp11::tuple_element<Dimension_index<d>::value,
Attribute_iterators>::type
type;
};
// Helper class allowing to retreive the d-cell-iterator attribute
template<int d, class Type=typename Attribute_type<d>::type>
struct Attribute_iterator
{
typedef typename CGAL::cpp11::tuple_element
<Dimension_index<d>::value, Attribute_iterators>::type type;
};
template<int d>
struct Attribute_iterator<d,Void>
{ typedef Void type; };
template<int d>
struct Attribute_iterator<d, CGAL::Void>
{ typedef CGAL::Void* type; };
// Helper class allowing to retreive the d-cell-const handle attribute
template<int d,
class Type=typename CGAL::cpp11::tuple_element<d,Attributes>::type>
struct Attribute_const_iterator
{
typedef typename CGAL::cpp11::tuple_element
<Dimension_index<d>::value, Attribute_const_iterators>::type type;
};
// Helper class allowing to retreive the d-cell-const handle attribute
template<int d, class Type=typename Attribute_type<d>::type>
struct Attribute_const_iterator
{
typedef typename CGAL::cpp11::tuple_element
<Dimension_index<d>::value, Attribute_const_iterators>::type type;
};
template<int d>
struct Attribute_const_iterator<d,Void>
{ typedef Void type; };
template<int d>
struct Attribute_const_iterator<d, CGAL::Void>
{ typedef CGAL::Void* type; };
// Helper class allowing to retreive the d-cell-attribute range
template<int d, class Type=
typename CGAL::cpp11::tuple_element<d,Attributes>::type>
struct Attribute_range
{
typedef typename CGAL::cpp11::tuple_element<Dimension_index<d>::value,
Attribute_ranges>::type type;
};
// Helper class allowing to retreive the d-cell-attribute range
template<int d, class Type=typename Attribute_type<d>::type>
struct Attribute_range
{
typedef typename CGAL::cpp11::tuple_element
<Dimension_index<d>::value, Attribute_ranges>::type type;
};
template<int d>
struct Attribute_range<d,Void>
{ typedef Void type; };
template<int d>
struct Attribute_range<d, CGAL::Void>
{ typedef CGAL::Void type; };
// Helper class allowing to retreive the d-cell-attribute range
template<int d,
class Type=typename CGAL::cpp11::tuple_element<d,Attributes>::type>
struct Attribute_const_range
{
typedef const typename CGAL::cpp11::tuple_element
<Dimension_index<d>::value, Attribute_ranges >::type type;
};
// Helper class allowing to retreive the d-cell-attribute const range
template<int d, class Type=typename Attribute_type<d>::type>
struct Attribute_const_range
{
typedef const typename CGAL::cpp11::tuple_element
<Dimension_index<d>::value, Attribute_ranges >::type type;
};
template<int d>
struct Attribute_const_range<d,Void>
{ typedef Void type; };
template<int d>
struct Attribute_const_range<d, CGAL::Void>
{ typedef CGAL::Void type; };
#ifndef CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES
// To iterate onto each enabled attributes
template <class Functor>
struct Foreach_enabled_attributes
{
template <class ...Ts>
static void run(const Ts& ... t)
{ Foreach_static_restricted<Functor,Attributes >::run(t...); }
};
// To iterate onto each enabled attributes, except j-attributes
template <class Functor, unsigned int j>
struct Foreach_enabled_attributes_except
{
template <class ...Ts>
static void run(const Ts& ... t)
{ Foreach_static_restricted_except<Functor,Attributes,j>::run(t...); }
};
// To iterate onto each enabled attributes
template <class Functor>
struct Foreach_enabled_attributes
{
template <class ...Ts>
static void run(const Ts& ... t)
{ Foreach_static_restricted<Functor,Attributes >::run(t...); }
};
// To iterate onto each enabled attributes, except j-attributes
template <class Functor, unsigned int j>
struct Foreach_enabled_attributes_except
{
template <class ...Ts>
static void run(const Ts& ... t)
{ Foreach_static_restricted_except<Functor,Attributes,j>::run(t...); }
};
#else
// This one cannot be moved in Combinatorial_map_utility_novariadic.h
// because this is an inner struct which uses inner type Attributes.

View File

@ -1068,6 +1068,45 @@ struct Conditionnal_run_except<Functor,n,n,Type>
const T6&,const T7&,const T8&,const T9&){}
};
//------------------------------------------------------------------------------
template <class Functor,int n>
struct Conditionnal_run_except<Functor,n,n,CGAL::Void>
{
static void run(){}
template<class T1>
static void run(const T1&){}
template<class T1,class T2>
static void run(const T1&,const T2&){}
template<class T1,class T2,class T3>
static void run(const T1&,const T2&,const T3&){}
template<class T1,class T2,class T3,class T4>
static void run(const T1&,const T2&,const T3&,const T4&){}
template<class T1,class T2,class T3,class T4,class T5>
static void run(const T1&,const T2&,const T3&,const T4&,const T5&){}
template<class T1,class T2,class T3,class T4,class T5,class T6>
static void run(const T1&,const T2&,const T3&,const T4&,const T5&,
const T6&){}
template<class T1,class T2,class T3,class T4,class T5,class T6,class T7>
static void run(const T1&,const T2&,const T3&,const T4&,const T5&,
const T6&,const T7&){}
template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,
class T8>
static void run(const T1&,const T2&,const T3&,const T4&,const T5&,
const T6&,const T7&,const T8&){}
template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,
class T8,class T9>
static void run(const T1&,const T2&,const T3&,const T4&,const T5&,
const T6&,const T7&,const T8&,const T9&){}
};
//------------------------------------------------------------------------------
template <class Functor,class T,int n=0>
struct Foreach_static_restricted;

View File

@ -51,7 +51,7 @@ void drawAllPoints( Map&amap )
}
template<class Map>
void test2D()
bool test2D()
{
typedef typename Map::Dart_handle Dart_handle;
@ -137,7 +137,7 @@ void test2D()
drawAllPoints(map);
// Triangulate the facet between the two triangles
insert_cell_0_in_cell_2( map, d1 );
CGAL::insert_cell_0_in_cell_2( map, d1 );
cout << "Parcours all after insert_cell_0_in_cell_2: ";
drawAllPoints(map);
@ -426,7 +426,7 @@ void test2D()
d1 = make_combinatorial_hexahedron ( map );
map.display_characteristics ( cout ) << ", valid=" << map.is_valid() << endl;
insert_cell_0_in_cell_2 ( map, d1 );
CGAL::insert_cell_0_in_cell_2 ( map, d1 );
map.display_characteristics ( cout ) << ", valid=" << map.is_valid() << endl;
std::vector<Dart_handle> V;
@ -459,7 +459,7 @@ void test2D()
d2 = map.create_dart ( Point ( 1, 0, 0 ) );
map.display_characteristics ( cout ) << ", valid=" << map.is_valid() << endl;
cout << "insert edge1: " << flush;
insert_edge ( map, d1, d2 );
CGAL::insertedge ( map, d1, d2 );
map.display_characteristics ( cout ) << ", valid=" << map.is_valid() << endl;
map.clear();*/
@ -467,14 +467,14 @@ void test2D()
map.template sew<1> ( d1, d1 );
map.display_characteristics ( cout ) << ", valid=" << map.is_valid() << endl;
cout << "insert edge2: " << flush;
insert_edge ( map, d1, d1->beta ( 2 ) );
CGAL::insertedge ( map, d1, d1->beta ( 2 ) );
map.display_characteristics ( cout ) << ", valid=" << map.is_valid() << endl;
map.clear();*/
d1 = make_combinatorial_polygon ( map,4 );
map.display_characteristics ( cout ) << ", valid=" << map.is_valid() << endl;
cout << "insert edge3: " << flush;
insert_cell_1_in_cell_2 ( map, d1, d1->beta(1)->beta(1) );
CGAL::insert_cell_1_in_cell_2 ( map, d1, d1->beta(1)->beta(1) );
map.display_characteristics ( cout ) << ", valid=" << map.is_valid() << endl;
map.clear();
@ -485,7 +485,7 @@ void test2D()
<< endl;
cout << "insert edge4: "
<< flush;
insert_cell_1_in_cell_2 ( map, d1, d1->beta(1)->beta(1) );
CGAL::insert_cell_1_in_cell_2 ( map, d1, d1->beta(1)->beta(1) );
map.display_characteristics ( cout ) << ", valid=" << map.is_valid() << endl;
map.clear();
@ -496,12 +496,14 @@ void test2D()
map.template sew<2> ( d1, d2 );
map.display_characteristics ( cout ) << ", valid=" << map.is_valid() << endl;
cout << "insert edge5: " << flush;
insert_cell_1_in_cell_2 ( map, d1, d2 );
CGAL::insert_cell_1_in_cell_2 ( map, d1, d2 );
map.display_characteristics ( cout ) << ", valid=" << map.is_valid() << endl;
map.clear();*/
cout << "***************************** TEST INSERT EDGE 2D DONE."
<< endl;
return true;
}
#endif // CGAL_COMBINATORIAL_MAP_2_TEST

View File

@ -309,7 +309,7 @@ struct InsertVertex
std::cout<<"Before: ";
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
std::cout<<"After insert_vertex "<<nb++<<" : "<<std::flush;
insert_cell_0_in_cell_1(map,d);
CGAL::insert_cell_0_in_cell_1(map,d);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
}
private:
@ -317,7 +317,7 @@ private:
};
template<class Map>
bool test3D()
bool test3D()
{
typedef typename Map::Dart_handle Dart_handle;
Dart_handle d,dh,dh2,d1,d2,d3,d4;
@ -397,7 +397,7 @@ template<class Map>
cout << "Before insert_cell_0_in_cell_2: "; ;
insert_cell_0_in_cell_2(map,d1);
CGAL::insert_cell_0_in_cell_2(map,d1);
cout << "After insert_cell_0_in_cell_2: "; ;
@ -422,7 +422,7 @@ template<class Map>
cout << "Before insert_cell_0_in_cell_2: "; ;
// Triangulate the facet between the two tetrahedra
insert_cell_0_in_cell_2(map,d1);
CGAL::insert_cell_0_in_cell_2(map,d1);
cout << "map valid: " << map.is_valid() << endl;
cout << "After insert_cell_0_in_cell_2: "; ;
@ -689,7 +689,7 @@ template<class Map>
map.template sew<3>(d1, d2);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
d3 = insert_cell_0_in_cell_2(map,d1);
d3 = CGAL::insert_cell_0_in_cell_2(map,d1);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
{
@ -776,7 +776,7 @@ template<class Map>
map.template sew<3>(d1, d2);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
d3 = insert_cell_0_in_cell_2(map,d1);
d3 = CGAL::insert_cell_0_in_cell_2(map,d1);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
{
@ -815,44 +815,44 @@ template<class Map>
std::cout<<"************************* Test different cases *************************"<<std::endl;
d1 = map.create_dart();
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert vertex1: " << flush; insert_cell_0_in_cell_1(map,d1);
cout << "insert vertex1: " << flush; CGAL::insert_cell_0_in_cell_1(map,d1);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
map.clear();
d1 = map.create_dart(); map.template sew<1>(d1, d1);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert vertex2: " << flush; insert_cell_0_in_cell_1(map,d1);
cout << "insert vertex2: " << flush; CGAL::insert_cell_0_in_cell_1(map,d1);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
map.clear();
d1 = make_edge(map);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert vertex3: " << flush; insert_cell_0_in_cell_1(map,d1);
cout << "insert vertex3: " << flush; CGAL::insert_cell_0_in_cell_1(map,d1);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
map.clear();
d1 = make_edge(map);
map.template sew<1>(d1, d1); map.template sew<1>(d1->beta(2), d1->beta(2));
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert vertex4: " << flush; insert_cell_0_in_cell_1(map,d1);
cout << "insert vertex4: " << flush; CGAL::insert_cell_0_in_cell_1(map,d1);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
map.clear();
d1 = make_edge(map);
map.template sew<1>(d1, d1);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert vertex5: " << flush; insert_cell_0_in_cell_1(map,d1);
cout << "insert vertex5: " << flush; CGAL::insert_cell_0_in_cell_1(map,d1);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
map.clear();
d1 = make_combinatorial_polygon(map,3);
d2 = d1->beta(0); d3 = d1->beta(1);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert vertex6: " << flush; insert_cell_0_in_cell_1(map,d1);
cout << "insert vertex6: " << flush; CGAL::insert_cell_0_in_cell_1(map,d1);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert vertex7: " << flush; insert_cell_0_in_cell_1(map,d2);
cout << "insert vertex7: " << flush; CGAL::insert_cell_0_in_cell_1(map,d2);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert vertex8: " << flush; insert_cell_0_in_cell_1(map,d3);
cout << "insert vertex8: " << flush; CGAL::insert_cell_0_in_cell_1(map,d3);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
map.clear();
@ -860,11 +860,11 @@ template<class Map>
d2 = make_combinatorial_polygon(map,3);
map.template sew<3>(d1, d2); d2 = d1->beta(0); d3 = d1->beta(1);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert vertex9: " << flush; insert_cell_0_in_cell_1(map,d1);
cout << "insert vertex9: " << flush; CGAL::insert_cell_0_in_cell_1(map,d1);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert vertex10: " << flush; insert_cell_0_in_cell_1(map,d2);
cout << "insert vertex10: " << flush; CGAL::insert_cell_0_in_cell_1(map,d2);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert vertex11: " << flush; insert_cell_0_in_cell_1(map,d3);
cout << "insert vertex11: " << flush; CGAL::insert_cell_0_in_cell_1(map,d3);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
map.clear();
@ -872,7 +872,7 @@ template<class Map>
d2 = make_combinatorial_polygon(map,3);
map.template sew<2>(d1, d2);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert vertex12: " << flush; insert_cell_0_in_cell_1(map,d1);
cout << "insert vertex12: " << flush; CGAL::insert_cell_0_in_cell_1(map,d1);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
map.clear();
@ -880,9 +880,9 @@ template<class Map>
d2 = make_combinatorial_polygon(map,3);
map.template sew<2>(d1, d2);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert vertex13: " << flush; insert_cell_0_in_cell_1(map,d1->beta(1));
cout << "insert vertex13: " << flush; CGAL::insert_cell_0_in_cell_1(map,d1->beta(1));
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert vertex14: " << flush; insert_cell_0_in_cell_1(map,d1);
cout << "insert vertex14: " << flush; CGAL::insert_cell_0_in_cell_1(map,d1);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
map.clear();
@ -891,13 +891,13 @@ template<class Map>
map.template sew<3>(d1, d2);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert vertex15: " << flush; insert_cell_0_in_cell_1(map,d1->beta(1)->beta(1));
cout << "insert vertex15: " << flush; CGAL::insert_cell_0_in_cell_1(map,d1->beta(1)->beta(1));
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert vertex16: " << flush; insert_cell_0_in_cell_1(map,d1->beta(1));
cout << "insert vertex16: " << flush; CGAL::insert_cell_0_in_cell_1(map,d1->beta(1));
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert vertex17: " << flush; insert_cell_0_in_cell_1(map,d1->beta(0));
cout << "insert vertex17: " << flush; CGAL::insert_cell_0_in_cell_1(map,d1->beta(0));
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert vertex18: " << flush; insert_cell_0_in_cell_1(map,d1);
cout << "insert vertex18: " << flush; CGAL::insert_cell_0_in_cell_1(map,d1);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
map.clear();
@ -910,28 +910,30 @@ template<class Map>
/* d1 = map.create_dart();
d2 = map.create_dart();
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert edge1: " << flush; insert_cell_1_in_cell_2(map,d1, d2);
cout << "insert edge1: " << flush; CGAL::insert_cell_1_in_cell_2(map,d1, d2);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
map.clear();*/
/* d1 = make_edge(map,, );
map.template sew<1>(d1, d1);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert edge2: " << flush; insert_cell_1_in_cell_2(map,d1, d1->beta(2));
cout << "insert edge2: " << flush; CGAL::insert_cell_1_in_cell_2(map,d1, d1->beta(2));
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
map.clear();*/
d1 = make_edge(map);
d2 = make_edge(map);
map.template sew<3>(d1, d2); map.template sew<3>(d1->beta(2), d2->beta(2)); map.template sew<1>(d1, d1);
map.template sew<3>(d1, d2);
map.template sew<3>(d1->beta(2), d2->beta(2));
map.template sew<1>(d1, d1);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
/* cout << "insert edge3: " << flush; insert_cell_1_in_cell_2(map,d1, d1);
/* cout << "insert edge3: " << flush; CGAL::insert_cell_1_in_cell_2(map,d1, d1);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;*/
map.clear();
d1 = make_combinatorial_polygon(map,4 );
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert edge4: " << flush; insert_cell_1_in_cell_2(map,d1, d1->beta(1)->beta(1));
cout << "insert edge4: " << flush; CGAL::insert_cell_1_in_cell_2(map,d1, d1->beta(1)->beta(1));
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
map.clear();
@ -939,7 +941,7 @@ template<class Map>
d2 = make_combinatorial_polygon(map,4);
map.template sew<3>(d1, d2);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert edge5: " << flush; insert_cell_1_in_cell_2(map,d1, d1->beta(1)->beta(1));
cout << "insert edge5: " << flush; CGAL::insert_cell_1_in_cell_2(map,d1, d1->beta(1)->beta(1));
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
map.clear();
@ -947,7 +949,7 @@ template<class Map>
d2 = make_combinatorial_polygon(map,4);
map.template sew<2>(d1, d2);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert edge6: " << flush; insert_cell_1_in_cell_2(map,d1, d1->beta(1)->beta(1));
cout << "insert edge6: " << flush; CGAL::insert_cell_1_in_cell_2(map,d1, d1->beta(1)->beta(1));
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
map.clear();
map.clear();
@ -960,14 +962,14 @@ template<class Map>
d1 = map.create_dart();
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert dangling edge1: " << flush; insert_dangling_cell_1_in_cell_2(map,d1);
cout << "insert dangling edge1: " << flush; CGAL::insert_dangling_cell_1_in_cell_2(map,d1);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
map.clear();
d1 = make_edge(map);
map.template sew<1>(d1, d1);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert dangling edge2: " << flush; insert_dangling_cell_1_in_cell_2(map,d1);
cout << "insert dangling edge2: " << flush; CGAL::insert_dangling_cell_1_in_cell_2(map,d1);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
map.clear();
@ -975,13 +977,13 @@ template<class Map>
d2 = make_edge(map);
map.template sew<3>(d1, d2); map.template sew<3>(d1->beta(2), d2->beta(2)); map.template sew<1>(d1, d1);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert dangling edge3: " << flush; insert_dangling_cell_1_in_cell_2(map,d1);
cout << "insert dangling edge3: " << flush; CGAL::insert_dangling_cell_1_in_cell_2(map,d1);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
map.clear();
d1 = make_combinatorial_polygon(map,4);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert dangling edge4: " << flush; insert_dangling_cell_1_in_cell_2(map,d1);
cout << "insert dangling edge4: " << flush; CGAL::insert_dangling_cell_1_in_cell_2(map,d1);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
map.clear();
@ -989,7 +991,7 @@ template<class Map>
d2 = make_combinatorial_polygon(map,4);
map.template sew<3>(d1, d2);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert dangling edge5: " << flush; insert_dangling_cell_1_in_cell_2(map,d1);
cout << "insert dangling edge5: " << flush; CGAL::insert_dangling_cell_1_in_cell_2(map,d1);
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
map.clear();
@ -1005,7 +1007,7 @@ template<class Map>
v.push_back(d1); v.push_back(v[0]->beta(1));
v.push_back(v[1]->beta(1)); v.push_back(v[2]->beta(1));
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert facet1: " << flush; insert_cell_2_in_cell_3(map,v.begin(),v.end());
cout << "insert facet1: " << flush; CGAL::insert_cell_2_in_cell_3(map,v.begin(),v.end());
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
map.clear(); v.clear();
@ -1014,7 +1016,7 @@ template<class Map>
map.template sew<2>(d1, d2);
v.push_back(d1); v.push_back(v[0]->beta(1)); v.push_back(v[1]->beta(1));
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
cout << "insert facet2: " << flush; insert_cell_2_in_cell_3(map,v.begin(),v.end());
cout << "insert facet2: " << flush; CGAL::insert_cell_2_in_cell_3(map,v.begin(),v.end());
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
map.clear(); v.clear();
@ -1025,7 +1027,7 @@ template<class Map>
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
v.push_back(d2); v.push_back(v[0]->beta(1)->beta(2)->beta(1));
v.push_back(v[1]->beta(1)->beta(2)->beta(1)); v.push_back(v[2]->beta(1)->beta(2)->beta(1));
cout << "insert facet3: " << flush; insert_cell_2_in_cell_3(map,v.begin(),v.end());
cout << "insert facet3: " << flush; CGAL::insert_cell_2_in_cell_3(map,v.begin(),v.end());
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
map.clear(); v.clear();
@ -1040,7 +1042,7 @@ template<class Map>
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
v.push_back(d3); v.push_back(v[0]->beta(1)->beta(2)->beta(1));
v.push_back(v[1]->beta(1)->beta(2)->beta(1)); v.push_back(v[2]->beta(1)->beta(2)->beta(1));
cout << "insert facet4: " << flush; insert_cell_2_in_cell_3(map,v.begin(),v.end());
cout << "insert facet4: " << flush; CGAL::insert_cell_2_in_cell_3(map,v.begin(),v.end());
map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl;
map.clear(); v.clear();

View File

@ -74,19 +74,31 @@ int main()
{
typedef CGAL::Combinatorial_map<2,
CGAL::Combinatorial_map_min_items<2> > Map1;
test2D<Map1>();
if ( !test2D<Map1>() )
{
std::cout<<"ERROR during test2D<Map1>."<<std::endl;
return EXIT_FAILURE;
}
typedef CGAL::Combinatorial_map<2, Map_2_dart_max_items_3 > Map2;
test2D<Map2>();
if ( !test2D<Map2>() )
{
std::cout<<"ERROR during test2D<Map2>."<<std::endl;
return EXIT_FAILURE;
}
typedef CGAL::Combinatorial_map<2, Map_2_dart_max_items_3> Map3;
test2D<Map3>();
if ( !test2D<Map3>() )
{
std::cout<<"ERROR during test2D<Map3>."<<std::endl;
return EXIT_FAILURE;
}
typedef CGAL::Combinatorial_map<3,
CGAL::Combinatorial_map_min_items<3> > Map4;
if ( !test3D<Map4>() )
{
std::cout<<"ERROR during Test_LCC_4<LCC4b>."<<std::endl;
std::cout<<"ERROR during test3D<Map4>."<<std::endl;
return EXIT_FAILURE;
}

View File

@ -160,7 +160,7 @@ namespace CGAL {
Dart_handle create_dart(Vertex_attribute_handle ahandle)
{
Dart_handle res = create_dart();
this->template set_attribute_of_dart<0>(res,ahandle);
set_vertex_attribute_of_dart(res,ahandle);
return res;
}
@ -183,7 +183,10 @@ namespace CGAL {
*/
void set_vertex_attribute_of_dart(Dart_handle adart,
Vertex_attribute_handle ah)
{ return Base::template set_attribute_of_dart<0>(adart,ah); }
{
return internal::Set_i_attribute_of_dart_functor<Self, 0>::
run(this, adart,ah);
}
/** Set the vertex attribute of all the darts of the vertex.
* @param adart a dart of the vertex.
@ -191,7 +194,7 @@ namespace CGAL {
*/
void set_vertex_attribute(Dart_handle adart,
Vertex_attribute_handle ah)
{ return Base::template set_attribute<0>(adart,ah); }
{ return internal::Set_i_attribute_functor<Self, 0>::run(this, adart,ah); }
/// @return the Vertex_attribute_range for all vertex_attributes.
Vertex_attribute_range& vertex_attributes()
@ -631,10 +634,8 @@ namespace CGAL {
*/
Dart_handle insert_point_in_cell_1(Dart_handle dh, const Point& p)
{
Vertex_attribute_handle v=create_vertex_attribute(p);
Dart_handle res = CGAL::insert_cell_0_in_cell_1(*this, dh);
set_vertex_attribute(res, v);
return res;
return CGAL::insert_cell_0_in_cell_1(*this, dh,
create_vertex_attribute(p));
}
/** Insert a point in a given 2-cell.
@ -646,13 +647,13 @@ namespace CGAL {
{
Vertex_attribute_handle v = create_vertex_attribute(p);
Dart_handle first = CGAL::insert_cell_0_in_cell_2(*this, dh);
Dart_handle first = CGAL::insert_cell_0_in_cell_2(*this, dh, v);
if (first != NULL) // If the triangulated facet was not made of one dart
set_vertex_attribute(first, v);
else
if ( first== NULL ) // If the triangulated facet was made of one dart
erase_vertex_attribute(v);
CGAL_assertion( is_valid() );
return first;
}
@ -676,10 +677,8 @@ namespace CGAL {
*/
Dart_handle insert_dangling_cell_1_in_cell_2(Dart_handle dh, const Point& p)
{
Vertex_attribute_handle v = create_vertex_attribute(p);
Dart_handle res = CGAL::insert_dangling_cell_1_in_cell_2(*this, dh);
set_vertex_attribute(res, v);
return res;
return CGAL::insert_dangling_cell_1_in_cell_2
(*this, dh, create_vertex_attribute(p));
}
/** Insert a point in a given i-cell.