Commit 193a7dae authored by Sylvain Thery's avatar Sylvain Thery

resolve bug of deleting marked dart

parent fdfbd068
......@@ -146,6 +146,8 @@ public:
void setContainerBrowser(ContainerBrowser* bro) { m_currentBrowser = bro;}
bool hasBrowser() { return m_currentBrowser != NULL; }
/**************************************
* BASIC FEATURES *
**************************************/
......
......@@ -186,6 +186,41 @@ public:
//memset(m_tableData[i],0,_BLOCKSIZE_/8);
}
inline void allTrue()
{
for (unsigned int i = 0; i < m_tableData.size(); ++i)
{
unsigned int *ptr =m_tableData[i];
for (unsigned int j=0; j<_BLOCKSIZE_/32;++j)
*ptr++ = 0xffffffff;
}
//memset(m_tableData[i],0,_BLOCKSIZE_/8);
}
inline bool isAllFalse()
{
for (unsigned int i = 0; i < m_tableData.size(); ++i)
{
unsigned int *ptr =m_tableData[i];
for (unsigned int j=0; j<_BLOCKSIZE_/32;++j)
if (*ptr++ != 0)
return false;
}
return true;
}
inline bool isAllTrue()
{
for (unsigned int i = 0; i < m_tableData.size(); ++i)
{
unsigned int *ptr =m_tableData[i];
for (unsigned int j=0; j<_BLOCKSIZE_/32;++j)
if (*ptr++ != 0xffffffff)
return false;
}
return true;
}
/**************************************
* DATA ACCESS *
**************************************/
......
......@@ -200,7 +200,13 @@ public:
inline void markAll()
{
assert(m_markVector != NULL);
m_markVector->allFalse();
AttributeContainer& cont = m_map.template getAttributeContainer<CELL>() ;
if (cont.hasBrowser())
for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i))
this->m_markVector->setTrue(i);
else
m_markVector->allTrue();
}
inline bool isAllUnmarked()
......@@ -208,10 +214,15 @@ public:
assert(m_markVector != NULL);
AttributeContainer& cont = m_map.template getAttributeContainer<CELL>() ;
for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i))
if(m_markVector->operator[](i))
if (cont.hasBrowser())
{
for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i))
if(m_markVector->operator[](i))
return false ;
return true ;
return true ;
}
//else
return m_markVector->isAllFalse();
}
};
......@@ -244,7 +255,13 @@ public:
inline void unmarkAll()
{
assert(this->m_markVector != NULL);
this->m_markVector->allFalse();
AttributeContainer& cont = this->m_map.template getAttributeContainer<CELL>() ;
if (cont.hasBrowser())
for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i))
this->m_markVector->setFalse(i);
else
this->m_markVector->allFalse();
}
};
......@@ -380,32 +397,95 @@ public:
template <typename MAP, unsigned int CELL>
class CellMarkerNoUnmark: public CellMarkerBase<MAP, CELL>
{
#ifndef NDEBUG
int m_counter;
#endif
public:
CellMarkerNoUnmark(MAP& map, unsigned int thread = 0) :
CellMarkerBase<MAP, CELL>(map, thread)
#ifndef NDEBUG
,m_counter(0)
#endif
{}
CellMarkerNoUnmark(const MAP& map, unsigned int thread = 0) :
CellMarkerBase<MAP, CELL>(map, thread)
#ifndef NDEBUG
,m_counter(0)
#endif
{}
virtual ~CellMarkerNoUnmark()
{
// assert(isAllUnmarked()) ;
// CGoGN_ASSERT(this->isAllUnmarked())
#ifndef NDEBUG
if (m_counter != 0)
{
CGoGNerr << "CellMarkerNoUnmark: Warning problem unmarking not complete"<< CGoGNendl;
CGoGNerr << "CellMarkerNoUnmark: -> calling unmarkAll()"<< CGoGNendl;
unmarkAll();
}
#endif
}
protected:
CellMarkerNoUnmark(const CellMarkerNoUnmark& cm) :
CellMarkerBase<MAP, CELL>(cm)
#ifndef NDEBUG
,m_counter(cm.m_counter)
#endif
{}
public:
inline void unmarkAll()
{
assert(this->m_markVector != NULL);
this->m_markVector->allFalse();
AttributeContainer& cont = this->m_map.template getAttributeContainer<CELL>() ;
if (cont.hasBrowser())
for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i))
this->m_markVector->setFalse(i);
else
this->m_markVector->allFalse();
}
#ifndef NDEBUG
inline void mark(Cell<CELL> c)
{
if (this->isMarked(c))
return;
CellMarkerBase<MAP, CELL>::mark(c) ;
m_counter++;
}
inline void unmark(Cell<CELL> c)
{
if (!this->isMarked(c))
return;
CellMarkerBase<MAP, CELL>::unmark(c) ;
m_counter--;
}
inline void mark(unsigned int i)
{
if (this->isMarked(i))
return;
CellMarkerBase<MAP, CELL>::mark(i) ;
m_counter++;
}
/**
* unmark the dart
*/
inline void unmark(unsigned int i)
{
if (!this->isMarked(i))
return;
CellMarkerBase<MAP, CELL>::unmark(i) ;
m_counter--;
}
#endif
};
// Selector and count functors testing for marker existence
......
......@@ -173,26 +173,34 @@ public:
{
assert(m_markVector != NULL);
AttributeContainer& cont = m_map.template getAttributeContainer<DART>() ;
for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i))
m_markVector->setTrue(i);
if (cont.hasBrowser())
for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i))
m_markVector->setTrue(i);
else
m_markVector->allTrue();
}
/**
* unmark all darts
*/
// virtual void unmarkAll() = 0 ;
inline bool isAllUnmarked()
{
assert(m_markVector != NULL);
AttributeContainer& cont = m_map.template getAttributeContainer<DART>() ;
for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i))
if ((*m_markVector)[i])
return false ;
return true ;
if (cont.hasBrowser())
{
for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i))
if ((*m_markVector)[i])
return false ;
return true ;
}
//else
return m_markVector->isAllFalse();
}
};
/**
* class that allows the marking of darts
* \warning no default constructor
......@@ -222,7 +230,12 @@ protected:
public:
inline void unmarkAll()
{
this->m_markVector->allFalse();
AttributeContainer& cont = this->m_map.template getAttributeContainer<DART>();
if (cont.hasBrowser())
for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i))
this->m_markVector->setFalse(i);
else
this->m_markVector->allFalse();
}
} ;
......@@ -240,14 +253,12 @@ public:
DartMarkerStore(MAP& map, unsigned int thread=0) :
DartMarkerTmpl<MAP>(map, thread)
{
// m_markedDarts.reserve(128);
m_markedDarts = GenericMap::askUIntBuffer(thread);
}
DartMarkerStore(const MAP& map, unsigned int thread=0) :
DartMarkerTmpl<MAP>(map, thread)
{
// m_markedDarts.reserve(128);
m_markedDarts = GenericMap::askUIntBuffer(thread);
}
......@@ -255,8 +266,6 @@ public:
{
unmarkAll() ;
GenericMap::releaseUIntBuffer(m_markedDarts, this->m_thread);
// assert(isAllUnmarked) ;
// CGoGN_ASSERT(isAllUnmarked())
}
protected:
......@@ -286,7 +295,7 @@ public:
inline void unmarkAll()
{
for (std::vector<unsigned int>::iterator it = m_markedDarts->begin(); it != m_markedDarts->end(); ++it)
for (std::vector<unsigned int>::iterator it = m_markedDarts->begin(); it != m_markedDarts->end(); ++it)
this->m_markVector->setFalse(*it);
}
} ;
......@@ -299,31 +308,104 @@ public:
template <typename MAP>
class DartMarkerNoUnmark : public DartMarkerTmpl<MAP>
{
#ifndef NDEBUG
int m_counter;
#endif
public:
DartMarkerNoUnmark(const MAP& map) :
DartMarkerTmpl<MAP>(map)
#ifndef NDEBUG
,m_counter(0)
#endif
{}
DartMarkerNoUnmark(const MAP& map, unsigned int thread) :
DartMarkerTmpl<MAP>(map, thread)
#ifndef NDEBUG
,m_counter(0)
#endif
{}
virtual ~DartMarkerNoUnmark()
{
// assert(isAllUnmarked) ;
// CGoGN_ASSERT(isAllUnmarked())
#ifndef NDEBUG
if (m_counter != 0)
{
CGoGNerr << "DartMarkerNoUnmark: Warning problem unmarking not complete"<< CGoGNendl;
CGoGNerr << "DartMarkerNoUnmark: -> calling unmarkAll()"<< CGoGNendl;
unmarkAll();
}
#endif
}
protected:
DartMarkerNoUnmark(const DartMarkerNoUnmark& dm) :
DartMarkerTmpl<MAP>(dm)
#ifndef NDEBUG
,m_counter(dm.m_counter)
#endif
{}
public:
inline void unmarkAll()
{
this->m_markVector->allFalse();
AttributeContainer& cont = this->m_map.template getAttributeContainer<DART>();
if (cont.hasBrowser())
for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i))
this->m_markVector->setFalse(i);
else
this->m_markVector->allFalse();
}
#ifndef NDEBUG
inline void mark(Dart d)
{
if (this->isMarked(d))
return;
DartMarkerTmpl<MAP>::mark(d) ;
m_counter++;
}
/**
* unmark the dart
*/
inline void unmark(Dart d)
{
if (!this->isMarked(d))
return;
DartMarkerTmpl<MAP>::unmark(d) ;
m_counter--;
}
template <unsigned int ORBIT>
inline void markOrbit(Cell<ORBIT> c)
{
assert(this->m_markVector != NULL);
this->m_map.foreach_dart_of_orbit(c, [&] (Dart d)
{
if (!this->isMarked(d))
{
this->m_markVector->setTrue(this->m_map.dartIndex(d));
m_counter++;
}
}) ;
}
template <unsigned int ORBIT>
inline void unmarkOrbit(Cell<ORBIT> c)
{
assert(this->m_markVector != NULL);
this->m_map.foreach_dart_of_orbit(c, [&] (Dart d)
{
if (this->isMarked(d))
{
this->m_markVector->setFalse(this->m_map.dartIndex(d));
m_counter--;
}
}) ;
}
#endif
} ;
// Selector and count functors testing for marker existence
......
......@@ -501,33 +501,6 @@ public:
} ;
/**
* @brief The MapManipulator class
*/
class MapManipulator
{
protected:
std::string m_name;
public:
MapManipulator(const std::string& name, GenericMap *gm):
m_name(name)
{
gm->askManipulate(this);
}
~MapManipulator():
m_name(name)
{
gm->releaseManipulate(this);
}
const std::string& name() { return m_name;}
virtual MapManipulator* create(GenericMap *gm);
};
} //namespace CGoGN
#include "Topology/generic/genericmap.hpp"
......
......@@ -227,7 +227,10 @@ void Map2<MAP_IMPL>::deleteCC(Dart d)
}
for(std::vector<Dart>::iterator it = visited.begin(); it != visited.end(); ++it)
{
mark.unmark(*it);
this->deleteDart(*it) ;
}
}
template <typename MAP_IMPL>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment