Bug fix in cc with index

This commit is contained in:
Guillaume Damiand 2022-05-25 16:37:51 +02:00
parent 94cd1b4df8
commit c6b6c80145
3 changed files with 23 additions and 23 deletions

View File

@ -240,16 +240,13 @@ public:
void increase_to(size_type old_size) void increase_to(size_type old_size)
{ {
CGAL_assertion(m_cc_with_index->capacity()>old_size); CGAL_assertion(m_cc_with_index->capacity()>old_size);
CGAL_assertion(m_free_list==null_descriptor); // Previous container was full
m_used.resize(m_cc_with_index->capacity(), false); m_used.resize(m_cc_with_index->capacity(), false);
size_type i=0; for(size_type i=old_size;
if(old_size>0) i<static_cast<size_type>(m_cc_with_index->capacity()-1); ++i)
{ i=old_size-1; }
for(; i<static_cast<size_type>(m_cc_with_index->capacity()-1); ++i)
{ Traits::set_size_t((*m_cc_with_index)[i], i+1); } { Traits::set_size_t((*m_cc_with_index)[i], i+1); }
// Next of the last element is null_descriptor. // Next of the last element is null_descriptor.
Traits::set_size_t((*m_cc_with_index)[m_cc_with_index->capacity()-1], Traits::set_size_t((*m_cc_with_index)[m_cc_with_index->capacity()-1],
null_descriptor); m_free_list);
m_free_list=old_size; m_free_list=old_size;
} }
@ -571,6 +568,7 @@ public:
std::swap(size_, c.size_); std::swap(size_, c.size_);
std::swap(block_size, c.block_size); std::swap(block_size, c.block_size);
std::swap(all_items, c.all_items); std::swap(all_items, c.all_items);
//all_items.swap(c.all_items);
free_list.swap(c.free_list); free_list.swap(c.free_list);
} }
@ -828,7 +826,6 @@ clear()
{ {
for (size_type i=0; i<capacity_; ++i) for (size_type i=0; i<capacity_; ++i)
{ if ( is_used(i) ) alloc.destroy(&operator[](i)); } { if ( is_used(i) ) alloc.destroy(&operator[](i)); }
std::allocator_traits<allocator_type>::deallocate(alloc, all_items, capacity_); std::allocator_traits<allocator_type>::deallocate(alloc, all_items, capacity_);
all_items=nullptr; all_items=nullptr;
@ -848,9 +845,9 @@ increase_size()
{ {
if(is_used(index)) if(is_used(index))
{ {
/*std::allocator_traits<allocator_type>::construct std::allocator_traits<allocator_type>::construct
(alloc, &(all_items2[index]), std::move(all_items[index]));*/ (alloc, &(all_items2[index]), std::move(all_items[index]));
new (&all_items2[index]) value_type(all_items[index]); //new (&all_items2[index]) value_type(all_items[index]);
// TEMPO TO DEBUG // TEMPO TO DEBUG
CGAL_assertion(all_items[index]==all_items2[index]); CGAL_assertion(all_items[index]==all_items2[index]);
alloc.destroy(&(all_items[index])); alloc.destroy(&(all_items[index]));

View File

@ -145,6 +145,16 @@ namespace CGAL {
return mf[i]; return mf[i];
} }
bool operator==(const Self& other) const
{
if(mmarks!=other.mmarks ||
mattribute_descriptors!=other.mattribute_descriptors)
{ return false; }
for(unsigned int i=0; i<=dimension; ++i)
{ if(mf[i]!=other.mf[i]) { return false; }}
return true;
}
protected: protected:
/** Default constructor: no real initialisation, /** Default constructor: no real initialisation,
* because this is done in the combinatorial map class. * because this is done in the combinatorial map class.
@ -172,16 +182,6 @@ namespace CGAL {
return *this; return *this;
} }
friend bool operator==(const Self& d1, const Self& d2)
{
if(d1.mmarks!=d2.mmarks ||
d1.mattribute_descriptors!=d2.mattribute_descriptors)
{ return false; }
for(unsigned int i=0; i<=dimension; ++i)
{ if(d1.mf[i]!=d2.mf[i]) { return false; }}
return true;
}
/** Return the mark value of a given mark number. /** Return the mark value of a given mark number.
* @param amark the mark number. * @param amark the mark number.
* @return the value for this number. * @return the value for this number.
@ -296,6 +296,9 @@ namespace CGAL {
typedef Dart<d, Refs, Info_, WithID> Self; typedef Dart<d, Refs, Info_, WithID> Self;
typedef Info_ Info; typedef Info_ Info;
bool operator==(const Self& other) const
{ return Base::operator==(other) && minfo==other.minfo; }
protected: protected:
/** Default constructor: no real initialisation, /** Default constructor: no real initialisation,
* because this is done in the combinatorial or generalized map class. * because this is done in the combinatorial or generalized map class.
@ -306,14 +309,12 @@ namespace CGAL {
Dart(const Info_& info) : minfo(info) Dart(const Info_& info) : minfo(info)
{} {}
protected:
Info_& info() Info_& info()
{ return minfo; } { return minfo; }
const Info_& info() const const Info_& info() const
{ return minfo; } { return minfo; }
friend bool operator==(const Self& d1, const Self& d2)
{ return Base(d1)==Base(d2) && d1.minfo==d2.minfo; }
protected: protected:
Info minfo; Info minfo;
}; };

View File

@ -498,10 +498,12 @@ template<typename Map>
void create2Dmap(Map& map) void create2Dmap(Map& map)
{ {
for ( int i=0; i<15; ++i ) for ( int i=0; i<15; ++i )
{
map.make_tetrahedron(typename Map::Point(i, 0, 0), map.make_tetrahedron(typename Map::Point(i, 0, 0),
typename Map::Point(i, 2, 0), typename Map::Point(i, 2, 0),
typename Map::Point(i+1, 0, 0), typename Map::Point(i+1, 0, 0),
typename Map::Point(i+1, 1, 2)); typename Map::Point(i+1, 1, 2));
}
InitDartInfo<Map>::run(map); InitDartInfo<Map>::run(map);
CreateAttributes<Map,0>::run(map); CreateAttributes<Map,0>::run(map);
CreateAttributes<Map,1>::run(map); CreateAttributes<Map,1>::run(map);