mirror of https://github.com/CGAL/cgal
Wip group/degroup and operations
This commit is contained in:
parent
0778e0b166
commit
599d700c65
|
|
@ -23,12 +23,14 @@
|
|||
#include <CGAL/Compact_container.h>
|
||||
#include <CGAL/internal/Combinatorial_map_utility.h>
|
||||
#include <CGAL/internal/Combinatorial_map_functors.h>
|
||||
#include <CGAL/internal/Combinatorial_map_sewable.h>
|
||||
#include <CGAL/Combinatorial_map_min_items.h>
|
||||
#include <CGAL/Dart_const_iterators.h>
|
||||
#include <CGAL/Cell_const_iterators.h>
|
||||
#include <CGAL/Combinatorial_map_basic_operations.h>
|
||||
#include <bitset>
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
|
|
@ -96,11 +98,10 @@ namespace CGAL {
|
|||
|
||||
template<typename Map,unsigned int i>
|
||||
friend struct internal::Degroup_attribute_functor_run;
|
||||
*/
|
||||
|
||||
template <typename CMap, unsigned int i, typename Type_attr>
|
||||
friend struct internal::Degroup_one_attribute_functor;
|
||||
|
||||
*/
|
||||
template<typename Map>
|
||||
friend struct internal::Test_is_valid_attribute_functor;
|
||||
|
||||
|
|
@ -1139,11 +1140,11 @@ namespace CGAL {
|
|||
{
|
||||
CGAL_assertion(adart1 != NULL && adart2 != NULL);
|
||||
CGAL_assertion(adart1 != null_dart_handle && adart2 != null_dart_handle);
|
||||
Helper::template Foreach_enabled_attributes_except
|
||||
<internal::Group_attribute_functor_of_dart<Self>, 1>::
|
||||
run(this,adart1,adart2);
|
||||
adart1->basic_link_beta<0>(adart2);
|
||||
adart2->basic_link_beta<1>(adart1);
|
||||
Helper::template Foreach_enabled_attributes_except
|
||||
<internal::Group_attribute_functor_of_dart<Self, 0>, 1>::
|
||||
run(this,adart1,adart2);
|
||||
}
|
||||
|
||||
/** Double link two darts, and update the NULL attributes.
|
||||
|
|
@ -1159,11 +1160,11 @@ namespace CGAL {
|
|||
{
|
||||
CGAL_assertion(adart1 != NULL && adart2 != NULL);
|
||||
CGAL_assertion(adart1 != null_dart_handle && adart2 != null_dart_handle);
|
||||
Helper::template Foreach_enabled_attributes_except
|
||||
<internal::Group_attribute_functor_of_dart<Self>, 1>::
|
||||
run(this,adart1,adart2);
|
||||
adart1->basic_link_beta<1>(adart2);
|
||||
adart2->basic_link_beta<0>(adart1);
|
||||
Helper::template Foreach_enabled_attributes_except
|
||||
<internal::Group_attribute_functor_of_dart<Self, 1>, 1>::
|
||||
run(this,adart1,adart2);
|
||||
}
|
||||
|
||||
/** Double link two darts, and update the NULL attributes.
|
||||
|
|
@ -1183,11 +1184,11 @@ namespace CGAL {
|
|||
CGAL_assertion(adart1 != NULL && adart2 != NULL && adart1!=adart2 );
|
||||
CGAL_assertion(adart1 != null_dart_handle && adart2 != null_dart_handle);
|
||||
CGAL_assertion( 2<=i && i<=dimension );
|
||||
adart1->template basic_link_beta<i>(adart2);
|
||||
adart2->template basic_link_beta<i>(adart1);
|
||||
Helper::template Foreach_enabled_attributes_except
|
||||
<internal::Group_attribute_functor_of_dart<Self>, i>::
|
||||
run(this,adart1,adart2);
|
||||
adart1->template basic_link_beta<i>(adart2);
|
||||
adart2->template basic_link_beta<i>(adart1);
|
||||
}
|
||||
|
||||
/** Double link two darts, and update the NULL attributes.
|
||||
|
|
@ -1300,100 +1301,6 @@ namespace CGAL {
|
|||
else unlink_beta_for_involution(adart, i);
|
||||
}
|
||||
|
||||
/** Test if it is possible to sew by beta1 the two given darts
|
||||
* @param adart1 the first dart.
|
||||
* @param adart2 the second dart.
|
||||
* @return true iff \em adart1 can be 1-sewn with \em adart2.
|
||||
*/
|
||||
bool is_sewable_1(Dart_const_handle adart1, Dart_const_handle adart2) const
|
||||
{
|
||||
CGAL_assertion(adart1!=NULL && adart2!=NULL);
|
||||
|
||||
if ( !adart1->is_free(1) || !adart2->is_free(0) )
|
||||
return false;
|
||||
|
||||
if ( adart1 == adart2 ) return true;
|
||||
|
||||
CMap_dart_const_iterator_of_involution <Self,1> I1(*this, adart1);
|
||||
CMap_dart_const_iterator_of_involution_inv<Self,1> I2(*this, adart2);
|
||||
bool res = true;
|
||||
while (res && I1.cont() && I2.cont())
|
||||
{
|
||||
// We can remove this constraint which is not required for
|
||||
// combinatorial map definition, but which imposes quite "normal"
|
||||
// configurations
|
||||
if ( I1==adart2 || I2==adart1 ) res=false;
|
||||
|
||||
for (unsigned int j=3;res && j<=Self::dimension; ++j)
|
||||
{
|
||||
if ( I1->is_free(j)!=I2->is_free(j) )
|
||||
{
|
||||
res = false;
|
||||
}
|
||||
}
|
||||
++I1; ++I2;
|
||||
}
|
||||
if (I1.cont() != I2.cont())
|
||||
res = false;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/** Test if it is possible to sew by beta0 the two given darts
|
||||
* @param adart1 the first dart.
|
||||
* @param adart2 the second dart.
|
||||
* @return true iff \em adart1 can be 0-sewn with \em adart2.
|
||||
*/
|
||||
bool is_sewable_0(Dart_const_handle adart1, Dart_const_handle adart2) const
|
||||
{ return is_sewable_1(adart2, adart1); }
|
||||
|
||||
/** Test if it is possible to sew by betai the two given darts
|
||||
* for 2<=i<=dimension.
|
||||
* @param adart1 the first dart.
|
||||
* @param adart2 the second dart.
|
||||
* @return true iff \em adart1 can be 1-sewn with \em adart2.
|
||||
*/
|
||||
template<unsigned int i>
|
||||
bool is_sewable_for_involution(Dart_const_handle adart1,
|
||||
Dart_const_handle adart2) const
|
||||
{
|
||||
CGAL_assertion(2<=i && i<=Self::dimension);
|
||||
CGAL_assertion(adart1!=NULL && adart2!=NULL);
|
||||
|
||||
if ( !adart1->is_free(i) || !adart2->is_free(i) || adart1==adart2 )
|
||||
return false;
|
||||
|
||||
CMap_dart_const_iterator_of_involution<Self,i> I1(*this, adart1);
|
||||
CMap_dart_const_iterator_of_involution_inv<Self,i> I2(*this, adart2);
|
||||
bool res = true;
|
||||
while (res && I1.cont() && I2.cont())
|
||||
{
|
||||
// We can remove this constraint which is not required for
|
||||
// combinatorial map definition, but which is quite "normal"
|
||||
if ( I1==adart2 || I2==adart1 ) res=false;
|
||||
|
||||
// Special case to consider beta0 and beta1
|
||||
if ( i>2 )
|
||||
{
|
||||
if ( I1->is_free(0)!=I2->is_free(1) ) res = false;
|
||||
else if ( I1->is_free(1)!=I2->is_free(0) ) res = false;
|
||||
}
|
||||
|
||||
// General case
|
||||
for (unsigned int j=2;res && j<=Self::dimension; ++j)
|
||||
{
|
||||
if ( j+1!=i && j!=i && j!=i+1 &&
|
||||
I1->is_free(j)!=I2->is_free(j) )
|
||||
{ res = false; }
|
||||
}
|
||||
++I1; ++I2;
|
||||
}
|
||||
if (I1.cont() != I2.cont())
|
||||
res = false;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/** Test if it is possible to sew by betai the two given darts
|
||||
* @param adart1 the first dart.
|
||||
* @param adart2 the second dart.
|
||||
|
|
@ -1402,9 +1309,8 @@ namespace CGAL {
|
|||
template<unsigned int i>
|
||||
bool is_sewable(Dart_const_handle adart1, Dart_const_handle adart2) const
|
||||
{
|
||||
if ( i==0 ) return is_sewable_0(adart1, adart2);
|
||||
else if ( i==1 ) return is_sewable_1(adart1, adart2);
|
||||
else return is_sewable_for_involution<i>(adart1, adart2);
|
||||
return CGAL::internal::
|
||||
Is_sewable_functor<Self, i>::run(this, adart1, adart2);
|
||||
}
|
||||
|
||||
/** Topological sew by beta1 the two given darts plus all the required darts
|
||||
|
|
@ -1412,11 +1318,11 @@ namespace CGAL {
|
|||
* thus the map can be non valid.
|
||||
* @param adart1 the first dart.
|
||||
* @param adart2 the second dart.
|
||||
* @pre is_sewable_1(adart1, adart2).
|
||||
* @pre is_sewable<1>(adart1, adart2).
|
||||
*/
|
||||
void topo_sew_1(Dart_handle adart1, Dart_handle adart2)
|
||||
{
|
||||
CGAL_assertion( (is_sewable_1(adart1,adart2)) );
|
||||
CGAL_assertion( (is_sewable<1>(adart1,adart2)) );
|
||||
|
||||
int m = get_new_mark();
|
||||
std::deque<Dart_handle> dartv;
|
||||
|
|
@ -1429,15 +1335,14 @@ namespace CGAL {
|
|||
|
||||
CMap_dart_iterator_of_involution<Self,1> I1(*this, adart1);
|
||||
CMap_dart_iterator_of_involution_inv<Self,1> I2(*this, adart2);
|
||||
while ( I1.cont() )
|
||||
for ( ; I1.cont(); ++I1, ++I2 )
|
||||
{
|
||||
if ( is_marked(I1,m) ) basic_link_beta_1(I1, I2);
|
||||
else basic_link_beta_0(I1, I2);
|
||||
++I1; ++I2;
|
||||
}
|
||||
|
||||
for (typename std::deque<Dart_handle>::iterator
|
||||
it=dartv.begin(); it!=dartv.end(); ++it)
|
||||
for ( typename std::deque<Dart_handle>::iterator it=dartv.begin();
|
||||
it!=dartv.end(); ++it)
|
||||
{ unmark(*it,m); }
|
||||
CGAL_assertion( is_whole_map_unmarked(m) );
|
||||
free_mark(m);
|
||||
|
|
@ -1448,7 +1353,7 @@ namespace CGAL {
|
|||
* thus the map can be non valid.
|
||||
* @param adart1 the first dart.
|
||||
* @param adart2 the second dart.
|
||||
* @pre is_sewable_0(adart1, adart2).
|
||||
* @pre is_sewable<0>(adart1, adart2).
|
||||
*/
|
||||
void topo_sew_0(Dart_handle adart1, Dart_handle adart2)
|
||||
{ topo_sew_1(adart2, adart1); }
|
||||
|
|
@ -1459,20 +1364,19 @@ namespace CGAL {
|
|||
* @param adart1 the first dart.
|
||||
* @param adart2 the second dart.
|
||||
* @pre 2<=i<=dimension.
|
||||
* @pre is_sewable_for_involution<i>(adart1, adart2).
|
||||
* @pre is_sewable<i>(adart1, adart2).
|
||||
*/
|
||||
template<unsigned int i>
|
||||
void topo_sew_for_involution(Dart_handle adart1, Dart_handle adart2)
|
||||
{
|
||||
CGAL_assertion( 2<=i && i<=Self::dimension );
|
||||
CGAL_assertion( (is_sewable_for_involution<i>(adart1,adart2)) );
|
||||
CGAL_assertion( (is_sewable<i>(adart1,adart2)) );
|
||||
|
||||
CMap_dart_iterator_of_involution<Self,i> I1(*this, adart1);
|
||||
CMap_dart_iterator_of_involution_inv<Self,i> I2(*this, adart2);
|
||||
while ( I1.cont() )
|
||||
for ( ; I1.cont(); ++I1, ++I2 )
|
||||
{
|
||||
basic_link_beta_for_involution<i>(I1, I2);
|
||||
++I1; ++I2;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1486,7 +1390,7 @@ namespace CGAL {
|
|||
template<unsigned int i>
|
||||
void topo_sew(Dart_handle adart1, Dart_handle adart2)
|
||||
{
|
||||
if ( i==0 ) topo_sew_0(adart1, adart2);
|
||||
if ( i==0 ) topo_sew_1(adart2, adart1);
|
||||
else if ( i==1 ) topo_sew_1(adart1, adart2);
|
||||
else topo_sew_for_involution<i>(adart1, adart2);
|
||||
}
|
||||
|
|
@ -1496,15 +1400,15 @@ namespace CGAL {
|
|||
* attributes when necessary so that the final map is valid.
|
||||
* @param adart1 the first dart.
|
||||
* @param adart2 the second dart.
|
||||
* @pre is_sewable_0(adart1, adart2).
|
||||
* @pre is_sewable<0>(adart1, adart2).
|
||||
* @post is_valid()
|
||||
*/
|
||||
void sew_0(Dart_handle adart1, Dart_handle adart2)
|
||||
{
|
||||
CGAL_assertion( (is_sewable_0(adart1,adart2)) );
|
||||
CGAL_assertion( (is_sewable<0>(adart1,adart2)) );
|
||||
|
||||
int m = get_new_mark();
|
||||
std::vector<Dart_handle> dartv;
|
||||
std::deque<Dart_handle> dartv;
|
||||
for ( CMap_dart_iterator_basic_of_cell<Self,0> it(*this,adart1,m);
|
||||
it.cont(); ++it)
|
||||
{
|
||||
|
|
@ -1512,32 +1416,51 @@ namespace CGAL {
|
|||
dartv.push_back(it);
|
||||
}
|
||||
|
||||
CMap_dart_iterator_of_involution<Self,1> I1(*this, adart1);
|
||||
CMap_dart_iterator_of_involution_inv<Self,1> I2(*this, adart2);
|
||||
while ( I1.cont() )
|
||||
{
|
||||
Dart_handle od1=I1->other_extremity();
|
||||
Dart_handle od2=I2->other_extremity();
|
||||
/*if (od1!=NULL && od2!=NULL) TODO
|
||||
group_all_attributes_except(od1, od2, 1);*/
|
||||
++I1; ++I2;
|
||||
}
|
||||
int mark = get_new_mark();
|
||||
CGAL_assertion( mark!=-1 );
|
||||
|
||||
I1.rewind(); I2.rewind();
|
||||
while ( I1.cont() )
|
||||
CMap_dart_iterator_basic_of_involution<Self,1>
|
||||
I1(*this, adart1, mark);
|
||||
CMap_dart_iterator_basic_of_involution_inv<Self,1>
|
||||
I2(*this, adart2, mark);
|
||||
|
||||
// This first loop do not modify the map, but only the attributes
|
||||
// (by calling when required the onmerge functors).
|
||||
for ( ; I1.cont(); ++I1, ++I2 )
|
||||
{
|
||||
if ( is_marked(I1,m) )
|
||||
basic_link_beta_0(I1, I2);
|
||||
Helper::template Foreach_enabled_attributes_except
|
||||
<internal::Group_attribute_functor<Self, 0>, 1>::
|
||||
run(this, I1, I2);
|
||||
else
|
||||
basic_link_beta_1(I1, I2);
|
||||
++I1; ++I2;
|
||||
Helper::template Foreach_enabled_attributes_except
|
||||
<internal::Group_attribute_functor<Self, 1>, 1>::
|
||||
run(this, I1, I2);
|
||||
|
||||
/* TODO check AVANT Dart_handle od1=I1->other_extremity();
|
||||
Dart_handle od2=I2->other_extremity();
|
||||
if (od1!=NULL && od2!=NULL)
|
||||
run(this,adart1,adart2);
|
||||
group_all_attributes_except(od1, od2, 1);*/
|
||||
}
|
||||
|
||||
for (typename std::vector<Dart_handle>::iterator
|
||||
it=dartv.begin(); it!=dartv.end(); ++it)
|
||||
// Now we update the beta links.
|
||||
negate_mark( mark );
|
||||
for ( I1.rewind(), I2.rewind(); I1.cont(); ++I1, ++I2 )
|
||||
{
|
||||
if ( is_marked(I1,m) ) basic_link_beta_0(I1, I2);
|
||||
else basic_link_beta_1(I1, I2);
|
||||
}
|
||||
|
||||
for ( typename std::deque<Dart_handle>::iterator it=dartv.begin();
|
||||
it!=dartv.end(); ++it )
|
||||
{ unmark(*it,m); }
|
||||
CGAL_assertion( is_whole_map_unmarked(m) );
|
||||
free_mark(m);
|
||||
|
||||
negate_mark( mark );
|
||||
CGAL_assertion( is_whole_map_unmarked(mark) );
|
||||
free_mark(mark);
|
||||
}
|
||||
|
||||
/** Sew by beta1 the two given darts plus all the required darts
|
||||
|
|
@ -1545,14 +1468,14 @@ namespace CGAL {
|
|||
* attributes when necessary so that the final map is valid.
|
||||
* @param adart1 the first dart.
|
||||
* @param adart2 the second dart.
|
||||
* @pre is_sewable_1(adart1, adart2).
|
||||
* @pre is_sewable<1>(adart1, adart2).
|
||||
* @post is_valid()
|
||||
*/
|
||||
void sew_1(Dart_handle adart1, Dart_handle adart2)
|
||||
{
|
||||
CGAL_assertion( (is_sewable_1(adart1,adart2)) );
|
||||
CGAL_assertion( (is_sewable<1>(adart1,adart2)) );
|
||||
int m = get_new_mark();
|
||||
std::vector<Dart_handle> dartv;
|
||||
std::deque<Dart_handle> dartv;
|
||||
for ( CMap_dart_iterator_basic_of_cell<Self,0> it(*this,adart1,m);
|
||||
it.cont(); ++it )
|
||||
{
|
||||
|
|
@ -1560,29 +1483,46 @@ namespace CGAL {
|
|||
dartv.push_back(it);
|
||||
}
|
||||
|
||||
CMap_dart_iterator_of_involution<Self,1> I1(*this, adart1);
|
||||
CMap_dart_iterator_of_involution_inv<Self,1> I2(*this, adart2);
|
||||
while ( I1.cont() )
|
||||
{
|
||||
// TODO group_all_attributes_except(I1,I2,1);
|
||||
++I1; ++I2;
|
||||
}
|
||||
int mark = get_new_mark();
|
||||
CGAL_assertion( mark!=-1 );
|
||||
|
||||
I1.rewind(); I2.rewind();
|
||||
while ( I1.cont() )
|
||||
CMap_dart_iterator_basic_of_involution<Self,1>
|
||||
I1(*this, adart1, mark);
|
||||
CMap_dart_iterator_basic_of_involution_inv<Self,1>
|
||||
I2(*this, adart2, mark);
|
||||
|
||||
// This first loop do not modify the map, but only the attributes
|
||||
// (by calling when required the onmerge functors).
|
||||
for ( ; I1.cont(); ++I1, ++I2 )
|
||||
{
|
||||
if ( is_marked(I1,m) )
|
||||
basic_link_beta_1(I1, I2);
|
||||
Helper::template Foreach_enabled_attributes_except
|
||||
<internal::Group_attribute_functor<Self, 1>, 1>::
|
||||
run(this, I1, I2);
|
||||
else
|
||||
basic_link_beta_0(I1, I2);
|
||||
++I1; ++I2;
|
||||
Helper::template Foreach_enabled_attributes_except
|
||||
<internal::Group_attribute_functor<Self, 0>, 1>::
|
||||
run(this, I1, I2);
|
||||
// TODO check avant group_all_attributes_except(I1,I2,1);
|
||||
}
|
||||
|
||||
for (typename std::vector<Dart_handle>::iterator
|
||||
it=dartv.begin(); it!=dartv.end(); ++it)
|
||||
// Now we update the beta links.
|
||||
negate_mark( mark );
|
||||
for ( I1.rewind(), I2.rewind(); I1.cont(); ++I1, ++I2 )
|
||||
{
|
||||
if ( is_marked(I1,m) ) basic_link_beta_1(I1, I2);
|
||||
else basic_link_beta_0(I1, I2);
|
||||
}
|
||||
|
||||
for ( typename std::deque<Dart_handle>::iterator it=dartv.begin();
|
||||
it!=dartv.end(); ++it )
|
||||
{ unmark(*it,m); }
|
||||
CGAL_assertion( is_whole_map_unmarked(m) );
|
||||
free_mark(m);
|
||||
|
||||
negate_mark( mark );
|
||||
CGAL_assertion( is_whole_map_unmarked(mark) );
|
||||
free_mark(mark);
|
||||
}
|
||||
|
||||
/** Sew by betai the two given darts plus all the required darts
|
||||
|
|
@ -1598,7 +1538,7 @@ namespace CGAL {
|
|||
void sew_for_involution(Dart_handle adart1, Dart_handle adart2)
|
||||
{
|
||||
CGAL_assertion( 2<=i && i<=dimension );
|
||||
CGAL_assertion( (is_sewable_for_involution<i>(adart1,adart2)) );
|
||||
CGAL_assertion( (is_sewable<i>(adart1,adart2)) );
|
||||
|
||||
int mark = get_new_mark();
|
||||
CGAL_assertion( mark!=-1 );
|
||||
|
|
@ -1608,18 +1548,21 @@ namespace CGAL {
|
|||
CMap_dart_iterator_basic_of_involution_inv<Self,i>
|
||||
I2(*this, adart2, mark);
|
||||
|
||||
while ( I1.cont() )
|
||||
// This first loop do not modify the map, but only the attributes
|
||||
// (by calling when required the onmerge functors).
|
||||
for ( ; I1.cont(); ++I1, ++I2 )
|
||||
{
|
||||
// TODO group_all_attributes_except(I1,I2,i);
|
||||
++I1; ++I2;
|
||||
Helper::template Foreach_enabled_attributes_except
|
||||
<internal::Group_attribute_functor<Self>, i>::
|
||||
run(this, I1, I2);
|
||||
// TODO avant group_all_attributes_except(I1,I2,i);
|
||||
}
|
||||
|
||||
// Now we update the beta links.
|
||||
negate_mark( mark );
|
||||
I1.rewind(); I2.rewind();
|
||||
while ( I1.cont() )
|
||||
for ( I1.rewind(), I2.rewind(); I1.cont(); ++I1, ++I2 )
|
||||
{
|
||||
basic_link_beta_for_involution(I1, I2, i);
|
||||
++I1; ++I2;
|
||||
basic_link_beta_for_involution<i>(I1, I2);
|
||||
}
|
||||
|
||||
negate_mark( mark );
|
||||
|
|
@ -1666,10 +1609,10 @@ namespace CGAL {
|
|||
*/
|
||||
void topo_unsew_1(Dart_handle adart)
|
||||
{
|
||||
CGAL_assertion( adart!=NULL && !adart->is_free(1) );
|
||||
CGAL_assertion( adart!=NULL && !adart->template is_free<1>() );
|
||||
|
||||
int m = get_new_mark();
|
||||
std::vector<Dart_handle> dartv;
|
||||
std::deque<Dart_handle> dartv;
|
||||
for ( CMap_dart_iterator_basic_of_cell<Self,0> it(*this,adart,m);
|
||||
it.cont(); ++it)
|
||||
{
|
||||
|
|
@ -1677,18 +1620,15 @@ namespace CGAL {
|
|||
dartv.push_back(*it);
|
||||
}
|
||||
|
||||
for ( CMap_dart_iterator_of_involution<Self,1> it(*this, adart);
|
||||
it.cont(); ++it )
|
||||
{
|
||||
CMap_dart_iterator_of_involution<Self,1> it(*this, adart);
|
||||
while ( it.cont() )
|
||||
{
|
||||
if ( is_marked(*it,m) ) basic_unlink_beta_1(*it);
|
||||
else basic_unlink_beta_0(*it);
|
||||
++it;
|
||||
}
|
||||
if ( is_marked(*it,m) ) unlink_beta_1(*it);
|
||||
else unlink_beta_0(*it);
|
||||
}
|
||||
|
||||
for (typename std::vector<Dart_handle>::iterator
|
||||
it=dartv.begin(); it!=dartv.end(); ++it)
|
||||
for ( typename std::deque<Dart_handle>::iterator it=dartv.begin();
|
||||
it!=dartv.end(); ++it )
|
||||
{ unmark(*it,m); }
|
||||
CGAL_assertion( is_whole_map_unmarked(m) );
|
||||
free_mark(m);
|
||||
|
|
@ -1702,8 +1642,8 @@ namespace CGAL {
|
|||
*/
|
||||
void topo_unsew_0(Dart_handle adart)
|
||||
{
|
||||
CGAL_assertion( adart!=NULL && !adart->is_free(0) );
|
||||
topo_unsew_1(adart->beta(0));
|
||||
CGAL_assertion( adart!=NULL && !adart->template is_free<0>() );
|
||||
topo_unsew_1( adart->template beta<0>() );
|
||||
}
|
||||
|
||||
/** Topological unsew by betai the given dart plus all the required darts
|
||||
|
|
@ -1716,15 +1656,12 @@ namespace CGAL {
|
|||
template<unsigned int i>
|
||||
void topo_unsew_for_involution(Dart_handle adart)
|
||||
{
|
||||
CGAL_assertion( adart!=NULL && !adart->is_free(i) );
|
||||
CGAL_assertion( adart!=NULL && !adart->template is_free<i>() );
|
||||
CGAL_assertion( 2<=i && i<=Self::dimension );
|
||||
|
||||
CMap_dart_iterator_of_involution<Self,i> it(*this, adart);
|
||||
while ( it.cont() )
|
||||
{
|
||||
unlink_beta(*it, i);
|
||||
++it;
|
||||
}
|
||||
for ( CMap_dart_iterator_of_involution<Self,i> it(*this, adart);
|
||||
it.cont(); ++it )
|
||||
{ unlink_beta<i>(*it); }
|
||||
}
|
||||
|
||||
/** Topological unsew by betai the given dart plus all the required darts
|
||||
|
|
@ -1750,11 +1687,13 @@ namespace CGAL {
|
|||
*/
|
||||
void unsew_0(Dart_handle adart)
|
||||
{
|
||||
CGAL_assertion( adart!=NULL && !adart->is_free(0) );
|
||||
CGAL_assertion( adart!=NULL && !adart->template is_free<0>() );
|
||||
Dart_handle d2=NULL;
|
||||
|
||||
int m=get_new_mark();
|
||||
std::vector<Dart_handle> dartv;
|
||||
std::deque<Dart_handle> dartv;
|
||||
std::deque<Dart_handle> modified_darts;
|
||||
|
||||
for ( CMap_dart_iterator_basic_of_cell<Self,0> it(*this, adart, m);
|
||||
it.cont(); ++it)
|
||||
{
|
||||
|
|
@ -1762,37 +1701,36 @@ namespace CGAL {
|
|||
dartv.push_back(it);
|
||||
}
|
||||
|
||||
{
|
||||
CMap_dart_iterator_of_involution<Self,1> it(*this, adart);
|
||||
while ( it.cont() )
|
||||
for ( CMap_dart_iterator_of_involution<Self,1> it(*this, adart);
|
||||
it.cont(); ++it )
|
||||
{
|
||||
if ( is_marked(it, m) )
|
||||
{
|
||||
d2 = it->beta(0);
|
||||
modified_darts.push_back(it);
|
||||
modified_darts.push_back(it->template beta<0>());
|
||||
unlink_beta_0(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
d2 = it->beta(1);
|
||||
modified_darts.push_back(it);
|
||||
modified_darts.push_back(it->template beta<1>());
|
||||
unlink_beta_1(it);
|
||||
}
|
||||
|
||||
// TODO do the degroup after the loop (cf unsew_for_involution)
|
||||
Dart_handle od1=it->other_extremity();
|
||||
Dart_handle od2=d2->other_extremity();
|
||||
/* TODO if ( od1!=NULL && od2!=NULL )
|
||||
degroup_all_attributes_except(od1,od2,1); */
|
||||
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
for (typename std::vector<Dart_handle>::iterator
|
||||
it=dartv.begin(); it!=dartv.end(); ++it)
|
||||
for ( typename std::deque<Dart_handle>::iterator it=dartv.begin();
|
||||
it!=dartv.end(); ++it )
|
||||
{ unmark(*it,m); }
|
||||
|
||||
CGAL_assertion( is_whole_map_unmarked(m) );
|
||||
free_mark(m);
|
||||
|
||||
// TODO pass the mark m to know which dart is modified by b0 of b1
|
||||
// We test the split of all the incident cells for all the non
|
||||
// void attributes.
|
||||
Helper::template Foreach_enabled_attributes_except
|
||||
<internal::Test_split_attribute_functor<Self,0>, 1>::
|
||||
run(this, &modified_darts);
|
||||
}
|
||||
|
||||
/** Unsew by beta1 the given dart plus all the required darts
|
||||
|
|
@ -1808,7 +1746,9 @@ namespace CGAL {
|
|||
Dart_handle d2 = NULL;
|
||||
|
||||
int m = get_new_mark();
|
||||
std::vector<Dart_handle> dartv;
|
||||
std::deque<Dart_handle> dartv;
|
||||
std::deque<Dart_handle> modified_darts;
|
||||
|
||||
for ( CMap_dart_iterator_basic_of_cell<Self,0> it(*this,adart,m);
|
||||
it.cont(); ++it)
|
||||
{
|
||||
|
|
@ -1816,25 +1756,35 @@ namespace CGAL {
|
|||
dartv.push_back(it);
|
||||
}
|
||||
|
||||
{
|
||||
CMap_dart_iterator_of_involution<Self,1> it(*this, adart);
|
||||
while ( it.cont() )
|
||||
for ( CMap_dart_iterator_of_involution<Self,1> it(*this, adart);
|
||||
it.cont(); ++it )
|
||||
{
|
||||
if ( is_marked(it, m) )
|
||||
{ d2 = it->beta(1); unlink_beta_1(it); }
|
||||
{
|
||||
modified_darts.push_back(it);
|
||||
modified_darts.push_back(it->template beta<1>());
|
||||
unlink_beta_1(it);
|
||||
}
|
||||
else
|
||||
{ d2 = it->beta(0); unlink_beta_0(it); }
|
||||
// TODO do the degroup after the loop (cf unsew_for_involution)
|
||||
// TODO degroup_all_attributes_except(it,d2,1);
|
||||
++it;
|
||||
{
|
||||
modified_darts.push_back(it);
|
||||
modified_darts.push_back(it->template beta<0>());
|
||||
unlink_beta_0(it);
|
||||
}
|
||||
}
|
||||
|
||||
for (typename std::vector<Dart_handle>::iterator
|
||||
for ( typename std::deque<Dart_handle>::iterator
|
||||
it=dartv.begin(); it!=dartv.end(); ++it)
|
||||
{ unmark(*it,m); }
|
||||
CGAL_assertion( is_whole_map_unmarked(m) );
|
||||
free_mark(m);
|
||||
|
||||
// TODO pass the mark m to know which dart is modified by b0 of b1
|
||||
// We test the split of all the incident cells for all the non
|
||||
// void attributes.
|
||||
Helper::template Foreach_enabled_attributes_except
|
||||
<internal::Test_split_attribute_functor<Self,1>, 1>::
|
||||
run(this, &modified_darts);
|
||||
}
|
||||
|
||||
/** Unsew by betai the given dart plus all the required darts
|
||||
|
|
@ -1851,23 +1801,22 @@ namespace CGAL {
|
|||
CGAL_assertion(2<=i && i<=Self::dimension);
|
||||
CGAL_assertion( adart!=NULL && !adart->is_free(i) );
|
||||
|
||||
std::stack<internal::Couple_dart_and_dim<Dart_handle> > todegroup;
|
||||
std::deque<Dart_handle> modified_darts;
|
||||
|
||||
CMap_dart_iterator_of_involution<Self,i> it(*this, adart);
|
||||
while ( it.cont() )
|
||||
for ( CMap_dart_iterator_of_involution<Self,i> it(*this, adart);
|
||||
it.cont(); ++it )
|
||||
{
|
||||
todegroup.push(internal::Couple_dart_and_dim<Dart_handle>
|
||||
(it,it->beta(i),i));
|
||||
unlink_beta_for_involution(it,i);
|
||||
modified_darts.push_back(it);
|
||||
modified_darts.push_back(it->template beta<i>());
|
||||
unlink_beta_for_involution<i>(it);
|
||||
++it;
|
||||
}
|
||||
|
||||
while (!todegroup.empty() )
|
||||
{
|
||||
internal::Couple_dart_and_dim<Dart_handle> c=todegroup.top();
|
||||
todegroup.pop();
|
||||
// TODO degroup_all_attributes_except(c.d1,c.d2,c.dim);
|
||||
}
|
||||
// We test the split of all the incident cells for all the non
|
||||
// void attributes.
|
||||
Helper::template Foreach_enabled_attributes_except
|
||||
<internal::Test_split_attribute_functor<Self,i>, i>::
|
||||
run(this, &modified_darts);
|
||||
}
|
||||
|
||||
/** Unsew by betai the given dart plus all the required darts
|
||||
|
|
@ -2095,54 +2044,6 @@ namespace CGAL {
|
|||
<internal::Update_dart_of_attribute_functor<Self> >::run(this,ah,amark);
|
||||
}
|
||||
|
||||
/** Degroup the i-cell attribute of the two given darts, if required.
|
||||
* If the two darts are incident to the same attribute and do not belong to
|
||||
* the same i-cell, we create a new attibute and link each dart
|
||||
* belonging to the i-cell of adart2 onto this new attribute.
|
||||
* The new attribute is initialized by copying the old one then by using
|
||||
* the functor On_split from the original attribute.
|
||||
* @param adart1 the first dart.
|
||||
* @param adart2 the second dart.
|
||||
* @return true iff the attribute is split.
|
||||
*/
|
||||
template<unsigned int i, class Type_attr>
|
||||
bool degroup_enabled_attribute(Dart_handle adart1, Dart_handle adart2)
|
||||
{
|
||||
CGAL_static_assertion(i<=dimension);
|
||||
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
|
||||
"degroup_enabled_attribute<i> but "
|
||||
"i-attributes are disabled");
|
||||
CGAL_assertion(adart1 != NULL && adart2 != NULL);
|
||||
CGAL_assertion(adart1 != null_dart_handle && adart2 != null_dart_handle);
|
||||
|
||||
typename Attribute_handle<i>::type a1=adart1->template attribute<i>();
|
||||
typename Attribute_handle<i>::type a2=NULL;
|
||||
|
||||
// If the two attributes are not equal, nothing to do.
|
||||
if ( a1 != adart2->template attribute<i>() || a1 == NULL) return false;
|
||||
|
||||
// TODO improve this step: use basic iterator to iterate through cell<i>(adart2)
|
||||
// If the two darts belong to the same cell, nothing to do.
|
||||
if ( belong_to_same_cell<Self,i,dimension>(*this, adart1, adart2) )
|
||||
return false;
|
||||
|
||||
// Here we create a new attribute
|
||||
a2 = create_attribute<i>(*a1);
|
||||
|
||||
// We call the on_split functor
|
||||
internal::Apply_cell_functor<Type_attr,
|
||||
typename Type_attr::On_split>::run(*a1,*a2);
|
||||
|
||||
// We set the dart of the cell a1 onto adart1.
|
||||
a1->set_dart(adart1);
|
||||
|
||||
// and reuse the basic iterator here to unmark.
|
||||
// And we set all the dart of the cell of adart2 to v1.
|
||||
set_attribute<i>(adart2, a2);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Test the validity of a i-cell-attribute.
|
||||
* ie all the darts belonging to a i-cell are linked to the same attribute.
|
||||
* @param adart a dart.
|
||||
|
|
@ -3066,7 +2967,8 @@ namespace CGAL {
|
|||
"set_attribute_of_dart<i> but "
|
||||
"i-attributes are disabled");
|
||||
CGAL_assertion( adart!=NULL && adart!=null_dart_handle && ah!=NULL );
|
||||
CGAL_assertion( adart->template attribute<i>()!=ah );
|
||||
|
||||
if ( adart->template attribute<i>()==ah ) return;
|
||||
|
||||
decrease_attribute_ref_counting<i>(adart);
|
||||
adart->template set_attribute<i>(ah);
|
||||
|
|
@ -3076,7 +2978,7 @@ namespace CGAL {
|
|||
|
||||
public:
|
||||
|
||||
/** Set the i-attribute of all the darts of a given range.
|
||||
/** Set the i-attribute of all the darts of a given i-cell.
|
||||
* @param adart a starting dart.
|
||||
* @param ah an handle to the i-attribute to set.
|
||||
*/
|
||||
|
|
@ -3099,6 +3001,10 @@ namespace CGAL {
|
|||
}
|
||||
ah->set_dart(adart);
|
||||
}
|
||||
/** Set the i-attribute of all the darts of a given range.
|
||||
* @param adart a starting dart.
|
||||
* @param ah an handle to the i-attribute to set.
|
||||
*/
|
||||
template<unsigned int i, typename Range>
|
||||
void set_attribute(Dart_handle adart,
|
||||
typename Attribute_handle<i>::type ah)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,633 @@
|
|||
#ifndef CGAL_COMBINATORIAL_MAP_INSERTIONS_H
|
||||
#define CGAL_COMBINATORIAL_MAP_INSERTIONS_H
|
||||
|
||||
namespace CGAL {
|
||||
/** @file Combinatorial_map_insertions.h
|
||||
* Insertion operations on combinatorial map.
|
||||
*/
|
||||
|
||||
/** Insert a vertex in a given edge.
|
||||
* @param amap the used combinatorial map.
|
||||
* @param adart a dart of the edge (!=NULL && !=null_dart_handle).
|
||||
* @return a dart of the new vertex.
|
||||
*/
|
||||
template<class CMap>
|
||||
typename CMap::Dart_handle
|
||||
insert_cell_0_in_cell_1(CMap& amap, typename CMap::Dart_handle adart)
|
||||
{
|
||||
CGAL_assertion(adart != NULL && adart!=CMap::null_dart_handle);
|
||||
|
||||
typename CMap::Dart_handle d1, d2;
|
||||
int mark = amap.get_new_mark();
|
||||
|
||||
// 1) We store all the darts of the edge.
|
||||
std::deque<typename CMap::Dart_handle> vect;
|
||||
{
|
||||
for ( typename CMap::template Dart_of_cell_range<1>::iterator it=
|
||||
amap.template darts_of_cell<1>(adart).begin();
|
||||
it != amap.template darts_of_cell<1>(adart).end(); ++it )
|
||||
vect.push_back(it);
|
||||
}
|
||||
|
||||
// 2) For each dart of the cell, we modify link of neighbors.
|
||||
typename std::deque<typename CMap::Dart_handle>::iterator it = vect.begin();
|
||||
for (; it != vect.end(); ++it)
|
||||
{
|
||||
d1 = amap.create_dart();
|
||||
|
||||
if (!(*it)->is_free(1))
|
||||
{ amap.basic_link_beta_1(d1, (*it)->beta(1)); }
|
||||
|
||||
for ( unsigned int dim=2; dim<=CMap::dimension; ++dim )
|
||||
{
|
||||
if (!(*it)->is_free(dim) && amap.is_marked((*it)->beta(dim), mark))
|
||||
{
|
||||
amap.basic_link_beta_for_involution((*it)->beta(dim), d1, dim);
|
||||
amap.basic_link_beta_for_involution(*it, (*it)->beta(dim)->
|
||||
template beta<1>(), dim);
|
||||
}
|
||||
}
|
||||
|
||||
amap.template link_beta_1(*it, d1);
|
||||
// TODO remove this group, and use link_beta instead ?
|
||||
//amap.group_all_dart_attributes_except(*it, d1, 1);
|
||||
|
||||
amap.mark(*it, mark);
|
||||
}
|
||||
|
||||
for (it = vect.begin(); it != vect.end(); ++it)
|
||||
{ amap.unmark(*it, mark); }
|
||||
|
||||
amap.free_mark(mark);
|
||||
|
||||
internal::Degroup_attribute_functor_run<CMap, 1>::
|
||||
run(&amap, adart, adart->beta(1));
|
||||
|
||||
// CGAL_expensive_postcondition( amap.is_valid() );
|
||||
|
||||
return adart->beta(1);
|
||||
}
|
||||
|
||||
/** Insert a vertex in the given 2-cell which is splitted in triangles,
|
||||
* once for each inital edge of the facet.
|
||||
* @param amap the used combinatorial map.
|
||||
* @param adart a dart of the facet to triangulate.
|
||||
* @return A dart incident to the new vertex.
|
||||
*/
|
||||
// TODO revoir toute la gestion des attributs
|
||||
// (utilisation correcte des link avec/sans la maj)
|
||||
template < class CMap >
|
||||
typename CMap::Dart_handle
|
||||
insert_cell_0_in_cell_2(CMap& amap, typename CMap::Dart_handle adart)
|
||||
{
|
||||
CGAL_assertion(adart != NULL && adart!=CMap::null_dart_handle);
|
||||
|
||||
typename CMap::Dart_handle first = adart, prev = NULL, cur = NULL;
|
||||
typename CMap::Dart_handle n1 = NULL, n2 = NULL;
|
||||
|
||||
typename CMap::Dart_handle nn1 = NULL, nn2 = NULL;
|
||||
|
||||
// If the facet is open, we search the dart 0-free
|
||||
while (!first->is_free(0) && first->beta(0) != adart)
|
||||
first = first->beta(0);
|
||||
|
||||
// Stack of couple of dart and dimension for which
|
||||
// we must call on_split functor
|
||||
std::deque<typename CMap::Dart_handle> modified_darts;
|
||||
|
||||
// Mark used to mark darts already treated.
|
||||
int treated = amap.get_new_mark();
|
||||
|
||||
// Stack of marked darts
|
||||
std::stack<typename CMap::Dart_handle> tounmark;
|
||||
|
||||
// Now we run through the facet
|
||||
for (CGAL::CMap_dart_iterator_basic_of_orbit<CMap,1> it(amap,first);
|
||||
it.cont();)
|
||||
{
|
||||
cur = it;
|
||||
++it;
|
||||
amap.mark(cur, treated);
|
||||
tounmark.push(cur);
|
||||
|
||||
if ( cur!=first )
|
||||
{
|
||||
// TODO
|
||||
//if ( amap.template degroup_attribute_of_dart<2>(first, cur) )
|
||||
{
|
||||
// TODO Functor takiing a range, an attrib_handle, and that set
|
||||
// all the darts of the range to this handle
|
||||
/* for (typename CMap::template Dart_of_involution_range<1>::iterator
|
||||
it=template darts_of_involution<1>(dh2).begin(),
|
||||
itend=template darts_of_involution<1>(dh2).end(); it!=itend;
|
||||
++it)
|
||||
{
|
||||
}
|
||||
tosplit.push(internal::Couple_dart_and_dim
|
||||
<typename CMap::Dart_handle>
|
||||
(first,cur,2));*/
|
||||
}
|
||||
}
|
||||
|
||||
if (!cur->is_free(0))
|
||||
{
|
||||
n1 = amap.create_dart();
|
||||
amap.link_beta_0(cur, n1);
|
||||
}
|
||||
else n1 = NULL;
|
||||
|
||||
if (!cur->is_free(1))
|
||||
{
|
||||
n2 = amap.create_dart();
|
||||
amap.link_beta_1(cur, n2);
|
||||
}
|
||||
else n2 = NULL;
|
||||
|
||||
if (n1 != NULL && n2 != NULL)
|
||||
amap.link_beta_0(n1, n2);
|
||||
|
||||
if (n1 != NULL && prev != NULL)
|
||||
amap.template link_beta_for_involution<2>(prev, n1);
|
||||
|
||||
for (unsigned int dim=3; dim<=CMap::dimension; ++dim)
|
||||
{
|
||||
if ( !adart->is_free(dim) )
|
||||
{
|
||||
if ( !amap.is_marked(cur->beta(dim), treated) )
|
||||
{
|
||||
if (n1!=NULL)
|
||||
{
|
||||
nn1=amap.create_dart();
|
||||
amap.link_beta_1(cur->beta(dim), nn1);
|
||||
amap.basic_link_beta_for_involution(n1, nn1, dim);
|
||||
}
|
||||
else nn1=NULL;
|
||||
|
||||
if (n2!=NULL)
|
||||
{
|
||||
nn2=amap.create_dart();
|
||||
amap.link_beta_0(cur->beta(dim), nn2);
|
||||
amap.basic_link_beta_for_involution(n2, nn2, dim);
|
||||
}
|
||||
else nn2=NULL;
|
||||
|
||||
if (nn1 != NULL && nn2 != NULL)
|
||||
amap.basic_link_beta_1(nn1, nn2);
|
||||
|
||||
if (nn1 != NULL && prev != NULL)
|
||||
amap.basic_link_beta_for_involution(nn1, prev->beta(dim), 2);
|
||||
|
||||
amap.mark(cur->beta(dim), treated);
|
||||
tounmark.push(cur->beta(dim));
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( n1!=NULL )
|
||||
amap.basic_link_beta_for_involution(n1, cur->beta(dim)->beta(1), dim);
|
||||
if ( n2!=NULL )
|
||||
amap.basic_link_beta_for_involution(n2, cur->beta(dim)->beta(0), dim);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
prev = n2;
|
||||
}
|
||||
|
||||
if (n2 != NULL)
|
||||
{
|
||||
amap.template link_beta_for_involution<2>(first->beta(0), n2);
|
||||
for (unsigned int dim=3; dim<=CMap::dimension; ++dim)
|
||||
{
|
||||
if ( !adart->is_free(dim) )
|
||||
{
|
||||
amap.basic_link_beta_for_involution(first->beta(0)->beta(dim),
|
||||
n2->beta(dim), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now we unmark all marked darts
|
||||
while ( !tounmark.empty() )
|
||||
{
|
||||
amap.unmark(tounmark.top(), treated);
|
||||
tounmark.pop();
|
||||
}
|
||||
|
||||
CGAL_assertion(amap.is_whole_map_unmarked(treated));
|
||||
amap.free_mark(treated);
|
||||
|
||||
/* TODO while ( !tosplit.empty() )
|
||||
{
|
||||
internal::Couple_dart_and_dim<typename CMap::Dart_handle> c=tosplit.top();
|
||||
tosplit.pop();
|
||||
internal::Call_split_functor<CMap, 2>::run(c.d1, c.d2);
|
||||
} */
|
||||
|
||||
CGAL_expensive_postcondition( amap.is_valid() );
|
||||
|
||||
return n1;
|
||||
}
|
||||
/** Insert a dangling edge in a 2-cell between given by a dart.
|
||||
* @param amap the used combinatorial map.
|
||||
* @param adart1 a first dart of the facet (!=NULL && !=null_dart_handle).
|
||||
* @return a dart of the new edge, not incident to the vertex of adart1.
|
||||
*/
|
||||
template<class CMap>
|
||||
typename CMap::Dart_handle
|
||||
insert_dangling_cell_1_in_cell_2(CMap& amap, typename CMap::Dart_handle adart1)
|
||||
{
|
||||
CGAL_assertion(adart1!=NULL && adart1!=CMap::null_dart_handle);
|
||||
|
||||
int mark1 = amap.get_new_mark();
|
||||
std::deque<typename CMap::Dart_handle> to_unmark;
|
||||
{
|
||||
for ( CMap_dart_iterator_basic_of_cell<CMap,0> it(amap,adart1,mark1);
|
||||
it.cont(); ++it )
|
||||
{
|
||||
to_unmark.push_back(it);
|
||||
amap.mark(it,mark1);
|
||||
}
|
||||
}
|
||||
|
||||
typename CMap::Dart_handle d1 = NULL;
|
||||
typename CMap::Dart_handle d2 = NULL;
|
||||
unsigned int s1 = 0;
|
||||
|
||||
int treated = amap.get_new_mark();
|
||||
|
||||
CGAL::CMap_dart_iterator_of_involution<CMap,1> it1(amap,adart1);
|
||||
|
||||
for ( ; it1.cont(); ++it1)
|
||||
{
|
||||
d1 = amap.create_dart();
|
||||
d2 = amap.create_dart();
|
||||
|
||||
if ( amap.is_marked(it1, mark1) ) s1 = 0;
|
||||
else s1 = 1;
|
||||
|
||||
if ( !it1->is_free(s1) )
|
||||
{
|
||||
if ( s1==0 ) amap.template link_beta<1>(it1->template beta<0>(), d2);
|
||||
else amap.template link_beta<0>(it1->template beta<1>(), d2);
|
||||
}
|
||||
|
||||
if (s1==0)
|
||||
{
|
||||
amap.template link_beta<0>(it1, d1);
|
||||
amap.template link_beta<0>(d1,d2);
|
||||
}
|
||||
else
|
||||
{
|
||||
amap.template link_beta<1>(it1, d1);
|
||||
amap.template link_beta<1>(d1,d2);
|
||||
}
|
||||
|
||||
amap.template link_beta_for_involution<2>(d1, d2);
|
||||
|
||||
for ( unsigned int dim=3; dim<=CMap::dimension; ++dim)
|
||||
{
|
||||
if ( !it1->is_free(dim) &&
|
||||
amap.is_marked(it1->beta(dim), treated) )
|
||||
{
|
||||
amap.basic_link_beta_for_involution(it1->beta(dim)->beta_inv(s1), d1,
|
||||
dim);
|
||||
amap.basic_link_beta_for_involution
|
||||
(it1->beta(dim)->beta_inv(s1)->beta(2), d2, dim);
|
||||
}
|
||||
}
|
||||
|
||||
amap.mark(it1,treated);
|
||||
}
|
||||
|
||||
for ( it1.rewind(); it1.cont(); ++it1 )
|
||||
{ amap.unmark(it1,treated); }
|
||||
CGAL_assertion( amap.is_whole_map_unmarked(treated) );
|
||||
amap.free_mark(treated);
|
||||
|
||||
typename std::deque<typename CMap::Dart_handle>::iterator it =
|
||||
to_unmark.begin();
|
||||
for (; it != to_unmark.end(); ++it)
|
||||
{ amap.unmark(*it, mark1); }
|
||||
CGAL_assertion( amap.is_whole_map_unmarked(mark1) );
|
||||
amap.free_mark(mark1);
|
||||
|
||||
// CGAL_expensive_postcondition( amap.is_valid() );
|
||||
|
||||
return adart1->beta(0);
|
||||
}
|
||||
|
||||
/** Test if an edge can be inserted onto a 2-cell between two given darts.
|
||||
* @param amap the used combinatorial map.
|
||||
* @param adart1 a first dart.
|
||||
* @param adart2 a second dart.
|
||||
* @return true iff an edge can be inserted between adart1 and adart2.
|
||||
*/
|
||||
template < class CMap >
|
||||
bool is_insertable_cell_1_in_cell_2(const CMap& amap,
|
||||
typename CMap::Dart_const_handle adart1,
|
||||
typename CMap::Dart_const_handle adart2)
|
||||
{
|
||||
CGAL_assertion(adart1 != NULL && adart2 != NULL);
|
||||
if ( adart1==adart2 ) return false;
|
||||
for ( CMap_dart_const_iterator_of_orbit<CMap,1> it(amap,adart1);
|
||||
it.cont(); ++it )
|
||||
{
|
||||
if ( it==adart2 ) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Insert an edge in a 2-cell between two given darts.
|
||||
* @param amap the used combinatorial map.
|
||||
* @param adart1 a first dart of the facet (!=NULL && !=null_dart_handle).
|
||||
* @param adart2 a second dart of the facet. If NULL insert a dangling edge.
|
||||
* @return a dart of the new edge, and not incident to the
|
||||
* same vertex than adart1.
|
||||
*/
|
||||
template<class CMap>
|
||||
typename CMap::Dart_handle
|
||||
insert_cell_1_in_cell_2(CMap& amap,
|
||||
typename CMap::Dart_handle adart1,
|
||||
typename CMap::Dart_handle adart2)
|
||||
{
|
||||
if ( adart2==NULL ) return insert_dangling_cell_1_in_cell_2(amap,adart1);
|
||||
|
||||
CGAL_assertion(is_insertable_cell_1_in_cell_2<CMap>(amap, adart1, adart2));
|
||||
|
||||
int m1 = amap.get_new_mark();
|
||||
CMap_dart_iterator_basic_of_involution<CMap,1>
|
||||
it1 = CMap_dart_iterator_basic_of_involution<CMap,1>(amap, adart1, m1);
|
||||
int m2 = amap.get_new_mark();
|
||||
CMap_dart_iterator_basic_of_involution<CMap,1>
|
||||
it2 = CMap_dart_iterator_basic_of_involution<CMap,1>(amap, adart2, m2);
|
||||
|
||||
int mark1 = amap.get_new_mark();
|
||||
std::deque<typename CMap::Dart_handle> to_unmark;
|
||||
{
|
||||
for ( CMap_dart_iterator_basic_of_cell<CMap,0> it(amap,adart1,mark1);
|
||||
it.cont(); ++it )
|
||||
{
|
||||
to_unmark.push_back(it);
|
||||
amap.mark(it,mark1);
|
||||
}
|
||||
}
|
||||
|
||||
typename CMap::Dart_handle d1 = NULL;
|
||||
typename CMap::Dart_handle d2 = NULL;
|
||||
unsigned int s1 = 0;
|
||||
|
||||
int treated = amap.get_new_mark();
|
||||
|
||||
for ( ; it1.cont(); ++it1, ++it2)
|
||||
{
|
||||
CGAL_assertion (it2.cont() );
|
||||
d1 = amap.create_dart();
|
||||
d2 = amap.create_dart();
|
||||
|
||||
if ( amap.is_marked(it1, mark1) ) s1 = 0;
|
||||
else s1 = 1;
|
||||
|
||||
if ( !it1->is_free(s1) )
|
||||
{
|
||||
if ( s1==0 ) amap.basic_link_beta_1(it1->template beta<0>(), d2);
|
||||
else amap.link_beta_0(it1->template beta<1>(), d2);
|
||||
}
|
||||
|
||||
if ( !it2->is_free(s1) )
|
||||
{
|
||||
if ( s1==0 ) amap.basic_link_beta_1(it2->template beta<0>(), d1);
|
||||
else amap.link_beta_0(it2->template beta<1>(), d1);
|
||||
}
|
||||
|
||||
if ( s1==0 )
|
||||
{
|
||||
amap.link_beta_0(it1, d1);
|
||||
amap.link_beta_0(it2, d2);
|
||||
}
|
||||
else
|
||||
{
|
||||
amap.basic_link_beta_1(it1, d1);
|
||||
amap.basic_link_beta_1(it2, d2);
|
||||
}
|
||||
amap.link_beta_for_involution(d2, d1, 2);
|
||||
|
||||
for ( unsigned int dim=3; dim<=CMap::dimension; ++dim)
|
||||
{
|
||||
if ( !it1->is_free(dim) &&
|
||||
amap.is_marked(it1->beta(dim), treated) )
|
||||
{
|
||||
amap.basic_link_beta_for_involution
|
||||
(it1->beta(dim)->beta_inv(s1), d1, dim);
|
||||
amap.basic_link_beta_for_involution
|
||||
(it1->beta(dim)->beta_inv(s1)->beta(2), d2, dim);
|
||||
}
|
||||
}
|
||||
|
||||
amap.mark(it1,treated);
|
||||
}
|
||||
|
||||
internal::Degroup_attribute_functor_run<CMap, 2>::
|
||||
run(&amap, d1, d2);
|
||||
|
||||
amap.negate_mark(m1);
|
||||
amap.negate_mark(m2);
|
||||
it1.rewind(); it2.rewind();
|
||||
for ( ; it1.cont(); ++it1, ++it2)
|
||||
{
|
||||
amap.mark(it1,m1);
|
||||
amap.unmark(it1,treated);
|
||||
amap.mark(it2,m2);
|
||||
}
|
||||
amap.negate_mark(m1);
|
||||
amap.negate_mark(m2);
|
||||
CGAL_assertion( amap.is_whole_map_unmarked(m1) );
|
||||
CGAL_assertion( amap.is_whole_map_unmarked(m2) );
|
||||
CGAL_assertion( amap.is_whole_map_unmarked(treated) );
|
||||
amap.free_mark(m1);
|
||||
amap.free_mark(m2);
|
||||
amap.free_mark(treated);
|
||||
|
||||
typename std::deque<typename CMap::Dart_handle>::iterator it =
|
||||
to_unmark.begin();
|
||||
for (; it != to_unmark.end(); ++it)
|
||||
{ amap.unmark(*it, mark1); }
|
||||
CGAL_assertion( amap.is_whole_map_unmarked(mark1) );
|
||||
amap.free_mark(mark1);
|
||||
|
||||
// CGAL_expensive_postcondition( amap.is_valid() );
|
||||
|
||||
return adart1->template beta<0>();
|
||||
}
|
||||
|
||||
/** Test if a 2-cell can be inserted onto a given 3-cell along
|
||||
* a path of edges.
|
||||
* @param amap the used combinatorial map.
|
||||
* @param afirst iterator on the begining of the path.
|
||||
* @param alast iterator on the end of the path.
|
||||
* @return true iff a 2-cell can be inserted along the path.
|
||||
*/
|
||||
template <class CMap, class InputIterator>
|
||||
bool is_insertable_cell_2_in_cell_3(const CMap& amap,
|
||||
InputIterator afirst,
|
||||
InputIterator alast)
|
||||
{
|
||||
CGAL_static_assertion( CMap::dimension>= 3 );
|
||||
|
||||
// The path must have at least one dart.
|
||||
if (afirst==alast) return false;
|
||||
typename CMap::Dart_const_handle prec = NULL;
|
||||
typename CMap::Dart_const_handle od = NULL;
|
||||
|
||||
for (InputIterator it(afirst); it!=alast; ++it)
|
||||
{
|
||||
// The path must contain only non empty darts.
|
||||
if (*it == NULL || *it==CMap::null_dart_handle) return false;
|
||||
|
||||
// Two consecutive darts of the path must belong to two edges
|
||||
// incident to the same vertex of the same volume.
|
||||
if (prec != NULL)
|
||||
{
|
||||
od = prec->other_extremity();
|
||||
if ( od==CMap::null_dart_handle ) return false;
|
||||
|
||||
// of and *it must belong to the same vertex of the same volume
|
||||
if ( !belong_to_same_cell<CMap, 0, 2>(amap, od, *it) )
|
||||
return false;
|
||||
}
|
||||
prec = *it;
|
||||
}
|
||||
|
||||
// The path must be closed.
|
||||
od = prec->other_extremity();
|
||||
if ( od==CMap::null_dart_handle ) return false;
|
||||
|
||||
if (!belong_to_same_cell<CMap, 0, 2>(amap, od, *afirst))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Insert a 2-cell in a given 3-cell along a path of darts.
|
||||
* @param amap the used combinatorial map.
|
||||
* @param afirst iterator on the begining of the path.
|
||||
* @param alast iterator on the end of the path.
|
||||
* @return a dart of the new 2-cell.
|
||||
*/
|
||||
template<class CMap, class InputIterator>
|
||||
typename CMap::Dart_handle
|
||||
insert_cell_2_in_cell_3(CMap& amap, InputIterator afirst, InputIterator alast)
|
||||
{
|
||||
CGAL_assertion(is_insertable_cell_2_in_cell_3(amap,afirst,alast));
|
||||
|
||||
typename CMap::Dart_handle prec = NULL, d = NULL, dd = NULL, first = NULL;
|
||||
bool withBeta3 = false;
|
||||
|
||||
{
|
||||
for (InputIterator it(afirst); it!=alast; ++it)
|
||||
{
|
||||
if (!(*it)->is_free(2)) withBeta3 = true;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
for (InputIterator it(afirst); it!=alast; ++it)
|
||||
{
|
||||
d = amap.create_dart();
|
||||
if (withBeta3)
|
||||
{
|
||||
dd = amap.create_dart();
|
||||
amap.template basic_link_beta_for_involution<3>(d, dd);
|
||||
}
|
||||
|
||||
if (prec != NULL)
|
||||
{
|
||||
amap.template link_beta<0>(prec, d);
|
||||
if (withBeta3)
|
||||
amap.template link_beta<1>(prec->template beta<3>(), dd);
|
||||
}
|
||||
else first = d;
|
||||
|
||||
if (!(*it)->is_free(2))
|
||||
amap.template link_beta_for_involution<2>
|
||||
((*it)->template beta<2>(), dd);
|
||||
|
||||
amap.template link_beta_for_involution<2>(*it, d);
|
||||
|
||||
prec = d;
|
||||
}
|
||||
}
|
||||
|
||||
amap.template link_beta<0>(prec, first);
|
||||
if (withBeta3)
|
||||
{
|
||||
amap.template link_beta<1>(prec->template beta<3>(),
|
||||
first->template beta<3>());
|
||||
}
|
||||
|
||||
// Make copies of the new facet for dimension >=4
|
||||
for ( unsigned int dim=4; dim<=CMap::dimension; ++dim )
|
||||
{
|
||||
if ( !first->is_free(dim) )
|
||||
{
|
||||
typename CMap::Dart_handle first2 = NULL;
|
||||
prec = NULL;
|
||||
for ( CMap_dart_iterator_of_orbit<CMap,1> it(amap, first);
|
||||
it.cont(); ++it )
|
||||
{
|
||||
d = amap.create_dart();
|
||||
amap.link_beta_for_involution(it->template beta<2>(), d, dim);
|
||||
if ( withBeta3 )
|
||||
{
|
||||
dd = amap.create_dart();
|
||||
amap.link_beta_for_involution
|
||||
(it->template beta<2>()->template beta<3>(), dd, dim);
|
||||
amap.template basic_link_beta_for_involution<3>(d, dd);
|
||||
}
|
||||
if ( prec!=NULL )
|
||||
{
|
||||
amap.link_beta_0(prec, d);
|
||||
if ( withBeta3 )
|
||||
{
|
||||
amap.link_beta_1(prec->template beta<3>(), dd);
|
||||
}
|
||||
}
|
||||
else first2 = prec;
|
||||
|
||||
for ( unsigned dim2=2; dim2<=CMap::dimension; ++dim2 )
|
||||
{
|
||||
if ( dim2+1!=dim && dim2!=dim && dim2!=dim+1 )
|
||||
{
|
||||
if ( !it->is_free(dim2) &&
|
||||
it->beta(dim2)->is_free(dim) )
|
||||
amap.basic_link_beta_for_involution(it->beta(dim2)->beta(dim),
|
||||
d, dim2);
|
||||
if ( withBeta3 && !it->beta(3)->is_free(dim2) &&
|
||||
it->template beta<3>()->beta(dim2)->is_free(dim) )
|
||||
amap.basic_link_beta_for_involution
|
||||
(it->template beta<3>()->beta(dim2)->beta(dim), dd, dim2);
|
||||
}
|
||||
}
|
||||
prec = d;
|
||||
}
|
||||
amap.template link_beta<0>( prec, first2 );
|
||||
if ( withBeta3 )
|
||||
{
|
||||
amap.template link_beta<1>( prec->template beta<3>(),
|
||||
first2->template beta<3>() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Degroup the attributes
|
||||
if ( withBeta3 )
|
||||
internal::Degroup_attribute_functor_run<CMap, 3>::
|
||||
run(&amap, first, first->template beta<3>());
|
||||
|
||||
// CGAL_expensive_postcondition( amap.is_valid() );
|
||||
|
||||
return first;
|
||||
}
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // CGAL_COMBINATORIAL_MAP_INSERTIONS_H
|
||||
|
|
@ -365,14 +365,12 @@ namespace CGAL {
|
|||
/// Destructor.
|
||||
~CMap_non_basic_iterator()
|
||||
{
|
||||
if ( this->mmark_number!=-1 )
|
||||
{
|
||||
CGAL_assertion( this->mmark_number!=-1 );
|
||||
if (this->mmap->get_number_of_times_mark_reserved
|
||||
(this->mmark_number)==1)
|
||||
unmark_treated_darts();
|
||||
this->mmap->free_mark(this->mmark_number);
|
||||
}
|
||||
}
|
||||
|
||||
/// Copy constructor.
|
||||
CMap_non_basic_iterator(const Self& aiterator):
|
||||
|
|
@ -384,6 +382,11 @@ namespace CGAL {
|
|||
{
|
||||
if (this != &aiterator)
|
||||
{
|
||||
if (this->mmap->get_number_of_times_mark_reserved
|
||||
(this->mmark_number)==1)
|
||||
unmark_treated_darts();
|
||||
this->mmap->free_mark(this->mmark_number);
|
||||
|
||||
Base::operator=(aiterator);
|
||||
this->mmap->share_a_mark(this->mmark_number);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@
|
|||
#define CGAL_COMBINATORIAL_MAP_OPERATIONS_H 1
|
||||
|
||||
#include <CGAL/Combinatorial_map_basic_operations.h>
|
||||
#include <vector>
|
||||
#include <CGAL/Combinatorial_map_insertions.h>
|
||||
#include <deque>
|
||||
#include <stack>
|
||||
|
||||
namespace CGAL {
|
||||
|
|
@ -30,167 +31,6 @@ namespace CGAL {
|
|||
* Some operations to modify a combinatorial map.
|
||||
*/
|
||||
|
||||
/** Insert a vertex in the given 2-cell which is splitted in triangles,
|
||||
* once for each inital edge of the facet.
|
||||
* @param amap the used combinatorial map.
|
||||
* @param adart a dart of the facet to triangulate.
|
||||
* @return A dart incident to the new vertex.
|
||||
*/
|
||||
// TODO revoir toute la gestion des attributs
|
||||
// (utilisation correcte des link avec/sans la maj)
|
||||
template < class CMap >
|
||||
typename CMap::Dart_handle
|
||||
insert_cell_0_in_cell_2(CMap& amap, typename CMap::Dart_handle adart)
|
||||
{
|
||||
CGAL_assertion(adart != NULL && adart!=CMap::null_dart_handle);
|
||||
|
||||
typename CMap::Dart_handle first = adart, prev = NULL, cur = NULL;
|
||||
typename CMap::Dart_handle n1 = NULL, n2 = NULL;
|
||||
|
||||
typename CMap::Dart_handle nn1 = NULL, nn2 = NULL;
|
||||
|
||||
// If the facet is open, we search the dart 0-free
|
||||
while (!first->is_free(0) && first->beta(0) != adart)
|
||||
first = first->beta(0);
|
||||
|
||||
// Stack of couple of dart and dimension for which
|
||||
// we must call on_split functor
|
||||
std::stack<internal::Couple_dart_and_dim<typename CMap::Dart_handle> >
|
||||
tosplit;
|
||||
|
||||
// Mark used to mark darts already treated.
|
||||
int treated = amap.get_new_mark();
|
||||
|
||||
// Stack of marked darts
|
||||
std::stack<typename CMap::Dart_handle> tounmark;
|
||||
|
||||
// Now we run through the facet
|
||||
for (CGAL::CMap_dart_iterator_basic_of_orbit<CMap,1> it(amap,first);
|
||||
it.cont();)
|
||||
{
|
||||
cur = it;
|
||||
++it;
|
||||
amap.mark(cur, treated);
|
||||
tounmark.push(cur);
|
||||
|
||||
if ( cur!=first )
|
||||
{
|
||||
// TODO
|
||||
//if ( amap.template degroup_attribute_of_dart<2>(first, cur) )
|
||||
{
|
||||
// TODO Functor takiing a range, an attrib_handle, and that set
|
||||
// all the darts of the range to this handle
|
||||
/* for (typename CMap::template Dart_of_involution_range<1>::iterator
|
||||
it=template darts_of_involution<1>(dh2).begin(),
|
||||
itend=template darts_of_involution<1>(dh2).end(); it!=itend;
|
||||
++it)
|
||||
{
|
||||
}*/
|
||||
tosplit.push(internal::Couple_dart_and_dim
|
||||
<typename CMap::Dart_handle>
|
||||
(first,cur,2));
|
||||
}
|
||||
}
|
||||
|
||||
if (!cur->is_free(0))
|
||||
{
|
||||
n1 = amap.create_dart();
|
||||
amap.link_beta_0(cur, n1);
|
||||
}
|
||||
else n1 = NULL;
|
||||
|
||||
if (!cur->is_free(1))
|
||||
{
|
||||
n2 = amap.create_dart();
|
||||
amap.link_beta_1(cur, n2);
|
||||
}
|
||||
else n2 = NULL;
|
||||
|
||||
if (n1 != NULL && n2 != NULL)
|
||||
amap.link_beta_0(n1, n2);
|
||||
|
||||
if (n1 != NULL && prev != NULL)
|
||||
amap.template link_beta_for_involution<2>(prev, n1);
|
||||
|
||||
for (unsigned int dim=3; dim<=CMap::dimension; ++dim)
|
||||
{
|
||||
if ( !adart->is_free(dim) )
|
||||
{
|
||||
if ( !amap.is_marked(cur->beta(dim), treated) )
|
||||
{
|
||||
if (n1!=NULL)
|
||||
{
|
||||
nn1=amap.create_dart();
|
||||
amap.link_beta_1(cur->beta(dim), nn1);
|
||||
amap.basic_link_beta_for_involution(n1, nn1, dim);
|
||||
}
|
||||
else nn1=NULL;
|
||||
|
||||
if (n2!=NULL)
|
||||
{
|
||||
nn2=amap.create_dart();
|
||||
amap.link_beta_0(cur->beta(dim), nn2);
|
||||
amap.basic_link_beta_for_involution(n2, nn2, dim);
|
||||
}
|
||||
else nn2=NULL;
|
||||
|
||||
if (nn1 != NULL && nn2 != NULL)
|
||||
amap.basic_link_beta_1(nn1, nn2);
|
||||
|
||||
if (nn1 != NULL && prev != NULL)
|
||||
amap.basic_link_beta_for_involution(nn1, prev->beta(dim), 2);
|
||||
|
||||
amap.mark(cur->beta(dim), treated);
|
||||
tounmark.push(cur->beta(dim));
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( n1!=NULL )
|
||||
amap.basic_link_beta_for_involution(n1, cur->beta(dim)->beta(1), dim);
|
||||
if ( n2!=NULL )
|
||||
amap.basic_link_beta_for_involution(n2, cur->beta(dim)->beta(0), dim);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
prev = n2;
|
||||
}
|
||||
|
||||
if (n2 != NULL)
|
||||
{
|
||||
amap.template link_beta_for_involution<2>(first->beta(0), n2);
|
||||
for (unsigned int dim=3; dim<=CMap::dimension; ++dim)
|
||||
{
|
||||
if ( !adart->is_free(dim) )
|
||||
{
|
||||
amap.basic_link_beta_for_involution(first->beta(0)->beta(dim),
|
||||
n2->beta(dim), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now we unmark all marked darts
|
||||
while ( !tounmark.empty() )
|
||||
{
|
||||
amap.unmark(tounmark.top(), treated);
|
||||
tounmark.pop();
|
||||
}
|
||||
|
||||
CGAL_assertion(amap.is_whole_map_unmarked(treated));
|
||||
amap.free_mark(treated);
|
||||
|
||||
while ( !tosplit.empty() )
|
||||
{
|
||||
internal::Couple_dart_and_dim<typename CMap::Dart_handle> c=tosplit.top();
|
||||
tosplit.pop();
|
||||
internal::Call_split_functor<CMap, 2>::run(c.d1, c.d2);
|
||||
}
|
||||
|
||||
CGAL_expensive_postcondition( amap.is_valid() );
|
||||
|
||||
return n1;
|
||||
}
|
||||
|
||||
/** Test if an i-cell can be removed.
|
||||
* An i-cell can be removed if i==CMap::dimension or i==CMap::dimension-1,
|
||||
* or if there are at most two (i+1)-cell incident to it.
|
||||
|
|
@ -244,17 +84,6 @@ namespace CGAL {
|
|||
|
||||
const int iinv = CGAL_BETAINV(i);
|
||||
|
||||
/*int mark_for_incident_cells[CMap::Helper::nb_attribs];
|
||||
std::deque<std::deque<typename CMap::Dart_handle> >
|
||||
incident_cells[CMap::Helper::nb_attribs];
|
||||
|
||||
// Marks used to mark all the incident cells.
|
||||
for (int j=0; j<CMap::Helper::nb_attribs; ++j)
|
||||
{
|
||||
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.
|
||||
for ( CMap_dart_iterator_basic_of_cell<CMap,i> it(amap,adart,mark);
|
||||
it.cont(); ++it )
|
||||
|
|
@ -266,106 +95,38 @@ namespace CGAL {
|
|||
++res;
|
||||
}
|
||||
|
||||
// Second we store all the incident cells that can be split by
|
||||
// the operation.
|
||||
typename std::deque<typename CMap::Dart_handle>::iterator it =
|
||||
to_erase.begin();
|
||||
/*for (; it != to_erase.end(); ++it)
|
||||
{
|
||||
d1 = (*it)->beta(iinv);
|
||||
while ( d1!=CMap::null_dart_handle && amap.is_marked(d1, mark) )
|
||||
{
|
||||
d1 = d1->beta(i+1)->beta(iinv);
|
||||
if (d1 == (*it)->beta(iinv)) d1 = CMap::null_dart_handle;
|
||||
}
|
||||
|
||||
d2 = (*it)->beta(i+1)->beta(i);
|
||||
while ( d2!=CMap::null_dart_handle && amap.is_marked(d2, mark) )
|
||||
{
|
||||
d2 = d2->beta(i+1)->beta(i);
|
||||
if ( d2==(*it)->beta(i+1)->beta(i) ) d2=CMap::null_dart_handle;
|
||||
}
|
||||
|
||||
if (d1 != CMap::null_dart_handle)
|
||||
{
|
||||
if (d2 != CMap::null_dart_handle)
|
||||
{
|
||||
if ( dg1==NULL ) { dg1 = d1; dg2=d2; }
|
||||
CMap::Helper::template Foreach_enabled_attributes
|
||||
<internal::Store_incident_cells<CMap,i> >::
|
||||
run(&amap, d1, mark, &mark_for_incident_cells[0],
|
||||
&incident_cells[0]);
|
||||
CMap::Helper::template Foreach_enabled_attributes
|
||||
<internal::Store_incident_cells<CMap,i> >::
|
||||
run(&amap, d2, mark, &mark_for_incident_cells[0],
|
||||
&incident_cells[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !d1->is_free(i) )
|
||||
{
|
||||
CMap::Helper::template Foreach_enabled_attributes
|
||||
<internal::Store_incident_cells<CMap,i> >::
|
||||
run(&amap, d1->beta(i), mark, &mark_for_incident_cells[0],
|
||||
&incident_cells[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (d2 != CMap::null_dart_handle)
|
||||
{
|
||||
if ( !d2->is_free(iinv) )
|
||||
{
|
||||
CMap::Helper::template Foreach_enabled_attributes
|
||||
<internal::Store_incident_cells<CMap,i> >::
|
||||
run(&amap, d2, mark, &mark_for_incident_cells[0],
|
||||
&incident_cells[0]);
|
||||
}
|
||||
}
|
||||
|
||||
if ((*it)->is_free(i+1) && !(*it)->is_free(i))
|
||||
{
|
||||
d1 = (*it)->beta(i);
|
||||
if ( !d1->is_free(iinv) )
|
||||
{
|
||||
CMap::Helper::template Foreach_enabled_attributes
|
||||
<internal::Store_incident_cells<CMap,i> >::
|
||||
run(&amap, d1, mark, &mark_for_incident_cells[0],
|
||||
&incident_cells[0]);
|
||||
}
|
||||
}
|
||||
|
||||
// Required to process cells non consider in the cases above.
|
||||
amap.update_dart_of_all_attributes(*it, mark);
|
||||
}*/
|
||||
|
||||
for (; it != to_erase.end(); ++it)
|
||||
amap.update_dart_of_all_attributes(*it, mark);
|
||||
|
||||
// We group the two (i+1)-cells incident if they exist.
|
||||
if ( dg1!=NULL )
|
||||
internal::Group_attribute_functor_run<CMap, i+1>::
|
||||
run(&amap, dg1, dg2);
|
||||
|
||||
// Second we store all the incident cells that can be split by
|
||||
// the operation.
|
||||
typename std::deque<typename CMap::Dart_handle>::iterator it =
|
||||
to_erase.begin();
|
||||
for (; it != to_erase.end(); ++it)
|
||||
amap.update_dart_of_all_attributes(*it, mark);
|
||||
|
||||
std::deque<typename CMap::Dart_handle> modified_darts;
|
||||
// std::deque<typename CMap::Dart_handle> modified_darts2;
|
||||
|
||||
// For each dart of the i-cell, we modify i-links of neighbors.
|
||||
for ( it=to_erase.begin(); it != to_erase.end(); ++it)
|
||||
{
|
||||
d1=(*it)->beta(iinv);
|
||||
d1=(*it)->template beta<iinv>();
|
||||
while ( d1!=CMap::null_dart_handle && amap.is_marked(d1, mark) )
|
||||
{
|
||||
d1=d1->beta(i+1)->beta(iinv);
|
||||
if ( d1==(*it)->beta(iinv) ) d1=CMap::null_dart_handle;
|
||||
d1=d1->template beta<i+1>()->template beta<iinv>();
|
||||
if ( d1==(*it)->template beta<iinv>() ) d1=CMap::null_dart_handle;
|
||||
}
|
||||
|
||||
if ( !amap.is_marked(d1, mark_modified_darts) )
|
||||
{
|
||||
d2=(*it)->beta(i+1)->beta(i);
|
||||
d2=(*it)->template beta<i+1>()->template beta<i>();
|
||||
while ( d2!=CMap::null_dart_handle && amap.is_marked(d2, mark) )
|
||||
{
|
||||
d2=d2->beta(i+1)->beta(i);
|
||||
if ( d2==(*it)->beta(i+1)->beta(i) ) d2=CMap::null_dart_handle;
|
||||
d2=d2->template beta<i+1>()->template beta<i>();
|
||||
if ( d2==(*it)->template beta<i+1>()->template beta<i>() )
|
||||
d2=CMap::null_dart_handle;
|
||||
}
|
||||
|
||||
if ( !amap.is_marked(d2, mark_modified_darts) )
|
||||
|
|
@ -425,12 +186,9 @@ namespace CGAL {
|
|||
|
||||
// We test the split of all the incident cells for all the non
|
||||
// void attributes.
|
||||
CMap::Helper::template Foreach_enabled_attributes
|
||||
<internal::Test2_split_with_deque<CMap,i> >::
|
||||
// <internal::Test_split_with_deque<CMap,i> >::
|
||||
CMap::Helper::template Foreach_enabled_attributes_except
|
||||
<internal::Test_split_attribute_functor<CMap,i>, i>::
|
||||
run(&amap, &modified_darts, mark_modified_darts);
|
||||
//&modified_darts2);
|
||||
//&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 )
|
||||
|
|
@ -445,25 +203,13 @@ namespace CGAL {
|
|||
iterator it=modified_darts.begin();
|
||||
it!=modified_darts.end(); ++it )
|
||||
amap.unmark(*it, mark_modified_darts);
|
||||
/*for ( typename std::deque<typename CMap::Dart_handle>::
|
||||
iterator it=modified_darts2.begin();
|
||||
it!=modified_darts2.end(); ++it )
|
||||
amap.unmark(*it, mark_modified_darts);*/
|
||||
}
|
||||
|
||||
CGAL_assertion ( amap.is_whole_map_unmarked(mark_modified_darts) );
|
||||
amap.free_mark(mark_modified_darts);
|
||||
|
||||
// We free the marks.
|
||||
/*for (int j=0; j<CMap::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() );
|
||||
assert( amap.is_valid() );
|
||||
assert( amap.is_valid() ); // TODO remove
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
@ -540,8 +286,9 @@ namespace CGAL {
|
|||
|
||||
// 4) We test the split of all the incident cells for all the non
|
||||
// void attributes.
|
||||
CMap::Helper::template Foreach_enabled_attributes
|
||||
<internal::Test2_split_with_deque<CMap,i> >::
|
||||
CMap::Helper::template Foreach_enabled_attributes_except
|
||||
<internal::Test_split_attribute_functor<CMap,i>,
|
||||
CMap::dimension>::
|
||||
run(&amap, &modified_darts, -1); //, modified_darts2);
|
||||
//&mark_for_incident_cells[0],
|
||||
//&incident_cells[0]);
|
||||
|
|
@ -710,8 +457,8 @@ namespace CGAL {
|
|||
|
||||
// We test the split of all the incident cells for all the non
|
||||
// void attributes.
|
||||
CMap::Helper::template Foreach_enabled_attributes
|
||||
<internal::Test2_split_with_deque<CMap,0> >::
|
||||
CMap::Helper::template Foreach_enabled_attributes_except
|
||||
<internal::Test_split_attribute_functor<CMap,0>, 1>::
|
||||
// <internal::Test_split_with_deque<CMap,0> >::
|
||||
run(&amap,
|
||||
&modified_darts, -1); //mark_modified_darts);
|
||||
|
|
@ -750,27 +497,6 @@ namespace CGAL {
|
|||
size_t remove_cell(CMap& amap, typename CMap::Dart_handle adart)
|
||||
{ return Remove_cell_functor<CMap,i,CMap::dimension-i>::run(amap,adart); }
|
||||
|
||||
/** Test if an edge can be inserted onto a 2-cell between two given darts.
|
||||
* @param amap the used combinatorial map.
|
||||
* @param adart1 a first dart.
|
||||
* @param adart2 a second dart.
|
||||
* @return true iff an edge can be inserted between adart1 and adart2.
|
||||
*/
|
||||
template < class CMap >
|
||||
bool is_insertable_cell_1_in_cell_2(const CMap& amap,
|
||||
typename CMap::Dart_const_handle adart1,
|
||||
typename CMap::Dart_const_handle adart2)
|
||||
{
|
||||
CGAL_assertion(adart1 != NULL && adart2 != NULL);
|
||||
if ( adart1==adart2 ) return false;
|
||||
for ( CMap_dart_const_iterator_of_orbit<CMap,1> it(amap,adart1);
|
||||
it.cont(); ++it )
|
||||
{
|
||||
if ( it==adart2 ) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Test if an i-cell can be contracted.
|
||||
* An i-cell can be contracted if i==1
|
||||
* or if there are at most two (i-1)-cell incident to it.
|
||||
|
|
@ -917,8 +643,8 @@ namespace CGAL {
|
|||
|
||||
// We test the split of all the incident cells for all the non
|
||||
// void attributes.
|
||||
CMap::Helper::template Foreach_enabled_attributes
|
||||
<internal::Test2_split_with_deque<CMap,i> >::
|
||||
CMap::Helper::template Foreach_enabled_attributes_except
|
||||
<internal::Test_split_attribute_functor<CMap,i>, i>::
|
||||
run(&amap, &modified_darts, mark_modified_darts);
|
||||
|
||||
// We remove all the darts of the i-cell.
|
||||
|
|
@ -1029,8 +755,8 @@ namespace CGAL {
|
|||
|
||||
// We test the split of all the incident cells for all the non
|
||||
// void attributes.
|
||||
CMap::Helper::template Foreach_enabled_attributes
|
||||
<internal::Test2_split_with_deque<CMap,1> >::
|
||||
CMap::Helper::template Foreach_enabled_attributes_except
|
||||
<internal::Test_split_attribute_functor<CMap,1>, 1>::
|
||||
// <internal::Test_split_with_deque<CMap,0> >::
|
||||
run(&amap,
|
||||
&modified_darts, -1); //mark_modified_darts);
|
||||
|
|
@ -1060,443 +786,6 @@ namespace CGAL {
|
|||
size_t contract_cell(CMap& amap, typename CMap::Dart_handle adart)
|
||||
{ return Contract_cell_functor<CMap,i>::run(amap,adart); }
|
||||
|
||||
/** Test if a 2-cell can be inserted onto a given 3-cell along
|
||||
* a path of edges.
|
||||
* @param amap the used combinatorial map.
|
||||
* @param afirst iterator on the begining of the path.
|
||||
* @param alast iterator on the end of the path.
|
||||
* @return true iff a 2-cell can be inserted along the path.
|
||||
*/
|
||||
template <class CMap, class InputIterator>
|
||||
bool is_insertable_cell_2_in_cell_3(const CMap& amap,
|
||||
InputIterator afirst,
|
||||
InputIterator alast)
|
||||
{
|
||||
CGAL_static_assertion( CMap::dimension>= 3 );
|
||||
|
||||
// The path must have at least one dart.
|
||||
if (afirst==alast) return false;
|
||||
typename CMap::Dart_const_handle prec = NULL;
|
||||
typename CMap::Dart_const_handle od = NULL;
|
||||
|
||||
for (InputIterator it(afirst); it!=alast; ++it)
|
||||
{
|
||||
// The path must contain only non empty darts.
|
||||
if (*it == NULL || *it==CMap::null_dart_handle) return false;
|
||||
|
||||
// Two consecutive darts of the path must belong to two edges
|
||||
// incident to the same vertex of the same volume.
|
||||
if (prec != NULL)
|
||||
{
|
||||
od = prec->other_extremity();
|
||||
if ( od==CMap::null_dart_handle ) return false;
|
||||
|
||||
// of and *it must belong to the same vertex of the same volume
|
||||
if ( !belong_to_same_cell<CMap, 0, 2>(amap, od, *it) )
|
||||
return false;
|
||||
}
|
||||
prec = *it;
|
||||
}
|
||||
|
||||
// The path must be closed.
|
||||
od = prec->other_extremity();
|
||||
if ( od==CMap::null_dart_handle ) return false;
|
||||
|
||||
if (!belong_to_same_cell<CMap, 0, 2>(amap, od, *afirst))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Insert a vertex in a given edge.
|
||||
* @param amap the used combinatorial map.
|
||||
* @param adart a dart of the edge (!=NULL && !=null_dart_handle).
|
||||
* @return a dart of the new vertex.
|
||||
*/
|
||||
template<class CMap>
|
||||
typename CMap::Dart_handle
|
||||
insert_cell_0_in_cell_1(CMap& amap, typename CMap::Dart_handle adart)
|
||||
{
|
||||
CGAL_assertion(adart != NULL && adart!=CMap::null_dart_handle);
|
||||
|
||||
typename CMap::Dart_handle d1, d2;
|
||||
int mark = amap.get_new_mark();
|
||||
|
||||
std::vector<typename CMap::Dart_handle> vect;
|
||||
{
|
||||
for (typename CMap::template Dart_of_cell_range<1>::iterator it=
|
||||
amap.template darts_of_cell<1>(adart).begin();
|
||||
it != amap.template darts_of_cell<1>(adart).end(); ++it)
|
||||
vect.push_back(it);
|
||||
}
|
||||
|
||||
// 3) For each dart of the cell, we modify link of neighbors.
|
||||
typename std::vector<typename CMap::Dart_handle>::iterator it = vect.begin();
|
||||
for (; it != vect.end(); ++it)
|
||||
{
|
||||
d1 = amap.create_dart();
|
||||
|
||||
if (!(*it)->is_free(1))
|
||||
{ amap.template basic_link_beta<1>(d1, (*it)->beta(1)); }
|
||||
|
||||
for ( unsigned int dim = 2; dim<=CMap::dimension; ++dim )
|
||||
{
|
||||
if (!(*it)->is_free(dim) && amap.is_marked((*it)->beta(dim), mark))
|
||||
{
|
||||
amap.basic_link_beta((*it)->beta(dim), d1, dim);
|
||||
amap.basic_link_beta(*it, (*it)->beta(dim)->beta(1), dim);
|
||||
}
|
||||
}
|
||||
|
||||
amap.template basic_link_beta<1>(*it, d1);
|
||||
// TODO remove this group, and use link_beta instead ?
|
||||
//amap.group_all_dart_attributes_except(*it, d1, 1);
|
||||
|
||||
amap.mark(*it, mark);
|
||||
}
|
||||
|
||||
for (it = vect.begin(); it != vect.end(); ++it)
|
||||
{ amap.unmark(*it, mark); }
|
||||
|
||||
amap.free_mark(mark);
|
||||
|
||||
// TODO amap.template degroup_attribute<1>(adart, adart->beta(1));
|
||||
|
||||
// CGAL_expensive_postcondition( amap.is_valid() );
|
||||
|
||||
return adart->beta(1);
|
||||
}
|
||||
|
||||
/** Insert a dangling edge in a 2-cell between given by a dart.
|
||||
* @param amap the used combinatorial map.
|
||||
* @param adart1 a first dart of the facet (!=NULL && !=null_dart_handle).
|
||||
* @return a dart of the new edge, not incident to the vertex of adart1.
|
||||
*/
|
||||
template<class CMap>
|
||||
typename CMap::Dart_handle
|
||||
insert_dangling_cell_1_in_cell_2(CMap& amap, typename CMap::Dart_handle adart1)
|
||||
{
|
||||
CGAL_assertion(adart1!=NULL && adart1!=CMap::null_dart_handle);
|
||||
|
||||
int mark1 = amap.get_new_mark();
|
||||
std::vector<typename CMap::Dart_handle> to_unmark;
|
||||
{
|
||||
for ( CMap_dart_iterator_basic_of_cell<CMap,0> it(amap,adart1,mark1);
|
||||
it.cont(); ++it )
|
||||
{
|
||||
to_unmark.push_back(it);
|
||||
amap.mark(it,mark1);
|
||||
}
|
||||
}
|
||||
|
||||
typename CMap::Dart_handle d1 = NULL;
|
||||
typename CMap::Dart_handle d2 = NULL;
|
||||
unsigned int s1 = 0;
|
||||
|
||||
int treated = amap.get_new_mark();
|
||||
|
||||
CGAL::CMap_dart_iterator_of_involution<CMap,1> it1(amap,adart1);
|
||||
|
||||
for ( ; it1.cont(); ++it1)
|
||||
{
|
||||
d1 = amap.create_dart();
|
||||
d2 = amap.create_dart();
|
||||
|
||||
if ( amap.is_marked(it1, mark1) ) s1 = 0;
|
||||
else s1 = 1;
|
||||
|
||||
if ( !it1->is_free(s1) )
|
||||
{
|
||||
if ( s1==0 ) amap.template link_beta<1>(it1->beta(0), d2);
|
||||
else amap.template link_beta<0>(it1->beta(1), d2);
|
||||
}
|
||||
|
||||
if (s1==0)
|
||||
{
|
||||
amap.template link_beta<0>(it1, d1);
|
||||
amap.template basic_link_beta<0>(d1,d2);
|
||||
}
|
||||
else
|
||||
{
|
||||
amap.template link_beta<1>(it1, d1);
|
||||
amap.template basic_link_beta<1>(d1,d2);
|
||||
}
|
||||
|
||||
amap.template link_beta_for_involution<2>(d1, d2);
|
||||
|
||||
for ( unsigned int dim=3; dim<=CMap::dimension; ++dim)
|
||||
{
|
||||
if ( !it1->is_free(dim) &&
|
||||
amap.is_marked(it1->beta(dim), treated) )
|
||||
{
|
||||
amap.basic_link_beta_for_involution(it1->beta(dim)->beta_inv(s1), d1,
|
||||
dim);
|
||||
amap.basic_link_beta_for_involution
|
||||
(it1->beta(dim)->beta_inv(s1)->beta(2), d2, dim);
|
||||
}
|
||||
}
|
||||
|
||||
amap.mark(it1,treated);
|
||||
}
|
||||
|
||||
// amap.template degroup_attribute<1>(adart1, adart1->beta(0));
|
||||
// amap.template degroup_attribute<2>(d1, d2);
|
||||
|
||||
for ( it1.rewind(); it1.cont(); ++it1 )
|
||||
{
|
||||
amap.unmark(it1,treated);
|
||||
}
|
||||
CGAL_assertion( amap.is_whole_map_unmarked(treated) );
|
||||
amap.free_mark(treated);
|
||||
|
||||
typename std::vector<typename CMap::Dart_handle>::iterator it =
|
||||
to_unmark.begin();
|
||||
for (; it != to_unmark.end(); ++it)
|
||||
{ amap.unmark(*it, mark1); }
|
||||
CGAL_assertion( amap.is_whole_map_unmarked(mark1) );
|
||||
amap.free_mark(mark1);
|
||||
|
||||
// CGAL_expensive_postcondition( amap.is_valid() );
|
||||
|
||||
return adart1->beta(0);
|
||||
}
|
||||
|
||||
/** Insert an edge in a 2-cell between two given darts.
|
||||
* @param amap the used combinatorial map.
|
||||
* @param adart1 a first dart of the facet (!=NULL && !=null_dart_handle).
|
||||
* @param adart2 a second dart of the facet. If NULL insert a dangling edge.
|
||||
* @return a dart of the new edge, and not incident to the
|
||||
* same vertex than adart1.
|
||||
*/
|
||||
template<class CMap>
|
||||
typename CMap::Dart_handle
|
||||
insert_cell_1_in_cell_2(CMap& amap,
|
||||
typename CMap::Dart_handle adart1,
|
||||
typename CMap::Dart_handle adart2)
|
||||
{
|
||||
if ( adart2==NULL ) return insert_dangling_cell_1_in_cell_2(amap,adart1);
|
||||
|
||||
CGAL_assertion(is_insertable_cell_1_in_cell_2<CMap>(amap, adart1, adart2));
|
||||
|
||||
int m1 = amap.get_new_mark();
|
||||
CMap_dart_iterator_basic_of_involution<CMap,1>
|
||||
it1 = CMap_dart_iterator_basic_of_involution<CMap,1>(amap, adart1, m1);
|
||||
int m2 = amap.get_new_mark();
|
||||
CMap_dart_iterator_basic_of_involution<CMap,1>
|
||||
it2 = CMap_dart_iterator_basic_of_involution<CMap,1>(amap, adart2, m2);
|
||||
|
||||
int mark1 = amap.get_new_mark();
|
||||
std::vector<typename CMap::Dart_handle> to_unmark;
|
||||
{
|
||||
for ( CMap_dart_iterator_basic_of_cell<CMap,0> it(amap,adart1,mark1);
|
||||
it.cont(); ++it )
|
||||
{
|
||||
to_unmark.push_back(it);
|
||||
amap.mark(it,mark1);
|
||||
}
|
||||
}
|
||||
|
||||
typename CMap::Dart_handle d1 = NULL;
|
||||
typename CMap::Dart_handle d2 = NULL;
|
||||
unsigned int s1 = 0;
|
||||
|
||||
int treated = amap.get_new_mark();
|
||||
|
||||
for ( ; it1.cont(); ++it1, ++it2)
|
||||
{
|
||||
CGAL_assertion (it2.cont() );
|
||||
d1 = amap.create_dart();
|
||||
d2 = amap.create_dart();
|
||||
|
||||
if ( amap.is_marked(it1, mark1) ) s1 = 0;
|
||||
else s1 = 1;
|
||||
|
||||
if ( !it1->is_free(s1) )
|
||||
{
|
||||
if ( s1==0 ) amap.basic_link_beta_1(it1->beta(0), d2);
|
||||
else amap.link_beta_0(it1->beta(1), d2);
|
||||
}
|
||||
|
||||
if ( !it2->is_free(s1) )
|
||||
{
|
||||
if ( s1==0 ) amap.basic_link_beta_1(it2->beta(0), d1);
|
||||
else amap.link_beta_0(it2->beta(1), d1);
|
||||
}
|
||||
|
||||
if ( s1==0 )
|
||||
{
|
||||
amap.link_beta_0(it1, d1);
|
||||
amap.link_beta_0(it2, d2);
|
||||
}
|
||||
else
|
||||
{
|
||||
amap.basic_link_beta_1(it1, d1);
|
||||
amap.basic_link_beta_1(it2, d2);
|
||||
}
|
||||
amap.link_beta_for_involution(d2, d1, 2);
|
||||
|
||||
for ( unsigned int dim=3; dim<=CMap::dimension; ++dim)
|
||||
{
|
||||
if ( !it1->is_free(dim) &&
|
||||
amap.is_marked(it1->beta(dim), treated) )
|
||||
{
|
||||
amap.basic_link_beta_for_involution
|
||||
(it1->beta(dim)->beta_inv(s1), d1, dim);
|
||||
amap.basic_link_beta_for_involution
|
||||
(it1->beta(dim)->beta_inv(s1)->beta(2), d2, dim);
|
||||
}
|
||||
}
|
||||
|
||||
amap.mark(it1,treated);
|
||||
}
|
||||
|
||||
// amap.template degroup_attribute<1>(adart1, adart1->beta(0));
|
||||
// TODO amap.template degroup_attribute<2>(d1, d2);
|
||||
|
||||
amap.negate_mark(m1);
|
||||
amap.negate_mark(m2);
|
||||
it1.rewind(); it2.rewind();
|
||||
for ( ; it1.cont(); ++it1, ++it2)
|
||||
{
|
||||
amap.mark(it1,m1);
|
||||
amap.unmark(it1,treated);
|
||||
amap.mark(it2,m2);
|
||||
}
|
||||
amap.negate_mark(m1);
|
||||
amap.negate_mark(m2);
|
||||
CGAL_assertion( amap.is_whole_map_unmarked(m1) );
|
||||
CGAL_assertion( amap.is_whole_map_unmarked(m2) );
|
||||
CGAL_assertion( amap.is_whole_map_unmarked(treated) );
|
||||
amap.free_mark(m1);
|
||||
amap.free_mark(m2);
|
||||
amap.free_mark(treated);
|
||||
|
||||
typename std::vector<typename CMap::Dart_handle>::iterator it =
|
||||
to_unmark.begin();
|
||||
for (; it != to_unmark.end(); ++it)
|
||||
{ amap.unmark(*it, mark1); }
|
||||
CGAL_assertion( amap.is_whole_map_unmarked(mark1) );
|
||||
amap.free_mark(mark1);
|
||||
|
||||
// CGAL_expensive_postcondition( amap.is_valid() );
|
||||
|
||||
return adart1->beta(0);
|
||||
}
|
||||
|
||||
/** Insert a 2-cell in a given 3-cell along a path of darts.
|
||||
* @param amap the used combinatorial map.
|
||||
* @param afirst iterator on the begining of the path.
|
||||
* @param alast iterator on the end of the path.
|
||||
* @return a dart of the new 2-cell.
|
||||
*/
|
||||
template<class CMap, class InputIterator>
|
||||
typename CMap::Dart_handle
|
||||
insert_cell_2_in_cell_3(CMap& amap, InputIterator afirst, InputIterator alast)
|
||||
{
|
||||
CGAL_assertion(is_insertable_cell_2_in_cell_3(amap,afirst,alast));
|
||||
|
||||
typename CMap::Dart_handle prec = NULL, d = NULL, dd = NULL, first = NULL;
|
||||
bool withBeta3 = false;
|
||||
|
||||
{
|
||||
for (InputIterator it(afirst); it!=alast; ++it)
|
||||
{
|
||||
if (!(*it)->is_free(2)) withBeta3 = true;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
for (InputIterator it(afirst); it!=alast; ++it)
|
||||
{
|
||||
d = amap.create_dart();
|
||||
if (withBeta3)
|
||||
{
|
||||
dd = amap.create_dart();
|
||||
amap.basic_link_beta_for_involution(d, dd, 3);
|
||||
}
|
||||
|
||||
if (prec != NULL)
|
||||
{
|
||||
amap.template link_beta<0>(prec, d);
|
||||
if (withBeta3) amap.template link_beta<1>(prec->beta(3), dd);
|
||||
}
|
||||
else first = d;
|
||||
|
||||
if (!(*it)->is_free(2))
|
||||
amap.link_beta_for_involution((*it)->beta(2), dd, 2);
|
||||
|
||||
amap.link_beta_for_involution(*it, d, 2);
|
||||
|
||||
prec = d;
|
||||
}
|
||||
}
|
||||
|
||||
amap.template link_beta<0>(prec, first);
|
||||
if (withBeta3)
|
||||
{
|
||||
amap.template link_beta<1>(prec->beta(3), first->beta(3));
|
||||
}
|
||||
|
||||
// Make copies of the new facet for dimension >=4
|
||||
for ( unsigned int dim=4; dim<=CMap::dimension; ++dim )
|
||||
{
|
||||
if ( !first->is_free(dim) )
|
||||
{
|
||||
typename CMap::Dart_handle first2 = NULL;
|
||||
prec = NULL;
|
||||
for ( CMap_dart_iterator_of_orbit<CMap,1> it(amap, first);
|
||||
it.cont(); ++it )
|
||||
{
|
||||
d = amap.create_dart();
|
||||
amap.link_beta_for_involution(it->beta(2),d,dim);
|
||||
if ( withBeta3 )
|
||||
{
|
||||
dd = amap.create_dart();
|
||||
amap.link_beta_for_involution(it->beta(2)->beta(3),dd,dim);
|
||||
amap.basic_link_beta_for_involution(d, dd, 3);
|
||||
}
|
||||
if ( prec!=NULL )
|
||||
{
|
||||
amap.link_beta_0(prec,d);
|
||||
if ( withBeta3 )
|
||||
{
|
||||
amap.link_beta_1(prec->beta(3),dd);
|
||||
}
|
||||
}
|
||||
else first2 = prec;
|
||||
|
||||
for ( unsigned dim2=2; dim2<=CMap::dimension; ++dim2 )
|
||||
{
|
||||
if ( dim2+1!=dim && dim2!=dim && dim2!=dim+1 )
|
||||
{
|
||||
if ( !it->is_free(dim2) &&
|
||||
it->beta(dim2)->is_free(dim) )
|
||||
amap.basic_link_beta_for_involution(it->beta(dim2)->beta(dim),
|
||||
d, dim2);
|
||||
if ( withBeta3 && !it->beta(3)->is_free(dim2) &&
|
||||
it->beta(3)->beta(dim2)->is_free(dim) )
|
||||
amap.basic_link_beta_for_involution
|
||||
(it->beta(3)->beta(dim2)->beta(dim), dd, dim2);
|
||||
}
|
||||
}
|
||||
prec = d;
|
||||
}
|
||||
amap.template link_beta<0>( prec, first2 );
|
||||
if ( withBeta3 )
|
||||
{
|
||||
amap.template link_beta<1>( prec->beta(3), first2->beta(3) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Degroup the attributes
|
||||
/* TODO if ( withBeta3 )
|
||||
amap.template degroup_attribute<3>( first, first->beta(3) );
|
||||
*/
|
||||
// CGAL_expensive_postcondition( amap.is_valid() );
|
||||
|
||||
return first;
|
||||
}
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // CGAL_COMBINATORIAL_MAP_OPERATIONS_H //
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,343 @@
|
|||
// Copyright (c) 2010-2011 CNRS and LIRIS' Establishments (France).
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation; either version 3 of the License,
|
||||
// or (at your option) any later version.
|
||||
//
|
||||
// Licensees holding a valid commercial license may use this file in
|
||||
// accordance with the commercial license agreement provided with the software.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||
//
|
||||
#ifndef CGAL_COMBINATORIAL_MAP_SEWABLE_H
|
||||
#define CGAL_COMBINATORIAL_MAP_SEWABLE_H
|
||||
|
||||
/* Definition of functor used to test if two darts are i-sewable
|
||||
* (we use functors as there are different specializations).
|
||||
*/
|
||||
namespace CGAL
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
// Generic case for 2<=i<=dimension, and 3<dim.
|
||||
template<typename CMap, unsigned int i, unsigned int dim=CMap::dimension>
|
||||
struct Is_sewable_functor
|
||||
{
|
||||
static bool run( const CMap* amap,
|
||||
typename CMap::Dart_const_handle adart1,
|
||||
typename CMap::Dart_const_handle adart2 )
|
||||
{
|
||||
CGAL_assertion( 2<=i && i<=CMap::dimension );
|
||||
CGAL_assertion( 3<dim );
|
||||
CGAL_assertion(adart1!=NULL && adart2!=NULL);
|
||||
CGAL_assertion(adart1!=CMap::null_dart_handle &&
|
||||
adart2!=CMap::null_dart_handle);
|
||||
|
||||
if ( !adart1->template is_free<i>() ||
|
||||
!adart2->template is_free<i>() || adart1==adart2 )
|
||||
return false;
|
||||
|
||||
// TODO use a map (of hashtable) to build the isomorphism and to test
|
||||
// it during the while loop
|
||||
CMap_dart_const_iterator_of_involution<CMap,i> I1(*amap, adart1);
|
||||
CMap_dart_const_iterator_of_involution_inv<CMap,i> I2(*amap, adart2);
|
||||
bool res = true;
|
||||
while (res && I1.cont() && I2.cont())
|
||||
{
|
||||
// We can remove this constraint which is not required for
|
||||
// combinatorial map definition, but which is quite "normal"
|
||||
if ( I1==adart2 || I2==adart1 ) res=false;
|
||||
|
||||
// Special case to consider beta0 and beta1
|
||||
if ( i>2 )
|
||||
{
|
||||
if ( I1->is_free(0)!=I2->is_free(1) ) res = false;
|
||||
else if ( I1->is_free(1)!=I2->is_free(0) ) res = false;
|
||||
}
|
||||
|
||||
// General case
|
||||
for (unsigned int j=2;res && j<=CMap::dimension; ++j)
|
||||
{
|
||||
if ( j+1!=i && j!=i && j!=i+1 &&
|
||||
I1->is_free(j)!=I2->is_free(j) )
|
||||
{ res = false; }
|
||||
}
|
||||
++I1; ++I2;
|
||||
}
|
||||
if (I1.cont() != I2.cont())
|
||||
res = false;
|
||||
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
// Specialization for i=0 and 3<dim.
|
||||
template<typename CMap, unsigned int dim>
|
||||
struct Is_sewable_functor<CMap, 0, dim>
|
||||
{
|
||||
static bool run( const CMap* amap,
|
||||
typename CMap::Dart_const_handle adart1,
|
||||
typename CMap::Dart_const_handle adart2 )
|
||||
{
|
||||
CGAL_assertion( 3<dim );
|
||||
CGAL_assertion( adart1!=NULL && adart2!=NULL);
|
||||
CGAL_assertion( adart1!=CMap::null_dart_handle &&
|
||||
adart2!=CMap::null_dart_handle );
|
||||
|
||||
if ( !adart1->template is_free<0>() ||
|
||||
!adart2->template is_free<1>() )
|
||||
return false;
|
||||
|
||||
if ( adart1==adart2 ) return true;
|
||||
|
||||
// TODO use a map (of hashtable) to build the isomorphism and to test
|
||||
// it during the while loop
|
||||
CMap_dart_const_iterator_of_involution <CMap,1> I1(*amap, adart1);
|
||||
CMap_dart_const_iterator_of_involution_inv<CMap,1> I2(*amap, adart2);
|
||||
bool res = true;
|
||||
while (res && I1.cont() && I2.cont())
|
||||
{
|
||||
// We can remove this constraint which is not required for
|
||||
// combinatorial map definition, but which imposes quite "normal"
|
||||
// configurations
|
||||
if ( I1==adart2 || I2==adart1 ) res=false;
|
||||
|
||||
for (unsigned int j=3;res && j<=CMap::dimension; ++j)
|
||||
{
|
||||
if ( I1->is_free(j)!=I2->is_free(j) )
|
||||
{
|
||||
res = false;
|
||||
}
|
||||
}
|
||||
++I1; ++I2;
|
||||
}
|
||||
if (I1.cont() != I2.cont())
|
||||
res = false;
|
||||
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
// Specialization for i=0 and dim=1.
|
||||
template<typename CMap>
|
||||
struct Is_sewable_functor<CMap, 0, 1>
|
||||
{
|
||||
static bool run( const CMap* amap,
|
||||
typename CMap::Dart_const_handle adart1,
|
||||
typename CMap::Dart_const_handle adart2 )
|
||||
{
|
||||
CGAL_assertion(adart1!=NULL && adart2!=NULL);
|
||||
CGAL_assertion(adart1!=CMap::null_dart_handle &&
|
||||
adart2!=CMap::null_dart_handle);
|
||||
|
||||
if ( !adart1->template is_free<0>() ||
|
||||
!adart2->template is_free<1>() )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
// Specialization for i=1 and dim=1.
|
||||
template<typename CMap>
|
||||
struct Is_sewable_functor<CMap, 1, 1>
|
||||
{
|
||||
static bool run( const CMap* amap,
|
||||
typename CMap::Dart_const_handle adart1,
|
||||
typename CMap::Dart_const_handle adart2 )
|
||||
{
|
||||
CGAL_assertion(adart1!=NULL && adart2!=NULL);
|
||||
CGAL_assertion(adart1!=CMap::null_dart_handle &&
|
||||
adart2!=CMap::null_dart_handle);
|
||||
|
||||
if ( !adart1->template is_free<1>() ||
|
||||
!adart2->template is_free<0>() )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// Specialization for i=0 and dim=2.
|
||||
template<typename CMap>
|
||||
struct Is_sewable_functor<CMap, 0, 2>
|
||||
{
|
||||
static bool run( const CMap* amap,
|
||||
typename CMap::Dart_const_handle adart1,
|
||||
typename CMap::Dart_const_handle adart2 )
|
||||
{
|
||||
CGAL_assertion(adart1!=NULL && adart2!=NULL);
|
||||
CGAL_assertion(adart1!=CMap::null_dart_handle &&
|
||||
adart2!=CMap::null_dart_handle);
|
||||
|
||||
if ( !adart1->template is_free<0>() ||
|
||||
!adart2->template is_free<1>() )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
// Specialization for i=1 and dim=2.
|
||||
template<typename CMap>
|
||||
struct Is_sewable_functor<CMap, 1, 2>
|
||||
{
|
||||
static bool run( const CMap* amap,
|
||||
typename CMap::Dart_const_handle adart1,
|
||||
typename CMap::Dart_const_handle adart2 )
|
||||
{
|
||||
CGAL_assertion(adart1!=NULL && adart2!=NULL);
|
||||
CGAL_assertion(adart1!=CMap::null_dart_handle &&
|
||||
adart2!=CMap::null_dart_handle);
|
||||
|
||||
if ( !adart1->template is_free<1>() ||
|
||||
!adart2->template is_free<0>() )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
// Specialization for i=2 and dim=2.
|
||||
template<typename CMap>
|
||||
struct Is_sewable_functor<CMap, 2, 2>
|
||||
{
|
||||
static bool run( const CMap* amap,
|
||||
typename CMap::Dart_const_handle adart1,
|
||||
typename CMap::Dart_const_handle adart2 )
|
||||
{
|
||||
CGAL_assertion(adart1!=NULL && adart2!=NULL);
|
||||
CGAL_assertion(adart1!=CMap::null_dart_handle &&
|
||||
adart2!=CMap::null_dart_handle);
|
||||
|
||||
if ( !adart1->template is_free<2>() ||
|
||||
!adart2->template is_free<2>() || adart1==adart2 )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// Specialization for i=0 and dim=3.
|
||||
template<typename CMap>
|
||||
struct Is_sewable_functor<CMap, 0, 3>
|
||||
{
|
||||
static bool run( const CMap* amap,
|
||||
typename CMap::Dart_const_handle adart1,
|
||||
typename CMap::Dart_const_handle adart2 )
|
||||
{
|
||||
CGAL_assertion(adart1!=NULL && adart2!=NULL);
|
||||
CGAL_assertion(adart1!=CMap::null_dart_handle &&
|
||||
adart2!=CMap::null_dart_handle);
|
||||
|
||||
if ( !adart1->template is_free<0>() ||
|
||||
!adart2->template is_free<1>() )
|
||||
return false;
|
||||
|
||||
if ( adart1->template is_free<3>() )
|
||||
{
|
||||
if ( !adart2->template is_free<3>() ) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Here adart1 is not 3-free
|
||||
if ( adart2->template is_free<3>() ) return false;
|
||||
|
||||
CGAL_assertion( adart1->template beta<3>()->template is_free<1>() &&
|
||||
adart2->template beta<3>()->template is_free<0>() );
|
||||
return true;
|
||||
}
|
||||
};
|
||||
// Specialization for i=1 and dim=3.
|
||||
template<typename CMap>
|
||||
struct Is_sewable_functor<CMap, 1, 3>
|
||||
{
|
||||
static bool run( const CMap* amap,
|
||||
typename CMap::Dart_const_handle adart1,
|
||||
typename CMap::Dart_const_handle adart2 )
|
||||
{
|
||||
CGAL_assertion(adart1!=NULL && adart2!=NULL);
|
||||
CGAL_assertion(adart1!=CMap::null_dart_handle &&
|
||||
adart2!=CMap::null_dart_handle);
|
||||
|
||||
if ( !adart1->template is_free<1>() ||
|
||||
!adart2->template is_free<0>() )
|
||||
return false;
|
||||
|
||||
if ( adart1->template is_free<3>() )
|
||||
{
|
||||
if ( !adart2->template is_free<3>() ) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Here adart1 is not 3-free
|
||||
if ( adart2->template is_free<3>() ) return false;
|
||||
|
||||
CGAL_assertion( adart1->template beta<3>()->template is_free<0>() &&
|
||||
adart2->template beta<3>()->template is_free<1>() );
|
||||
return true;
|
||||
}
|
||||
};
|
||||
// Specialization for i=2 and dim=3.
|
||||
template<typename CMap>
|
||||
struct Is_sewable_functor<CMap, 2, 3>
|
||||
{
|
||||
static bool run( const CMap* amap,
|
||||
typename CMap::Dart_const_handle adart1,
|
||||
typename CMap::Dart_const_handle adart2 )
|
||||
{
|
||||
CGAL_assertion(adart1!=NULL && adart2!=NULL);
|
||||
CGAL_assertion(adart1!=CMap::null_dart_handle &&
|
||||
adart2!=CMap::null_dart_handle);
|
||||
|
||||
if ( !adart1->template is_free<2>() ||
|
||||
!adart2->template is_free<2>() || adart1==adart2 )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
// Specialization for i=3 and dim=3.
|
||||
template<typename CMap>
|
||||
struct Is_sewable_functor<CMap, 3, 3>
|
||||
{
|
||||
static bool run( const CMap* amap,
|
||||
typename CMap::Dart_const_handle adart1,
|
||||
typename CMap::Dart_const_handle adart2 )
|
||||
{
|
||||
CGAL_assertion(adart1!=NULL && adart2!=NULL);
|
||||
CGAL_assertion(adart1!=CMap::null_dart_handle &&
|
||||
adart2!=CMap::null_dart_handle);
|
||||
|
||||
if ( !adart1->template is_free<3>() ||
|
||||
!adart2->template is_free<3>() )
|
||||
return false;
|
||||
|
||||
CMap_dart_const_iterator_basic_of_orbit<CMap,1> I1(*amap, adart1);
|
||||
CMap_dart_const_iterator_basic_of_orbit<CMap,0> I2(*amap, adart2);
|
||||
bool res=true;
|
||||
while (res && I1.cont() && I2.cont())
|
||||
{
|
||||
CGAL_assertion( I1->template is_free<3>() ||
|
||||
I2->template is_free<3>() );
|
||||
|
||||
// We can remove this constraint which is not required for
|
||||
// combinatorial map definition, but which is quite "normal" as it avoid
|
||||
// fold cells.
|
||||
if ( I1==adart2 || I2==adart1 ) res=false;
|
||||
else if ( I1.prev_operation()!=I2.prev_operation() ) res=false;
|
||||
|
||||
++I1; ++I2;
|
||||
}
|
||||
if ( I1.cont()!=I2.cont() )
|
||||
res=false;
|
||||
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
} //namespace internal
|
||||
|
||||
} //namespace CGAL
|
||||
|
||||
#endif // CGAL_COMBINATORIAL_MAP_SEWABLE_H
|
||||
//******************************************************************************
|
||||
|
|
@ -26,6 +26,13 @@
|
|||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
/** Some utilities allowing to manage attributes. Indeed, as they as stores
|
||||
* in tuples, we need to define functors with variadic templated arguments
|
||||
* to deal with these attributes.
|
||||
*
|
||||
* The class Combinatorial_map_helper<CMap> defines:
|
||||
*
|
||||
*/
|
||||
namespace CGAL
|
||||
{
|
||||
namespace internal
|
||||
|
|
|
|||
Loading…
Reference in New Issue