diff --git a/Combinatorial_map/include/CGAL/Cell_attribute.h b/Combinatorial_map/include/CGAL/Cell_attribute.h index 713a2775c44..2a810e67d07 100644 --- a/Combinatorial_map/include/CGAL/Cell_attribute.h +++ b/Combinatorial_map/include/CGAL/Cell_attribute.h @@ -110,10 +110,10 @@ namespace CGAL { } /// Get the dart associated with the cell. - Dart_handle dart() { return NULL; } + Dart_handle dart() { return Refs::null_handle; } /// Get the dart associated with the cell. - Dart_const_handle dart() const { return NULL; } + Dart_const_handle dart() const { return Refs::null_handle; } /// Set the dart associated with the cell. void set_dart(Dart_handle) {} @@ -234,7 +234,7 @@ namespace CGAL { /// Test if the cell is valid. /// A cell is valid if its dart is not NULL. bool is_valid() const - { return mdart!=NULL; } + { return mdart!=Refs::null_handle; } bool operator==(const Cell_attribute_without_info&) const { return true; } @@ -244,7 +244,7 @@ namespace CGAL { // protected: /// Contructor without parameter. - Cell_attribute_without_info() : mdart(NULL), + Cell_attribute_without_info() : mdart(Refs::null_handle), mrefcounting(0) {} diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map.h b/Combinatorial_map/include/CGAL/Combinatorial_map.h index d5c5832c56d..4b20274e0f1 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map.h @@ -96,7 +96,9 @@ namespace CGAL { static const size_type NB_MARKS = Base::NB_MARKS; static const unsigned int dimension = Base::dimension; - static const typename Base::Null_handle_type null_handle; + + typedef typename Base::Null_handle_type Null_handle_type; + static Null_handle_type null_handle; using Base::null_dart_handle; using Base::mdarts; @@ -2100,7 +2102,7 @@ namespace CGAL { */ void topo_unsew_1(Dart_handle adart) { - CGAL_assertion( adart!=NULL && !adart->template is_free<1>() ); + CGAL_assertion( !is_free<1>(adart) ); int m = get_new_mark(); std::deque dartv; @@ -2133,7 +2135,7 @@ namespace CGAL { */ void topo_unsew_0(Dart_handle adart) { - CGAL_assertion( adart!=NULL && !adart->template is_free<0>() ); + CGAL_assertion( !is_free<0>(adart) ); topo_unsew_1( adart->template beta<0>() ); } @@ -2147,7 +2149,7 @@ namespace CGAL { template void topo_unsew_for_involution(Dart_handle adart) { - CGAL_assertion( adart!=NULL && !adart->template is_free() ); + CGAL_assertion( !is_free(adart) ); CGAL_assertion( 2<=i && i<=Self::dimension ); for ( CGAL::CMap_dart_iterator_of_involution it(*this, adart); @@ -3209,9 +3211,9 @@ namespace CGAL { Dart_basic_range(Self &amap) : mmap(amap) {} iterator begin() { return iterator(mmap); } - iterator end() { return iterator(mmap,NULL); } + iterator end() { return iterator(mmap,mmap.null_handle); } const_iterator begin() const { return const_iterator(mmap); } - const_iterator end() const { return const_iterator(mmap,NULL); } + const_iterator end() const { return const_iterator(mmap,mmap.null_handle); } size_type size() { return mmap.number_of_darts(); } bool empty() const @@ -3226,7 +3228,7 @@ namespace CGAL { Dart_basic_const_range(Self &amap) : mmap(amap) {} const_iterator begin() const { return const_iterator(mmap); } - const_iterator end() const { return const_iterator(mmap,NULL); } + const_iterator end() const { return const_iterator(mmap,mmap.null_handle); } size_type size() const { return mmap.number_of_darts(); } bool empty() const @@ -3281,9 +3283,9 @@ namespace CGAL { One_dart_per_cell_range(Self &amap) : mmap(amap), msize(0) {} iterator begin() { return iterator(mmap); } - iterator end() { return iterator(mmap,NULL); } + iterator end() { return iterator(mmap,mmap.null_handle); } const_iterator begin() const { return const_iterator(mmap); } - const_iterator end() const { return const_iterator(mmap,NULL); } + const_iterator end() const { return const_iterator(mmap,mmap.null_handle); } size_type size() { if (msize==0) @@ -3306,7 +3308,7 @@ namespace CGAL { One_dart_per_cell_const_range(const Self &amap) : mmap(amap), msize(0) {} const_iterator begin() const { return const_iterator(mmap); } - const_iterator end() const { return const_iterator(mmap,NULL); } + const_iterator end() const { return const_iterator(mmap,mmap.null_handle); } size_type size() { if (msize==0) @@ -3371,13 +3373,13 @@ namespace CGAL { * simultaneously through all the darts of the two maps and we have * each time of the iteration two "dual" darts. */ - Dart_handle dual(Self& amap, Dart_handle adart=NULL) + Dart_handle dual(Self& amap, Dart_handle adart=null_handle) { CGAL_assertion( is_without_boundary(dimension) ); CGAL::Unique_hash_map< Dart_handle, Dart_handle, typename Self::Hash_function > dual; - Dart_handle d, d2, res = NULL; + Dart_handle d, d2, res = amap.null_handle; // We clear amap. TODO return a new amap ? amap.clear(); @@ -3387,7 +3389,7 @@ namespace CGAL { it!=darts().end(); ++it) { dual[it] = amap.create_dart(); - if ( it==adart && res==NULL ) res = dual[it]; + if ( it==adart && res==amap.null_handle ) res = dual[it]; } // Then we link the darts by using the dual formula : @@ -3422,7 +3424,7 @@ namespace CGAL { // CGAL_postcondition(amap2.is_valid()); - if ( res==NULL ) res = amap.darts().begin(); + if ( res==amap.null_handle ) res = amap.darts().begin(); return res; } @@ -3669,7 +3671,7 @@ namespace CGAL { template < unsigned int d_, class Refs, class Items_, class Alloc_, class Storage_ > - const typename Combinatorial_map_base:: + typename Combinatorial_map_base:: Base::Null_handle_type Combinatorial_map_base::null_handle = Combinatorial_map_base::Base::null_handle; diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_constructors.h b/Combinatorial_map/include/CGAL/Combinatorial_map_constructors.h index db31b5075f5..e1b0bf54b87 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_constructors.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_constructors.h @@ -78,7 +78,6 @@ bool is_face_combinatorial_polygon(const Map& amap, unsigned int alg) { CGAL_assertion(alg>0); - CGAL_assertion(adart!=NULL); unsigned int nb = 0; typename Map::Dart_const_handle cur = adart; @@ -127,8 +126,6 @@ template < class Map > bool is_volume_combinatorial_tetrahedron(const Map& amap, typename Map::Dart_const_handle d1) { - CGAL_assertion(d1!=NULL); - typename Map::Dart_const_handle d2 = amap.beta(d1, 2); typename Map::Dart_const_handle d3 = amap.beta(d2, 0, 2); typename Map::Dart_const_handle d4 = amap.beta(d2, 1, 2); @@ -232,8 +229,6 @@ template < class Map > bool is_volume_combinatorial_hexahedron(const Map& amap, typename Map::Dart_const_handle d1) { - CGAL_assertion(d1!=NULL); - typename Map::Dart_const_handle d2 = amap.beta(d1, 1, 1, 2); typename Map::Dart_const_handle d3 = amap.beta(d2, 1, 1, 2); typename Map::Dart_const_handle d4 = amap.beta(d3, 1, 1, 2); diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_insertions.h b/Combinatorial_map/include/CGAL/Combinatorial_map_insertions.h index 2267f0265e5..360466c83c8 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_insertions.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_insertions.h @@ -35,7 +35,7 @@ template typename CMap::Dart_handle insert_cell_0_in_cell_1( CMap& amap, typename CMap::Dart_handle adart, typename CMap::template - Attribute_handle<0>::type ah=NULL ) + Attribute_handle<0>::type ah=CMap::null_handle ) { typename CMap::Dart_handle d1, d2; int mark=amap.get_new_mark(); @@ -112,14 +112,14 @@ template < class CMap > typename CMap::Dart_handle insert_cell_0_in_cell_2( CMap& amap, typename CMap::Dart_handle adart, typename CMap::template - Attribute_handle<0>::type ah=NULL ) + Attribute_handle<0>::type ah=CMap::null_handle ) { - CGAL_assertion(adart != NULL && adart!=amap.null_dart_handle); + CGAL_assertion(adart!=amap.null_dart_handle); - typename CMap::Dart_handle first=adart, prev=NULL, cur=NULL; - typename CMap::Dart_handle next=NULL, n1=NULL, n2=NULL; - - typename CMap::Dart_handle nn1 = NULL, nn2 = NULL; + typename CMap::Dart_handle first=adart, prev=amap.null_handle, + cur=amap.null_handle, next=amap.null_handle, + n1=amap.null_handle, n2=amap.null_handle, + nn1=amap.null_handle, nn2=amap.null_handle; // If the facet is open, we search the dart 0-free while ( !amap.template is_free<0>(first) && @@ -145,21 +145,21 @@ insert_cell_0_in_cell_2( CMap& amap, typename CMap::Dart_handle adart, n1=amap.create_dart(); amap.link_beta_0(cur, n1); } - else n1 = NULL; + else n1 = amap.null_handle; if (!amap.template is_free<1>(cur)) { n2 = amap.create_dart(); amap.link_beta_1(cur, n2); } - else n2 = NULL; + else n2 = amap.null_handle; - if ( n1!=NULL ) + if ( n1!=amap.null_handle ) { - if ( n2!=NULL ) + if ( n2!=amap.null_handle ) amap.basic_link_beta_0(n1, n2); - if ( prev!=NULL ) + if ( prev!=amap.null_handle ) amap.template basic_link_beta_for_involution<2>(prev, n1); CGAL::internal::Set_i_attribute_of_dart_functor:: @@ -172,15 +172,15 @@ insert_cell_0_in_cell_2( CMap& amap, typename CMap::Dart_handle adart, { if ( !amap.is_marked(amap.beta(cur, dim), treated) ) { - if (n1!=NULL) + if (n1!=amap.null_handle) { nn1=amap.create_dart(); amap.link_beta_1(amap.beta(cur, dim), nn1); amap.basic_link_beta_for_involution(n1, nn1, dim); } - else nn1=NULL; + else nn1=amap.null_handle; - if (n2!=NULL) + if (n2!=amap.null_handle) { nn2=amap.create_dart(); amap.link_beta_0(amap.beta(cur, dim), nn2); @@ -188,12 +188,12 @@ insert_cell_0_in_cell_2( CMap& amap, typename CMap::Dart_handle adart, CGAL::internal::Set_i_attribute_of_dart_functor:: run(&amap, nn2, ah); } - else nn2=NULL; + else nn2=amap.null_handle; - if (nn1 != NULL && nn2 != NULL) + if (nn1 != amap.null_handle && nn2 != amap.null_handle) amap.basic_link_beta_1(nn1, nn2); - if (nn1 != NULL && prev != NULL) + if (nn1 != amap.null_handle && prev != amap.null_handle) amap.template basic_link_beta_for_involution<2> (nn1, amap.beta(prev, dim)); @@ -201,10 +201,10 @@ insert_cell_0_in_cell_2( CMap& amap, typename CMap::Dart_handle adart, } else { - if ( n1!=NULL ) + if ( n1!=amap.null_handle ) amap.basic_link_beta_for_involution(n1, amap.beta(cur, dim, 1), dim); - if ( n2!=NULL ) + if ( n2!=amap.null_handle ) amap.basic_link_beta_for_involution(n2, amap.beta(cur, dim, 0), dim); } @@ -216,7 +216,7 @@ insert_cell_0_in_cell_2( CMap& amap, typename CMap::Dart_handle adart, } while(cur!=first && cur!=amap.null_dart_handle); - if (n2 != NULL) + if (n2 != amap.null_handle) { amap.template basic_link_beta_for_involution<2> (amap.template beta<0>(first), n2); @@ -265,7 +265,7 @@ typename CMap::Dart_handle insert_dangling_cell_1_in_cell_2( CMap& amap, typename CMap::Dart_handle adart1, typename CMap::template - Attribute_handle<0>::type ah=NULL ) + Attribute_handle<0>::type ah=CMap::null_handle ) { int mark1 = amap.get_new_mark(); std::deque to_unmark; @@ -278,8 +278,8 @@ insert_dangling_cell_1_in_cell_2( CMap& amap, } } - typename CMap::Dart_handle d1 = NULL; - typename CMap::Dart_handle d2 = NULL; + typename CMap::Dart_handle d1 = amap.null_handle; + typename CMap::Dart_handle d2 = amap.null_handle; unsigned int s1 = 0; int treated=amap.get_new_mark(); @@ -386,7 +386,7 @@ insert_cell_1_in_cell_2(CMap& amap, typename CMap::Dart_handle adart1, typename CMap::Dart_handle adart2) { - if ( adart2==NULL ) return insert_dangling_cell_1_in_cell_2(amap,adart1); + if ( adart2==amap.null_handle ) return insert_dangling_cell_1_in_cell_2(amap,adart1); CGAL_assertion(is_insertable_cell_1_in_cell_2(amap, adart1, adart2)); @@ -407,8 +407,8 @@ insert_cell_1_in_cell_2(CMap& amap, } } - typename CMap::Dart_handle d1=NULL; - typename CMap::Dart_handle d2=NULL; + typename CMap::Dart_handle d1=amap.null_handle; + typename CMap::Dart_handle d2=amap.null_handle; unsigned int s1=0; int treated=amap.get_new_mark(); @@ -511,20 +511,20 @@ bool is_insertable_cell_2_in_cell_3(const CMap& amap, // The path must have at least one dart. if (afirst==alast) return false; - typename CMap::Dart_const_handle prec = NULL; - typename CMap::Dart_const_handle od = NULL; + typename CMap::Dart_const_handle prec = amap.null_handle; + typename CMap::Dart_const_handle od = amap.null_handle; for (InputIterator it(afirst); it!=alast; ++it) { // The path must contain only non empty darts. - if (*it == NULL || *it==amap.null_dart_handle) return false; + if (*it == amap.null_handle || *it==amap.null_dart_handle) return false; // Two consecutive darts of the path must belong to two edges // incident to the same vertex of the same volume. - if (prec != NULL) + if (prec != amap.null_handle) { od = amap.other_extremity(prec); - if ( od==NULL ) return false; + if ( od==amap.null_handle ) return false; // of and *it must belong to the same vertex of the same volume if ( !CGAL::belong_to_same_cell(amap, od, *it) ) @@ -535,7 +535,7 @@ bool is_insertable_cell_2_in_cell_3(const CMap& amap, // The path must be closed. od = amap.other_extremity(prec); - if ( od==NULL ) return false; + if ( od==amap.null_handle ) return false; if (!CGAL::belong_to_same_cell(amap, od, *afirst)) return false; @@ -555,7 +555,8 @@ insert_cell_2_in_cell_3(CMap& amap, InputIterator afirst, InputIterator alast) { CGAL_assertion(is_insertable_cell_2_in_cell_3(amap,afirst,alast)); - typename CMap::Dart_handle prec = NULL, d = NULL, dd = NULL, first = NULL; + typename CMap::Dart_handle prec = amap.null_handle, d = amap.null_handle, + dd = amap.null_handle, first = amap.null_handle; bool withBeta3 = false; { @@ -572,7 +573,7 @@ insert_cell_2_in_cell_3(CMap& amap, InputIterator afirst, InputIterator alast) if ( withBeta3 ) dd = amap.create_dart(); - if (prec != NULL) + if (prec != amap.null_handle) { amap.basic_link_beta_0(prec, d); if (withBeta3) @@ -604,8 +605,8 @@ insert_cell_2_in_cell_3(CMap& amap, InputIterator afirst, InputIterator alast) { if ( !amap.is_free(first, dim) ) { - typename CMap::Dart_handle first2 = NULL; - prec = NULL; + typename CMap::Dart_handle first2 = amap.null_handle; + prec = amap.null_handle; for ( CMap_dart_iterator_basic_of_orbit it(amap, first); it.cont(); ++it ) { @@ -618,7 +619,7 @@ insert_cell_2_in_cell_3(CMap& amap, InputIterator afirst, InputIterator alast) (amap.template beta<2,3>(it), dd, dim); amap.template basic_link_beta_for_involution<3>(d, dd); } - if ( prec!=NULL ) + if ( prec!=amap.null_handle ) { amap.link_beta_0(prec, d); if ( withBeta3 ) diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_iterators_base.h b/Combinatorial_map/include/CGAL/Combinatorial_map_iterators_base.h index 12e8fcd9aae..5f94af54381 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_iterators_base.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_iterators_base.h @@ -206,7 +206,7 @@ namespace CGAL { mmark_number(amark), minitial_dart(adart) { - if ( minitial_dart!=NULL ) + if ( minitial_dart!=amap.null_handle ) { this->mmap->mark_null_dart(mmark_number); this->mmap->mark(minitial_dart, mmark_number); @@ -320,7 +320,7 @@ namespace CGAL { CMap_extend_iterator(Map& amap, Dart_handle adart, int amark): Base(amap, adart, amark) { - if ( this->minitial_dart!=NULL && + if ( this->minitial_dart!=amap.null_handle && !this->mmap->is_free(this->minitial_dart, Bi) && this->mmap->beta(this->minitial_dart, Bi)!=this->minitial_dart ) { @@ -492,9 +492,9 @@ namespace CGAL { mmap(amap), mdart(adart), msize(0) {} iterator begin() { return iterator(mmap,mdart); } - iterator end() { return iterator(mmap,NULL); } + iterator end() { return iterator(mmap,mmap.null_handle); } const_iterator begin() const { return const_iterator(mmap,mdart); } - const_iterator end() const { return const_iterator(mmap,NULL); } + const_iterator end() const { return const_iterator(mmap,mmap.null_handle); } typename Map_::size_type size() { if (msize==0) @@ -520,9 +520,9 @@ namespace CGAL { mmap(amap), mdart(adart), msize(0), mmark(amark) {} iterator begin() { return iterator(mmap,mdart,mmark); } - iterator end() { return iterator(mmap,NULL,mmark); } + iterator end() { return iterator(mmap,mmap.null_handle,mmark); } const_iterator begin() const { return const_iterator(mmap,mdart,mmark); } - const_iterator end() const { return const_iterator(mmap,NULL,mmark); } + const_iterator end() const { return const_iterator(mmap,mmap.null_handle,mmark); } typename Map_::size_type size() { if (msize==0) @@ -549,7 +549,7 @@ namespace CGAL { mmap(amap), mdart(adart), msize(0) {} const_iterator begin() const { return const_iterator(mmap,mdart); } - const_iterator end() const { return const_iterator(mmap,NULL); } + const_iterator end() const { return const_iterator(mmap,mmap.null_handle); } typename Map_::size_type size() { if (msize==0) @@ -574,7 +574,7 @@ namespace CGAL { mmap(amap), mdart(adart), msize(0), mmark(amark) {} const_iterator begin() const { return const_iterator(mmap,mdart,mmark); } - const_iterator end() const { return const_iterator(mmap,NULL,mmark); } + const_iterator end() const { return const_iterator(mmap,mmap.null_handle,mmark); } typename Map_::size_type size() { if (msize==0) diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h b/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h index 67a0096ba34..2c73b27e7af 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h @@ -95,7 +95,7 @@ namespace CGAL size_t res = 0; typename CMap::Dart_handle d1, d2; - typename CMap::Dart_handle dg1=NULL, dg2=NULL; + typename CMap::Dart_handle dg1=amap.null_handle, dg2=amap.null_handle; int mark = amap.get_new_mark(); int mark_modified_darts = amap.get_new_mark(); @@ -109,14 +109,14 @@ namespace CGAL it.cont(); ++it ) { to_erase.push_back(it); - if ( !amap.template is_free(it) && dg1==NULL ) + if ( !amap.template is_free(it) && dg1==amap.null_handle ) { dg1=it; dg2=amap.template beta(it); } amap.mark(it, mark); ++res; } // We group the two (i+1)-cells incident if they exist. - if ( dg1!=NULL ) + if ( dg1!=amap.null_handle ) CGAL::internal::Group_attribute_functor_run:: run(&amap, dg1, dg2); @@ -334,7 +334,7 @@ namespace CGAL size_t res = 0; typename CMap::Dart_handle d1, d2; - typename CMap::Dart_handle dg1=NULL, dg2=NULL; + typename CMap::Dart_handle dg1=amap.null_handle, dg2=amap.null_handle; int mark = amap.get_new_mark(); // int mark_modified_darts = amap.get_new_mark(); @@ -345,14 +345,14 @@ namespace CGAL it.cont(); ++it ) { to_erase.push_back(it); - if ( !amap.template is_free<0>(it) && dg1==NULL ) + if ( !amap.template is_free<0>(it) && dg1==amap.null_handle ) { dg1=it; dg2=amap.template beta<0>(it); } amap.mark(it, mark); ++res; } // We group the two edges incident if they exist. - if ( dg1!=NULL ) + if ( dg1!=amap.null_handle ) CGAL::internal::Group_attribute_functor_run:: run(&amap, dg1, dg2); @@ -507,7 +507,7 @@ namespace CGAL size_t res = 0; typename CMap::Dart_handle d1, d2; - typename CMap::Dart_handle dg1=NULL, dg2=NULL; + typename CMap::Dart_handle dg1=amap.null_handle, dg2=amap.null_handle; int mark = amap.get_new_mark(); int mark_modified_darts = amap.get_new_mark(); @@ -520,14 +520,14 @@ namespace CGAL it.cont(); ++it ) { to_erase.push_back(it); - if ( !amap.template is_free(it) && dg1==NULL ) + if ( !amap.template is_free(it) && dg1==amap.null_handle ) { dg1=it; dg2=amap.template beta(it); } amap.mark(it, mark); ++res; } // We group the two (i+1)-cells incident if they exist. - if ( dg1!=NULL ) + if ( dg1!=amap.null_handle ) CGAL::internal::Group_attribute_functor_run:: run(&amap, dg1, dg2); @@ -656,7 +656,7 @@ namespace CGAL size_t res = 0; typename CMap::Dart_handle d1, d2; - typename CMap::Dart_handle dg1=NULL, dg2=NULL; + typename CMap::Dart_handle dg1=amap.null_handle, dg2=amap.null_handle; int mark = amap.get_new_mark(); // int mark_modified_darts = amap.get_new_mark(); @@ -667,7 +667,7 @@ namespace CGAL it.cont(); ++it ) { to_erase.push_back(it); - if ( dg1==NULL && !amap.template is_free<0>(it) && + if ( dg1==amap.null_handle && !amap.template is_free<0>(it) && !amap.template is_free<1>(it) ) { dg1=amap.template beta<0>(it); dg2=amap.template beta<1>(it); } amap.mark(it, mark); @@ -675,7 +675,7 @@ namespace CGAL } // We group the two vertices incident if they exist. - if ( dg1!=NULL ) + if ( dg1!=amap.null_handle ) CGAL::internal::Group_attribute_functor_run:: run(&amap, dg1, dg2); diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_storages.h b/Combinatorial_map/include/CGAL/Combinatorial_map_storages.h index 4ed0bb92a06..9edfb54c45d 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_storages.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_storages.h @@ -58,6 +58,9 @@ namespace CGAL { typedef typename Dart_container::const_iterator Dart_const_handle; typedef typename Dart_container::size_type size_type; + typedef CGAL::Void* Null_handle_type; + static Null_handle_type null_handle; + typedef Items_ Items; typedef Alloc_ Alloc; @@ -396,6 +399,11 @@ namespace CGAL { typename Helper::Attribute_containers mattribute_containers; }; + /// null_handle + template < unsigned int d_, class Items_, class Alloc_ > + typename Combinatorial_map_storage_1::Null_handle_type + Combinatorial_map_storage_1::null_handle = NULL; + #ifdef CGAL_CMAP_DEPRECATED /// Allocation of static data members /// mnull_dart_container diff --git a/Combinatorial_map/include/CGAL/Dart.h b/Combinatorial_map/include/CGAL/Dart.h index a69216995fa..fb420306afc 100644 --- a/Combinatorial_map/include/CGAL/Dart.h +++ b/Combinatorial_map/include/CGAL/Dart.h @@ -263,17 +263,6 @@ namespace CGAL { (mattribute_handles); } - /// Set the handle on the i th attribute - template - void set_attribute( typename Attribute_handle::type ahandle ) - { - CGAL_static_assertion_msg(Helper::template Dimension_index::value>=0, - "set_attribute called but i-attributes are disabled."); - CGAL::cpp11::get::value> - (mattribute_handles) = ahandle; - if (ahandle!=NULL) ahandle->inc_nb_refs(); - } - /** Return the mark value of a given mark number. * @param amark the mark number. * @return the value for this number. diff --git a/Combinatorial_map/include/CGAL/Dart_iterators.h b/Combinatorial_map/include/CGAL/Dart_iterators.h index 4f7fa122fe4..4385e7baa5d 100644 --- a/Combinatorial_map/include/CGAL/Dart_iterators.h +++ b/Combinatorial_map/include/CGAL/Dart_iterators.h @@ -166,7 +166,7 @@ namespace CGAL { Self& operator++() { CGAL_assertion(this->cont()); - this->set_current_dart(NULL); + this->set_current_dart(this->mmap->null_handle); this->mprev_op = OP_END; return *this; } @@ -248,7 +248,7 @@ namespace CGAL { if ((*this)==this->mfirst_dart) { - this->set_current_dart(NULL); + this->set_current_dart(this->mmap->null_handle); this->mprev_op = OP_END; } } @@ -256,7 +256,7 @@ namespace CGAL { { if (this->mmap->is_free(*this, 1)) { - this->set_current_dart(NULL); + this->set_current_dart(this->mmap->null_handle); this->mprev_op = OP_END; } else @@ -338,7 +338,7 @@ namespace CGAL { if ((*this)==this->mfirst_dart) { - this->set_current_dart(NULL); + this->set_current_dart(this->mmap->null_handle); this->mprev_op = OP_END; } } @@ -346,7 +346,7 @@ namespace CGAL { { if (this->mmap->is_free(*this, 0)) { - this->set_current_dart(NULL); + this->set_current_dart(this->mmap->null_handle); this->mprev_op = OP_END; } else @@ -402,7 +402,7 @@ namespace CGAL { CGAL_assertion(this->cont()); if ((*this)!=this->mfirst_dart || this->mmap->is_free(*this, Bi)) { - this->set_current_dart(NULL); + this->set_current_dart(this->mmap->null_handle); this->mprev_op = OP_END; } else @@ -485,7 +485,7 @@ namespace CGAL { else { this->mprev_op = OP_END; - this->set_current_dart(NULL); + this->set_current_dart(this->mmap->null_handle); } } } @@ -500,7 +500,7 @@ namespace CGAL { else { this->mprev_op = OP_END; - this->set_current_dart(NULL); + this->set_current_dart(this->mmap->null_handle); } } else if (mcurdart==2) @@ -514,7 +514,7 @@ namespace CGAL { { CGAL_assertion (mcurdart==3); this->mprev_op = OP_END; - this->set_current_dart(NULL); + this->set_current_dart(this->mmap->null_handle); } return *this; @@ -623,7 +623,7 @@ namespace CGAL { mexist_betaj(false), mprev_betaj(false), mfirst_border(true) - { if (adart!=NULL) + { if (adart!=this->mmap->null_handle) mexist_betaj=!this->mmap->is_free(adart, delta); } /// Main constructor. @@ -634,7 +634,7 @@ namespace CGAL { mexist_betaj(false), mprev_betaj(false), mfirst_border(true) - { if (adart!=NULL) + { if (adart!=this->mmap->null_handle) mexist_betaj=!this->mmap->is_free(adart, delta); } /// Prefix ++ operator. @@ -654,7 +654,7 @@ namespace CGAL { ++mit; this->mprev_op = mit.prev_operation(); if ( !mit.cont() ) - this->set_current_dart(NULL); + this->set_current_dart(this->mmap->null_handle); else { if ( !mfirst_border ) @@ -723,7 +723,7 @@ namespace CGAL { mexist_betaj(false), mprev_betaj(false), mfirst_border(true) - { if (adart!=NULL) + { if (adart!=this->mmap->null_handle) mexist_betaj=!this->mmap->is_free(adart, 1+delta); } /// Main constructor. @@ -734,7 +734,7 @@ namespace CGAL { mexist_betaj(false), mprev_betaj(false), mfirst_border(true) - { if (adart!=NULL) + { if (adart!=this->mmap->null_handle) mexist_betaj=!this->mmap->is_free(adart, 1+delta); } /// Prefix ++ operator. @@ -754,7 +754,7 @@ namespace CGAL { ++mit; this->mprev_op = mit.prev_operation(); if ( !mit.cont() ) - this->set_current_dart(NULL); + this->set_current_dart(this->mmap->null_handle); else { if ( !mfirst_border ) @@ -854,7 +854,7 @@ namespace CGAL { if (this->mmap->is_free(this->mfirst_dart, Bi+1)) { this->mprev_op = OP_END; - this->set_current_dart(NULL); + this->set_current_dart(this->mmap->null_handle); } else { @@ -877,7 +877,7 @@ namespace CGAL { if (this->mmap->is_free(this->mfirst_dart, Bi+1)) { this->mprev_op = OP_END; - this->set_current_dart(NULL); + this->set_current_dart(this->mmap->null_handle); } else { @@ -892,7 +892,7 @@ namespace CGAL { if ((*this)==this->mfirst_dart) { this->mprev_op = OP_END; - this->set_current_dart(NULL); + this->set_current_dart(this->mmap->null_handle); } else { @@ -909,7 +909,7 @@ namespace CGAL { if (this->mmap->is_free(*this, Bi)) { this->mprev_op = OP_END; - this->set_current_dart(NULL); + this->set_current_dart(this->mmap->null_handle); } else { @@ -923,7 +923,7 @@ namespace CGAL { if (this->mmap->is_free(*this, Bi+1)) { this->mprev_op = OP_END; - this->set_current_dart(NULL); + this->set_current_dart(this->mmap->null_handle); } else { @@ -1137,7 +1137,7 @@ namespace CGAL { { this->mprev_op = OP_POP; } else { - this->set_current_dart(NULL); + this->set_current_dart(this->mmap->null_handle); this->mprev_op = OP_END; } return *this; @@ -1176,7 +1176,7 @@ namespace CGAL { Base(amap, adart), mmark_number(amark) { - if (adart!=NULL) + if (adart!=this->mmap->null_handle) { this->mmap->mark_null_dart(mmark_number); this->mmap->mark(adart, mmark_number); @@ -1198,13 +1198,13 @@ namespace CGAL { { CGAL_assertion(mmark_number != -1); CGAL_assertion(this->cont()); - Dart_handle nd = NULL; + Dart_handle nd = this->mmap->null_handle; for ( unsigned int k=0; kis_unmarked((*this), k, mmark_number) ) { - if (nd == NULL) + if (nd == this->mmap->null_handle) { nd = this->mmap->beta(*this, k); CGAL_assertion(nd!=this->mmap->null_dart_handle); @@ -1221,7 +1221,7 @@ namespace CGAL { { if ( this->is_unmarked((*this), k, mmark_number) ) { - if (nd == NULL) + if (nd == this->mmap->null_handle) { nd = this->mmap->beta(*this, k); CGAL_assertion(nd!=this->mmap->null_dart_handle); @@ -1235,7 +1235,7 @@ namespace CGAL { } } - if (nd == NULL) + if (nd == this->mmap->null_handle) { if (!mto_treat.empty()) { @@ -1246,7 +1246,7 @@ namespace CGAL { else { this->mprev_op = OP_END; - this->set_current_dart(NULL); + this->set_current_dart(this->mmap->null_handle); } } @@ -1288,7 +1288,7 @@ namespace CGAL { Base(amap, adart), mmark_number(amark) { - if (adart!=NULL) + if (adart!=this->mmap->null_handle) { this->mmap->mark(adart, mmark_number); this->mmap->mark_null_dart(mmark_number); @@ -1311,13 +1311,13 @@ namespace CGAL { CGAL_assertion(mmark_number != -1); CGAL_assertion(this->cont()); - Dart_handle nd = NULL; + Dart_handle nd = this->mmap->null_handle; for ( unsigned int k=2; k<=d; ++k ) { if ( this->is_unmarked((*this), k, mmark_number) ) { - if (nd == NULL) + if (nd == this->mmap->null_handle) { nd = this->mmap->beta(*this, k); CGAL_assertion(nd!=this->mmap->null_dart_handle); @@ -1331,7 +1331,7 @@ namespace CGAL { } } - if (nd == NULL) + if (nd == this->mmap->null_handle) { if (!mto_treat.empty()) { @@ -1343,7 +1343,7 @@ namespace CGAL { else { this->mprev_op = OP_END; - this->set_current_dart(NULL); + this->set_current_dart(this->mmap->null_handle); } } @@ -1384,7 +1384,7 @@ namespace CGAL { int amark): Base(amap, adart), mmark_number(amark) - { if (adart!=NULL) + { if (adart!=this->mmap->null_handle) { this->mmap->mark(adart, mmark_number); this->mmap->mark_null_dart(mmark_number); @@ -1407,13 +1407,13 @@ namespace CGAL { CGAL_assertion(mmark_number != -1); CGAL_assertion(this->cont()); - Dart_handle nd = NULL; + Dart_handle nd = this->mmap->null_handle; for ( unsigned int k=2; k<=d; ++k ) { if ( this->is_unmarked2((*this), 0, k, mmark_number) ) { - if (nd == NULL) + if (nd == this->mmap->null_handle) { nd = this->mmap->beta(*this, 0, k); CGAL_assertion(nd!=this->mmap->null_dart_handle); @@ -1427,7 +1427,7 @@ namespace CGAL { } if ( this->is_unmarked2((*this), k, 1, mmark_number) ) { - if (nd == NULL) + if (nd == this->mmap->null_handle) { nd = this->mmap->beta(*this, k, 1); CGAL_assertion(nd!=this->mmap->null_dart_handle); @@ -1443,7 +1443,7 @@ namespace CGAL { { if ( this->is_unmarked2((*this), k, l, mmark_number) ) { - if (nd == NULL) + if (nd == this->mmap->null_handle) { nd = this->mmap->beta(*this, k, l); CGAL_assertion(nd!=this->mmap->null_dart_handle); @@ -1457,7 +1457,7 @@ namespace CGAL { } if ( this->is_unmarked2((*this), l, k, mmark_number) ) { - if (nd == NULL) + if (nd == this->mmap->null_handle) { nd = this->mmap->beta(*this, l, k); CGAL_assertion(nd!=this->mmap->null_dart_handle); @@ -1472,7 +1472,7 @@ namespace CGAL { } } - if (nd == NULL) + if (nd == this->mmap->null_handle) { if (!mto_treat.empty()) { @@ -1484,7 +1484,7 @@ namespace CGAL { else { this->mprev_op = OP_END; - this->set_current_dart(NULL); + this->set_current_dart(this->mmap->null_handle); } } @@ -1720,7 +1720,7 @@ namespace CGAL { if ((*this)==this->mmap->null_dart_handle) { this->mprev_op = OP_END; - this->set_current_dart(NULL); + this->set_current_dart(this->mmap->null_handle); } else { @@ -1732,7 +1732,7 @@ namespace CGAL { if ((*this)==this->mfirst_dart) { this->mprev_op = OP_END; - this->set_current_dart(NULL); + this->set_current_dart(this->mmap->null_handle); } else this->mprev_op = OP_BETA0I; @@ -1744,7 +1744,7 @@ namespace CGAL { if ((*this) == this->mmap->null_dart_handle) { this->mprev_op = OP_END; - this->set_current_dart(NULL); + this->set_current_dart(this->mmap->null_handle); } else this->mprev_op = OP_BETA21; @@ -1904,7 +1904,7 @@ namespace CGAL { { CGAL_assertion( d>=3 && d<=Map::dimension ); CGAL_assertion( i>=3 && i<=Map::dimension ); - if (adart!=NULL) + if (adart!=this->mmap->null_handle) { this->mmap->mark(adart, mmark_number); this->mmap->mark_null_dart(mmark_number); @@ -1927,13 +1927,13 @@ namespace CGAL { CGAL_assertion(mmark_number != -1); CGAL_assertion(this->cont()); - Dart_handle nd = NULL; + Dart_handle nd = this->mmap->null_handle; for ( int k=0; k<2; ++k ) { if ( this->is_unmarked((*this), k, mmark_number) ) { - if (nd == NULL) + if (nd == this->mmap->null_handle) { nd = this->mmap->beta(*this, k); CGAL_assertion(nd!=this->mmap->null_dart_handle); @@ -1952,7 +1952,7 @@ namespace CGAL { if ( k!=i-1 && k!=i && k!=i+1 && this->is_unmarked((*this), k, mmark_number) ) { - if (nd == NULL) + if (nd == this->mmap->null_handle) { nd = this->mmap->beta(*this, k); CGAL_assertion(nd!=this->mmap->null_dart_handle); @@ -1966,7 +1966,7 @@ namespace CGAL { } } - if (nd == NULL) + if (nd == this->mmap->null_handle) { if (!mto_treat.empty()) { @@ -1977,7 +1977,7 @@ namespace CGAL { else { this->mprev_op = OP_END; - this->set_current_dart(NULL); + this->set_current_dart(this->mmap->null_handle); } } @@ -2026,7 +2026,7 @@ namespace CGAL { mmark_number(amark) { CGAL_assertion( i>=3 && i<=Map::dimension ); - if (adart!=NULL) + if (adart!=this->mmap->null_handle) { this->mmap->mark(adart, mmark_number); this->mmap->mark_null_dart(mmark_number); @@ -2049,13 +2049,13 @@ namespace CGAL { CGAL_assertion(mmark_number != -1); CGAL_assertion(this->cont()); - Dart_handle nd = NULL; + Dart_handle nd = this->mmap->null_handle; for ( int k=1; k>=0; --k ) { if ( this->is_unmarked((*this), k, mmark_number) ) { - if (nd == NULL) + if (nd == this->mmap->null_handle) { nd = this->mmap->beta(*this, k); CGAL_assertion(nd!=this->mmap->null_dart_handle); @@ -2073,7 +2073,7 @@ namespace CGAL { if ( k!=i-1 && k!=i && k!=i+1 && this->is_unmarked((*this), k, mmark_number) ) { - if (nd == NULL) + if (nd == this->mmap->null_handle) { nd = this->mmap->beta(*this, k); CGAL_assertion(nd!=this->mmap->null_dart_handle); @@ -2087,7 +2087,7 @@ namespace CGAL { } } - if (nd == NULL) + if (nd == this->mmap->null_handle) { if (!mto_treat.empty()) { @@ -2098,7 +2098,7 @@ namespace CGAL { else { this->mprev_op = OP_END; - this->set_current_dart(NULL); + this->set_current_dart(this->mmap->null_handle); } } @@ -2143,7 +2143,7 @@ namespace CGAL { int amark): Base(amap, adart), mmark_number(amark) - { if (adart!=NULL) + { if (adart!=this->mmap->null_handle) { this->mmap->mark(adart, mmark_number); this->mmap->mark_null_dart(mmark_number); @@ -2166,13 +2166,13 @@ namespace CGAL { CGAL_assertion(mmark_number != -1); CGAL_assertion(this->cont()); - Dart_handle nd = NULL; + Dart_handle nd = this->mmap->null_handle; for ( unsigned int k=3; k<=d; ++k ) { if ( this->is_unmarked((*this), k, mmark_number) ) { - if (nd == NULL) + if (nd == this->mmap->null_handle) { nd = this->mmap->beta(*this, k); CGAL_assertion(nd!=this->mmap->null_dart_handle); @@ -2186,7 +2186,7 @@ namespace CGAL { } } - if (nd == NULL) + if (nd == this->mmap->null_handle) { if (!mto_treat.empty()) { @@ -2197,7 +2197,7 @@ namespace CGAL { else { this->mprev_op = OP_END; - this->set_current_dart(NULL); + this->set_current_dart(this->mmap->null_handle); } } @@ -2269,7 +2269,7 @@ namespace CGAL { int amark): Base(amap, adart), mmark_number(amark) - { if ( adart!=NULL) + { if ( adart!=this->mmap->null_handle) { this->mmap->mark(adart, mmark_number); this->mmap->mark_null_dart(mmark_number); @@ -2292,13 +2292,13 @@ namespace CGAL { CGAL_assertion(mmark_number != -1); CGAL_assertion(this->cont()); - Dart_handle nd = NULL; + Dart_handle nd = this->mmap->null_handle; for ( unsigned int k=4; k<=d; ++k ) { if ( this->is_unmarked((*this), k, mmark_number) ) { - if (nd == NULL) + if (nd == this->mmap->null_handle) { nd = this->mmap->beta(*this, k); CGAL_assertion(nd!=this->mmap->null_dart_handle); @@ -2312,7 +2312,7 @@ namespace CGAL { } } - if (nd == NULL) + if (nd == this->mmap->null_handle) { if (!mto_treat.empty()) { @@ -2323,7 +2323,7 @@ namespace CGAL { else { this->mprev_op = OP_END; - this->set_current_dart(NULL); + this->set_current_dart(this->mmap->null_handle); } } diff --git a/Combinatorial_map/test/Combinatorial_map/Combinatorial_map_copy_test.cpp b/Combinatorial_map/test/Combinatorial_map/Combinatorial_map_copy_test.cpp index bd14a5f05d2..69f1dd725a2 100644 --- a/Combinatorial_map/test/Combinatorial_map/Combinatorial_map_copy_test.cpp +++ b/Combinatorial_map/test/Combinatorial_map/Combinatorial_map_copy_test.cpp @@ -167,7 +167,7 @@ struct CreateAttributes for(typename Map::Dart_range::iterator it=map.darts().begin(), itend=map.darts().end(); it!=itend; ++it) { - if ( it->template attribute()==NULL ) + if ( it->template attribute()==map.null_handle ) map.template set_attribute (it, map.template create_attribute(++nb)); } diff --git a/Linear_cell_complex/demo/Linear_cell_complex/Linear_cell_complex_3_subdivision.cpp b/Linear_cell_complex/demo/Linear_cell_complex/Linear_cell_complex_3_subdivision.cpp index 18d37179120..74667e0e9de 100644 --- a/Linear_cell_complex/demo/Linear_cell_complex/Linear_cell_complex_3_subdivision.cpp +++ b/Linear_cell_complex/demo/Linear_cell_complex/Linear_cell_complex_3_subdivision.cpp @@ -37,7 +37,6 @@ public: Vertex operator () (Vertex & v) const { Dart_handle d = v.dart (); - CGAL_assertion (d != NULL); int degree = 0; bool open = false; @@ -83,7 +82,7 @@ flip_edge (LCC & m, Dart_handle d) CGAL_assertion ( !m.is_free(d,1) && !m.is_free(d,0) ); CGAL_assertion ( !m.is_free(m.beta(d,2), 0) && !m.is_free(m.beta(d, 2), 1) ); - if (!CGAL::is_removable(m,d)) return NULL; + if (!CGAL::is_removable(m,d)) return LCC::null_handle; Dart_handle d1 = m.beta(d,1); Dart_handle d2 = m.beta(d,2,0); @@ -170,12 +169,11 @@ subdivide_lcc_3 (LCC & m) // 4) We flip all the old edges. m.negate_mark (mark); // Now only new darts are marked. - Dart_handle d2 = NULL; + Dart_handle d2 =LCC::null_handle; for (LCC::Dart_range::iterator it (m.darts().begin ()); it != m.darts().end ();) { d2 = it++; - CGAL_assertion (d2 != NULL); if (!m.is_marked (d2, mark)) // This is an old dart. { // We process only the last dart of a same edge. diff --git a/Linear_cell_complex/demo/Linear_cell_complex/Linear_cell_complex_pqq_subdivision.cpp b/Linear_cell_complex/demo/Linear_cell_complex/Linear_cell_complex_pqq_subdivision.cpp index fda845861d7..bb2f1d7a2f3 100644 --- a/Linear_cell_complex/demo/Linear_cell_complex/Linear_cell_complex_pqq_subdivision.cpp +++ b/Linear_cell_complex/demo/Linear_cell_complex/Linear_cell_complex_pqq_subdivision.cpp @@ -37,7 +37,6 @@ public: Vertex operator () (Vertex & v) const { Dart_handle d = v.dart (); - CGAL_assertion (d != NULL); // Old points aren't concerned. if (mlcc.is_marked(d, old)) @@ -119,7 +118,6 @@ public: Vertex operator () (Vertex & v) const { Dart_handle d = v.dart (); - CGAL_assertion (d != NULL); // Just old points are concerned. if (!mlcc.is_marked(d, old)) diff --git a/Linear_cell_complex/demo/Linear_cell_complex/MainWindow.cpp b/Linear_cell_complex/demo/Linear_cell_complex/MainWindow.cpp index 2dfc3cd28e6..5d906b17f2b 100644 --- a/Linear_cell_complex/demo/Linear_cell_complex/MainWindow.cpp +++ b/Linear_cell_complex/demo/Linear_cell_complex/MainWindow.cpp @@ -167,7 +167,7 @@ void MainWindow::clear_all() void MainWindow::on_new_volume(Dart_handle adart) { - CGAL_assertion( scene.lcc->attribute<3>(adart)==NULL); + CGAL_assertion( scene.lcc->attribute<3>(adart)==LCC::null_handle); CGAL::Set_i_attribute_functor:: run(scene.lcc, adart, scene.lcc->create_attribute<3>()); update_volume_list_add(scene.lcc->attribute<3>(adart)); @@ -178,7 +178,7 @@ void MainWindow::init_all_new_volumes() for (LCC::One_dart_per_cell_range<3>::iterator it(scene.lcc->one_dart_per_cell<3>().begin()); it.cont(); ++it) - if ( scene.lcc->attribute<3>(it)==NULL ) + if ( scene.lcc->attribute<3>(it)==LCC::null_handle ) { on_new_volume(it); } } @@ -751,7 +751,7 @@ void MainWindow::on_actionMerge_all_volumes_triggered() timer.start(); #endif - Dart_handle prev = NULL; + Dart_handle prev = scene.lcc->null_handle; for (LCC::Dart_range::iterator it(scene.lcc->darts().begin()), itend=scene.lcc->darts().end(); it!=itend; ) { @@ -762,7 +762,7 @@ void MainWindow::on_actionMerge_all_volumes_triggered() { CGAL::remove_cell(*scene.lcc,it); itend=scene.lcc->darts().end(); - if ( prev==NULL ) it=scene.lcc->darts().begin(); + if ( prev==scene.lcc->null_handle ) it=scene.lcc->darts().begin(); else { it=prev; if ( it!=itend ) ++it; } } else diff --git a/Linear_cell_complex/demo/Linear_cell_complex/Viewer.cpp b/Linear_cell_complex/demo/Linear_cell_complex/Viewer.cpp index 63e7a05bf84..2562a694b52 100644 --- a/Linear_cell_complex/demo/Linear_cell_complex/Viewer.cpp +++ b/Linear_cell_complex/demo/Linear_cell_complex/Viewer.cpp @@ -76,7 +76,7 @@ void Viewer::drawFacet(Dart_const_handle ADart) { LCC &m = *scene->lcc; ::glBegin(GL_POLYGON); - CGAL_assertion( m.attribute<3>(ADart)!=NULL ); + CGAL_assertion( m.attribute<3>(ADart)!=LCC::null_handle ); // double r = (double)ADart->attribute<3>()->info().r()/255.0; double r = (double)m.info<3>(ADart).color().r()/255.0; @@ -128,7 +128,7 @@ void Viewer::drawEdges(Dart_const_handle ADart) { LCC::Point p = m.point(it); Dart_const_handle d2 = m.other_extremity(it); - if ( d2!=NULL ) + if ( d2!=LCC::null_handle ) { LCC::Point p2 = m.point(d2); glVertex3f( p.x(),p.y(),p.z()); @@ -158,7 +158,7 @@ void Viewer::draw_one_vol(Dart_const_handle adart, bool filled) for (LCC::One_dart_per_incident_cell_range<1,3>::const_iterator it(m,adart); it.cont(); ++it) { - if ( m.other_extremity(it)!=NULL ) + if ( m.other_extremity(it)!=LCC::null_handle ) { LCC::Point p1 = m.point(it); LCC::Point p2 = m.point(m.other_extremity(it)); diff --git a/Linear_cell_complex/include/CGAL/Linear_cell_complex.h b/Linear_cell_complex/include/CGAL/Linear_cell_complex.h index 2a1b76a674b..dc4ba4aebae 100644 --- a/Linear_cell_complex/include/CGAL/Linear_cell_complex.h +++ b/Linear_cell_complex/include/CGAL/Linear_cell_complex.h @@ -321,7 +321,7 @@ namespace CGAL { for (typename Dart_range::const_iterator it(this->darts().begin()), itend(this->darts().end()); valid && it != itend; ++it) { - if ( vertex_attribute(it) == NULL ) + if ( vertex_attribute(it)==null_handle ) { std::cerr << "Map not valid: dart "<<&(*it) <<" does not have a vertex."<< std::endl; @@ -344,7 +344,7 @@ namespace CGAL { bool samegeometry = true; for ( ; samegeometry && it1.cont() && it2.cont(); ++it1, ++it2) { - if ( this->other_extremity(it2)!=NULL && + if ( this->other_extremity(it2)!=null_handle && point(it1)!=point(this->other_extremity(it2)) ) samegeometry = false; } @@ -686,7 +686,7 @@ namespace CGAL { Dart_handle first = CGAL::insert_cell_0_in_cell_2(*this, dh, v); - if ( first== NULL ) // If the triangulated facet was made of one dart + if ( first==null_handle ) // If the triangulated facet was made of one dart erase_vertex_attribute(v); #ifdef CGAL_CMAP_TEST_VALID_INSERTIONS @@ -739,7 +739,7 @@ namespace CGAL { * simultaneously through all the darts of the two lcc and we have * each time of the iteration two "dual" darts. */ - Dart_handle dual_points_at_barycenter(Self & alcc, Dart_handle adart=NULL) + Dart_handle dual_points_at_barycenter(Self & alcc, Dart_handle adart=null_handle) { Dart_handle res = Base::dual(alcc, adart); @@ -750,7 +750,7 @@ namespace CGAL { for (typename Dart_range::iterator it(this->darts().begin()); it!=this->darts().end(); ++it, ++it2) { - if (vertex_attribute(it2) == NULL) + if (vertex_attribute(it2)==null_handle) { alcc.set_vertex_attribute(it2, alcc.create_vertex_attribute (barycenter(it))); diff --git a/Linear_cell_complex/include/CGAL/Linear_cell_complex_constructors.h b/Linear_cell_complex/include/CGAL/Linear_cell_complex_constructors.h index 01a8951f176..f828f59596a 100644 --- a/Linear_cell_complex/include/CGAL/Linear_cell_complex_constructors.h +++ b/Linear_cell_complex/include/CGAL/Linear_cell_complex_constructors.h @@ -63,7 +63,7 @@ namespace CGAL { std::string txt; typename LCC::FT x, y; - Dart_handle d1 = NULL, d2 = NULL; + Dart_handle d1 = alcc.null_handle, d2 = alcc.null_handle; unsigned int v1, v2; unsigned int nbSommets = 0; @@ -76,7 +76,7 @@ namespace CGAL { { std::cout << "Problem: file does not contain enough vertices." << std::endl; - return NULL; + return alcc.null_handle; } ais >> x >> y; @@ -92,7 +92,7 @@ namespace CGAL { { std::cout << "Problem: file does not contain enough edges." << std::endl; - return NULL; + return alcc.null_handle; } // We read an egde (given by the number of its two vertices). @@ -115,8 +115,8 @@ namespace CGAL { List_iterator it; LCC_iterator it2; - Dart_handle first = NULL; - Dart_handle prec = NULL; + Dart_handle first = alcc.null_handle; + Dart_handle prec = alcc.null_handle; typename LCC::Point sommet1, sommet2; for (unsigned int i = 0; i < initVertices.size(); ++i) @@ -182,10 +182,10 @@ namespace CGAL { CGAL_static_assertion( LCC::dimension>=2 && LCC::ambient_dimension==2 ); // Case of empty triangulations. - if (atr.number_of_vertices() == 0) return NULL; + if (atr.number_of_vertices() == 0) return LCC::null_handle; // Check the dimension. - if (atr.dimension() != 2) return NULL; + if (atr.dimension() != 2) return LCC::null_handle; CGAL_assertion(atr.is_valid()); typedef typename Triangulation::Vertex_handle TVertex_handle; @@ -213,8 +213,8 @@ namespace CGAL { itmap_tcell maptcell_it; - typename LCC::Dart_handle res=NULL, dart=NULL; - typename LCC::Dart_handle cur=NULL, neighbor=NULL; + typename LCC::Dart_handle res=LCC::null_handle, dart=LCC::null_handle; + typename LCC::Dart_handle cur=LCC::null_handle, neighbor=LCC::null_handle; for (it = atr.all_faces_begin(); it != atr.all_faces_end(); ++it) { @@ -228,7 +228,7 @@ namespace CGAL { TV[it->vertex(1)], TV[it->vertex(2)]); - if ( dart==NULL ) + if ( dart==LCC::null_handle ) { if ( it->vertex(0) == atr.infinite_vertex() ) dart = res; @@ -265,7 +265,7 @@ namespace CGAL { } } - CGAL_assertion(dart!=NULL); + CGAL_assertion(dart!=LCC::null_handle); return dart; } @@ -285,10 +285,10 @@ namespace CGAL { CGAL_static_assertion( LCC::dimension>=3 && LCC::ambient_dimension==3 ); // Case of empty triangulations. - if (atr.number_of_vertices() == 0) return NULL; + if (atr.number_of_vertices() == 0) return LCC::null_handle; // Check the dimension. - if (atr.dimension() != 3) return NULL; + if (atr.dimension() != 3) return LCC::null_handle; CGAL_assertion(atr.is_valid()); typedef typename Triangulation::Vertex_handle TVertex_handle; @@ -316,8 +316,8 @@ namespace CGAL { itmap_tcell maptcell_it; - typename LCC::Dart_handle res=NULL, dart=NULL; - typename LCC::Dart_handle cur=NULL, neighbor=NULL; + typename LCC::Dart_handle res=LCC::null_handle, dart=LCC::null_handle; + typename LCC::Dart_handle cur=LCC::null_handle, neighbor=LCC::null_handle; for (it = atr.cells_begin(); it != atr.cells_end(); ++it) { @@ -332,7 +332,7 @@ namespace CGAL { TV[it->vertex(2)], TV[it->vertex(3)]); - if ( dart==NULL ) + if ( dart==LCC::null_handle ) { if ( it->vertex(0) == atr.infinite_vertex() ) dart = res; @@ -375,7 +375,7 @@ namespace CGAL { (*mytc)[it] = res; } } - CGAL_assertion(dart!=NULL); + CGAL_assertion(dart!=LCC::null_handle); return dart; } @@ -401,20 +401,20 @@ namespace CGAL { Halfedge_handle_map TC; itmap_hds it; - typename LCC::Dart_handle d = NULL, prev = NULL; - typename LCC::Dart_handle firstFacet = NULL, firstAll = NULL; + typename LCC::Dart_handle d = LCC::null_handle, prev = LCC::null_handle; + typename LCC::Dart_handle firstFacet = LCC::null_handle, firstAll = LCC::null_handle; // First traversal to build the darts and link them. for (Facet_iterator i = apoly.facets_begin(); i != apoly.facets_end(); ++i) { HF_circulator j = i->facet_begin(); - prev = NULL; + prev = LCC::null_handle; do { d = alcc.create_dart(); TC[j] = d; - if (prev != NULL) alcc.template link_beta<1>(prev, d); + if (prev != LCC::null_handle) alcc.template link_beta<1>(prev, d); else firstFacet = d; it = TC.find(j->opposite()); if (it != TC.end()) @@ -423,7 +423,7 @@ namespace CGAL { } while (++j != i->facet_begin()); alcc.template link_beta<1>(prev, firstFacet); - if (firstAll == NULL) firstAll = firstFacet; + if (firstAll == LCC::null_handle) firstAll = firstFacet; } // Second traversal to update the geometry. @@ -434,7 +434,7 @@ namespace CGAL { do { d = TC[j]; // Get the dart associated to the Halfedge - if (alcc.temp_vertex_attribute(d) == NULL) + if (alcc.temp_vertex_attribute(d) == LCC::null_handle) { alcc.set_vertex_attribute (d, alcc.create_vertex_attribute(j->opposite()->vertex()->point())); @@ -537,7 +537,7 @@ namespace CGAL { if (!ais.good()) { std::cout << "Error reading flux." << std::endl; - return NULL; + return LCC::null_handle; } CGAL::Polyhedron_3 P; ais >> P; diff --git a/Linear_cell_complex/include/CGAL/Linear_cell_complex_incremental_builder.h b/Linear_cell_complex/include/CGAL/Linear_cell_complex_incremental_builder.h index 7f77f8308f8..937cf3e45e1 100644 --- a/Linear_cell_complex/include/CGAL/Linear_cell_complex_incremental_builder.h +++ b/Linear_cell_complex/include/CGAL/Linear_cell_complex_incremental_builder.h @@ -50,7 +50,7 @@ namespace CGAL { void begin_facet() { - CGAL_assertion( first_dart==NULL && prev_dart==NULL ); + CGAL_assertion( first_dart==lcc.null_handle && prev_dart==lcc.null_handle ); // std::cout<<"Begin facet: "<(prev_dart, cur); Dart_handle opposite=find_dart_between(i,lcc.temp_vertex_attribute(prev_dart)); - if ( opposite!=NULL ) + if ( opposite!=lcc.null_handle ) { CGAL_assertion( lcc.template is_free<2>(opposite) ); lcc.template link_beta<2>(prev_dart, opposite); @@ -85,12 +85,12 @@ namespace CGAL { void end_facet() { - CGAL_assertion( first_dart!=NULL && prev_dart!=NULL ); + CGAL_assertion( first_dart!=lcc.null_handle && prev_dart!=lcc.null_handle ); lcc.template link_beta<1>(prev_dart, first_dart); Dart_handle opposite = find_dart_between(first_vertex,lcc.temp_vertex_attribute(prev_dart)); - if ( opposite!=NULL ) + if ( opposite!=lcc.null_handle ) { CGAL_assertion( lcc.template is_free<2>(opposite) ); lcc.template link_beta<2>(prev_dart, opposite); @@ -98,16 +98,16 @@ namespace CGAL { add_dart_in_vertex_to_dart_map( prev_dart, prev_vertex ); - first_dart = NULL; - prev_dart = NULL; + first_dart = lcc.null_handle; + prev_dart = lcc.null_handle; // std::cout<<" end facet."<(*it))==vh ) return (*it); } - return NULL; + return lcc.null_handle; } void add_dart_in_vertex_to_dart_map( Dart_handle adart, size_type i ) { - CGAL_assertion( adart!=NULL ); + CGAL_assertion( adart!=lcc.null_handle ); CGAL_assertion( !lcc.template is_free<1>(adart) ); vertex_to_dart_map[i].push_back(adart); } diff --git a/Linear_cell_complex/include/CGAL/Linear_cell_complex_operations.h b/Linear_cell_complex/include/CGAL/Linear_cell_complex_operations.h index d90687dd70c..3a212fbf1dc 100644 --- a/Linear_cell_complex/include/CGAL/Linear_cell_complex_operations.h +++ b/Linear_cell_complex/include/CGAL/Linear_cell_complex_operations.h @@ -56,7 +56,7 @@ namespace CGAL { start = amap.template beta<0>(start); if ( amap.template is_free<1>(start) || - amap.other_extremity(amap.template beta<1>(start))==NULL ) + amap.other_extremity(amap.template beta<1>(start))==LCC::null_handle ) return normal; unsigned int nb = 0; @@ -64,7 +64,7 @@ namespace CGAL { const Point* prev = &amap.point(start); const Point* curr = &amap.point(adart); - for ( ; adart!=start && amap.other_extremity(adart)!=NULL; + for ( ; adart!=start && amap.other_extremity(adart)!=LCC::null_handle; adart=amap.template beta<1>(adart) ) { const Point* next = &amap.point( amap.other_extremity(adart)); diff --git a/Linear_cell_complex/include/CGAL/Linear_cell_complex_storages.h b/Linear_cell_complex/include/CGAL/Linear_cell_complex_storages.h index c2988416b48..63b43d8fed0 100644 --- a/Linear_cell_complex/include/CGAL/Linear_cell_complex_storages.h +++ b/Linear_cell_complex/include/CGAL/Linear_cell_complex_storages.h @@ -58,6 +58,9 @@ namespace CGAL { typedef typename Dart_container::const_iterator Dart_const_handle; typedef typename Dart_container::size_type size_type; + typedef CGAL::Void* Null_handle_type; + static Null_handle_type null_handle; + typedef Items_ Items; typedef Alloc_ Alloc; @@ -410,17 +413,31 @@ namespace CGAL { typename Helper::Attribute_containers mattribute_containers; }; + /// null_handle + template + typename Linear_cell_complex_storage_1::Null_handle_type + Linear_cell_complex_storage_1::null_handle = NULL; + #ifdef CGAL_CMAP_DEPRECATED /// Allocation of static data members /// mnull_dart_container - template - typename Linear_cell_complex_storage_1::Dart_container - Linear_cell_complex_storage_1::mnull_dart_container; + template + typename Linear_cell_complex_storage_1::Dart_container + Linear_cell_complex_storage_1::mnull_dart_container; /// null_dart_handle - template < unsigned int d_, class Items_, class Alloc_ > - typename Linear_cell_complex_storage_1::Dart_handle - Linear_cell_complex_storage_1::null_dart_handle; + template + typename Linear_cell_complex_storage_1::Dart_handle + Linear_cell_complex_storage_1::null_dart_handle; // = mnull_dart_container.emplace( std::bitset() ); // Does not work on windows => segfault // Thus we initialize null_dart_handle in the Combinatorial_map constructor diff --git a/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_copy_test.cpp b/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_copy_test.cpp index 403a64e8f9f..aa164791081 100644 --- a/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_copy_test.cpp +++ b/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_copy_test.cpp @@ -166,10 +166,10 @@ struct Converter_map9_points_into_map5_points (const Map9& map1, Map5& map2, Map9::Dart_const_handle dh1, Map5::Dart_handle dh2) const { - CGAL_assertion( map1.attribute<0>(dh1)!=NULL ); + CGAL_assertion( map1.attribute<0>(dh1)!=map1.null_handle ); Map5::Attribute_handle<0>::type res = map2.attribute<0>(dh2); - if ( res==NULL ) + if ( res==map2.null_handle ) { res = map2.create_attribute<0>(); } @@ -221,7 +221,7 @@ struct CreateAttributes for(typename Map::Dart_range::iterator it=map.darts().begin(), itend=map.darts().end(); it!=itend; ++it) { - if ( map.template attribute(it)==NULL ) + if ( map.template attribute(it)==map.null_handle ) { map.template set_attribute(it, map.template create_attribute()); SetInfoIfNonVoid::run(map, map.template attribute(it), ++nb); diff --git a/Polyhedron/demo/Polyhedron/Scene_combinatorial_map_item.h b/Polyhedron/demo/Polyhedron/Scene_combinatorial_map_item.h index 00a8b143eb4..566ce79f454 100644 --- a/Polyhedron/demo/Polyhedron/Scene_combinatorial_map_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_combinatorial_map_item.h @@ -1,6 +1,7 @@ #ifndef SCENE_COMBINATORIAL_MAP_ITEM_H #define SCENE_COMBINATORIAL_MAP_ITEM_H +#define CGAL_CMAP_DEPRECATED 1 //========= #include