diff --git a/Combinatorial_map/examples/Combinatorial_map/map_3_index.cpp b/Combinatorial_map/examples/Combinatorial_map/map_3_index.cpp index 4165523cc58..d44beb8185c 100644 --- a/Combinatorial_map/examples/Combinatorial_map/map_3_index.cpp +++ b/Combinatorial_map/examples/Combinatorial_map/map_3_index.cpp @@ -1,7 +1,8 @@ #include #include -#include +#include #include +#include #include struct Myitem @@ -11,68 +12,43 @@ struct Myitem template struct Dart_wrapper { - typedef CGAL::Cell_attribute Vol_attrib; + typedef CGAL::Cell_attribute Vol_attrib; typedef std::tuple Attributes; }; }; -typedef CGAL::Combinatorial_map<3,Myitem> CMap_3; -typedef CMap_3::Dart_descriptor Dart_descriptor; +using CMap_3=CGAL::Combinatorial_map<3,Myitem>; +using Dart_descriptor=CMap_3::Dart_descriptor; int main() { CMap_3 cm; // Create 2 hexahedra. - Dart_descriptor d1 = cm.make_combinatorial_hexahedron(); - Dart_descriptor d2 = cm.make_combinatorial_hexahedron(); + Dart_descriptor d1=cm.make_combinatorial_hexahedron(); + Dart_descriptor d2=cm.make_combinatorial_hexahedron(); + cm.sew<3>(d1, d2); // 3-Sew the two hexahedra along one facet. + + // Create two 3-attributes and associated them to darts. + cm.set_attribute<3>(d1, cm.create_attribute<3>()); + cm.set_attribute<3>(d2, cm.create_attribute<3>()); - // 1) Create all 2-attributes and associated them to darts. - for (CMap_3::Dart_range::iterator - it=cm.darts().begin(), itend=cm.darts().end(); - it!=itend; ++it) - { - if ( cm.attribute<2>(it)==CMap_3::null_descriptor ) - cm.set_attribute<2>(it, cm.create_attribute<2>()); - } + // Associate a vector of size_t to darts + std::vector array_for_darts(cm.upper_bound_on_dart_ids()); + std::generate(array_for_darts.begin(), array_for_darts.end(), std::rand); - // 2) Set the color of all facets of the first hexahedron to 7. - for (CMap_3::One_dart_per_incident_cell_range<2, 3>::iterator - it=cm.one_dart_per_incident_cell<2,3>(d1).begin(), - itend=cm.one_dart_per_incident_cell<2,3>(d1).end(); it!=itend; ++it) - { cm.info<2>(it)=7; } + // Associate a vector of string to 3-attributes + std::vector array_for_vols(cm.upper_bound_on_attribute_ids<3>()); + std::size_t i=0; + for(auto& e: array_for_vols) + { e="vol"+std::to_string(i++); } - // 3) Set the color of all facets of the second hexahedron to 13. - for (CMap_3::One_dart_per_incident_cell_range<2, 3>::iterator it= - cm.one_dart_per_incident_cell<2,3>(d2).begin(), - itend=cm.one_dart_per_incident_cell<2,3>(d2).end(); it!=itend; ++it) - { cm.info<2>(it)=13; } - - // 4) 3-Sew the two hexahedra along one facet. - cm.sew<3>(d1, d2); - - // 5) Display all the values of 2-attributes. - for (CMap_3::Attribute_range<2>::type::iterator - it=cm.attributes<2>().begin(), itend=cm.attributes<2>().end(); - it!=itend; ++it) - { - std::cout<(it)<<"; "; - } - std::cout<::type::iterator - it=cm.attributes<2>().begin(), itend=cm.attributes<2>().end(); - it!=itend; ++it) - { - std::cout<(it)<<"; "; - } - std::cout<(d1)]<<" and " + <(d2)]<