diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map.h b/Combinatorial_map/include/CGAL/Combinatorial_map.h index a7994adbd72..b56fbb744ce 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map.h @@ -3381,22 +3381,23 @@ namespace CGAL { { CGAL_assertion( is_without_boundary(dimension) ); - CGAL::Unique_hash_map< Dart_handle, Dart_handle, - typename Self::Hash_function > dual(Dart_handle(), darts().size()); + CGAL::Unique_hash_map + dual(Dart_handle(), darts().size()); Dart_handle d, d2, res = amap.null_handle; // We clear amap. TODO return a new amap ? amap.clear(); // We create a copy of all the dart of the map. - for ( typename Dart_range::iterator it=darts().begin(); - it!=darts().end(); ++it) + for (typename Dart_range::iterator it=darts().begin(); + it!=darts().end(); ++it) { - dual[it] = amap.create_dart(); + dual[it]=amap.create_dart(); internal::Copy_dart_info_functor:: run(static_cast(amap), static_cast(*this), it, dual[it]); - if ( it==adart && res==amap.null_handle ) res = dual[it]; + if (it==adart && res==amap.null_handle) { res=dual[it]; } } // Then we link the darts by using the dual formula : @@ -3407,20 +3408,20 @@ namespace CGAL { 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]; + d=it2; // The supposition on the order allows to avoid d=dual[it]; CGAL_assertion( it2==dual[it] ); // First case outside the loop since we need to use link_beta1 if ( amap.template is_free<1>(d) && beta(it)!=null_dart_handle ) - amap.basic_link_beta_1(d, dual[beta(it)]); + { amap.basic_link_beta_1(d, dual[beta(it)]); } // and during the loop we use link_beta(d1,d2,i) for ( unsigned int i=dimension-2; i>=1; --i) { if ( amap.is_free(d,dimension-i) && beta(it, dimension, i)!=null_dart_handle ) - amap.basic_link_beta(d, dual[beta(it, dimension, i)], dimension-i); + { amap.basic_link_beta(d, dual[beta(it, dimension, i)], dimension-i); } } if ( amap.template is_free(d) ) { @@ -3429,7 +3430,7 @@ namespace CGAL { } } - if ( res==amap.null_handle ) res = amap.darts().begin(); + if ( res==amap.null_handle ) { res=amap.darts().begin(); } return res; } diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_storages_with_index.h b/Combinatorial_map/include/CGAL/Combinatorial_map_storages_with_index.h index 25df0736003..84721376096 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_storages_with_index.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_storages_with_index.h @@ -117,15 +117,19 @@ namespace CGAL { Dart_range(Self &amap) : mmap(amap) {} iterator begin() - { iterator res=mmap.mdarts.begin(); ++res; return res; } + { + CGAL_assertion(!mmap.mdarts.empty()); // The container mdarts is not empty + // it has at least the null_dart + iterator res=mmap.mdarts.begin(); ++res; return res; + } iterator end() { return mmap.mdarts.end(); } const_iterator begin() const { const_iterator res=mmap.mdarts.begin(); ++res; return res; } const_iterator end() const { return mmap.mdarts.end(); } - size_type size() + size_type size() const { return mmap.mdarts.size()-1; } bool empty() const - { return size()==0; } // is_empty(); } + { return size()==0; } // mmap.is_empty(); } size_type index(Dart_index idx) const { return idx; } size_type index(const_iterator cit) const @@ -146,7 +150,7 @@ namespace CGAL { void init_storage() { // Allocate a dart for null_dart_handle - assert(mdarts.empty()); + assert(mdarts.empty()); // the compact container is empty Dart_index local_null_dart_handle = mdarts.emplace(); if(local_null_dart_handle!=0) { @@ -163,11 +167,11 @@ namespace CGAL { * @return true iff the map is empty. */ bool is_empty() const - { return this->mdarts.size()==1; } + { return darts().empty(); } /// @return the number of darts. size_type number_of_darts() const - { return mdarts.size()-1; } + { return darts().size(); } /** Return if this dart is free for adimension. * @param dh a dart handle diff --git a/Linear_cell_complex/include/CGAL/CMap_linear_cell_complex_storages_with_index.h b/Linear_cell_complex/include/CGAL/CMap_linear_cell_complex_storages_with_index.h index a4f574019ff..bdebc35edd4 100644 --- a/Linear_cell_complex/include/CGAL/CMap_linear_cell_complex_storages_with_index.h +++ b/Linear_cell_complex/include/CGAL/CMap_linear_cell_complex_storages_with_index.h @@ -136,12 +136,16 @@ namespace CGAL { Dart_range(Self &amap) : mmap(amap) {} iterator begin() - { iterator res=mmap.mdarts.begin(); ++res; return res; } + { + CGAL_assertion(!mmap.mdarts.empty()); // The container mdarts is not empty + // it has at least the null_dart + iterator res=mmap.mdarts.begin(); ++res; return res; + } iterator end() { return mmap.mdarts.end(); } const_iterator begin() const { const_iterator res=mmap.mdarts.begin(); ++res; return res; } const_iterator end() const { return mmap.mdarts.end(); } - size_type size() + size_type size() const { return mmap.mdarts.size()-1; } bool empty() const { return size()==0; } // mmap.is_empty(); } @@ -165,7 +169,7 @@ namespace CGAL { void init_storage() { // Allocate a dart for null_dart_handle - assert(mdarts.empty()); + assert(mdarts.empty()); // the compact container is empty Dart_index local_null_dart_handle = mdarts.emplace(); if(local_null_dart_handle!=0) { @@ -182,11 +186,11 @@ namespace CGAL { * @return true iff the map is empty. */ bool is_empty() const - { return this->mdarts.size()==1; } + { return darts().empty(); } /// @return the number of darts. size_type number_of_darts() const - { return mdarts.size()-1; } + { return darts().size(); } /** Return if this dart is free for adimension. * @param dh a dart handle diff --git a/Linear_cell_complex/include/CGAL/Linear_cell_complex_base.h b/Linear_cell_complex/include/CGAL/Linear_cell_complex_base.h index 611f5b353c7..752c1fefe5d 100644 --- a/Linear_cell_complex/include/CGAL/Linear_cell_complex_base.h +++ b/Linear_cell_complex/include/CGAL/Linear_cell_complex_base.h @@ -815,22 +815,22 @@ namespace CGAL { */ Dart_handle dual_points_at_barycenter(Self & alcc, Dart_handle adart=null_handle) { - Dart_handle res = Base::dual(alcc, adart); + Dart_handle res=Base::dual(alcc, adart); // Now the lcc alcc is topologically correct, we just need to add // its geometry to each vertex (the barycenter of the corresponding // dim-cell in the initial map). - typename Dart_range::iterator it2 = alcc.darts().begin(); + typename Dart_range::iterator it2=alcc.darts().begin(); for (typename Dart_range::iterator it(darts().begin()); it!=darts().end(); ++it, ++it2) { - if (vertex_attribute(it2)==null_handle) + if (alcc.vertex_attribute(it2)==null_handle) { alcc.set_vertex_attribute(it2, alcc.create_vertex_attribute (barycenter(it))); } } - CGAL_assertion( is_valid() ); + CGAL_expensive_assertion(alcc.is_valid()); return res; }