diff --git a/Combinatorial_map/doc/Combinatorial_map/Combinatorial_map.txt b/Combinatorial_map/doc/Combinatorial_map/Combinatorial_map.txt index 423f49aae1c..2e36037ea23 100644 --- a/Combinatorial_map/doc/Combinatorial_map/Combinatorial_map.txt +++ b/Combinatorial_map/doc/Combinatorial_map/Combinatorial_map.txt @@ -115,7 +115,7 @@ To answer this need, a combinatorial map allows to create attributes whic
  • an i-cell may have no associated i-attribute. -Since i-cells are not explicitely represented in combinatorial maps, the association between i-cells and i-attributes is transferred to darts: if attribute a is associated to i-cell c, all the darts belonging to c are associated to a. +Since i-cells are not explicitly represented in combinatorial maps, the association between i-cells and i-attributes is transferred to darts: if attribute a is associated to i-cell c, all the darts belonging to c are associated to a. We can see two examples of combinatorial maps having some attributes in \cgalFigureRef{fig_cmap_with_attribs}. In the first example (Left), a 2D combinatorial map has 1-attributes containing a float, for example corresponding to the length of the associated 1-cell, and 2-attributes containing a color in RGB format. In the second example (Right), a 3D combinatorial map has 2-attributes containing a color in RGB format. @@ -280,7 +280,7 @@ There are also two different classes of ranges containing one dart per i- The iterators of the \link GenericMap::Dart_range `Dart_range`\endlink are bidirectional iterators, while the iterators of the other four ranges are forward iterators. The value type of all these iterators is `Dart` thus all these iterators can be directly used as \link GenericMap::Dart_descriptor `Dart_descriptor`\endlink. -Additionally, there is a range over non void i-attributes: \link GenericMap::Attribute_range `Attribute_range::type`\endlink, having a bidirectional iterator with value type \link GenericMap::Attribute_type Attribute_type::type`\endlink. +Additionally, there is a range over non void i-attributes: \link GenericMap::Attribute_range `Attribute_range::type`\endlink, having a bidirectional iterator with value type \link GenericMap::Attribute_type `Attribute_type::type`\endlink. For each range, there is an associated const range, a model of the `ConstRange` concept. You can find some examples of ranges in Section \ref ssecexample3DCM "A 3D Combinatorial Map". diff --git a/Combinatorial_map/doc/Combinatorial_map/Concepts/CombinatorialMap.h b/Combinatorial_map/doc/Combinatorial_map/Concepts/CombinatorialMap.h index 007d8b424c5..03f492d1b08 100644 --- a/Combinatorial_map/doc/Combinatorial_map/Concepts/CombinatorialMap.h +++ b/Combinatorial_map/doc/Combinatorial_map/Concepts/CombinatorialMap.h @@ -4,7 +4,7 @@ The concept `CombinatorialMap` defines a d-dimensional combinatorial map. -\cgalRefines `GenericMap` +\cgalRefines{GenericMap} \cgalHasModel \link CGAL::Combinatorial_map `CGAL::Combinatorial_map`\endlink diff --git a/Combinatorial_map/doc/Combinatorial_map/Concepts/GenericMap.h b/Combinatorial_map/doc/Combinatorial_map/Concepts/GenericMap.h index 31bcaf161d6..790d378bd07 100644 --- a/Combinatorial_map/doc/Combinatorial_map/Concepts/GenericMap.h +++ b/Combinatorial_map/doc/Combinatorial_map/Concepts/GenericMap.h @@ -4,7 +4,7 @@ The concept `GenericMap` defines a d-dimensional generic map. This concept is defined only to factorize the common notions between \link CombinatorialMap `CombinatorialMap`\endlink and \link GeneralizedMap `GeneralizedMap`\endlink concepts. -\cgalRefines DefaultConstructible +\cgalRefines{DefaultConstructible} A generic map has a set of darts D, and functions \f$ f_0\f$,\f$ \ldots\f$,\f$ f_{d}\f$ that link these darts between them. @@ -450,28 +450,28 @@ template const Attribute_type::type::Info& info_of_attribute(typename Attribute_const_descriptor::type ah) const; /*! -A shorcut for \link GenericMap::info_of_attribute `info_of_attribute`\endlink`(`\link GenericMap::attribute `attribute`\endlink`(adart))`. +A shortcut for \link GenericMap::info_of_attribute `info_of_attribute`\endlink`(`\link GenericMap::attribute `attribute`\endlink`(adart))`. \pre \link GenericMap::attribute `attribute`\endlink`(adart)!=nullptr`. */ template typename Attribute_type::type::Info & info(Dart_descriptor adart); /*! -A shorcut for \link GenericMap::info_of_attribute(typename Attribute_const_descriptor::type)const `info_of_attribute`\endlink`(`\link GenericMap::attribute(Dart_const_descriptor)const `attribute`\endlink`(adart))` for const descriptor. +A shortcut for \link GenericMap::info_of_attribute(typename Attribute_const_descriptor::type)const `info_of_attribute`\endlink`(`\link GenericMap::attribute(Dart_const_descriptor)const `attribute`\endlink`(adart))` for const descriptor. \pre \link GenericMap::attribute(Dart_const_descriptor)const `attribute`\endlink`(adart)!=nullptr`. */ template const typename Attribute_type::type::Info & info(Dart_const_descriptor adart) const; /*! -A shorcut for \link GenericMap::dart_of_attribute `dart_of_attribute`\endlink`(`\link GenericMap::attribute `attribute`\endlink`(adart))`. +A shortcut for \link GenericMap::dart_of_attribute `dart_of_attribute`\endlink`(`\link GenericMap::attribute `attribute`\endlink`(adart))`. \pre `attribute(adart)!=nullptr`. */ template Dart_descriptor & dart(Dart_descriptor adart); /*! -A shorcut for \link GenericMap::dart_of_attribute(typename Attribute_const_descriptor::type)const `dart_of_attribute`\endlink`(`\link GenericMap::attribute(Dart_const_descriptor)const `attribute`\endlink`(adart))` for const descriptor. +A shortcut for \link GenericMap::dart_of_attribute(typename Attribute_const_descriptor::type)const `dart_of_attribute`\endlink`(`\link GenericMap::attribute(Dart_const_descriptor)const `attribute`\endlink`(adart))` for const descriptor. \pre `attribute(adart)!=nullptr`. */ template @@ -679,7 +679,7 @@ Returns the status of the management of the attributes of the generic map. (ca1.dart()).size(); CMap_3::size_type nb2=mmap.darts_of_cell<2>(ca2.dart()).size(); mmap.info<2>(ca1.dart())*=(double(nb1)/(nb1+nb2)); diff --git a/Combinatorial_map/include/CGAL/Cell_attribute.h b/Combinatorial_map/include/CGAL/Cell_attribute.h index 091fb5730a1..0c931f0e30d 100644 --- a/Combinatorial_map/include/CGAL/Cell_attribute.h +++ b/Combinatorial_map/include/CGAL/Cell_attribute.h @@ -176,11 +176,11 @@ struct Init_id; { return !operator==(other); } protected: - /// Contructor without parameter. + /// Constructor without parameter. Cell_attribute_without_info(): mrefcounting(0), m_for_cc(Refs::null_descriptor) {} - /// Copy contructor. + /// Copy constructor. Cell_attribute_without_info(const Cell_attribute_without_info& acell): mrefcounting(acell.mrefcounting) {} @@ -301,12 +301,12 @@ struct Init_id; { return !operator==(other); } protected: - /// Contructor without parameter. + /// Constructor without parameter. Cell_attribute_without_info() : mdart(Refs::null_descriptor), mrefcounting(0) {} - /// Copy contructor. + /// Copy constructor. Cell_attribute_without_info(const Cell_attribute_without_info& acell): mdart(acell.mdart), mrefcounting(acell.mrefcounting) @@ -398,7 +398,7 @@ struct Init_id; typedef void Info; protected: - /// Default contructor. + /// Default constructor. Cell_attribute() {} }; @@ -461,11 +461,11 @@ struct Init_id; { return !operator==(other); } protected: - /// Default contructor. + /// Default constructor. Cell_attribute() {} - /// Contructor with an info in parameter. + /// Constructor with an info in parameter. Cell_attribute(const Info_& ainfo) : Info_for_cell_attribute(ainfo) {} diff --git a/Combinatorial_map/include/CGAL/Cell_attribute_with_id.h b/Combinatorial_map/include/CGAL/Cell_attribute_with_id.h index 768e0b82aeb..7366d118928 100644 --- a/Combinatorial_map/include/CGAL/Cell_attribute_with_id.h +++ b/Combinatorial_map/include/CGAL/Cell_attribute_with_id.h @@ -42,11 +42,11 @@ namespace CGAL { friend class Concurrent_compact_container; protected: - /// Default contructor. + /// Default constructor. Cell_attribute_with_id() {} - /// Contructor with an info in parameter. + /// Constructor with an info in parameter. Cell_attribute_with_id(const Info_& ainfo) : Cell_attribute(ainfo) {} @@ -64,7 +64,7 @@ namespace CGAL { friend class Concurrent_compact_container; protected: - /// Default contructor. + /// Default constructor. Cell_attribute_with_id() {} }; diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map.h b/Combinatorial_map/include/CGAL/Combinatorial_map.h index 77af5bbc736..ee80b2978c2 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map.h @@ -219,7 +219,7 @@ namespace CGAL { * @param dartinfoconverter functor to transform original information of darts into information of copies * @param pointconverter functor to transform points in original map into points of copies. * @param copy_perforated_darts true to copy also darts marked perforated (if any) - * @param mark_perforated_darts true to mark darts wich are copies of perforated darts (if any) + * @param mark_perforated_darts true to mark darts which are copies of perforated darts (if any) * @post *this is valid. */ template ::value> (mattribute_containers).emplace(args...); // Reinitialize the ref counting of the new attribute. This is normally - // not required except if create_attribute is used as "copy contructor". + // not required except if create_attribute is used as "copy constructor". this->template init_attribute_ref_counting(res); internal::Init_id::type>::run (this->template attributes(), res); @@ -1639,8 +1639,8 @@ namespace CGAL { CGAL_static_assertion(i<=dimension); CGAL_static_assertion_msg(Helper::template Dimension_index::value>=0, "set_attribute but i-attributes are disabled"); - - for (typename Dart_of_cell_range::iterator it(*this, dh); it.cont(); ++it) + for (typename Dart_of_cell_range::iterator it(*this, dh); + it.cont(); ++it) { this->template set_dart_attribute(it, ah); } @@ -3543,7 +3543,7 @@ namespace CGAL { ::run(*this, map2, current, other); } - // We test if the injection is valid with its neighboors. + // We test if the injection is valid with its neighbors. // We go out as soon as it is not satisfied. for (i=0; match && i<=dimension; ++i) { @@ -3772,7 +3772,7 @@ namespace CGAL { /** Test if a face is a combinatorial polygon of length alg * (a cycle of alg darts beta1 links together). - * @param adart an intial dart + * @param adart an initial dart * @return true iff the face containing adart is a polygon of length alg. */ bool is_face_combinatorial_polygon(Dart_const_descriptor adart, @@ -3858,7 +3858,7 @@ namespace CGAL { } /** Test if a volume is a combinatorial tetrahedron. - * @param adart an intial dart + * @param adart an initial dart * @return true iff the volume containing adart is a combinatorial tetrahedron. */ bool is_volume_combinatorial_tetrahedron(Dart_const_descriptor d1) const @@ -3951,7 +3951,7 @@ namespace CGAL { } /** Test if a volume is a combinatorial hexahedron. - * @param adart an intial dart + * @param adart an initial dart * @return true iff the volume containing adart is a combinatorial hexahedron. */ bool is_volume_combinatorial_hexahedron(Dart_const_descriptor d1) const @@ -4145,7 +4145,7 @@ namespace CGAL { } /** Insert a vertex in the given 2-cell which is split in triangles, - * once for each inital edge of the facet. + * once for each initial edge of the facet. * @param adart a dart of the facet to triangulate. * @param update_attributes a boolean to update the enabled attributes * (deprecated, now we use are_attributes_automatically_managed()) diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map/internal/Combinatorial_map_copy_functors.h b/Combinatorial_map/include/CGAL/Combinatorial_map/internal/Combinatorial_map_copy_functors.h index d3d11cbdfc7..5cbf7b7861a 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map/internal/Combinatorial_map_copy_functors.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map/internal/Combinatorial_map_copy_functors.h @@ -41,7 +41,7 @@ namespace internal // **************************************************************************** // Map1 is the existing map, to convert into map2. // Functor called only when both i-attributes have non void info. -// General cases when both info are differents. +// General cases when both info are different. template< typename Map1, typename Map2, unsigned int i, typename Info1=typename Map1::template Attribute_type::type::Info, @@ -439,7 +439,7 @@ struct Default_converter_cmap_attributes }; // **************************************************************************** // Cast converter always copy attributes, doing a cast. This can work only -// if both types are convertible and this is user responsability +// if both types are convertible and this is user responsibility // to use it only in this case. template< typename Map1, typename Map2, unsigned int i> struct Cast_converter_cmap_attributes @@ -480,7 +480,7 @@ struct Default_converter_dart_info }; // **************************************************************************** // Cast converter of dart info. This can work only if both types are -// convertible and this is user responsability to use it only in this case. +// convertible and this is user responsibility to use it only in this case. template< typename Map1, typename Map2> struct Cast_converter_dart_info { diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map/internal/Combinatorial_map_group_functors.h b/Combinatorial_map/include/CGAL/Combinatorial_map/internal/Combinatorial_map_group_functors.h index 6fd93934b2c..d86c152c503 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map/internal/Combinatorial_map_group_functors.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map/internal/Combinatorial_map_group_functors.h @@ -33,7 +33,7 @@ * Group_attribute_functor to group the -attributes of two * given i-cells (except for j-adim). If one i-attribute is nullptr, we set the * darts of its i-cell to the second attribute. If both i-attributes are - * non nullptr, we overide all the i-attribute of the second i-cell to the + * non nullptr, we override all the i-attribute of the second i-cell to the * first i-attribute. * * Group_neighboor_attribute to group the -attributes of beta_i(d1) and @@ -609,6 +609,15 @@ void test_split_attribute_functor_one_dart Attribute_descriptor_i a1 = amap.template attribute(adart); if ( found_attributes.is_defined(a1) ) { // Here the attribute was already present in the hash_map + + // We need to call reserve for the cc with index case. Indeed, if the vector + // is reallocated, the reference returned by get_attribute(a1) will be + // invalidated, and the copy will be wrong. Note that there is no overhead + // since the creation of the attribute need one allocation. + amap.template attributes().reserve(amap.template attributes().size()+1); + + // Now we are sure that the creation of a new attribute will not imply + // a realloc. Attribute_descriptor_i a2 = amap.template create_attribute(amap.template get_attribute(a1)); diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map/internal/Combinatorial_map_internal_functors.h b/Combinatorial_map/include/CGAL/Combinatorial_map/internal/Combinatorial_map_internal_functors.h index 5fe14f3217b..3e0b147942c 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map/internal/Combinatorial_map_internal_functors.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map/internal/Combinatorial_map_internal_functors.h @@ -39,7 +39,7 @@ * valid (all its darts are linked to the same attribute, no other dart is * linked with this attribute). * - * internal::Count_cell_functor to count the nuber of i-cells. + * internal::Count_cell_functor to count the number of i-cells. * * internal::Count_bytes_one_attribute_functor to count the memory * occupied by i-attributes. @@ -66,7 +66,7 @@ * internal::Test_is_same_attribute_functor to test if two * i-attributes of two darts are isomorphic (ie they have the same info). * - * inernal::Test_is_same_attribute_point_functor to test if + * internal::Test_is_same_attribute_point_functor to test if * the point of two i-attributes are equal. * * internal::Reverse_orientation_of_map_functor to reverse the diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map/internal/Combinatorial_map_utility.h b/Combinatorial_map/include/CGAL/Combinatorial_map/internal/Combinatorial_map_utility.h index 884c4f80b98..4488da87fe1 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map/internal/Combinatorial_map_utility.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map/internal/Combinatorial_map_utility.h @@ -533,7 +533,7 @@ namespace CGAL struct Attribute_type { typedef Void type; }; - // Helper class allowing to retreive the d-cell-descriptor attribute + // Helper class allowing to retrieve the d-cell-descriptor attribute template::type, typename WithIndex=typename CMap::Use_index> struct Attribute_descriptor @@ -550,7 +550,7 @@ namespace CGAL struct Attribute_descriptor { typedef typename CMap::Dart_index type; }; - // Helper class allowing to retreive the d-cell-const descriptor attribute + // Helper class allowing to retrieve the d-cell-const descriptor attribute template::type> struct Attribute_const_descriptor { @@ -562,7 +562,7 @@ namespace CGAL struct Attribute_const_descriptor { typedef CGAL::Void* type; }; - // Helper class allowing to retreive the d-cell-iterator attribute + // Helper class allowing to retrieve the d-cell-iterator attribute template::type> struct Attribute_iterator { @@ -574,7 +574,7 @@ namespace CGAL struct Attribute_iterator { typedef CGAL::Void* type; }; - // Helper class allowing to retreive the d-cell-const descriptor attribute + // Helper class allowing to retrieve the d-cell-const descriptor attribute template::type> struct Attribute_const_iterator { @@ -586,7 +586,7 @@ namespace CGAL struct Attribute_const_iterator { typedef CGAL::Void* type; }; - // Helper class allowing to retreive the d-cell-attribute range + // Helper class allowing to retrieve the d-cell-attribute range template::type> struct Attribute_range { diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_iterators_base.h b/Combinatorial_map/include/CGAL/Combinatorial_map_iterators_base.h index eeb2c40b146..0b2c39bc720 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_iterators_base.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_iterators_base.h @@ -28,7 +28,7 @@ namespace CGAL { * Basic classes that serve as tools for definition of iterators. There are 3 classes: * - CMap_dart_iterator is the basic generic class defining - * what is an interator on darts. + * what is an iterator on darts. * - CMap_extend_iterator to extend the given iterator by adding * the involution Bi. * - CMap_non_basic_iterator to transform the basic iterator Ite diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_save_load.h b/Combinatorial_map/include/CGAL/Combinatorial_map_save_load.h index 31e8cff3946..e691fce122c 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_save_load.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_save_load.h @@ -347,7 +347,7 @@ namespace CGAL { using boost::property_tree::ptree; ptree pt; - // update pt adding nodes containing attributes informations + // update pt adding nodes containing attributes information CMap::Helper::template Foreach_enabled_attributes >::run(const_cast(amap), pt, myDarts); @@ -371,7 +371,7 @@ namespace CGAL { tree.put("data", ""); /** First we save general information of the map (by default nothing, - the fuction can be specialized by users). */ + the function can be specialized by users). */ f(tree); // map dart => number @@ -818,7 +818,7 @@ namespace CGAL { read_xml(input, pt); /** First we load general information of the map (by default nothing, - the fuction can be specialized by users). */ + the function can be specialized by users). */ f(pt); // Then we load darts and attributes. 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 aad7d643787..584442412c5 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_storages_with_index.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_storages_with_index.h @@ -146,6 +146,8 @@ namespace CGAL { { return cit; } bool is_used(size_type i) const { return mmap.mdarts.is_used(i); } + bool owns(size_type i) const + { return mmap.mdarts.owns(i); } private: Self & mmap; }; @@ -286,6 +288,13 @@ namespace CGAL { { CGAL_static_assertion_msg(Helper::template Dimension_index::value>=0, "copy_attribute called but i-attributes are disabled."); + // We need to do a reserve before the emplace in order to avoid a bug of + // invalid reference when the container is reallocated. + std::get::value> + (mattribute_containers).reserve + (std::get::value> + (mattribute_containers).size()+1); + typename Attribute_descriptor::type res= std::get::value> (mattribute_containers).emplace(get_attribute(ah)); diff --git a/Combinatorial_map/include/CGAL/Compact_container_with_index.h b/Combinatorial_map/include/CGAL/Compact_container_with_index.h index c3ddb24005b..d3d67c57a88 100644 --- a/Combinatorial_map/include/CGAL/Compact_container_with_index.h +++ b/Combinatorial_map/include/CGAL/Compact_container_with_index.h @@ -755,16 +755,21 @@ public: return false; } - bool owns_dereferencable(const_iterator cit) const + bool owns(size_type i) const + { return i=n) return; - capacity_=n; increase_size(); } diff --git a/Combinatorial_map/include/CGAL/Dart.h b/Combinatorial_map/include/CGAL/Dart.h index 761e9023249..3308def6103 100644 --- a/Combinatorial_map/include/CGAL/Dart.h +++ b/Combinatorial_map/include/CGAL/Dart.h @@ -241,7 +241,7 @@ namespace CGAL { } protected: - /// Neighboors for each dimension +1 (from 0 to dimension). + /// Neighbors for each dimension +1 (from 0 to dimension). Dart_descriptor mf[dimension+1]; /// Values of Boolean marks. diff --git a/Combinatorial_map/include/CGAL/Info_for_cell_attribute.h b/Combinatorial_map/include/CGAL/Info_for_cell_attribute.h index f45b23d76f8..ba13c664c21 100644 --- a/Combinatorial_map/include/CGAL/Info_for_cell_attribute.h +++ b/Combinatorial_map/include/CGAL/Info_for_cell_attribute.h @@ -19,10 +19,10 @@ namespace CGAL { class Info_for_cell_attribute { public: - /// Contructor without parameter. + /// Constructor without parameter. Info_for_cell_attribute()=default; // default => zero-initializing built-in types - /// Contructor with an info in parameter. + /// Constructor with an info in parameter. Info_for_cell_attribute(const Info& ainfo) : minfo(ainfo) {} diff --git a/Combinatorial_map/test/Combinatorial_map/CMakeLists.txt b/Combinatorial_map/test/Combinatorial_map/CMakeLists.txt index 94b110c4ac7..6357af2198d 100644 --- a/Combinatorial_map/test/Combinatorial_map/CMakeLists.txt +++ b/Combinatorial_map/test/Combinatorial_map/CMakeLists.txt @@ -24,9 +24,17 @@ target_compile_definitions(Combinatorial_map_copy_test_index PUBLIC USE_COMPACT_ target_link_libraries(Combinatorial_map_copy_test_index PUBLIC CGAL CGAL::Data) cgal_add_compilation_test(Combinatorial_map_copy_test_index) +create_single_source_cgal_program(cmap_test_split_attribute.cpp) + # Link with OpenMesh if possible find_package(OpenMesh QUIET) if(TARGET OpenMesh::OpenMesh) + message(STATUS "Found OpenMesh") + target_link_libraries(Combinatorial_map_copy_test PRIVATE OpenMesh::OpenMesh) + target_compile_definitions(Combinatorial_map_copy_test PRIVATE -DCGAL_USE_OPENMESH) target_link_libraries(Combinatorial_map_copy_test_index PRIVATE OpenMesh::OpenMesh) + target_compile_definitions(Combinatorial_map_copy_test_index PRIVATE -DCGAL_USE_OPENMESH) +else() + message(STATUS "NOTICE: Tests will not use OpenMesh.") endif() diff --git a/Combinatorial_map/test/Combinatorial_map/cmap_test_split_attribute.cpp b/Combinatorial_map/test/Combinatorial_map/cmap_test_split_attribute.cpp new file mode 100644 index 00000000000..49e8795eef7 --- /dev/null +++ b/Combinatorial_map/test/Combinatorial_map/cmap_test_split_attribute.cpp @@ -0,0 +1,92 @@ +#include +#include +#include +#include +#include +#include + +struct MyInfo +{ + MyInfo() :data(1) + {} + + MyInfo(int i) :data(i) + {} + + int data; +}; + +struct Myitem1 +{ + using Use_index=CGAL::Tag_true; // use indices + using Index_type=std::uint16_t; // 16 bits + template + struct Dart_wrapper + { + typedef CGAL::Cell_attribute attrib; + typedef std::tuple Attributes; + }; +}; + +struct Myitem2 +{ + template + struct Dart_wrapper + { + typedef CGAL::Cell_attribute attrib; + typedef std::tuple Attributes; + }; +}; + +using CMap1=CGAL::Combinatorial_map<3,Myitem1>; +using CMap2=CGAL::Combinatorial_map<3,Myitem2>; + +#define NB 1000 +template +bool test(const std::string& s) +{ + bool res=true; + CMap m; + // 1) create a face and one attribute. + typename CMap::Dart_descriptor dd=m.make_combinatorial_polygon(4); + m.template set_attribute<2>(dd, m.template create_attribute<2>(2)); + // 2) Split this face NB times => will create new 2-attributes for new faces + for(std::size_t i=0; i(newd)==CMap::null_descriptor) + { + std::cout<<"ERROR1: "<(newd)==CMap::null_descriptor"<(newd).data!=2) + { + std::cout<<"ERROR2: "<(newd).data<(newd); + if(m.template attribute<2>(newd)==CMap::null_descriptor) + { + std::cout<<"ERROR3: "<(newd)==CMap::null_descriptor"<(newd).data!=2) + { + std::cout<<"ERROR4: "<(newd).data<("CMap1") || !test("CMap2")) + { return EXIT_FAILURE; } + + return EXIT_SUCCESS; +} diff --git a/Generalized_map/doc/Generalized_map/Concepts/GeneralizedMap.h b/Generalized_map/doc/Generalized_map/Concepts/GeneralizedMap.h index 172e2481899..91c430a9d91 100644 --- a/Generalized_map/doc/Generalized_map/Concepts/GeneralizedMap.h +++ b/Generalized_map/doc/Generalized_map/Concepts/GeneralizedMap.h @@ -4,7 +4,7 @@ The concept `GeneralizedMap` defines a d-dimensional generalized map. -\cgalRefines `GenericMap` +\cgalRefines{GenericMap} \cgalHasModel \link CGAL::Generalized_map `CGAL::Generalized_map`\endlink diff --git a/Generalized_map/doc/Generalized_map/Generalized_map.txt b/Generalized_map/doc/Generalized_map/Generalized_map.txt index 0b08884f40a..491a8c9ed3d 100644 --- a/Generalized_map/doc/Generalized_map/Generalized_map.txt +++ b/Generalized_map/doc/Generalized_map/Generalized_map.txt @@ -117,7 +117,7 @@ To answer this need, a generalized map allows to create attributes which
  • an i-cell may have no associated i-attribute. -Since i-cells are not explicitely represented in generalized maps, the association between i-cells and i-attributes is transferred to darts: if attribute a is associated to i-cell c, all the darts belonging to c are associated to a. +Since i-cells are not explicitly represented in generalized maps, the association between i-cells and i-attributes is transferred to darts: if attribute a is associated to i-cell c, all the darts belonging to c are associated to a. We can see two examples of generalized maps having some attributes in \cgalFigureRef{fig_gmap_with_attribs}. In the first example (Left), a 2D generalized map has 1-attributes containing a float, for example corresponding to the length of the associated 1-cell, and 2-attributes containing a color in RGB format. In the second example (Right), a 3D generalized map has 2-attributes containing a color in RGB format. @@ -279,7 +279,7 @@ There are also two different classes of ranges containing one dart per i- The iterators of the \link GenericMap::Dart_range `Dart_range`\endlink are bidirectional iterators, while the iterators of the other four ranges are forward iterators. The value type of all these iterators is `Dart` thus all these iterators can be directly used as \link GenericMap::Dart_descriptor `Dart_descriptor`\endlink. -Additionally, there is a range over non void i-attributes: \link GenericMap::Attribute_range `Attribute_range::type`\endlink, having a bidirectional iterator with value type \link GenericMap::Attribute_type Attribute_type::type`\endlink. +Additionally, there is a range over non void i-attributes: \link GenericMap::Attribute_range `Attribute_range::type`\endlink, having a bidirectional iterator with value type \link GenericMap::Attribute_type `Attribute_type::type`\endlink. For each range, there is an associated const range, a model of the `ConstRange` concept. You can find some examples of ranges in Section \ref ssecexample3DGM "A 3D Generalized Map". diff --git a/Generalized_map/examples/Generalized_map/gmap_3_dynamic_onmerge.cpp b/Generalized_map/examples/Generalized_map/gmap_3_dynamic_onmerge.cpp index 48651e5ef92..4c8717af339 100644 --- a/Generalized_map/examples/Generalized_map/gmap_3_dynamic_onmerge.cpp +++ b/Generalized_map/examples/Generalized_map/gmap_3_dynamic_onmerge.cpp @@ -40,7 +40,7 @@ struct Split_functor // operator() automatically called after a split. void operator()(Face_attribute& ca1, Face_attribute& ca2) { - // We need to reinitalize the weight of the two faces + // We need to reinitialize the weight of the two faces GMap_3::size_type nb1=mmap.darts_of_cell<2>(ca1.dart()).size(); GMap_3::size_type nb2=mmap.darts_of_cell<2>(ca2.dart()).size(); mmap.info<2>(ca1.dart())*=(double(nb1)/(nb1+nb2)); diff --git a/Generalized_map/include/CGAL/Generalized_map.h b/Generalized_map/include/CGAL/Generalized_map.h index d65292ed5a0..4f4b29152fb 100644 --- a/Generalized_map/include/CGAL/Generalized_map.h +++ b/Generalized_map/include/CGAL/Generalized_map.h @@ -193,7 +193,7 @@ namespace CGAL { * @param dartinfoconverter functor to transform original information of darts into information of copies * @param pointconverter functor to transform points in original map into points of copies. * @param copy_perforated_darts true to copy also darts marked perforated (if any) - * @param mark_perforated_darts true to mark darts wich are copies of perforated darts (if any) + * @param mark_perforated_darts true to mark darts which are copies of perforated darts (if any) * @post *this is valid. */ template ::value> (mattribute_containers).emplace(args...); // Reinitialize the ref counting of the new attribute. This is normally - // not required except if create_attribute is used as "copy contructor". + // not required except if create_attribute is used as "copy constructor". this->template init_attribute_ref_counting(res); internal::Init_id::type>::run (this->template attributes(), res); @@ -2635,7 +2635,7 @@ namespace CGAL { ::run(*this, map2, current, other); } - // We test if the injection is valid with its neighboors. + // We test if the injection is valid with its neighbors. // We go out as soon as it is not satisfied. for (i = 0; match && i <= dimension; ++i) { @@ -3024,7 +3024,7 @@ namespace CGAL { /** Test if a face is a combinatorial polygon of length alg * (a cycle of alg edges alpha1 links together). - * @param adart an intial dart + * @param adart an initial dart * @return true iff the face containing adart is a polygon of length alg. */ bool is_face_combinatorial_polygon(Dart_const_descriptor adart, @@ -3118,7 +3118,7 @@ namespace CGAL { } /** Test if a volume is a combinatorial tetrahedron. - * @param adart an intial dart + * @param adart an initial dart * @return true iff the volume containing adart is a combinatorial tetrahedron. */ bool is_volume_combinatorial_tetrahedron(Dart_const_descriptor d1) const @@ -3195,7 +3195,7 @@ namespace CGAL { } /** Test if a volume is a combinatorial hexahedron. - * @param adart an intial dart + * @param adart an initial dart * @return true iff the volume containing adart is a combinatorial hexahedron. */ bool is_volume_combinatorial_hexahedron(Dart_const_descriptor d1) const @@ -3388,7 +3388,7 @@ namespace CGAL { } /** Insert a vertex in the given 2-cell which is split in triangles, - * once for each inital edge of the facet. + * once for each initial edge of the facet. * @param adart a dart of the facet to triangulate. * @return A dart incident to the new vertex. */ @@ -3643,10 +3643,13 @@ namespace CGAL { d2 = create_dart(); mark(it1,treated); + if (!isfree1) + { d3 = create_dart(); d4 = create_dart(); this->template basic_link_alpha<2>(d1, d3); this->template basic_link_alpha<2>(d2, d4); + } for (unsigned int dim=3; dim<=dimension; ++dim) { @@ -3654,21 +3657,30 @@ namespace CGAL { is_marked(alpha(it1, dim), treated) ) { basic_link_alpha(alpha(it1, dim, 1), d1, dim); - basic_link_alpha(alpha(it1, dim, 1, 0), d2, dim); + basic_link_alpha(alpha(d1, dim, 0), d2, dim); - basic_link_alpha(alpha(it1, dim, 1, 2), d3, dim); - basic_link_alpha(alpha(it1, dim, 1, 2, 0), d4, dim); + if (!isfree1) + { + basic_link_alpha(alpha(it1, 1, dim, 1), d3, dim); + basic_link_alpha(alpha(d3, dim, 0), d4, dim); + } } } if (!isfree1) - { this->template link_alpha<1>(this->template alpha<1>(it1), d3); } - this->template link_alpha<1>(it1, d1); + { + this->template link_alpha<1>(this->template alpha<1>(it1), d3); + if ( adart2!=null_descriptor ) + { + CGAL_assertion (it2.cont()); + this->template link_alpha<1>(this->template alpha<1>(it2), d4); + } + } + this->template link_alpha<1>(it1, d1); if (adart2!=null_descriptor) { CGAL_assertion (it2.cont()); - this->template link_alpha<1>(this->template alpha<1>(it2), d4); this->template link_alpha<1>(it2, d2); ++it2; } @@ -3678,14 +3690,18 @@ namespace CGAL { update_attributes && ah!=null_descriptor) { internal::Set_i_attribute_of_dart_functor::run(*this, d2, ah); - internal::Set_i_attribute_of_dart_functor::run(*this, d4, ah); + if (!isfree1) + { + internal::Set_i_attribute_of_dart_functor::run(*this, d4, ah); + } } } // We do the link_alpha<0> after the link_alpha<1> to update the // possible attributes of d2. this->template link_alpha<0>(d1, d2); - this->template link_alpha<0>(d3, d4); + if (!isfree1) + { this->template link_alpha<0>(d3, d4); } } if (are_attributes_automatically_managed() && update_attributes) @@ -3705,10 +3721,9 @@ namespace CGAL { } else // Here we degroup 2-attributes { - // TODO if ( !this->template is_free<2>(d1) && d2!=null_descriptor ) - if (adart2!=null_descriptor) + if (!this->template is_free<2>(d1) && d2!=null_descriptor) { CGAL::internal::GMap_degroup_attribute_functor_run:: - run(*this, adart1, adart2); } + run(*this, d1, this->template alpha<2>(d1)); } } } diff --git a/Generalized_map/include/CGAL/Generalized_map/internal/Generalized_map_group_functors.h b/Generalized_map/include/CGAL/Generalized_map/internal/Generalized_map_group_functors.h index 7514a5a0089..69179ad118c 100644 --- a/Generalized_map/include/CGAL/Generalized_map/internal/Generalized_map_group_functors.h +++ b/Generalized_map/include/CGAL/Generalized_map/internal/Generalized_map_group_functors.h @@ -34,7 +34,7 @@ * GMap_group_attribute_functor to group the -attributes of two * given i-cells (except for j-adim). If one i-attribute is nullptr, we set the * darts of its i-cell to the second attribute. If both i-attributes are - * non nullptr, we overide all the i-attribute of the second i-cell to the + * non nullptr, we override all the i-attribute of the second i-cell to the * first i-attribute. * * GMap_degroup_attribute_functor_run to degroup one i-attributes in two @@ -304,6 +304,13 @@ void GMap_test_split_attribute_functor_one_dart Attribute_descriptor_i a1 = amap.template attribute(adart); if ( found_attributes.is_defined(a1) ) { // Here the attribute was already present in the hash_map + + // We need to call reserve for the cc with index case. Indeed, if the vector + // is reallocated, the reference returned by get_attribute(a1) will be + // invalidated, and the copy will be wrong. Note that there is no overhead + // since the creation of the attribute need one allocation. + amap.template attributes().reserve(amap.template attributes().size()+1); + Attribute_descriptor_i a2 = amap.template create_attribute(amap.template get_attribute(a1)); diff --git a/Generalized_map/include/CGAL/Generalized_map_storages_with_index.h b/Generalized_map/include/CGAL/Generalized_map_storages_with_index.h index 80044bdc7d3..828004b8416 100644 --- a/Generalized_map/include/CGAL/Generalized_map_storages_with_index.h +++ b/Generalized_map/include/CGAL/Generalized_map_storages_with_index.h @@ -242,6 +242,13 @@ namespace CGAL { { CGAL_static_assertion_msg(Helper::template Dimension_index::value>=0, "copy_attribute called but i-attributes are disabled."); + // We need to do a reserve before the emplace in order to avoid a bug of + // invalid reference when the container is reallocated. + std::get::value> + (mattribute_containers).reserve + (std::get::value> + (mattribute_containers).size()+1); + typename Attribute_descriptor::type res= std::get::value> (mattribute_containers).emplace(get_attribute(ah)); diff --git a/Generalized_map/test/Generalized_map/CMakeLists.txt b/Generalized_map/test/Generalized_map/CMakeLists.txt index d712bb061dc..e773e5c3218 100644 --- a/Generalized_map/test/Generalized_map/CMakeLists.txt +++ b/Generalized_map/test/Generalized_map/CMakeLists.txt @@ -7,20 +7,10 @@ project(Generalized_map_Tests) # CGAL and its components find_package(CGAL REQUIRED) -# Boost and its components -find_package(Boost REQUIRED) - -if(NOT Boost_FOUND) - - message( - STATUS "This project requires the Boost library, and will not be compiled.") - - return() - -endif() - -set(hfiles Generalized_map_2_test.h Generalized_map_3_test.h - Generalized_map_4_test.h GMap_test_insertions.h) +set(hfiles Generalized_map_2_test.h + Generalized_map_3_test.h + Generalized_map_4_test.h + GMap_test_insertions.h) create_single_source_cgal_program("Generalized_map_test.cpp" ${hfiles}) @@ -28,3 +18,5 @@ add_executable(Generalized_map_test_index Generalized_map_test.cpp ${hfiles}) target_compile_definitions(Generalized_map_test_index PUBLIC USE_COMPACT_CONTAINER_WITH_INDEX) target_link_libraries(Generalized_map_test_index PUBLIC CGAL CGAL::Data) cgal_add_compilation_test(Generalized_map_test_index) + +create_single_source_cgal_program("gmap_test_split_attribute.cpp") diff --git a/Generalized_map/test/Generalized_map/gmap_test_split_attribute.cpp b/Generalized_map/test/Generalized_map/gmap_test_split_attribute.cpp new file mode 100644 index 00000000000..6dd17ee0a84 --- /dev/null +++ b/Generalized_map/test/Generalized_map/gmap_test_split_attribute.cpp @@ -0,0 +1,92 @@ +#include +#include +#include +#include +#include +#include + +struct MyInfo +{ + MyInfo() :data(1) + {} + + MyInfo(int i) :data(i) + {} + + int data; +}; + +struct Myitem1 +{ + using Use_index=CGAL::Tag_true; // use indices + using Index_type=std::uint16_t; // 16 bits + template + struct Dart_wrapper + { + typedef CGAL::Cell_attribute attrib; + typedef std::tuple Attributes; + }; +}; + +struct Myitem2 +{ + template + struct Dart_wrapper + { + typedef CGAL::Cell_attribute attrib; + typedef std::tuple Attributes; + }; +}; + +using GMap1=CGAL::Generalized_map<3,Myitem1>; +using GMap2=CGAL::Generalized_map<3,Myitem2>; + +#define NB 1000 +template +bool test(const std::string& s) +{ + bool res=true; + GMap m; + // 1) create a face and one attribute. + typename GMap::Dart_descriptor dd=m.make_combinatorial_polygon(4); + m.template set_attribute<2>(dd, m.template create_attribute<2>(2)); + // 2) Split this face NB times => will create new 2-attributes for new faces + for(std::size_t i=0; i(dd)); + if(m.template attribute<2>(newd)==GMap::null_descriptor) + { + std::cout<<"ERROR1: "<(newd)==GMap::null_descriptor"<(newd).data!=2) + { + std::cout<<"ERROR2: "<(newd).data<(newd); + if(m.template attribute<2>(newd)==GMap::null_descriptor) + { + std::cout<<"ERROR3: "<(newd)==GMap::null_descriptor"<(newd).data!=2) + { + std::cout<<"ERROR4: "<(newd).data<("GMap1") || !test("GMap2")) + { return EXIT_FAILURE; } + + return EXIT_SUCCESS; +} diff --git a/Linear_cell_complex/benchmark/Linear_cell_complex_2/cmake/FindCGAL.cmake b/Linear_cell_complex/benchmark/Linear_cell_complex_2/cmake/FindCGAL.cmake index 7dc0446bf45..a4b0902e60d 100644 --- a/Linear_cell_complex/benchmark/Linear_cell_complex_2/cmake/FindCGAL.cmake +++ b/Linear_cell_complex/benchmark/Linear_cell_complex_2/cmake/FindCGAL.cmake @@ -10,7 +10,7 @@ # CGAL_USE_FILE - CMake file to use CGAL. # -# Construct consitent error messages for use below. +# Construct consistent error messages for use below. set(CGAL_DIR_DESCRIPTION "directory containing CGALConfig.cmake. This is either the binary directory where CGAL was configured or PREFIX/lib/CGAL for an installation.") set(CGAL_DIR_MESSAGE "CGAL not found. Set the CGAL_DIR cmake variable or environment variable to the ${CGAL_DIR_DESCRIPTION}") diff --git a/Linear_cell_complex/benchmark/Linear_cell_complex_2/surface_mesh/Surface_mesh.h b/Linear_cell_complex/benchmark/Linear_cell_complex_2/surface_mesh/Surface_mesh.h index 889ee37db5d..f092321e4a9 100644 --- a/Linear_cell_complex/benchmark/Linear_cell_complex_2/surface_mesh/Surface_mesh.h +++ b/Linear_cell_complex/benchmark/Linear_cell_complex_2/surface_mesh/Surface_mesh.h @@ -705,7 +705,7 @@ public: //---------------------------------------------------- circulator types { public: - /// default constructur + /// default constructor Halfedge_around_face_circulator(const Surface_mesh* m=NULL, Face f=Face()) : mesh_(m) { diff --git a/Linear_cell_complex/benchmark/Linear_cell_complex_2/surface_mesh/Vector.h b/Linear_cell_complex/benchmark/Linear_cell_complex_2/surface_mesh/Vector.h index 8f9487c28cc..21aa768dbfb 100644 --- a/Linear_cell_complex/benchmark/Linear_cell_complex_2/surface_mesh/Vector.h +++ b/Linear_cell_complex/benchmark/Linear_cell_complex_2/surface_mesh/Vector.h @@ -137,7 +137,7 @@ public: } - /// assign a scalar to all componenets + /// assign a scalar to all components Vector& operator=(const Scalar s) { for (int i=0; iset_dart_attribute<0>(scene.lcc->beta(d2,1),(scene.lcc)->create_vertex_attribute(scene.lcc->point(d1))); (scene.lcc)->set_dart_attribute<0>(scene.lcc->beta(d3,1),(scene.lcc)->create_vertex_attribute(scene.lcc->point(d2))); (scene.lcc)->set_dart_attribute<0>(scene.lcc->beta(d1,1),(scene.lcc)->create_vertex_attribute(scene.lcc->point(d3))); diff --git a/Linear_cell_complex/examples/Linear_cell_complex/README.txt b/Linear_cell_complex/examples/Linear_cell_complex/README.txt index 6326da0e665..e461312f2dd 100644 --- a/Linear_cell_complex/examples/Linear_cell_complex/README.txt +++ b/Linear_cell_complex/examples/Linear_cell_complex/README.txt @@ -5,7 +5,7 @@ Examples for Linear_cell_complex package: linear_cell_complex_3_with_colored_vertices.cpp linear_cell_complex_4.cpp - Three "basic" examples, detailled in the user manual. + Three "basic" examples, detailed in the user manual. * plane_graph_to_lcc_2.cpp diff --git a/Linear_cell_complex/test/Linear_cell_complex/CMakeLists.txt b/Linear_cell_complex/test/Linear_cell_complex/CMakeLists.txt index 0b7a094a29d..9adb636537f 100644 --- a/Linear_cell_complex/test/Linear_cell_complex/CMakeLists.txt +++ b/Linear_cell_complex/test/Linear_cell_complex/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.1...3.23) project(Linear_cell_complex_Tests) -find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5) +find_package(CGAL REQUIRED) set(hfiles Linear_cell_complex_2_test.h Linear_cell_complex_3_test.h Linear_cell_complex_3_test.h) @@ -26,11 +26,6 @@ target_compile_definitions(Linear_cell_complex_3_test_index PUBLIC USE_COMPACT_C target_link_libraries(Linear_cell_complex_3_test_index PUBLIC CGAL CGAL::Data) cgal_add_compilation_test(Linear_cell_complex_3_test_index) -if(CGAL_Qt5_FOUND) - target_link_libraries(Linear_cell_complex_3_test PUBLIC CGAL::CGAL_Basic_viewer) - target_link_libraries(Linear_cell_complex_3_test_index PUBLIC CGAL::CGAL_Basic_viewer) -endif() - add_executable(Linear_cell_complex_4_test_index Linear_cell_complex_4_test.cpp ${hfiles}) target_compile_definitions(Linear_cell_complex_4_test_index PUBLIC USE_COMPACT_CONTAINER_WITH_INDEX) target_link_libraries(Linear_cell_complex_4_test_index PUBLIC CGAL CGAL::Data) diff --git a/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_3_test.h b/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_3_test.h index 8b8d55ea375..1f696a41811 100644 --- a/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_3_test.h +++ b/Linear_cell_complex/test/Linear_cell_complex/Linear_cell_complex_3_test.h @@ -20,7 +20,6 @@ #include "Linear_cell_complex_2_test.h" #include #include -#include template bool check_number_of_cells_3(LCC& lcc, unsigned int nbv, unsigned int nbe, unsigned int nbf, unsigned int nbvol, @@ -218,7 +217,6 @@ bool test_LCC_3() if ( !check_number_of_cells_3(lcc, 11, 13, 8, 2, 2) ) return false; - // CGAL::draw(lcc); trace_test_begin(); lcc.template remove_cell<0>(dh9); if ( !check_number_of_cells_3(lcc, 10, 12, 8, 2, 2) ) @@ -983,7 +981,6 @@ bool test_LCC_3() lcc.insert_cell_1_between_two_cells_2(lcc.template opposite<2>(lcc.next(lcc.next(dh1))), lcc.next(lcc.next(dh3))); - CGAL::draw(lcc); // TODO remove if (!check_number_of_cells_3(lcc, 16, 25, 11, 2, 1) ) return false;