Two bugfix: 1) one mark not shared for CMap_cell_iterator 2) use of two least significant bits for Cell_attribute when support of dart is disable. Add tests in test suite for these cases.

This commit is contained in:
Guillaume Damiand 2013-04-26 10:57:53 +02:00
parent f58aa32242
commit 8510fb2853
3 changed files with 76 additions and 6 deletions

View File

@ -131,20 +131,20 @@ namespace CGAL {
/// Increment the reference counting. /// Increment the reference counting.
void inc_nb_refs() void inc_nb_refs()
{ ++mrefcounting; } { mrefcounting+=4; } // 4 because this is the 3rd bit (ie 1<<2)
/// Decrement the reference counting. /// Decrement the reference counting.
void dec_nb_refs() void dec_nb_refs()
{ {
CGAL_assertion( mrefcounting>0 ); CGAL_assertion( mrefcounting>3 );
--mrefcounting; mrefcounting-=4; // 4 because this is the 3rd bit (ie 1<<2)
} }
public:
/// Get the reference counting. /// Get the reference counting.
unsigned int get_nb_refs() const unsigned int get_nb_refs() const
{ return mrefcounting; } { return (mrefcounting>>2); } // >>2 to ignore the 2 least significant bits
public:
void * for_compact_container() const void * for_compact_container() const
{ return vp; } { return vp; }
void * & for_compact_container() void * & for_compact_container()

View File

@ -112,7 +112,10 @@ namespace CGAL {
CMap_cell_iterator(const Self& aiterator): CMap_cell_iterator(const Self& aiterator):
Ite(aiterator), Ite(aiterator),
mcell_mark_number(aiterator.mcell_mark_number) mcell_mark_number(aiterator.mcell_mark_number)
{ this->mmap->share_a_mark(this->mcell_mark_number); } {
this->mmap->share_a_mark(this->mmark_number);
this->mmap->share_a_mark(this->mcell_mark_number);
}
/// Assignment operator. /// Assignment operator.
Self& operator=(const Self& aiterator) Self& operator=(const Self& aiterator)
@ -120,6 +123,7 @@ namespace CGAL {
if (this != &aiterator) if (this != &aiterator)
{ {
Ite::operator=(aiterator); Ite::operator=(aiterator);
this->mmap->share_a_mark(this->mmark_number);
this->mmap->share_a_mark(mcell_mark_number); this->mmap->share_a_mark(mcell_mark_number);
} }
return *this; return *this;

View File

@ -32,6 +32,19 @@ struct Myitems_2
}; };
}; };
struct Myitems_2c
{
template <class LCC>
struct Dart_wrapper
{
typedef CGAL::Dart<2, LCC> Dart;
typedef CGAL::Cell_attribute_with_point<LCC,int,CGAL::Tag_false,Sum_functor,
Divide_by_two_functor> myattrib;
typedef CGAL::cpp11::tuple<myattrib, myattrib, myattrib>
Attributes;
};
};
struct Myitems_3 struct Myitems_3
{ {
template <class LCC> template <class LCC>
@ -46,6 +59,20 @@ struct Myitems_3
}; };
}; };
struct Myitems_3c
{
template <class LCC>
struct Dart_wrapper
{
typedef CGAL::Dart<3, LCC> Dart;
typedef CGAL::Cell_attribute_with_point<LCC,int,CGAL::Tag_false,Sum_functor,
Divide_by_two_functor> myattrib;
typedef CGAL::cpp11::tuple<myattrib, myattrib, myattrib, myattrib>
Attributes;
};
};
struct Myitems_4 struct Myitems_4
{ {
template <class LCC> template <class LCC>
@ -60,6 +87,19 @@ struct Myitems_4
}; };
}; };
struct Myitems_4c
{
template <class LCC>
struct Dart_wrapper
{
typedef CGAL::Dart<4, LCC> Dart;
typedef CGAL::Cell_attribute_with_point<LCC,int,CGAL::Tag_false,Sum_functor,
Divide_by_two_functor> myattrib;
typedef CGAL::cpp11::tuple<myattrib, myattrib, myattrib, myattrib,myattrib>
Attributes;
};
};
int main() int main()
{ {
@ -95,6 +135,14 @@ int main()
return EXIT_FAILURE; return EXIT_FAILURE;
} }
typedef CGAL::Linear_cell_complex<2,2,
CGAL::Linear_cell_complex_traits<2>,
Myitems_2c> LCC2c;
if ( !test_LCC_2<LCC2c>() )
{
std::cout<<" Error during Test_LCC_2<LCC2c>."<<std::endl;
return EXIT_FAILURE;
}
typedef CGAL::Linear_cell_complex<3,3, typedef CGAL::Linear_cell_complex<3,3,
CGAL::Linear_cell_complex_traits<3>, CGAL::Linear_cell_complex_traits<3>,
Myitems_3> LCC3b; Myitems_3> LCC3b;
@ -103,6 +151,15 @@ int main()
std::cout<<" Error during Test_LCC_3<LCC3b>."<<std::endl; std::cout<<" Error during Test_LCC_3<LCC3b>."<<std::endl;
return EXIT_FAILURE; return EXIT_FAILURE;
} }
typedef CGAL::Linear_cell_complex<3,3,
CGAL::Linear_cell_complex_traits<3>,
Myitems_3c> LCC3c;
if ( !test_LCC_3<LCC3c>() )
{
std::cout<<" Error during Test_LCC_3<LCC3c>."<<std::endl;
return EXIT_FAILURE;
}
typedef CGAL::Linear_cell_complex<4,4, typedef CGAL::Linear_cell_complex<4,4,
CGAL::Linear_cell_complex_traits<4>, CGAL::Linear_cell_complex_traits<4>,
@ -113,6 +170,15 @@ int main()
return EXIT_FAILURE; return EXIT_FAILURE;
} }
typedef CGAL::Linear_cell_complex<4,4,
CGAL::Linear_cell_complex_traits<4>,
Myitems_4c> LCC4c;
if ( !test_LCC_4<LCC4b>() )
{
std::cout<<" Error during Test_LCC_4<LCC4c>."<<std::endl;
return EXIT_FAILURE;
}
std::cout<<" Success."<<std::endl; std::cout<<" Success."<<std::endl;
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }