This commit is contained in:
Guillaume Damiand 2013-01-28 17:54:28 +01:00
parent 18aa10a293
commit 2f19803fb8
3 changed files with 95 additions and 28 deletions

View File

@ -112,6 +112,9 @@ namespace CGAL {
template<typename Map>
friend struct internal::Decrease_attribute_functor;
template<typename Map, unsigned int i, typename Enabled>
friend struct internal::Update_dart_of_one_attribute_functor;
public:
/// Types definition
typedef Combinatorial_map_base<d_, Refs, Items_,Alloc_> Self;
@ -2333,7 +2336,12 @@ namespace CGAL {
it(*this,adart,amark); it.cont(); ++it)
{
if ( it->template attribute<i>() != a )
{
std::cout<<"ERROR: an attribute of the cell is different "
<<&*a<<" != "<<&*it->template attribute<i>()<<" for dart "
<<&*it<<std::endl;
valid = false;
}
if ( a!=NULL && it==a->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 "
<<nb<<" != "<<a->get_nb_refs()<<" for dart "
<<&*adart<<std::endl;
valid = false;
}
if ( a!=NULL && a->dart()!=NULL && !found_dart )
{
std::cout<<"ERROR: the dart of an attribute does not belong to the cell "
<<&*a->dart()<<" != NULL "<<" for dart "
<<&*adart<<std::endl;
valid = false;
}
return valid;
}

View File

@ -308,6 +308,7 @@ namespace CGAL {
}
}
// Required to process cells non consider in the cases above.
amap.update_dart_of_all_attributes(*it, mark);
}
@ -363,13 +364,6 @@ namespace CGAL {
}
}
// We remove all the darts of the i-cell.
for ( it=to_erase.begin(); it!=to_erase.end(); ++it )
{ amap.erase_dart(*it); }
CGAL_assertion( amap.is_whole_map_unmarked(mark) );
amap.free_mark(mark);
// We test the split of all the incident cells for all the non
// void attributes.
Map::Helper::template Foreach_enabled_attributes
@ -377,14 +371,22 @@ namespace CGAL {
run(&amap, &mark_for_incident_cells[0],
&incident_cells[0]);
// We remove all the darts of the i-cell.
for ( it=to_erase.begin(); it!=to_erase.end(); ++it )
{ amap.erase_dart(*it); }
CGAL_assertion( amap.is_whole_map_unmarked(mark) );
amap.free_mark(mark);
// We free the marks.
for (int j=0; j<Map::Helper::nb_attribs; ++j)
{
CGAL_assertion( amap.is_whole_map_marked
(mark_for_incident_cells [j]) );
amap.free_mark( mark_for_incident_cells [j] );
(mark_for_incident_cells[j]) );
amap.free_mark( mark_for_incident_cells[j] );
}
assert(amap.is_valid());
CGAL_expensive_postcondition( amap.is_valid() );
return res;
@ -482,6 +484,7 @@ namespace CGAL {
amap.free_mark( mark_for_incident_cells [j] );
}
assert(amap.is_valid());
CGAL_expensive_postcondition( amap.is_valid() );
return res;
@ -637,6 +640,7 @@ namespace CGAL {
amap.free_mark( mark_for_incident_cells [j] );
}
assert(amap.is_valid());
CGAL_expensive_postcondition( amap.is_valid() );
return res;

View File

@ -134,6 +134,24 @@ namespace CGAL {
{ amap->template update_dart_of_attribute<i>(ah,amark); }
};
template<typename Map, unsigned int i, typename Enabled=
typename Map::Helper::
#ifndef CGAL_CFG_TEMPLATE_IN_DEFAULT_PARAMETER_BUG
template
#endif
Attribute_type<i>::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<i>(ah,amark); }
};
template<typename Map, unsigned int i>
struct Update_dart_of_one_attribute_functor<Map, i, CGAL::Void>
{
static void run(Map*, typename Map::Dart_handle, int)
{}
};
/// Functor used to reserve one mark for each enabled attribute.
template<typename Map>
struct Reserve_mark_functor
@ -452,7 +470,8 @@ namespace CGAL {
struct Beta_functor<Dart_handle, int, Betas...>
{
static Dart_handle run(Dart_handle ADart, int B, Betas... betas)
{ return Beta_functor<Dart_handle, Betas...>::run(ADart->beta(B), betas...); }
{ return Beta_functor<Dart_handle, Betas...>::run(ADart->beta(B),
betas...); }
};
template<typename Dart_handle>
@ -481,10 +500,6 @@ namespace CGAL {
const int mark_for_jcells = mark_for_incident_cells
[Map::Helper::template Dimension_index<j>::value];
if ( amap->is_marked(adart, mark_for_jcells) ||
adart->template attribute<j>()==NULL )
return;
std::deque<std::deque<typename Map::Dart_handle> >& jcells =
store[Map::Helper::template Dimension_index<j>::value];
@ -493,6 +508,9 @@ namespace CGAL {
CGAL_assertion( amap->is_reserved(mark_for_icell) );
CGAL_assertion( amap->is_reserved(mark_for_jcells) );
if ( !amap->is_marked(adart, mark_for_jcells) &&
adart->template attribute<j>()!=NULL )
{
jcells.push_back(std::deque<typename Map::Dart_handle>());
for ( CMap_dart_iterator_basic_of_cell<Map,j>
itj(*amap, adart, mark_for_jcells); itj.cont(); ++itj )
@ -503,9 +521,30 @@ namespace CGAL {
}
amap->mark(itj, mark_for_jcells);
}
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<j>()!=NULL )
{
jcells.push_back(std::deque<typename Map::Dart_handle>());
for ( CMap_dart_iterator_basic_of_cell<Map,j>
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();
}
}
}
};
template<typename Map, unsigned int i>
@ -548,28 +587,34 @@ namespace CGAL {
if ( nbofjcell>1 )
{
a2 = amap->template create_attribute<j>(*a1);
a2->set_dart(*itj);
std::cout<<"A2 "<<&*a2<<" "<<&**itj<<": ";
// We call the on_split functor
Apply_cell_functor
<typename Map::Helper::template Attribute_type<j>::type,
typename Map::Helper::template Attribute_type<j>::type::On_split>::
run(*a1, *a2);
}
else
{
a1=(*itj)->template attribute<j>();
// TODO a1->set_dart(*itj);
// TODO
a1->set_dart(*itj);
std::cout<<"A1 "<<&*a1<<" "<<&**itj<<": ";
}
for ( CMap_dart_iterator_basic_of_cell<Map,j>
itj2(*amap, *itj, mark_for_jcells);
itj2.cont(); ++itj2 )
{
std::cout<<&*itj2<<", ";
if ( nbofjcell>1 )
amap->template set_attribute_of_dart<j>(itj2, a2);
amap->mark(itj2, mark_for_jcells);
}
std::cout<<std::endl;
if ( nbofjcell>1 )
Apply_cell_functor
<typename Map::Helper::template Attribute_type<j>::type,
typename Map::Helper::template Attribute_type<j>::type::
On_split>::run(*a1, *a2);
}
}
}