diff --git a/Combinatorial_map/examples/Combinatorial_map/map_3_bug.cpp b/Combinatorial_map/examples/Combinatorial_map/map_3_bug.cpp deleted file mode 100644 index 49a8ddf0d35..00000000000 --- a/Combinatorial_map/examples/Combinatorial_map/map_3_bug.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#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 100 -int main() -{ - CMap1 cm1; - CMap2 cm2; - - CMap1::Attribute_descriptor<0>::type a1=cm1.create_attribute<0>(2); - for(std::size_t i=0; i::type a2=cm1.create_attribute<0>(cm1.info_of_attribute<0>(a1)); - if(cm1.info_of_attribute<0>(a1).data!=cm1.info_of_attribute<0>(a2).data) - { std::cout<<"ERROR1: "<(a1).data<<" and "<(a2).data<<" ("<::type a3=cm2.create_attribute<0>(3); - for(std::size_t i=0; i::type a4=cm2.create_attribute<0>(cm2.info_of_attribute<0>(a3)); - if(cm2.info_of_attribute<0>(a3).data!=cm2.info_of_attribute<0>(a4).data) - { std::cout<<"ERROR2: "<(a3).data<<" and "<(a4).data<<" ("< +#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/test/Generalized_map/CMakeLists.txt b/Generalized_map/test/Generalized_map/CMakeLists.txt index 642815d6c08..e773e5c3218 100644 --- a/Generalized_map/test/Generalized_map/CMakeLists.txt +++ b/Generalized_map/test/Generalized_map/CMakeLists.txt @@ -18,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..51e5618ce9c --- /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; +}