mirror of https://github.com/CGAL/cgal
Bug fix in size function in ranges
This commit is contained in:
parent
2ee8f25ba6
commit
fd4162a5a1
|
|
@ -91,12 +91,13 @@ namespace CGAL {
|
||||||
/// Constructor with a dart in parameter (for end iterator).
|
/// Constructor with a dart in parameter (for end iterator).
|
||||||
CMap_one_dart_per_cell_const_iterator(const Map_& amap,
|
CMap_one_dart_per_cell_const_iterator(const Map_& amap,
|
||||||
Dart_const_handle adart):
|
Dart_const_handle adart):
|
||||||
Base(amap)
|
Base(amap, adart)
|
||||||
{ this->set_current_dart(adart); }
|
{}
|
||||||
/// Constructor from non const version.
|
/// Constructor from non const version.
|
||||||
CMap_one_dart_per_cell_const_iterator
|
CMap_one_dart_per_cell_const_iterator
|
||||||
(const CMap_one_dart_per_cell_iterator<Map_,i,dim,false>& it):
|
(const CMap_one_dart_per_cell_iterator<Map_,i,dim,false>& it):
|
||||||
Base(*const_cast<const Map_*>(it.get_combinatorial_map()))
|
Base(*const_cast<const Map_*>(it.get_combinatorial_map()),
|
||||||
|
it.get_first_dart())
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
//****************************************************************************
|
//****************************************************************************
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,7 @@ namespace CGAL {
|
||||||
unmark_treated_darts();
|
unmark_treated_darts();
|
||||||
this->mmap->free_mark(mcell_mark_number);
|
this->mmap->free_mark(mcell_mark_number);
|
||||||
this->mmap->free_mark(this->mmark_number);
|
this->mmap->free_mark(this->mmark_number);
|
||||||
|
this->mcell_mark_number = -1; // To avoid basic class to try to unmark darts.
|
||||||
this->mmark_number = -1; // To avoid basic class to try to unmark darts.
|
this->mmark_number = -1; // To avoid basic class to try to unmark darts.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -216,6 +217,7 @@ namespace CGAL {
|
||||||
if (this->mmap->get_number_of_times_mark_reserved(mmark_number)==1)
|
if (this->mmap->get_number_of_times_mark_reserved(mmark_number)==1)
|
||||||
unmark_treated_darts();
|
unmark_treated_darts();
|
||||||
this->mmap->free_mark(mmark_number);
|
this->mmap->free_mark(mmark_number);
|
||||||
|
this->mmark_number = -1; // To avoid basic class to try to unmark darts.
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Copy constructor.
|
/// Copy constructor.
|
||||||
|
|
@ -316,12 +318,22 @@ namespace CGAL {
|
||||||
mark_cell<Map,i,dim>(amap, (*this), mmark_number);
|
mark_cell<Map,i,dim>(amap, (*this), mmark_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Constructor with a dart in parameter (for end iterator).
|
||||||
|
CMap_cell_iterator(Map& amap, Dart_handle adart):
|
||||||
|
Base(amap, adart),
|
||||||
|
mmark_number(amap.get_new_mark())
|
||||||
|
{
|
||||||
|
if (adart!=this->mmap->null_handle)
|
||||||
|
mark_cell<Map,i,dim>(amap, (*this), mmark_number);
|
||||||
|
}
|
||||||
|
|
||||||
/// Destructor.
|
/// Destructor.
|
||||||
~CMap_cell_iterator()
|
~CMap_cell_iterator()
|
||||||
{
|
{
|
||||||
if (this->mmap->get_number_of_times_mark_reserved(mmark_number)==1)
|
if (this->mmap->get_number_of_times_mark_reserved(mmark_number)==1)
|
||||||
unmark_treated_darts();
|
unmark_treated_darts();
|
||||||
this->mmap->free_mark(mmark_number);
|
this->mmap->free_mark(mmark_number);
|
||||||
|
this->mmark_number = -1; // To avoid basic class to try to unmark darts.
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Copy constructor.
|
/// Copy constructor.
|
||||||
|
|
@ -429,8 +441,9 @@ namespace CGAL {
|
||||||
CMap_one_dart_per_cell_iterator(Map& amap): Base(amap)
|
CMap_one_dart_per_cell_iterator(Map& amap): Base(amap)
|
||||||
{}
|
{}
|
||||||
/// Constructor with a dart in parameter (for end iterator).
|
/// Constructor with a dart in parameter (for end iterator).
|
||||||
CMap_one_dart_per_cell_iterator(Map& amap, Dart_handle adart): Base(amap)
|
CMap_one_dart_per_cell_iterator(Map& amap, Dart_handle adart):
|
||||||
{ this->set_current_dart(adart); }
|
Base(amap, adart)
|
||||||
|
{}
|
||||||
};
|
};
|
||||||
//****************************************************************************
|
//****************************************************************************
|
||||||
//****************************************************************************
|
//****************************************************************************
|
||||||
|
|
|
||||||
|
|
@ -3265,7 +3265,7 @@ namespace CGAL {
|
||||||
iterator end() { return iterator(mmap,mmap.null_handle); }
|
iterator end() { return iterator(mmap,mmap.null_handle); }
|
||||||
const_iterator begin() const { return const_iterator(mmap); }
|
const_iterator begin() const { return const_iterator(mmap); }
|
||||||
const_iterator end() const { return const_iterator(mmap,mmap.null_handle); }
|
const_iterator end() const { return const_iterator(mmap,mmap.null_handle); }
|
||||||
size_type size()
|
size_type size() const
|
||||||
{ return mmap.number_of_darts(); }
|
{ return mmap.number_of_darts(); }
|
||||||
bool empty() const
|
bool empty() const
|
||||||
{ return mmap.is_empty(); }
|
{ return mmap.is_empty(); }
|
||||||
|
|
@ -3337,10 +3337,10 @@ namespace CGAL {
|
||||||
iterator end() { return iterator(mmap,mmap.null_handle); }
|
iterator end() { return iterator(mmap,mmap.null_handle); }
|
||||||
const_iterator begin() const { return const_iterator(mmap); }
|
const_iterator begin() const { return const_iterator(mmap); }
|
||||||
const_iterator end() const { return const_iterator(mmap,mmap.null_handle); }
|
const_iterator end() const { return const_iterator(mmap,mmap.null_handle); }
|
||||||
size_type size()
|
size_type size() const
|
||||||
{
|
{
|
||||||
if (msize==0)
|
if (msize==0)
|
||||||
for ( const_iterator it=begin(); it!=end(); ++it)
|
for ( const_iterator it=begin(), itend=end(); it!=end(); ++it)
|
||||||
++msize;
|
++msize;
|
||||||
return msize;
|
return msize;
|
||||||
}
|
}
|
||||||
|
|
@ -3348,7 +3348,7 @@ namespace CGAL {
|
||||||
{ return mmap.is_empty(); }
|
{ return mmap.is_empty(); }
|
||||||
private:
|
private:
|
||||||
Self & mmap;
|
Self & mmap;
|
||||||
size_type msize;
|
mutable size_type msize;
|
||||||
};
|
};
|
||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
// One_dart_per_cell_const_range
|
// One_dart_per_cell_const_range
|
||||||
|
|
@ -3360,10 +3360,10 @@ namespace CGAL {
|
||||||
{}
|
{}
|
||||||
const_iterator begin() const { return const_iterator(mmap); }
|
const_iterator begin() const { return const_iterator(mmap); }
|
||||||
const_iterator end() const { return const_iterator(mmap,mmap.null_handle); }
|
const_iterator end() const { return const_iterator(mmap,mmap.null_handle); }
|
||||||
size_type size()
|
size_type size() const
|
||||||
{
|
{
|
||||||
if (msize==0)
|
if (msize==0)
|
||||||
for ( const_iterator it=begin(); it!=end(); ++it)
|
for ( const_iterator it=begin(), itend=end(); it!=end(); ++it)
|
||||||
++msize;
|
++msize;
|
||||||
return msize;
|
return msize;
|
||||||
}
|
}
|
||||||
|
|
@ -3371,7 +3371,7 @@ namespace CGAL {
|
||||||
{ return mmap.is_empty(); }
|
{ return mmap.is_empty(); }
|
||||||
private:
|
private:
|
||||||
const Self & mmap;
|
const Self & mmap;
|
||||||
size_type msize;
|
mutable size_type msize;
|
||||||
};
|
};
|
||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
/// @return a range on the i-cells incindent to the given j-cell.
|
/// @return a range on the i-cells incindent to the given j-cell.
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,10 @@ namespace CGAL {
|
||||||
* the involution Bi.
|
* the involution Bi.
|
||||||
* - CMap_non_basic_iterator<Map_,Ite> to transform the basic iterator Ite
|
* - CMap_non_basic_iterator<Map_,Ite> to transform the basic iterator Ite
|
||||||
* into the corresponding non basic iterator.
|
* into the corresponding non basic iterator.
|
||||||
|
* - CMap_range<Map,It,ConstIt,BasicIt> generic definition of a range
|
||||||
|
* given an iterator and its const version
|
||||||
|
* - CMap_const_range<Map,It,ConstIt,BasicIt> generic definition of a const
|
||||||
|
* range given an iterator and its const version
|
||||||
*/
|
*/
|
||||||
//****************************************************************************
|
//****************************************************************************
|
||||||
/// OperationState: type to keep the last operation used by the previous ++.
|
/// OperationState: type to keep the last operation used by the previous ++.
|
||||||
|
|
@ -405,6 +409,7 @@ namespace CGAL {
|
||||||
(this->mmark_number)==1)
|
(this->mmark_number)==1)
|
||||||
unmark_treated_darts();
|
unmark_treated_darts();
|
||||||
this->mmap->free_mark(this->mmark_number);
|
this->mmap->free_mark(this->mmark_number);
|
||||||
|
this->mmark_number = -1; // To avoid basic class to try to unmark darts.
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Copy constructor.
|
/// Copy constructor.
|
||||||
|
|
@ -421,6 +426,7 @@ namespace CGAL {
|
||||||
(this->mmark_number)==1)
|
(this->mmark_number)==1)
|
||||||
unmark_treated_darts();
|
unmark_treated_darts();
|
||||||
this->mmap->free_mark(this->mmark_number);
|
this->mmap->free_mark(this->mmark_number);
|
||||||
|
this->mmark_number = -1;
|
||||||
|
|
||||||
Base::operator=(aiterator);
|
Base::operator=(aiterator);
|
||||||
this->mmap->share_a_mark(this->mmark_number);
|
this->mmap->share_a_mark(this->mmark_number);
|
||||||
|
|
@ -495,10 +501,10 @@ namespace CGAL {
|
||||||
iterator end() { return iterator(mmap,mmap.null_handle); }
|
iterator end() { return iterator(mmap,mmap.null_handle); }
|
||||||
const_iterator begin() const { return const_iterator(mmap,mdart); }
|
const_iterator begin() const { return const_iterator(mmap,mdart); }
|
||||||
const_iterator end() const { return const_iterator(mmap,mmap.null_handle); }
|
const_iterator end() const { return const_iterator(mmap,mmap.null_handle); }
|
||||||
typename Map_::size_type size()
|
typename Map_::size_type size() const
|
||||||
{
|
{
|
||||||
if (msize==0)
|
if (msize==0)
|
||||||
for (const_iterator it=begin(); it!=end(); ++it)
|
for ( const_iterator it=begin(), itend=end(); it!=end(); ++it)
|
||||||
++msize;
|
++msize;
|
||||||
return msize;
|
return msize;
|
||||||
}
|
}
|
||||||
|
|
@ -507,7 +513,7 @@ namespace CGAL {
|
||||||
private:
|
private:
|
||||||
Map_ & mmap;
|
Map_ & mmap;
|
||||||
typename Map_::Dart_handle mdart;
|
typename Map_::Dart_handle mdart;
|
||||||
typename Map_::size_type msize;
|
mutable typename Map_::size_type msize;
|
||||||
};
|
};
|
||||||
//****************************************************************************
|
//****************************************************************************
|
||||||
template <typename Map_, typename It, typename Const_it>
|
template <typename Map_, typename It, typename Const_it>
|
||||||
|
|
@ -523,7 +529,7 @@ namespace CGAL {
|
||||||
iterator end() { return iterator(mmap,mmap.null_handle,mmark); }
|
iterator end() { return iterator(mmap,mmap.null_handle,mmark); }
|
||||||
const_iterator begin() const { return const_iterator(mmap,mdart,mmark); }
|
const_iterator begin() const { return const_iterator(mmap,mdart,mmark); }
|
||||||
const_iterator end() const { return const_iterator(mmap,mmap.null_handle,mmark); }
|
const_iterator end() const { return const_iterator(mmap,mmap.null_handle,mmark); }
|
||||||
typename Map_::size_type size()
|
typename Map_::size_type size() const
|
||||||
{
|
{
|
||||||
if (msize==0)
|
if (msize==0)
|
||||||
for ( CMap_non_basic_iterator<Map_,const_iterator> it(mmap,mdart);
|
for ( CMap_non_basic_iterator<Map_,const_iterator> it(mmap,mdart);
|
||||||
|
|
@ -536,7 +542,7 @@ namespace CGAL {
|
||||||
private:
|
private:
|
||||||
Map_ & mmap;
|
Map_ & mmap;
|
||||||
typename Map_::Dart_handle mdart;
|
typename Map_::Dart_handle mdart;
|
||||||
typename Map_::size_type msize;
|
mutable typename Map_::size_type msize;
|
||||||
int mmark;
|
int mmark;
|
||||||
};
|
};
|
||||||
//****************************************************************************
|
//****************************************************************************
|
||||||
|
|
@ -550,10 +556,10 @@ namespace CGAL {
|
||||||
{}
|
{}
|
||||||
const_iterator begin() const { return const_iterator(mmap,mdart); }
|
const_iterator begin() const { return const_iterator(mmap,mdart); }
|
||||||
const_iterator end() const { return const_iterator(mmap,mmap.null_handle); }
|
const_iterator end() const { return const_iterator(mmap,mmap.null_handle); }
|
||||||
typename Map_::size_type size()
|
typename Map_::size_type size() const
|
||||||
{
|
{
|
||||||
if (msize==0)
|
if (msize==0)
|
||||||
for (const_iterator it=begin(); it!=end(); ++it)
|
for ( const_iterator it=begin(), itend=end(); it!=end(); ++it)
|
||||||
++msize;
|
++msize;
|
||||||
return msize;
|
return msize;
|
||||||
}
|
}
|
||||||
|
|
@ -562,7 +568,7 @@ namespace CGAL {
|
||||||
private:
|
private:
|
||||||
const Map_ & mmap;
|
const Map_ & mmap;
|
||||||
typename Map_::Dart_const_handle mdart;
|
typename Map_::Dart_const_handle mdart;
|
||||||
typename Map_::size_type msize;
|
mutable typename Map_::size_type msize;
|
||||||
};
|
};
|
||||||
//****************************************************************************
|
//****************************************************************************
|
||||||
template <typename Map_, typename Const_it>
|
template <typename Map_, typename Const_it>
|
||||||
|
|
@ -575,7 +581,7 @@ namespace CGAL {
|
||||||
{}
|
{}
|
||||||
const_iterator begin() const { return const_iterator(mmap,mdart,mmark); }
|
const_iterator begin() const { return const_iterator(mmap,mdart,mmark); }
|
||||||
const_iterator end() const { return const_iterator(mmap,mmap.null_handle,mmark); }
|
const_iterator end() const { return const_iterator(mmap,mmap.null_handle,mmark); }
|
||||||
typename Map_::size_type size()
|
typename Map_::size_type size() const
|
||||||
{
|
{
|
||||||
if (msize==0)
|
if (msize==0)
|
||||||
for ( CMap_non_basic_iterator<Map_,const_iterator> it(mmap,mdart);
|
for ( CMap_non_basic_iterator<Map_,const_iterator> it(mmap,mdart);
|
||||||
|
|
@ -588,7 +594,7 @@ namespace CGAL {
|
||||||
private:
|
private:
|
||||||
const Map_ & mmap;
|
const Map_ & mmap;
|
||||||
typename Map_::Dart_const_handle mdart;
|
typename Map_::Dart_const_handle mdart;
|
||||||
typename Map_::size_type msize;
|
mutable typename Map_::size_type msize;
|
||||||
int mmark;
|
int mmark;
|
||||||
};
|
};
|
||||||
//****************************************************************************
|
//****************************************************************************
|
||||||
|
|
|
||||||
|
|
@ -545,6 +545,8 @@ namespace CGAL {
|
||||||
<typename LCC::Traits> > (alcc, P);
|
<typename LCC::Traits> > (alcc, P);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Export the alcc in off file format. If dimension>2, export all faces but only once.
|
||||||
|
*/
|
||||||
template < class LCC >
|
template < class LCC >
|
||||||
void write_off(LCC& alcc, std::ostream& out)
|
void write_off(LCC& alcc, std::ostream& out)
|
||||||
{
|
{
|
||||||
|
|
@ -559,7 +561,7 @@ namespace CGAL {
|
||||||
writer.write_header( out,
|
writer.write_header( out,
|
||||||
alcc.number_of_vertex_attributes(),
|
alcc.number_of_vertex_attributes(),
|
||||||
alcc.number_of_darts(),
|
alcc.number_of_darts(),
|
||||||
alcc.template one_dart_per_cell<2,2>().size() );
|
alcc.template one_dart_per_cell<2>().size() );
|
||||||
|
|
||||||
typedef typename LCC::Vertex_attribute_range::iterator VCI;
|
typedef typename LCC::Vertex_attribute_range::iterator VCI;
|
||||||
VCI vit, vend = alcc.vertex_attributes().end();
|
VCI vit, vend = alcc.vertex_attributes().end();
|
||||||
|
|
@ -584,23 +586,28 @@ namespace CGAL {
|
||||||
{
|
{
|
||||||
std::size_t n = 0;
|
std::size_t n = 0;
|
||||||
// First we count the number of vertices of the face.
|
// First we count the number of vertices of the face.
|
||||||
for ( typename LCC::template Dart_of_cell_range<2,2>::iterator
|
for ( typename LCC::template Dart_of_orbit_range<1>::iterator
|
||||||
itf=alcc.template darts_of_cell<2,2>(itall).begin(),
|
itf=alcc.template darts_of_orbit<1>(itall).begin(),
|
||||||
itfend=alcc.template darts_of_cell<2,2>(itall).end();
|
itfend=alcc.template darts_of_orbit<1>(itall).end();
|
||||||
itf!=itfend; ++itf, ++n );
|
itf!=itfend; ++itf, ++n );
|
||||||
|
|
||||||
CGAL_assertion( n>=3 );
|
CGAL_assertion( n>=3 );
|
||||||
writer.write_facet_begin(n);
|
writer.write_facet_begin(n);
|
||||||
|
|
||||||
// Second we write the indices of vertices.
|
// Second we write the indices of vertices.
|
||||||
for ( typename LCC::template Dart_of_cell_range<2,2>::iterator
|
for ( typename LCC::template Dart_of_orbit_range<1>::iterator
|
||||||
itf=alcc.template darts_of_cell<2,2>(itall).begin(),
|
itf=alcc.template darts_of_orbit<1>(itall).begin(),
|
||||||
itfend=alcc.template darts_of_cell<2,2>(itall).end();
|
itfend=alcc.template darts_of_orbit<1>(itall).end();
|
||||||
itf!=itfend; ++itf )
|
itf!=itfend; ++itf )
|
||||||
{
|
{
|
||||||
// TODO case with index
|
// TODO case with index
|
||||||
writer.write_facet_vertex_index(index[VCI(alcc.vertex_attribute(itf))]);
|
writer.write_facet_vertex_index(index[VCI(alcc.vertex_attribute(itf))]);
|
||||||
alcc.mark(itf, m);
|
|
||||||
|
for ( typename LCC::template Dart_of_involution_basic_range<1>::iterator
|
||||||
|
itinv=alcc.template darts_of_involution_basic<1>(itf, m).begin(),
|
||||||
|
itinvend=alcc.template darts_of_involution_basic<1>(itf, m).end();
|
||||||
|
itinv!=itinvend; ++itinv )
|
||||||
|
alcc.mark(itinv, m);
|
||||||
}
|
}
|
||||||
writer.write_facet_end();
|
writer.write_facet_end();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,15 @@ namespace CGAL {
|
||||||
public Helper::template Attribute_const_range<i>
|
public Helper::template Attribute_const_range<i>
|
||||||
{};
|
{};
|
||||||
|
|
||||||
|
typedef typename Attribute_type<0>::type Vertex_attribute;
|
||||||
|
typedef typename Attribute_handle<0>::type Vertex_attribute_handle;
|
||||||
|
typedef typename Attribute_const_handle<0>::type
|
||||||
|
Vertex_attribute_const_handle;
|
||||||
|
|
||||||
|
typedef typename Attribute_range<0>::type Vertex_attribute_range;
|
||||||
|
typedef typename Attribute_const_range<0>::type
|
||||||
|
Vertex_attribute_const_range;
|
||||||
|
|
||||||
/// Number of marks
|
/// Number of marks
|
||||||
static const size_type NB_MARKS = 32;
|
static const size_type NB_MARKS = 32;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue