Onsplit, another version

This commit is contained in:
Guillaume Damiand 2013-01-29 08:17:38 +01:00
parent 7f6cf79490
commit bde3be7571
2 changed files with 114 additions and 12 deletions

View File

@ -225,7 +225,7 @@ namespace CGAL {
const int iinv = CGAL_BETAINV(i);
int mark_for_incident_cells[Map::Helper::nb_attribs];
/* int mark_for_incident_cells[Map::Helper::nb_attribs];
std::deque<std::deque<typename Map::Dart_handle> >
incident_cells[Map::Helper::nb_attribs];
@ -234,7 +234,7 @@ namespace CGAL {
{
mark_for_incident_cells [j] = amap.get_new_mark();
CGAL_assertion( mark_for_incident_cells[j]!=-1 );
}
}*/
// First we store and mark all the darts of the i-cell to remove.
size_t res = 0;
@ -252,7 +252,7 @@ namespace CGAL {
// the operation.
typename std::deque<typename Map::Dart_handle>::iterator it =
to_erase.begin();
for (; it != to_erase.end(); ++it)
/* for (; it != to_erase.end(); ++it)
{
d1 = (*it)->beta(iinv);
while ( d1!=Map::null_dart_handle && amap.is_marked(d1, mark) )
@ -318,11 +318,14 @@ namespace CGAL {
// Required to process cells non consider in the cases above.
amap.update_dart_of_all_attributes(*it, mark);
}
}*/
// We group the two (i+1)-cells incident if they exist.
if ( dg1!=NULL )
amap.template group_attribute<i+1>(dg1, dg2);
// TODO GROUP BEFORE TO MODIFY
/* if ( dg1!=NULL )
amap.template group_attribute<i+1>(dg1, dg2);*/
std::deque<typename Map::Dart_handle> modified_darts;
// For each dart of the i-cell, we modify i-links of neighbors.
for ( it=to_erase.begin(); it != to_erase.end(); ++it)
@ -349,10 +352,15 @@ namespace CGAL {
{
d1->basic_link_beta(d2, i);
if ( i==1 ) d2->basic_link_beta(d1, 0);
modified_darts.push_back(d1);
}
else
{
if ( !d1->is_free(i) ) d1->unlink_beta(i);
if ( !d1->is_free(i) )
{
d1->unlink_beta(i);
modified_darts.push_back(d1);
}
}
}
else if (d2 != Map::null_dart_handle)
@ -360,6 +368,7 @@ namespace CGAL {
if ( !d2->is_free(iinv) )
{
d2->unlink_beta(iinv);
modified_darts.push_back(d2);
}
}
if ((*it)->is_free(i+1) && !(*it)->is_free(i))
@ -368,6 +377,7 @@ namespace CGAL {
if ( !d1->is_free(iinv) )
{
d1->unlink_beta(iinv);
modified_darts.push_back(d1);
}
}
}
@ -375,9 +385,10 @@ namespace CGAL {
// We test the split of all the incident cells for all the non
// void attributes.
Map::Helper::template Foreach_enabled_attributes
<internal::Test_split_with_deque<Map,i> >::
run(&amap, &mark_for_incident_cells[0],
&incident_cells[0]);
<internal::Test2_split_with_deque<Map,i> >::
run(&amap, &modified_darts);
//&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 )
@ -387,13 +398,13 @@ namespace CGAL {
amap.free_mark(mark);
// We free the marks.
for (int j=0; j<Map::Helper::nb_attribs; ++j)
/* 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] );
}
*/
CGAL_expensive_postcondition( amap.is_valid() );
return res;

View File

@ -24,6 +24,7 @@
#include <CGAL/Cell_const_iterators.h>
#include <CGAL/Combinatorial_map_basic_operations.h>
#include <stack>
#include <set>
namespace CGAL {
namespace internal {
@ -620,6 +621,96 @@ namespace CGAL {
}
};
template<typename Map, unsigned int i>
struct Test2_split_with_deque
{
template <unsigned int j>
static void run( Map* amap,
std::deque<typename Map::Dart_handle>
*modified_darts )
{
if ( i==j ) return;
CGAL_assertion( amap!=NULL );
int nbofjcell = 0;
typename Map::Helper::template Attribute_handle<j>::type
a1 = NULL;
typename Map::Helper::template Attribute_handle<j>::type
a2=NULL;
std::set<typename Map::Helper::template
Attribute_handle<j>::type> found_attributes;
int mark = amap->get_new_mark();
for ( typename std::deque<typename Map::Dart_handle>::
iterator it=modified_darts->begin();
it!=modified_darts->end(); ++it )
{
if ( (*it)->template attribute<j>()!=NULL &&
!amap->is_marked(*it, mark) )
{
a1 = (*it)->template attribute<j>();
if ( found_attributes.insert(a1).second )
{ // Here the attribute was not in the set as we are able
// to insert it.
a2 = amap->template create_attribute<j>(*a1);
// std::cout<<"A2 "<<&*a2<<" "<<&**itj<<": ";
for ( CMap_dart_iterator_basic_of_cell<Map,j>
itj(*amap, *it, mark);
itj.cont(); ++itj )
{
// std::cout<<&*itj<<", ";
amap->template set_attribute_of_dart<j>(itj, a2);
amap->mark(itj, mark);
}
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
{ // Here the attribute was already present in the set
a1->set_dart(*it);
// std::cout<<"A1 "<<&*a1<<" "<<&**itj<<": ";
for ( CMap_dart_iterator_basic_of_cell<Map,j>
itj(*amap, *it, mark);
itj.cont(); ++itj )
{
// std::cout<<&*itj<<", ";
CGAL_assertion( itj->template attribute<j>()==a1 );
amap->mark(itj, mark);
}
}
// std::cout<<std::endl;
}
}
// Now we unmark all the marked darts.
amap->negate_mark(mark);
for ( typename std::deque<typename Map::Dart_handle>::
iterator it=modified_darts->begin();
it!=modified_darts->end(); ++it )
{
if ( !amap->is_marked(*it, mark) )
for ( CMap_dart_iterator_basic_of_cell<Map,j>
itj(*amap, *it, mark);
itj.cont(); ++itj )
{
amap->mark(itj, mark);
}
}
CGAL_assertion( amap->is_whole_map_marked(mark) );
amap->free_mark(mark);
}
};
} // namespace internal
} // namespace CGAL