merge next

This commit is contained in:
Olivier Devillers 2011-11-08 15:19:20 +00:00
commit 43a831ae5e
8 changed files with 143 additions and 68 deletions

View File

@ -76,6 +76,13 @@ namespace CGAL {
template <int d, typename Refs_>
friend struct Dart;
template < unsigned int d_, class Refs_,
class Items_, class Alloc_ >
friend class Generalized_map_base;
template <int d, typename Refs_>
friend struct GMap_dart;
template <class T, class Alloc_>
friend class Compact_container;
@ -161,10 +168,17 @@ namespace CGAL {
template < unsigned int d_, class Refs_,
class Items_, class Alloc_ >
friend class Combinatorial_map_base;
template <int d, typename Refs_>
friend struct Dart;
template < unsigned int d_, class Refs_,
class Items_, class Alloc_ >
friend class Generalized_map_base;
template <int d, typename Refs_>
friend struct GMap_dart;
template <class T, class Alloc_>
friend class Compact_container;

View File

@ -1085,7 +1085,7 @@ namespace CGAL {
std::vector<unsigned int>
count_cells(const std::vector<unsigned int>& acells) const
{
std::vector<unsigned int> res(dimension+1);
std::vector<unsigned int> res;
int m = get_new_mark();
negate_mark(m); // We mark all the cells.
@ -1097,6 +1097,19 @@ namespace CGAL {
return res;
}
/** Count the number of cells in each dimension.
* @return a vector containing the number of cells.
*/
std::vector<unsigned int> count_all_cells() const
{
std::vector<unsigned int> dim(dimension+2);
for (unsigned int i=0; i<dimension+2; ++i)
dim[i]=i;
return count_cells(dim);
}
protected:
/** Set simultaneously all the marks of a given dart.
* @param adart the dart.

View File

@ -56,12 +56,20 @@ namespace CGAL {
std::stack<internal::Couple_dart_and_dim<typename Map::Dart_handle> >
tosplit;
// Mark used to mark darts already treated.
int treated = amap.get_new_mark();
// Stack of marked darts
std::stack<typename Map::Dart_handle> tounmark;
// Now we run through the facet
for (CGAL::CMap_dart_iterator_basic_of_orbit<Map,1> it(amap,first);
it.cont();)
{
cur = it;
++it;
amap.mark(cur, treated);
tounmark.push(cur);
if ( cur!=first )
{
@ -97,27 +105,40 @@ namespace CGAL {
{
if ( !adart->is_free(dim) )
{
if (n1!=NULL)
if ( !amap.is_marked(cur->beta(dim), treated) )
{
nn1=amap.create_dart();
amap.template link_beta<1>(cur->beta(dim), nn1);
amap.link_beta(n1, nn1, dim);
}
else nn1=NULL;
if (n1!=NULL)
{
nn1=amap.create_dart();
amap.template link_beta<1>(cur->beta(dim), nn1);
amap.link_beta(n1, nn1, dim);
}
else nn1=NULL;
if (n2!=NULL)
{
nn2=amap.create_dart();
amap.template link_beta<0>(cur->beta(dim), nn2);
amap.link_beta(n2, nn2, dim);
}
else nn2=NULL;
if (n2!=NULL)
{
nn2=amap.create_dart();
amap.template link_beta<0>(cur->beta(dim), nn2);
amap.link_beta(n2, nn2, dim);
}
else nn2=NULL;
if (nn1 != NULL && nn2 != NULL)
amap.template basic_link_beta<1>(nn1, nn2);
if (nn1 != NULL && nn2 != NULL)
amap.template basic_link_beta<1>(nn1, nn2);
if (nn1 != NULL && prev != NULL)
amap.link_beta(nn1, prev->beta(dim), 2);
if (nn1 != NULL && prev != NULL)
amap.link_beta(nn1, prev->beta(dim), 2);
amap.mark(cur->beta(dim), treated);
tounmark.push(cur->beta(dim));
}
else
{
if ( n1!=NULL )
amap.link_beta(n1, cur->beta(dim)->beta(1), dim);
if ( n2!=NULL )
amap.link_beta(n2, cur->beta(dim)->beta(0), dim);
}
}
}
@ -131,11 +152,21 @@ namespace CGAL {
{
if ( !adart->is_free(dim) )
{
amap.link_beta(first->beta(0)->beta(dim), nn2, 2);
amap.link_beta(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 Map::Dart_handle> c=tosplit.top();
@ -415,33 +446,39 @@ namespace CGAL {
// 4) For each dart of the cell, we modify link of neighbors.
for ( it=to_erase.begin(); it!=to_erase.end(); ++it )
{
if ( !(*it)->is_free(0) && (*it)->beta(0)!=(*it) )
if ( !(*it)->is_free(0) )
{
amap.template basic_link_beta<1>((*it)->beta(0), (*it)->beta(1));
if ( !(*it)->is_free(1) && (*it)->beta(0)!=(*it) )
amap.template basic_link_beta<1>((*it)->beta(0), (*it)->beta(1));
else
{
todegroup.push(Dart_pair((*it)->beta(0), *it));
(*it)->beta(0)->unlink_beta(1);
}
for ( unsigned int j=2; j<=Map::dimension; ++j )
{
if ( !(*it)->is_free(j) )
((*it)->beta(0))->basic_link_beta((*it)->beta(j),j);
amap.basic_link_beta((*it)->beta(0), (*it)->beta(j), j);
//((*it)->beta(0))->basic_link_beta((*it)->beta(j),j);
}
}
else
{
for ( unsigned int j=1; j<=Map::dimension; ++j )
if ( !(*it)->is_free(1) )
{
if (!(*it)->is_free(j))
{
d1 = (*it)->beta(j);
if ( !d1->is_free(CGAL_BETAINV(j)) )
{
todegroup.push(Dart_pair(d1, d1->beta_inv(j)));
d1->unlink_beta(CGAL_BETAINV(j));
}
}
todegroup.push(Dart_pair((*it)->beta(1), *it));
(*it)->beta(1)->unlink_beta(0);
}
for ( unsigned int j=2; j<=Map::dimension; ++j )
{
if ( !(*it)->is_free(j) )
amap.unlink_beta(*it, j);
}
}
}
// 5) We degroup all the pairs
while ( !todegroup.empty() )
{
@ -449,16 +486,16 @@ namespace CGAL {
todegroup.pop();
amap.degroup_all_attributes(p.first,p.second);
}
// 6) We remove all the darts of the cell.
for (it = to_erase.begin(); it != to_erase.end(); ++it)
{ amap.erase_dart(*it); }
CGAL_assertion( amap.is_whole_map_unmarked(mark) );
amap.free_mark(mark);
// CGAL_postcondition( amap.is_valid() );
return res;
}
};

View File

@ -73,6 +73,9 @@ namespace CGAL {
template <typename Map,unsigned int i>
friend struct internal::link_beta_functor;
template <typename Map,unsigned int i>
friend struct internal::unlink_beta_functor;
public:
typedef Dart<d,Refs> Self;
typedef typename Refs::Dart_handle Dart_handle;

View File

@ -135,7 +135,7 @@ namespace CGAL {
static bool run(const Map& amap,
typename Map::Dart_const_handle adart1,
typename Map::Dart_const_handle adart2)
{ return is_sewable_functor<Map,1>::run(amap,adart1,adart2); }
{ return is_sewable_functor<Map,1>::run(amap,adart2,adart1); }
};
/// Functor used to i-topo_sew two darts, 2<=i<=dimension.
@ -198,7 +198,7 @@ namespace CGAL {
struct topo_sew_functor<Map,0>{
static void run(Map& amap,typename Map::Dart_handle adart1,
typename Map::Dart_handle adart2)
{ topo_sew_functor<Map,1>::run(amap,adart1,adart2); }
{ topo_sew_functor<Map,1>::run(amap,adart2,adart1); }
};
/// Functor used to i-sew two darts, 2<=i<=dimension.
@ -240,25 +240,28 @@ namespace CGAL {
for (CMap_dart_iterator_basic_of_cell<Map,0> it(amap,adart1,mark);
it.cont(); ++it)
{
amap.mark(*it,mark);
dartv.push_back(*it);
amap.mark(it,mark);
dartv.push_back(it);
}
CMap_dart_iterator_of_involution<Map,1> I1(amap, adart1);
CMap_dart_iterator_of_involution_inv<Map,1> I2(amap, adart2);
while ( I1.cont() )
{
group_all_attributes_except(*I1,*I2,1);
++I1; ++I2;
typename Map::Dart_handle od1=I1->other_extremity();
typename Map::Dart_handle od2=I2->other_extremity();
if (od1!=NULL && od2!=NULL)
amap.group_all_attributes_except(od1, od2, 1);
++I1; ++I2;
}
I1.rewind(); I2.rewind();
while ( I1.cont() )
{
if ( amap.is_marked(*I1,mark) )
amap.template basic_link_beta<0>(*I1, *I2);
if ( amap.is_marked(I1,mark) )
amap.template basic_link_beta<0>(I1, I2);
else
amap.template basic_link_beta<1>(*I1, *I2);
amap.template basic_link_beta<1>(I1, I2);
++I1; ++I2;
}
@ -303,7 +306,7 @@ namespace CGAL {
amap.template basic_link_beta<0>(I1, I2);
++I1; ++I2;
}
for (typename std::vector<typename Map::Dart_handle>::iterator
it=dartv.begin(); it!=dartv.end(); ++it)
{ amap.unmark(*it,mark); }
@ -414,19 +417,19 @@ namespace CGAL {
for (CMap_dart_iterator_basic_of_cell<Map,0> it(amap,adart,mark);
it.cont(); ++it)
{
amap.mark(*it,mark);
dartv.push_back(*it);
amap.mark(it,mark);
dartv.push_back(it);
}
{
CMap_dart_iterator_of_involution<Map,1> it(amap, adart);
while ( it.cont() )
{
if ( amap.is_marked(*it,mark) )
{ d2 = it->beta(1); amap.template unlink_beta<1>(*it); }
if ( amap.is_marked(it,mark) )
{ d2 = it->beta(1); amap.template unlink_beta<1>(it); }
else
{ d2 = it->beta(0); amap.template unlink_beta<0>(*it); }
amap.degroup_all_attributes_except(*it,d2,1);
{ d2 = it->beta(0); amap.template unlink_beta<0>(it); }
amap.degroup_all_attributes_except(it,d2,1);
++it;
}
}
@ -435,11 +438,11 @@ namespace CGAL {
it=dartv.begin(); it!=dartv.end(); ++it)
{ amap.unmark(*it,mark); }
CGAL_assertion( amap.is_whole_map_unmarked(mark) );
amap.free_mark(mark);
amap.free_mark(mark);
}
};
/// Functor used to 1-unsew one dart.
/// Functor used to 0-unsew one dart.
template <typename Map>
struct unsew_functor<Map,0>{
static void run(Map& amap,typename Map::Dart_handle adart)
@ -452,19 +455,24 @@ namespace CGAL {
for (CMap_dart_iterator_basic_of_cell<Map,0> it(amap,adart,mark);
it.cont(); ++it)
{
amap.mark(*it,mark);
dartv.push_back(*it);
amap.mark(it,mark);
dartv.push_back(it);
}
{
CMap_dart_iterator_of_involution<Map,1> it(amap, adart);
while ( it.cont() )
{
if ( amap.is_marked(*it,mark) )
{ d2 = it->beta(0); amap.template unlink_beta<0>(*it); }
if ( amap.is_marked(it,mark) )
{ d2 = it->beta(0); amap.template unlink_beta<0>(it); }
else
{ d2 = it->beta(1); amap.template unlink_beta<1>(*it); }
amap.degroup_all_attributes_except(*it,d2,1);
{ d2 = it->beta(1); amap.template unlink_beta<1>(it); }
typename Map::Dart_handle od1=it->other_extremity();
typename Map::Dart_handle od2=d2->other_extremity();
if ( od1!=NULL && od2!=NULL )
amap.degroup_all_attributes_except(od1,od2,1);
++it;
}
}

View File

@ -1,5 +1,5 @@
\begin{ccPkgDescription}{Geometric Object Generators\label{Pkg:Generators}}
\ccPkgHowToCiteCgal{cgal:hhk-gog-12}
\ccPkgHowToCiteCgal{cgal:dhhk-gog-12}
\ccPkgSummary{This package provides a variety of generators for geometric objects.
They are useful as synthetic test data sets, e.g.~for testing

View File

@ -902,7 +902,7 @@ chmod u+w "$LOCK_FILE"
echo $$ > "$LOCK_FILE"
# that line makes the script remove the lock file in case of unwanted exit
trap "rm -f $LOCK_FILE" EXIT HUP INT TERM
trap "rm -f \"$LOCK_FILE\"" EXIT HUP INT TERM
# Notify test started
if [ ! "${MAIL_ADDRESS}" = "must_be_set_in_.autocgalrc" ]; then
@ -948,13 +948,13 @@ if [ -z "${DO_NOT_TEST}" ]; then
run_test
fi
cd ${CGAL_ROOT}
cd "${CGAL_ROOT}"
if [ -e "LATEST" ]; then
mv LATEST RELEASE_NR
fi
rm -f $LOCK_FILE;
rm -f "$LOCK_FILE";
# EOF

View File

@ -1,6 +1,6 @@
\begin{ccPkgDescription}{Spatial Sorting \label{Pkg:SpatialSorting}}
\ccPkgHowToCiteCgal{cgal:d-ss-12}
\ccPkgHowToCiteCgal{cgal:dd-ss-12}
\ccPkgSummary{This package provides functions
for sorting geometric objects in two, three and higher dimensions, in order to improve
efficiency of incremental geometric algorithms.}