Commit fe862269 authored by Sylvain Thery's avatar Sylvain Thery

remove polymorphism in markers

parent f3916a06
......@@ -32,7 +32,10 @@
namespace CGoGN
{
/**
* @brief The CellMarkerGen class
* @warning CellMarkerGen is no polymorphic version of CellMarker
*/
class CellMarkerGen
{
friend class GenericMap ;
......@@ -53,7 +56,7 @@ public:
releaseOnDestruct(true)
{}
virtual ~CellMarkerGen()
~CellMarkerGen()
{}
unsigned int getThread() { return m_thread ; }
......@@ -66,15 +69,15 @@ public:
*/
void setReleaseOnDestruct(bool b) { releaseOnDestruct = b ; }
virtual void mark(Dart d) = 0 ;
virtual void unmark(Dart d) = 0 ;
virtual bool isMarked(Dart d) const = 0 ;
virtual void mark(unsigned int em) = 0 ;
virtual void unmark(unsigned int em) = 0 ;
virtual bool isMarked(unsigned int em) const = 0 ;
virtual void markAll() = 0 ;
virtual void unmarkAll() = 0 ;
virtual bool isAllUnmarked() = 0 ;
// virtual void mark(Dart d) = 0 ;
// virtual void unmark(Dart d) = 0 ;
// virtual bool isMarked(Dart d) const = 0 ;
// virtual void mark(unsigned int em) = 0 ;
// virtual void unmark(unsigned int em) = 0 ;
// virtual bool isMarked(unsigned int em) const = 0 ;
// virtual void markAll() = 0 ;
// virtual void unmarkAll() = 0 ;
// virtual bool isAllUnmarked() = 0 ;
};
/**
......@@ -98,7 +101,7 @@ public:
m_map.cellMarkers[m_thread].push_back(this) ;
}
virtual ~CellMarkerBase()
/*virtual */~CellMarkerBase()
{
if(releaseOnDestruct)
{
......@@ -126,7 +129,7 @@ public:
/**
* mark the cell of dart
*/
virtual void mark(Dart d)
inline void mark(Dart d)
{
assert(m_map.getMarkerSet<CELL>(m_thread).testMark(m_mark));
assert(m_markVector != NULL);
......@@ -140,7 +143,7 @@ public:
/**
* unmark the cell of dart
*/
virtual void unmark(Dart d)
inline void unmark(Dart d)
{
assert(m_map.getMarkerSet<CELL>(m_thread).testMark(m_mark));
assert(m_markVector != NULL);
......@@ -154,7 +157,7 @@ public:
/**
* test if cell of dart is marked
*/
virtual bool isMarked(Dart d) const
inline bool isMarked(Dart d) const
{
assert(m_map.getMarkerSet<CELL>(m_thread).testMark(m_mark));
assert(m_markVector != NULL);
......@@ -168,7 +171,7 @@ public:
/**
* mark the cell
*/
virtual void mark(unsigned int em)
inline void mark(unsigned int em)
{
assert(m_map.getMarkerSet<CELL>(m_thread).testMark(m_mark));
assert(m_markVector != NULL);
......@@ -179,7 +182,7 @@ public:
/**
* unmark the cell
*/
virtual void unmark(unsigned int em)
inline void unmark(unsigned int em)
{
assert(m_map.getMarkerSet<CELL>(m_thread).testMark(m_mark));
assert(m_markVector != NULL);
......@@ -190,7 +193,7 @@ public:
/**
* test if cell is marked
*/
virtual bool isMarked(unsigned int em) const
inline bool isMarked(unsigned int em) const
{
assert(m_map.getMarkerSet<CELL>(m_thread).testMark(m_mark));
assert(m_markVector != NULL);
......@@ -201,7 +204,7 @@ public:
/**
* mark all the cells
*/
virtual void markAll()
inline void markAll()
{
assert(m_map.getMarkerSet<CELL>(m_thread).testMark(m_mark));
assert(m_markVector != NULL);
......@@ -211,7 +214,7 @@ public:
m_markVector->operator[](i).setMark(m_mark) ;
}
virtual bool isAllUnmarked()
inline bool isAllUnmarked()
{
assert(m_map.getMarkerSet<CELL>(m_thread).testMark(m_mark));
assert(m_markVector != NULL);
......@@ -235,7 +238,7 @@ public:
CellMarker(GenericMap& map, unsigned int thread = 0) : CellMarkerBase<CELL>(map, thread)
{}
virtual ~CellMarker()
~CellMarker()
{
unmarkAll() ;
}
......@@ -245,7 +248,7 @@ protected:
{}
public:
virtual void unmarkAll()
inline void unmarkAll()
{
assert(this->m_map.template getMarkerSet<CELL>(this->m_thread).testMark(this->m_mark));
assert(this->m_markVector != NULL);
......@@ -271,7 +274,7 @@ public:
CellMarkerStore(GenericMap& map, unsigned int thread = 0) : CellMarkerBase<CELL>(map, thread)
{}
virtual ~CellMarkerStore()
~CellMarkerStore()
{
unmarkAll() ;
// assert(isAllUnmarked);
......@@ -283,19 +286,19 @@ protected:
{}
public:
void mark(Dart d)
inline void mark(Dart d)
{
CellMarkerBase<CELL>::mark(d) ;
m_markedCells.push_back(this->m_map.template getEmbedding<CELL>(d)) ;
}
void mark(unsigned int em)
inline void mark(unsigned int em)
{
CellMarkerBase<CELL>::mark(em) ;
m_markedCells.push_back(em) ;
}
void unmarkAll()
inline void unmarkAll()
{
assert(this->m_map.template getMarkerSet<CELL>(this->m_thread).testMark(this->m_mark));
assert(this->m_markVector != NULL);
......@@ -319,7 +322,7 @@ public:
CellMarkerMemo(GenericMap& map, unsigned int thread = 0) : CellMarkerBase<CELL>(map, thread)
{}
virtual ~CellMarkerMemo()
~CellMarkerMemo()
{
unmarkAll() ;
// assert(isAllUnmarked);
......@@ -331,7 +334,7 @@ protected:
{}
public:
void mark(Dart d)
inline void mark(Dart d)
{
if(!this->isMarked(d))
{
......@@ -340,7 +343,7 @@ public:
}
}
void unmarkAll()
inline void unmarkAll()
{
assert(this->m_map.template getMarkerSet<CELL>(this->m_thread).testMark(this->m_mark));
assert(this->m_markVector != NULL);
......@@ -351,7 +354,8 @@ public:
m_markedDarts.clear();
}
std::vector<Dart> get_markedCells()
inline std::vector<Dart> get_markedCells()
{
return m_markedDarts;
}
......@@ -368,7 +372,7 @@ public:
CellMarkerNoUnmark(GenericMap& map, unsigned int thread = 0) : CellMarkerBase<CELL>(map, thread)
{}
virtual ~CellMarkerNoUnmark()
~CellMarkerNoUnmark()
{
// assert(isAllUnmarked()) ;
// CGoGN_ASSERT(this->isAllUnmarked())
......@@ -379,7 +383,7 @@ protected:
{}
public:
void unmarkAll()
inline void unmarkAll()
{
assert(this->m_map.template getMarkerSet<CELL>(this->m_thread).testMark(this->m_mark));
assert(this->m_markVector != NULL);
......@@ -401,13 +405,13 @@ protected:
const CellMarkerBase<CELL>& m_cmarker ;
public:
SelectorCellMarked(const CellMarkerBase<CELL>& cm) : m_cmarker(cm) {}
bool operator()(Dart d) const
inline bool operator()(Dart d) const
{
if (m_cmarker.isMarked(d))
return true ;
return false ;
}
FunctorSelect* copy() const { return new SelectorCellMarked(m_cmarker); }
inline FunctorSelect* copy() const { return new SelectorCellMarked(m_cmarker); }
};
template <unsigned int CELL>
......@@ -417,13 +421,13 @@ protected:
const CellMarkerBase<CELL>& m_cmarker ;
public:
SelectorCellUnmarked(const CellMarkerBase<CELL>& cm) : m_cmarker(cm) {}
bool operator()(Dart d) const
inline bool operator()(Dart d) const
{
if (!m_cmarker.isMarked(d))
return true ;
return false ;
}
FunctorSelect* copy() const { return new SelectorCellUnmarked(m_cmarker); }
inline FunctorSelect* copy() const { return new SelectorCellUnmarked(m_cmarker); }
};
// Functor version (needed for use with foreach_xxx)
......@@ -435,7 +439,7 @@ protected:
CellMarkerBase<CELL>& m_marker;
public:
FunctorCellIsMarked(CellMarkerBase<CELL>& cm) : m_marker(cm) {}
bool operator()(Dart d)
inline bool operator()(Dart d)
{
return m_marker.isMarked(d);
}
......@@ -448,7 +452,7 @@ protected:
CellMarkerBase<CELL>& m_marker;
public:
FunctorCellIsUnmarked(CellMarkerBase<CELL>& cm) : m_marker(cm) {}
bool operator()(Dart d)
inline bool operator()(Dart d)
{
return !m_marker.isMarked(d);
}
......
......@@ -61,7 +61,7 @@ public:
m_map.dartMarkers[m_thread].push_back(this) ;
}
virtual ~DartMarkerGen()
~DartMarkerGen()
{
if (releaseOnDestruct)
{
......@@ -79,12 +79,12 @@ public:
}
}
unsigned int getThread()
inline unsigned int getThread()
{
return m_thread ;
}
void updateMarkVector(AttributeMultiVector<Mark>* amv)
inline void updateMarkVector(AttributeMultiVector<Mark>* amv)
{
m_markVector = amv ;
}
......@@ -99,7 +99,7 @@ protected:
/**
* set if the mark has to be release on destruction or not
*/
void setReleaseOnDestruct(bool b)
inline void setReleaseOnDestruct(bool b)
{
releaseOnDestruct = b ;
}
......@@ -108,7 +108,7 @@ public:
/**
* mark the dart
*/
virtual void mark(Dart d)
inline void mark(Dart d)
{
assert(m_map.getMarkerSet<DART>(m_thread).testMark(m_mark));
unsigned int d_index = m_map.dartIndex(d) ;
......@@ -118,7 +118,7 @@ public:
/**
* unmark the dart
*/
virtual void unmark(Dart d)
inline void unmark(Dart d)
{
assert(m_map.getMarkerSet<DART>(m_thread).testMark(m_mark));
unsigned int d_index = m_map.dartIndex(d) ;
......@@ -128,7 +128,7 @@ public:
/**
* test if dart is marked
*/
virtual bool isMarked(Dart d) const
inline bool isMarked(Dart d) const
{
assert(m_map.getMarkerSet<DART>(m_thread).testMark(m_mark));
unsigned int d_index = m_map.dartIndex(d) ;
......@@ -139,7 +139,7 @@ public:
* mark the darts of the given orbit of d
*/
template <unsigned int ORBIT>
void markOrbit(Dart d)
inline void markOrbit(Dart d)
{
assert(m_map.getMarkerSet<DART>(m_thread).testMark(m_mark));
FunctorMark<GenericMap> fm(m_map, m_mark, m_markVector) ;
......@@ -150,7 +150,7 @@ public:
* unmark the darts of the given orbit of d
*/
template <unsigned int ORBIT>
void unmarkOrbit(Dart d)
inline void unmarkOrbit(Dart d)
{
assert(m_map.getMarkerSet<DART>(m_thread).testMark(m_mark));
FunctorUnmark<GenericMap> fm(m_map, m_mark, m_markVector) ;
......@@ -182,7 +182,7 @@ public:
/**
* mark all darts
*/
virtual void markAll()
inline void markAll()
{
assert(m_map.getMarkerSet<DART>(m_thread).testMark(m_mark));
AttributeContainer& cont = m_map.getAttributeContainer<DART>() ;
......@@ -193,9 +193,9 @@ public:
/**
* unmark all darts
*/
virtual void unmarkAll() = 0 ;
// virtual void unmarkAll() = 0 ;
bool isAllUnmarked()
inline bool isAllUnmarked()
{
assert(m_map.getMarkerSet<DART>(m_thread).testMark(m_mark));
assert(m_markVector != NULL);
......@@ -224,7 +224,7 @@ public:
{
}
virtual ~DartMarker()
~DartMarker()
{
unmarkAll() ;
}
......@@ -236,7 +236,7 @@ protected:
}
public:
void unmarkAll()
inline void unmarkAll()
{
assert(m_map.getMarkerSet<DART>(m_thread).testMark(m_mark));
AttributeContainer& cont = m_map.getAttributeContainer<DART>() ;
......@@ -280,7 +280,7 @@ protected:
}
public:
void mark(Dart d)
inline void mark(Dart d)
{
DartMarkerGen::mark(d) ;
unsigned int d_index = m_map.dartIndex(d) ;
......@@ -288,7 +288,7 @@ public:
}
template <unsigned int ORBIT>
void markOrbit(Dart d)
inline void markOrbit(Dart d)
{
assert(m_map.getMarkerSet<DART>(m_thread).testMark(m_mark));
FunctorMarkStore<GenericMap> fm(m_map, m_mark, m_markVector, m_markedDarts) ;
......@@ -309,7 +309,7 @@ public:
// m_markedDarts.push_back(d) ;
// }
void unmarkAll()
inline void unmarkAll()
{
assert(m_map.getMarkerSet<DART>(m_thread).testMark(m_mark));
for (std::vector<unsigned int>::iterator it = m_markedDarts.begin(); it != m_markedDarts.end(); ++it)
......@@ -348,7 +348,7 @@ protected:
}
public:
void unmarkAll()
inline void unmarkAll()
{
assert(m_map.getMarkerSet<DART>(m_thread).testMark(m_mark));
AttributeContainer& cont = m_map.getAttributeContainer<DART>() ;
......@@ -369,11 +369,11 @@ public:
m_marker(m)
{
}
bool operator()(Dart d) const
inline bool operator()(Dart d) const
{
return m_marker.isMarked(d) ;
}
FunctorSelect* copy() const
inline FunctorSelect* copy() const
{
return new SelectorMarked(m_marker) ;
}
......@@ -388,11 +388,11 @@ public:
m_marker(m)
{
}
bool operator()(Dart d) const
inline bool operator()(Dart d) const
{
return !m_marker.isMarked(d) ;
}
FunctorSelect* copy() const
inline FunctorSelect* copy() const
{
return new SelectorUnmarked(m_marker) ;
}
......@@ -409,7 +409,7 @@ public:
m_marker(dm)
{
}
bool operator()(Dart d)
inline bool operator()(Dart d)
{
return m_marker.isMarked(d) ;
}
......@@ -424,7 +424,7 @@ public:
m_marker(dm)
{
}
bool operator()(Dart d)
inline bool operator()(Dart d)
{
return !m_marker.isMarked(d) ;
}
......
This diff is collapsed.
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef __VTraversor2_H__
#define __VTraversor2_H__
#include "Topology/generic/dart.h"
#include "Topology/generic/traversorGen.h"
namespace CGoGN
{
/*******************************************************************************
VERTEX CENTERED TRAVERSALS
*******************************************************************************/
// Traverse the edges incident to a given vertex
template <typename MAP>
class VTraversor2VE: public Traversor<MAP>
{
private:
MAP& m ;
Dart start ;
Dart current ;
std::vector<Dart>* m_QLT;
std::vector<Dart>::iterator m_ItDarts;
public:
VTraversor2VE(MAP& map, Dart dart) ;
Dart begin() ;
Dart end() ;
Dart next() ;
} ;
// Traverse the faces incident to a given vertex
template <typename MAP>
class VTraversor2VF : public Traversor<MAP>
{
private:
MAP& m ;
Dart start ;
Dart current ;
std::vector<Dart>* m_QLT;
std::vector<Dart>::iterator m_ItDarts;
public:
VTraversor2VF(MAP& map, Dart dart) ;
Dart begin() ;
Dart end() ;
Dart next() ;
} ;
// Traverse the vertices adjacent to a given vertex through sharing a common edge
template <typename MAP>
class VTraversor2VVaE : public Traversor<MAP>
{
private:
MAP& m ;
Dart start ;
Dart current ;
std::vector<Dart>* m_QLT;
std::vector<Dart>::iterator m_ItDarts;
public:
VTraversor2VVaE(MAP& map, Dart dart) ;
Dart begin() ;
Dart end() ;
Dart next() ;
} ;
// Traverse the vertices adjacent to a given vertex through sharing a common face
template <typename MAP>
class VTraversor2VVaF : public Traversor<MAP>
{
private:
MAP& m ;
Dart start ;
Dart current ;
Dart stop ;
std::vector<Dart>* m_QLT;
std::vector<Dart>::iterator m_ItDarts;
public:
VTraversor2VVaF(MAP& map, Dart dart) ;
Dart begin() ;
Dart end() ;
Dart next() ;
} ;
/*******************************************************************************
EDGE CENTERED TRAVERSALS
*******************************************************************************/
// Traverse the vertices incident to a given edge
template <typename MAP>
class VTraversor2EV : public Traversor<MAP>
{
private:
MAP& m ;
Dart start ;
Dart current ;
std::vector<Dart>* m_QLT;
std::vector<Dart>::iterator m_ItDarts;
public:
VTraversor2EV(MAP& map, Dart dart) ;
Dart begin() ;
Dart end() ;
Dart next() ;
} ;
// Traverse the faces incident to a given edge
template <typename MAP>
class VTraversor2EF : public Traversor<MAP>
{
private:
MAP& m ;
Dart start ;
Dart current ;
std::vector<Dart>* m_QLT;
std::vector<Dart>::iterator m_ItDarts;
public:
VTraversor2EF(MAP& map, Dart dart) ;
Dart begin() ;
Dart end() ;
Dart next() ;
} ;
// Traverse the edges adjacent to a given edge through sharing a common vertex
template <typename MAP>
class VTraversor2EEaV : public Traversor<MAP>
{
private:
MAP& m ;
Dart start ;
Dart current ;
Dart stop1, stop2 ;
std::vector<Dart>* m_QLT;
std::vector<Dart>::iterator m_ItDarts;
public:
VTraversor2EEaV(MAP& map, Dart dart) ;
Dart begin() ;
Dart end() ;
Dart next() ;
} ;
// Traverse the edges adjacent to a given edge through sharing a common face
template <typename MAP>
class VTraversor2EEaF : public Traversor<MAP>
{
private:
MAP& m ;
Dart start ;
Dart current ;
Dart stop1, stop2 ;
std::vector<Dart>* m_QLT;
std::vector<Dart>::iterator m_ItDarts;
public:
VTraversor2EEaF(MAP& map, Dart dart) ;
Dart begin() ;
Dart end() ;
Dart next() ;
} ;
/*******************************************************************************
FACE CENTERED TRAVERSALS
*******************************************************************************/
// Traverse the vertices incident to a given face
template <typename MAP>
class VTraversor2FV : public Traversor<MAP>