From 2f19803fb8c1598ea4ccd6cb437641ca28e31987 Mon Sep 17 00:00:00 2001 From: Guillaume Damiand Date: Mon, 28 Jan 2013 17:54:28 +0100 Subject: [PATCH] Wip --- .../include/CGAL/Combinatorial_map.h | 18 +++++ .../CGAL/Combinatorial_map_operations.h | 24 +++--- .../internal/Combinatorial_map_functors.h | 81 ++++++++++++++----- 3 files changed, 95 insertions(+), 28 deletions(-) diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map.h b/Combinatorial_map/include/CGAL/Combinatorial_map.h index 1b3d94ef5bb..fe4c790c48f 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map.h @@ -112,6 +112,9 @@ namespace CGAL { template friend struct internal::Decrease_attribute_functor; + template + friend struct internal::Update_dart_of_one_attribute_functor; + public: /// Types definition typedef Combinatorial_map_base Self; @@ -2333,7 +2336,12 @@ namespace CGAL { it(*this,adart,amark); it.cont(); ++it) { if ( it->template attribute() != a ) + { + std::cout<<"ERROR: an attribute of the cell is different " + <<&*a<<" != "<<&*it->template attribute()<<" for dart " + <<&*it<dart() ) found_dart = true; @@ -2342,10 +2350,20 @@ namespace CGAL { } if ( a!=NULL && a->get_nb_refs()!=nb ) + { + std::cout<<"ERROR: the number of reference of an attribute is not correct " + <dart()!=NULL && !found_dart ) + { + std::cout<<"ERROR: the dart of an attribute does not belong to the cell " + <<&*a->dart()<<" != NULL "<<" for dart " + <<&*adart<template update_dart_of_attribute(ah,amark); } }; + template::type> + struct Update_dart_of_one_attribute_functor + { + static void run(Map* amap, typename Map::Dart_handle ah, int amark) + { amap->template update_dart_of_attribute(ah,amark); } + }; + template + struct Update_dart_of_one_attribute_functor + { + static void run(Map*, typename Map::Dart_handle, int) + {} + }; + /// Functor used to reserve one mark for each enabled attribute. template struct Reserve_mark_functor @@ -452,7 +470,8 @@ namespace CGAL { struct Beta_functor { static Dart_handle run(Dart_handle ADart, int B, Betas... betas) - { return Beta_functor::run(ADart->beta(B), betas...); } + { return Beta_functor::run(ADart->beta(B), + betas...); } }; template @@ -481,10 +500,6 @@ namespace CGAL { const int mark_for_jcells = mark_for_incident_cells [Map::Helper::template Dimension_index::value]; - if ( amap->is_marked(adart, mark_for_jcells) || - adart->template attribute()==NULL ) - return; - std::deque >& jcells = store[Map::Helper::template Dimension_index::value]; @@ -493,18 +508,42 @@ namespace CGAL { CGAL_assertion( amap->is_reserved(mark_for_icell) ); CGAL_assertion( amap->is_reserved(mark_for_jcells) ); - jcells.push_back(std::deque()); - for ( CMap_dart_iterator_basic_of_cell - itj(*amap, adart, mark_for_jcells); itj.cont(); ++itj ) + if ( !amap->is_marked(adart, mark_for_jcells) && + adart->template attribute()!=NULL ) { - if ( !amap->is_marked(itj, mark_for_icell) ) + jcells.push_back(std::deque()); + for ( CMap_dart_iterator_basic_of_cell + itj(*amap, adart, mark_for_jcells); itj.cont(); ++itj ) { - jcells.back().push_back(itj); + if ( !amap->is_marked(itj, mark_for_icell) ) + { + jcells.back().push_back(itj); + } + amap->mark(itj, mark_for_jcells); } - amap->mark(itj, mark_for_jcells); + if ( jcells.back().empty() ) jcells.pop_back(); } - if ( jcells.back().empty() ) jcells.pop_back(); + if ( i!=1 && j==0 ) + { + typename Map::Dart_handle od = adart->other_extremity(); + + if ( od!=NULL && !amap->is_marked(od, mark_for_jcells) && + od->template attribute()!=NULL ) + { + jcells.push_back(std::deque()); + for ( CMap_dart_iterator_basic_of_cell + itj(*amap, od, mark_for_jcells); itj.cont(); ++itj ) + { + if ( !amap->is_marked(itj, mark_for_icell) ) + { + jcells.back().push_back(itj); + } + amap->mark(itj, mark_for_jcells); + } + if ( jcells.back().empty() ) jcells.pop_back(); + } + } } }; @@ -548,28 +587,34 @@ namespace CGAL { if ( nbofjcell>1 ) { a2 = amap->template create_attribute(*a1); - a2->set_dart(*itj); + std::cout<<"A2 "<<&*a2<<" "<<&**itj<<": "; // We call the on_split functor - Apply_cell_functor - ::type, - typename Map::Helper::template Attribute_type::type::On_split>:: - run(*a1, *a2); } else { a1=(*itj)->template attribute(); - // TODO a1->set_dart(*itj); + // TODO + a1->set_dart(*itj); + std::cout<<"A1 "<<&*a1<<" "<<&**itj<<": "; } for ( CMap_dart_iterator_basic_of_cell itj2(*amap, *itj, mark_for_jcells); itj2.cont(); ++itj2 ) { + std::cout<<&*itj2<<", "; if ( nbofjcell>1 ) amap->template set_attribute_of_dart(itj2, a2); amap->mark(itj2, mark_for_jcells); } + std::cout<1 ) + Apply_cell_functor + ::type, + typename Map::Helper::template Attribute_type::type:: + On_split>::run(*a1, *a2); } } }