diff --git a/Combinatorial_map/include/CGAL/Cell_attribute.h b/Combinatorial_map/include/CGAL/Cell_attribute.h index 19e17583223..647f5c6258e 100644 --- a/Combinatorial_map/include/CGAL/Cell_attribute.h +++ b/Combinatorial_map/include/CGAL/Cell_attribute.h @@ -86,6 +86,9 @@ namespace CGAL { template friend class Compact_container; + template + friend struct internal::Decrease_attribute_functor_run; + public: typedef Tag_false Supports_cell_dart; @@ -182,6 +185,9 @@ namespace CGAL { template friend class Compact_container; + template + friend struct internal::Decrease_attribute_functor_run; + public: typedef Tag_true Supports_cell_dart; diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map.h b/Combinatorial_map/include/CGAL/Combinatorial_map.h index ecaa92b0c0f..6e1d0ad5ad1 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map.h @@ -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 + , + 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 + >::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 , 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 , 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 + , i>:: + run(this,adart1,adart2); adart1->template basic_link_beta(adart2); adart2->template basic_link_beta(adart1); - Helper::template Foreach_enabled_attributes_except - , 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 dartv; - for ( CMap_dart_iterator_basic_of_cell it(*this,adart1,m); - it.cont(); ++it) + if ( adart1==adart2 ) { - mark(it,m); - dartv.push_back(it); + for ( CMap_dart_iterator_of_involution it(*this, adart1); + it.cont(); ++it ) + { + basic_link_beta_1(it, it); + } } - - CMap_dart_iterator_of_involution I1(*this, adart1); - CMap_dart_iterator_of_involution_inv 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 dartv; + for ( CMap_dart_iterator_basic_of_cell it(*this,adart1,m); + it.cont(); ++it) + { + mark(it,m); + dartv.push_back(it); + } - for ( typename std::deque::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 I1(*this, adart1); + CMap_dart_iterator_of_involution_inv 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::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 it(*this, adart1); + it.cont(); ++it ) + { + basic_link_beta_1(it, it); + } + return; + } + int m = get_new_mark(); std::deque dartv; for ( CMap_dart_iterator_basic_of_cell 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 it(*this, adart1); + it.cont(); ++it ) + { + basic_link_beta_1(it, it); + } + return; + } + int m = get_new_mark(); std::deque dartv; for ( CMap_dart_iterator_basic_of_cell 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 , 1>:: @@ -1553,7 +1610,7 @@ namespace CGAL { for ( ; I1.cont(); ++I1, ++I2 ) { Helper::template Foreach_enabled_attributes_except - , 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()); unlink_beta_for_involution(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 - void decrease_attribute_ref_counting(Dart_handle adart) - { - CGAL_static_assertion_msg(Helper::template Dimension_index::value>=0, - "decrease_attribute_ref_counting but " - "i-attributes are disabled"); - if ( adart->template attribute()!=NULL ) - { - adart->template attribute()->dec_nb_refs(); - if ( adart->template attribute()->get_nb_refs()==0 ) - erase_attribute(adart->template attribute()); - } - } - 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 " - <get_nb_refs()<<" for dart " <<&*adart<(); } //-------------------------------------------------------------------------- - /** Set the i th attribute of the given dart. - * @param adart a dart. - * @param ah the attribute to set. - */ - template - void set_attribute_of_dart(Dart_handle adart, - typename Attribute_handle::type ah) - { - CGAL_static_assertion(i<=dimension); - CGAL_static_assertion_msg(Helper::template Dimension_index::value>=0, - "set_attribute_of_dart but " - "i-attributes are disabled"); - CGAL_assertion( adart!=NULL && adart!=null_dart_handle && ah!=NULL ); - - if ( adart->template attribute()==ah ) return; - - decrease_attribute_ref_counting(adart); - adart->template set_attribute(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 - void set_attribute(Dart_handle adart, - typename Attribute_handle::type ah) - { - CGAL_static_assertion(i<=dimension); - CGAL_static_assertion_msg(Helper::template Dimension_index::value>=0, - "set_attribute but i-attributes are disabled"); - CGAL_assertion( adart!=NULL && adart!=null_dart_handle && ah!=NULL ); - for ( typename Dart_of_cell_range::iterator it(*this, adart); - it.cont(); ++it) - { - if ( it->template attribute()!=ah ) - { - decrease_attribute_ref_counting(it); - it->template set_attribute(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 - void set_attribute(Dart_handle adart, - typename Attribute_handle::type ah) - { - CGAL_static_assertion(i<=dimension); - CGAL_static_assertion_msg(Helper::template Dimension_index::value>=0, - "set_attribute 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()!=ah ) - { - decrease_attribute_ref_counting(it); - it->template set_attribute(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()-> + template beta()!=null_dart_handle ) + amap.basic_link_beta_1(d, dual[it->template beta()-> + template beta()]); // 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()->beta(i)!=null_dart_handle ) + amap.basic_link_beta(d, dual[it->template beta()-> + beta(i)], dimension-i); } - if ( d->is_free(dimension) ) + if ( d->template is_free() ) { - CGAL_assertion ( !it->is_free(dimension) ); - amap.link_beta(d, dual[it->beta(dimension)],dimension); + CGAL_assertion ( !it->template is_free() ); + amap.basic_link_beta(d, dual[it->template beta()], + dimension); } } diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_insertions.h b/Combinatorial_map/include/CGAL/Combinatorial_map_insertions.h index 67e14648dfd..ce632f93884 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_insertions.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_insertions.h @@ -13,19 +13,21 @@ namespace CGAL { */ template 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 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::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:: 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 tounmark; // Now we run through the facet - for (CGAL::CMap_dart_iterator_basic_of_orbit it(amap,first); - it.cont();) + for ( CGAL::CMap_dart_iterator_basic_of_orbit 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 - - (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::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:: + 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:: + 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 c=tosplit.top(); - tosplit.pop(); - internal::Call_split_functor::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 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 it1(amap,adart1); + CGAL::CMap_dart_iterator_of_involution 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::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:: run(&amap, first, first->template beta<3>()); + } - // CGAL_expensive_postcondition( amap.is_valid() ); + CGAL_assertion( amap.is_valid() ); return first; } diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h b/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h index 05632564998..1622f3a9cd6 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h @@ -109,6 +109,14 @@ namespace CGAL { amap.update_dart_of_all_attributes(*it, mark); std::deque modified_darts; + std::deque 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 &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(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(); 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 - , i>:: - run(&amap, modified_darts, mark_modified_darts); + if ( i==1 ) + CMap::Helper::template Foreach_enabled_attributes_except + , i>:: + run(&amap, modified_darts, modified_darts2, + mark_modified_darts); + else + CMap::Helper::template Foreach_enabled_attributes_except + , 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:: + 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() ) { - d1->unlink_beta(i); + d1->template unlink_beta(); 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(); 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(); 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:: + internal::Group_attribute_functor_run:: 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>(); } } diff --git a/Combinatorial_map/include/CGAL/Dart.h b/Combinatorial_map/include/CGAL/Dart.h index b219a46f459..0af7239ea26 100644 --- a/Combinatorial_map/include/CGAL/Dart.h +++ b/Combinatorial_map/include/CGAL/Dart.h @@ -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& amarks) : mmarks(amarks) - { - for (unsigned int i = 0; i <= dimension; ++i) - mbeta[i] = Refs::null_dart_handle; - - Helper::template Foreach_enabled_attributes:: - 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=0 && (size_type)amark 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& 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& amarks) : mmarks(amarks) + { + for (unsigned int i = 0; i <= dimension; ++i) + mbeta[i] = Refs::null_dart_handle; + + Helper::template Foreach_enabled_attributes:: + 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=0 && (size_type)amark 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& amarks) const + { mmarks = amarks; } + /// Functor used to initialize all attributes to NULL. struct Init_attribute_functor { diff --git a/Combinatorial_map/include/CGAL/internal/Combinatorial_map_functors.h b/Combinatorial_map/include/CGAL/internal/Combinatorial_map_functors.h index ee1646e9bad..a25c23f0c73 100644 --- a/Combinatorial_map/include/CGAL/internal/Combinatorial_map_functors.h +++ b/Combinatorial_map/include/CGAL/internal/Combinatorial_map_functors.h @@ -57,6 +57,12 @@ * Beta_functor_static to call several beta on the given dart. * Indices are given as template arguments. * + * Set_i_attribute_of_dart_functor to set the i-attribute of a given + * dart. + + * Set_i_attribute_functor to set the i-attribute of a given + * i-cell. + * * Group_attribute_functor_of_dart to group the -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 + struct Display_attribute_functor + { + template + static void run(const CMap* amap, + typename CMap::Dart_const_handle adart) + { + if ( adart->template attribute()==NULL ) + std::cout<<"NULL"; + else + std::cout<<&*(adart->template attribute()); + } + }; + // ************************************************************************** /// Functor for counting i-cell template 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::type> + struct Decrease_attribute_functor_run + { + static void run(CMap* amap, typename CMap::Dart_handle adart) + { + if ( adart->template attribute()!=NULL ) + { + adart->template attribute()->dec_nb_refs(); + if ( adart->template attribute()->get_nb_refs()==0 ) + amap->template erase_attribute(adart->template attribute()); + } + } + }; + /// Specialization for void attributes. + template + struct Decrease_attribute_functor_run + { + static void run(CMap*, typename CMap::Dart_handle) + {} + }; + // ************************************************************************** /// Functor used to call decrease_attribute_ref_counting /// on each i-cell attribute enabled template @@ -264,14 +309,78 @@ namespace CGAL { template static void run(CMap* amap, typename CMap::Dart_handle adart) - { amap->template decrease_attribute_ref_counting(adart); } + { Decrease_attribute_functor_run::run(amap, adart); } + }; + // ************************************************************************** + /// Functor used to set the i-attribute of a given dart. + template::type> + struct Set_i_attribute_of_dart_functor + { + static void run( CMap* amap, typename CMap::Dart_handle dh, + typename CMap::Helper::template Attribute_handle::type + ah ) + { + CGAL_static_assertion(i<=CMap::dimension); + CGAL_assertion( dh!=NULL && dh!=CMap::null_dart_handle ); + + if ( dh->template attribute()==ah ) return; + + Decrease_attribute_functor_run::run(amap, dh); + dh->template set_attribute(ah); + } + }; + /// Specialization for void attributes. + template + struct Set_i_attribute_of_dart_functor + { + static void run( CMap*, typename CMap::Dart_handle, + typename CMap::Helper::template Attribute_handle::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 + template, + typename T=typename CMap::Helper::template Attribute_type::type> + struct Set_i_attribute_functor + { + static void run( CMap* amap, typename CMap::Dart_handle dh, + typename CMap::Helper::template Attribute_handle::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()!=ah ) + { + Decrease_attribute_functor_run::run(amap, it); + it->template set_attribute(ah); + } + } + ah->set_dart(dh); + } + }; + /// Specialization for void attributes. + template + struct Set_i_attribute_functor + { + static void run( CMap*, typename CMap::Dart_handle, + typename CMap::Helper::template Attribute_handle::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::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::value>=0, "Group_attribute_functor_of_dart_run 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(dh1, a2); - else amap->template set_attribute_of_dart(dh2, a1); + if ( a1==NULL ) + Set_i_attribute_of_dart_functor::run(amap, dh1, a2); + else + Set_i_attribute_of_dart_functor::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 struct Group_attribute_functor_of_dart_run { @@ -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::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::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 struct Group_attribute_functor_of_dart_run { @@ -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::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 struct Group_attribute_functor_of_dart_run { @@ -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::run(amap, dh2, a1); } } } @@ -502,10 +609,11 @@ namespace CGAL Call_merge_functor::run(a1, a2); } } - amap->template set_attribute(toSet, a1); + Set_i_attribute_functor::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 struct Group_attribute_functor_run { @@ -542,8 +650,7 @@ namespace CGAL Call_merge_functor::run(a1, a2); } } - // TODO set_attribute templated by a range - amap->template set_attribute<0>(toSet, a1); + Set_i_attribute_functor::run(amap, toSet, a1); } } // Second extremity @@ -564,13 +671,13 @@ namespace CGAL Call_merge_functor::run(a1, a2); } } - // TODO set_attribute templated by a range - amap->template set_attribute<0>(toSet, a1); + Set_i_attribute_functor::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 struct Group_attribute_functor_run { @@ -605,13 +712,13 @@ namespace CGAL Call_merge_functor::run(a1, a2); } } - // TODO set_attribute templated by a range - amap->template set_attribute<0>(toSet, a1); + Set_i_attribute_functor::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 struct Group_attribute_functor_run { @@ -646,8 +753,7 @@ namespace CGAL Call_merge_functor::run(a1, a2); } } - // TODO set_attribute templated by a range - amap->template set_attribute<0>(toSet, a1); + Set_i_attribute_functor::run(amap, toSet, a1); } } } @@ -792,8 +898,12 @@ namespace CGAL typename CMap::Helper::template Attribute_handle::type a1=adart1->template attribute(); - // If the two attributes are different, nothing to do. - if ( a1!=adart2->template attribute() || 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() && + adart2->template attribute()!=NULL ) return; CGAL_assertion( (!belong_to_same_cell (*amap, adart1, adart2)) ); @@ -801,7 +911,7 @@ namespace CGAL typename CMap::Helper::template Attribute_handle::type a2 = amap->template create_attribute(*a1); - amap->template set_attribute(adart2, a2); + Set_i_attribute_functor::run(amap, adart2, a2); Call_split_functor::run(a1, a2); } }; @@ -863,7 +973,7 @@ namespace CGAL for ( CMap_dart_iterator_basic_of_cell itj(*amap, adart, mark); itj.cont(); ++itj ) { - amap->template set_attribute_of_dart(itj, a2); + Set_i_attribute_of_dart_functor::run(amap, itj, a2); amap->mark(itj, mark); } Call_split_functor::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 struct Test_split_attribute_functor_run { + static void run( CMap*, const std::deque&, + int =-1) + { CGAL_assertion(false); } static void run( CMap* amap, const std::deque &modified_darts, @@ -1205,11 +1311,14 @@ namespace CGAL struct Test_split_attribute_functor_run { static void run( CMap*, const std::deque&, - int=-1) - { CGAL_assertion(false); } - static void run( CMap*, const std::deque&, - const std::deque&, int=-1) + int =-1) { CGAL_assertion(false); } + static void run( CMap* amap, const std::deque& + modified_darts, + const std::deque& + modified_darts2, int mark_modified_darts=-1) + { Test_split_attribute_functor_run:: + run(amap, modified_darts, modified_darts2, mark_modified_darts); } }; // Specialization for void attributes. template @@ -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 to allows to use this functor with diff --git a/Combinatorial_map/include/CGAL/internal/Combinatorial_map_group_functors.h b/Combinatorial_map/include/CGAL/internal/Combinatorial_map_group_functors.h new file mode 100644 index 00000000000..3bc2a769f4c --- /dev/null +++ b/Combinatorial_map/include/CGAL/internal/Combinatorial_map_group_functors.h @@ -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 diff --git a/Combinatorial_map/include/CGAL/internal/Combinatorial_map_sewable.h b/Combinatorial_map/include/CGAL/internal/Combinatorial_map_sewable.h index 57334ff0d5a..2d0c41714c9 100644 --- a/Combinatorial_map/include/CGAL/internal/Combinatorial_map_sewable.h +++ b/Combinatorial_map/include/CGAL/internal/Combinatorial_map_sewable.h @@ -126,6 +126,16 @@ struct Is_sewable_functor } }; +// Specialization for i=1 and 3 +struct Is_sewable_functor +{ + static bool run( const CMap* amap, + typename CMap::Dart_const_handle adart1, + typename CMap::Dart_const_handle adart2 ) + { return Is_sewable_functor::run(amap, adart2, adart1); } +}; + // Specialization for i=0 and dim=1. template struct Is_sewable_functor diff --git a/Combinatorial_map/include/CGAL/internal/Combinatorial_map_utility.h b/Combinatorial_map/include/CGAL/internal/Combinatorial_map_utility.h index 6051a9717b1..770a0fb329e 100644 --- a/Combinatorial_map/include/CGAL/internal/Combinatorial_map_utility.h +++ b/Combinatorial_map/include/CGAL/internal/Combinatorial_map_utility.h @@ -279,6 +279,13 @@ namespace CGAL static void run(T...){} }; + template + struct Conditionnal_run_except + { + template + static void run(T...){} + }; + template struct Conditionnal_run_except { @@ -377,7 +384,6 @@ namespace CGAL template struct Combinatorial_map_helper { - // defines as type Compact_container template 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::value; + Number_of_different_type_in_tuple::value; // Given a dimension of the cell, return the index of // corresponding attribute template struct Dimension_index { static const int value= - Nb_type_different_in_tuple_up_to_k::value; }; + Nb_type_different_in_tuple_up_to_k::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::type type; }; - template - struct Attribute_type - { typedef Void type; }; + template + struct Attribute_type + { typedef Void type; }; - // Helper class allowing to retreive the d-cell-handle attribute - template::type> - struct Attribute_handle - { - typedef typename CGAL::cpp11::tuple_element - ::value,Attribute_handles>::type type; - }; + // Helper class allowing to retreive the d-cell-handle attribute + template::type> + struct Attribute_handle + { + typedef typename CGAL::cpp11::tuple_element + ::value,Attribute_handles>::type type; + }; - template - struct Attribute_handle - { typedef Void type; }; + template + struct Attribute_handle + { typedef CGAL::Void* type; }; - // Helper class allowing to retreive the d-cell-const handle attribute - template::type> - struct Attribute_const_handle - { - typedef typename CGAL::cpp11::tuple_element - ::value, Attribute_const_handles>::type type; - }; + // Helper class allowing to retreive the d-cell-const handle attribute + template::type> + struct Attribute_const_handle + { + typedef typename CGAL::cpp11::tuple_element + ::value, Attribute_const_handles>::type type; + }; - template - struct Attribute_const_handle - { typedef Void type; }; + template + struct Attribute_const_handle + { typedef CGAL::Void* type; }; - // Helper class allowing to retreive the d-cell-iterator attribute - template::type> - struct Attribute_iterator - { - typedef typename CGAL::cpp11::tuple_element::value, - Attribute_iterators>::type - type; - }; + // Helper class allowing to retreive the d-cell-iterator attribute + template::type> + struct Attribute_iterator + { + typedef typename CGAL::cpp11::tuple_element + ::value, Attribute_iterators>::type type; + }; - template - struct Attribute_iterator - { typedef Void type; }; + template + struct Attribute_iterator + { typedef CGAL::Void* type; }; - // Helper class allowing to retreive the d-cell-const handle attribute - template::type> - struct Attribute_const_iterator - { - typedef typename CGAL::cpp11::tuple_element - ::value, Attribute_const_iterators>::type type; - }; + // Helper class allowing to retreive the d-cell-const handle attribute + template::type> + struct Attribute_const_iterator + { + typedef typename CGAL::cpp11::tuple_element + ::value, Attribute_const_iterators>::type type; + }; - template - struct Attribute_const_iterator - { typedef Void type; }; + template + struct Attribute_const_iterator + { typedef CGAL::Void* type; }; - // Helper class allowing to retreive the d-cell-attribute range - template::type> - struct Attribute_range - { - typedef typename CGAL::cpp11::tuple_element::value, - Attribute_ranges>::type type; - }; + // Helper class allowing to retreive the d-cell-attribute range + template::type> + struct Attribute_range + { + typedef typename CGAL::cpp11::tuple_element + ::value, Attribute_ranges>::type type; + }; - template - struct Attribute_range - { typedef Void type; }; + template + struct Attribute_range + { typedef CGAL::Void type; }; - // Helper class allowing to retreive the d-cell-attribute range - template::type> - struct Attribute_const_range - { - typedef const typename CGAL::cpp11::tuple_element - ::value, Attribute_ranges >::type type; - }; + // Helper class allowing to retreive the d-cell-attribute const range + template::type> + struct Attribute_const_range + { + typedef const typename CGAL::cpp11::tuple_element + ::value, Attribute_ranges >::type type; + }; - template - struct Attribute_const_range - { typedef Void type; }; + template + struct Attribute_const_range + { typedef CGAL::Void type; }; #ifndef CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES - // To iterate onto each enabled attributes - template - struct Foreach_enabled_attributes - { - template - static void run(const Ts& ... t) - { Foreach_static_restricted::run(t...); } - }; - // To iterate onto each enabled attributes, except j-attributes - template - struct Foreach_enabled_attributes_except - { - template - static void run(const Ts& ... t) - { Foreach_static_restricted_except::run(t...); } - }; + // To iterate onto each enabled attributes + template + struct Foreach_enabled_attributes + { + template + static void run(const Ts& ... t) + { Foreach_static_restricted::run(t...); } + }; + // To iterate onto each enabled attributes, except j-attributes + template + struct Foreach_enabled_attributes_except + { + template + static void run(const Ts& ... t) + { Foreach_static_restricted_except::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. diff --git a/Combinatorial_map/include/CGAL/internal/Combinatorial_map_utility_novariadic.h b/Combinatorial_map/include/CGAL/internal/Combinatorial_map_utility_novariadic.h index 838c81acc62..ddd857123bb 100644 --- a/Combinatorial_map/include/CGAL/internal/Combinatorial_map_utility_novariadic.h +++ b/Combinatorial_map/include/CGAL/internal/Combinatorial_map_utility_novariadic.h @@ -1068,6 +1068,45 @@ struct Conditionnal_run_except const T6&,const T7&,const T8&,const T9&){} }; //------------------------------------------------------------------------------ +template +struct Conditionnal_run_except +{ + static void run(){} + + template + static void run(const T1&){} + + template + static void run(const T1&,const T2&){} + + template + static void run(const T1&,const T2&,const T3&){} + + template + static void run(const T1&,const T2&,const T3&,const T4&){} + + template + static void run(const T1&,const T2&,const T3&,const T4&,const T5&){} + + template + static void run(const T1&,const T2&,const T3&,const T4&,const T5&, + const T6&){} + + template + static void run(const T1&,const T2&,const T3&,const T4&,const T5&, + const T6&,const T7&){} + + template + static void run(const T1&,const T2&,const T3&,const T4&,const T5&, + const T6&,const T7&,const T8&){} + + template + static void run(const T1&,const T2&,const T3&,const T4&,const T5&, + const T6&,const T7&,const T8&,const T9&){} +}; +//------------------------------------------------------------------------------ template struct Foreach_static_restricted; diff --git a/Combinatorial_map/test/Combinatorial_map/Combinatorial_map_2_test.h b/Combinatorial_map/test/Combinatorial_map/Combinatorial_map_2_test.h index 9b4ec1a37db..2ade396c3cc 100644 --- a/Combinatorial_map/test/Combinatorial_map/Combinatorial_map_2_test.h +++ b/Combinatorial_map/test/Combinatorial_map/Combinatorial_map_2_test.h @@ -51,7 +51,7 @@ void drawAllPoints( Map&amap ) } template -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 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 diff --git a/Combinatorial_map/test/Combinatorial_map/Combinatorial_map_3_test.h b/Combinatorial_map/test/Combinatorial_map/Combinatorial_map_3_test.h index 3a7b399742d..1cab8f9bbb9 100644 --- a/Combinatorial_map/test/Combinatorial_map/Combinatorial_map_3_test.h +++ b/Combinatorial_map/test/Combinatorial_map/Combinatorial_map_3_test.h @@ -309,7 +309,7 @@ struct InsertVertex std::cout<<"Before: "; map.display_characteristics(cout) << ", valid=" << map.is_valid() << endl; std::cout<<"After insert_vertex "< 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 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 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 std::cout<<"************************* Test different cases *************************"<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 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 /* 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 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 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 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 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 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 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 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 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 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(); diff --git a/Combinatorial_map/test/Combinatorial_map/Combinatorial_map_test.cpp b/Combinatorial_map/test/Combinatorial_map/Combinatorial_map_test.cpp index d9f3a81e8d5..32da220bc6f 100644 --- a/Combinatorial_map/test/Combinatorial_map/Combinatorial_map_test.cpp +++ b/Combinatorial_map/test/Combinatorial_map/Combinatorial_map_test.cpp @@ -74,19 +74,31 @@ int main() { typedef CGAL::Combinatorial_map<2, CGAL::Combinatorial_map_min_items<2> > Map1; - test2D(); - + if ( !test2D() ) + { + std::cout<<"ERROR during test2D."< Map2; - test2D(); + if ( !test2D() ) + { + std::cout<<"ERROR during test2D."< Map3; - test2D(); + if ( !test2D() ) + { + std::cout<<"ERROR during test2D."< > Map4; if ( !test3D() ) { - std::cout<<"ERROR during Test_LCC_4."<."<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:: + 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::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.