Commit 4e878d8e authored by Pierre Kraemer's avatar Pierre Kraemer

template in the dart/cell markers

parent b066d4a5
...@@ -125,9 +125,6 @@ void Topo3PrimalRender::updateData(typename PFP::MAP& mapx, const EMBV& position ...@@ -125,9 +125,6 @@ void Topo3PrimalRender::updateData(typename PFP::MAP& mapx, const EMBV& position
typedef typename PFP::REAL REAL; typedef typename PFP::REAL REAL;
typedef Geom::Vec3f VEC3F; typedef Geom::Vec3f VEC3F;
Map3& map = dynamic_cast<Map3&>(mapx); // TODO reflechir comment virer ce warning quand on compile avec PFP::MAP=Map3
if (m_attIndex.map() != &mapx) if (m_attIndex.map() != &mapx)
m_attIndex = mapx.template getAttribute<unsigned int, DART>("dart_index"); m_attIndex = mapx.template getAttribute<unsigned int, DART>("dart_index");
if (!m_attIndex.isValid()) if (!m_attIndex.isValid())
...@@ -197,7 +194,7 @@ void Topo3PrimalRender::updateData(typename PFP::MAP& mapx, const EMBV& position ...@@ -197,7 +194,7 @@ void Topo3PrimalRender::updateData(typename PFP::MAP& mapx, const EMBV& position
*positionDartBuf++ = PFP::toVec3f(P); *positionDartBuf++ = PFP::toVec3f(P);
*positionDartBuf++ = PFP::toVec3f(PP); *positionDartBuf++ = PFP::toVec3f(PP);
if (map.isBoundaryMarked3(d)) if (mapx.isBoundaryMarked3(d))
{ {
*colorDartBuf++ = m_boundaryDartsColor; *colorDartBuf++ = m_boundaryDartsColor;
*colorDartBuf++ = m_boundaryDartsColor; *colorDartBuf++ = m_boundaryDartsColor;
...@@ -216,8 +213,8 @@ void Topo3PrimalRender::updateData(typename PFP::MAP& mapx, const EMBV& position ...@@ -216,8 +213,8 @@ void Topo3PrimalRender::updateData(typename PFP::MAP& mapx, const EMBV& position
*positionDartBuf++ = PFP::toVec3f(Q); *positionDartBuf++ = PFP::toVec3f(Q);
*positionDartBuf++ = PFP::toVec3f(QQ); *positionDartBuf++ = PFP::toVec3f(QQ);
Dart dx = map.phi3(d); Dart dx = mapx.phi3(d);
if (map.isBoundaryMarked3(dx)) if (mapx.isBoundaryMarked3(dx))
{ {
*colorDartBuf++ = m_boundaryDartsColor; *colorDartBuf++ = m_boundaryDartsColor;
*colorDartBuf++ = m_boundaryDartsColor; *colorDartBuf++ = m_boundaryDartsColor;
...@@ -251,9 +248,9 @@ void Topo3PrimalRender::updateData(typename PFP::MAP& mapx, const EMBV& position ...@@ -251,9 +248,9 @@ void Topo3PrimalRender::updateData(typename PFP::MAP& mapx, const EMBV& position
m_nbRel2=0; m_nbRel2=0;
for (Dart d = map.begin(); d != map.end(); map.next(d)) for (Dart d = mapx.begin(); d != mapx.end(); mapx.next(d))
{ {
Dart e = map.phi2(map.phi3(d)); Dart e = mapx.phi2(mapx.phi3(d));
//if (d < e) //if (d < e)
{ {
......
...@@ -66,14 +66,12 @@ void TopoRender::updateDataBoundary(typename PFP::MAP& map, const VertexAttribut ...@@ -66,14 +66,12 @@ void TopoRender::updateDataBoundary(typename PFP::MAP& map, const VertexAttribut
template<typename PFP> template<typename PFP>
void TopoRender::updateData(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, float ke, float kf, bool withBoundary) void TopoRender::updateData(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, float ke, float kf, bool withBoundary)
{ {
Map2* ptrMap2 = dynamic_cast<Map2*>(&map); if (map.mapTypeName()[0] == "M") // "Map2"
if (ptrMap2 != NULL)
{ {
updateDataMap<PFP>(map, positions, ke, kf, withBoundary); updateDataMap<PFP>(map, positions, ke, kf, withBoundary);
return; return;
} }
GMap2* ptrGMap2 = dynamic_cast<GMap2*>(&map); if (map.mapTypeName()[0] == "G") // "GMap2"
if (ptrGMap2 != NULL)
{ {
updateDataGMap<PFP>(map, positions, ke, kf, withBoundary); updateDataGMap<PFP>(map, positions, ke, kf, withBoundary);
return; return;
......
...@@ -37,15 +37,16 @@ namespace CGoGN ...@@ -37,15 +37,16 @@ namespace CGoGN
* Browser that traverses all darts and jumps over * Browser that traverses all darts and jumps over
* those not selected by the selector * those not selected by the selector
*/ */
template <typename MAP>
class DartContainerBrowserSelector : public ContainerBrowser class DartContainerBrowserSelector : public ContainerBrowser
{ {
protected: protected:
AttributeContainer* m_cont ; AttributeContainer* m_cont ;
const FunctorSelect* m_selector ; const FunctorSelect* m_selector ;
AttribMap& m_map; MAP& m_map;
public: public:
DartContainerBrowserSelector(AttribMap& m, const FunctorSelect& fs); DartContainerBrowserSelector(MAP& m, const FunctorSelect& fs);
~DartContainerBrowserSelector(); ~DartContainerBrowserSelector();
unsigned int begin() const; unsigned int begin() const;
unsigned int end() const; unsigned int end() const;
...@@ -54,6 +55,8 @@ public: ...@@ -54,6 +55,8 @@ public:
void disable(); void disable();
} ; } ;
template <unsigned int CELL> template <unsigned int CELL>
class ContainerBrowserCellMarked : public ContainerBrowser class ContainerBrowserCellMarked : public ContainerBrowser
{ {
......
...@@ -21,57 +21,44 @@ ...@@ -21,57 +21,44 @@
* Contact information: cgogn@unistra.fr * * Contact information: cgogn@unistra.fr *
* * * *
*******************************************************************************/ *******************************************************************************/
#include "Topology/generic/dart.h" #include "Topology/generic/dart.h"
#include "Topology/generic/attribmap.h" #include "Topology/generic/attribmap.h"
namespace CGoGN namespace CGoGN
{ {
template <typename MAP>
inline DartContainerBrowserSelector::DartContainerBrowserSelector(AttribMap& m, const FunctorSelect& fs): inline DartContainerBrowserSelector<MAP>::DartContainerBrowserSelector(MAP& m, const FunctorSelect& fs):
m_map(m) m_map(m)
{ {
if (GenericMap::isMultiRes()) m_cont = &m.getDartContainer();
{
m_cont = &(m.getMRAttributeContainer());
}
else
{
m_cont = &(m.getAttributeContainer<DART>());
}
m_selector = fs.copy(); m_selector = fs.copy();
} }
inline DartContainerBrowserSelector::~DartContainerBrowserSelector() template <typename MAP>
inline DartContainerBrowserSelector<MAP>::~DartContainerBrowserSelector()
{ {
delete m_selector; delete m_selector;
} }
inline unsigned int DartContainerBrowserSelector::begin() const template <typename MAP>
inline unsigned int DartContainerBrowserSelector<MAP>::begin() const
{ {
if (GenericMap::isMultiRes()) unsigned int it = m_cont->realBegin() ;
{ while ( (it != m_cont->realEnd()) && !m_selector->operator()(m_map.indexDart(it)) )
unsigned int it = m_cont->realBegin() ; m_cont->realNext(it);
while ( (it != m_cont->realEnd()) && !m_selector->operator()(m_map.indexDart(it)) ) return it;
m_cont->realNext(it);
return it;
}
else
{
unsigned int it = m_cont->realBegin() ;
while ( (it != m_cont->realEnd()) && !m_selector->operator()(Dart(it)) )
m_cont->realNext(it);
return it;
}
} }
inline unsigned int DartContainerBrowserSelector::end() const template <typename MAP>
inline unsigned int DartContainerBrowserSelector<MAP>::end() const
{ {
return m_cont->realEnd(); return m_cont->realEnd();
} }
inline void DartContainerBrowserSelector::next(unsigned int& it) const template <typename MAP>
inline void DartContainerBrowserSelector<MAP>::next(unsigned int& it) const
{ {
do do
{ {
...@@ -80,39 +67,55 @@ inline void DartContainerBrowserSelector::next(unsigned int& it) const ...@@ -80,39 +67,55 @@ inline void DartContainerBrowserSelector::next(unsigned int& it) const
while ( (it != m_cont->realEnd()) && !m_selector->operator()(Dart(it)) ) ; while ( (it != m_cont->realEnd()) && !m_selector->operator()(Dart(it)) ) ;
} }
template <typename MAP>
inline void DartContainerBrowserSelector::enable() inline void DartContainerBrowserSelector<MAP>::enable()
{ {
m_cont->setContainerBrowser(this); m_cont->setContainerBrowser(this);
} }
inline void DartContainerBrowserSelector::disable() template <typename MAP>
inline void DartContainerBrowserSelector<MAP>::disable()
{ {
m_cont->setContainerBrowser(NULL); m_cont->setContainerBrowser(NULL);
} }
inline ContainerBrowserLinked::ContainerBrowserLinked(AttribMap& m, unsigned int orbit): inline ContainerBrowserLinked::ContainerBrowserLinked(AttribMap& m, unsigned int orbit):
autoAttribute(true), m_first(0xffffffff), m_end(0xffffffff) autoAttribute(true),
m_first(0xffffffff),
m_end(0xffffffff)
{ {
m_cont = &(m.getAttributeContainer(orbit)); m_cont = &(m.getAttributeContainer(orbit));
m_links = m_cont->addAttribute<unsigned int>("Browser_Links") ; m_links = m_cont->addAttribute<unsigned int>("Browser_Links") ;
} }
inline ContainerBrowserLinked::ContainerBrowserLinked(AttributeContainer& c): inline ContainerBrowserLinked::ContainerBrowserLinked(AttributeContainer& c):
m_cont(&c), autoAttribute(true), m_first(0xffffffff), m_end(0xffffffff) m_cont(&c),
autoAttribute(true),
m_first(0xffffffff),
m_end(0xffffffff)
{ {
m_links = m_cont->addAttribute<unsigned int>("Browser_Links") ; m_links = m_cont->addAttribute<unsigned int>("Browser_Links") ;
} }
inline ContainerBrowserLinked::ContainerBrowserLinked(AttributeContainer& c, AttributeMultiVector<unsigned int>* links): inline ContainerBrowserLinked::ContainerBrowserLinked(AttributeContainer& c, AttributeMultiVector<unsigned int>* links):
m_cont(&c), m_links(links), autoAttribute(false), m_first(0xffffffff), m_end(0xffffffff) m_cont(&c),
m_links(links),
autoAttribute(false),
m_first(0xffffffff),
m_end(0xffffffff)
{} {}
inline ContainerBrowserLinked::ContainerBrowserLinked(ContainerBrowserLinked& cbl): inline ContainerBrowserLinked::ContainerBrowserLinked(ContainerBrowserLinked& cbl):
m_cont(cbl.m_cont), m_links(cbl.m_links), m_first(0xffffffff), m_end(0xffffffff) m_cont(cbl.m_cont),
m_links(cbl.m_links),
m_first(0xffffffff),
m_end(0xffffffff)
{} {}
inline ContainerBrowserLinked::~ContainerBrowserLinked() inline ContainerBrowserLinked::~ContainerBrowserLinked()
...@@ -157,7 +160,6 @@ inline void ContainerBrowserLinked::pushBack(unsigned int it) ...@@ -157,7 +160,6 @@ inline void ContainerBrowserLinked::pushBack(unsigned int it)
} }
} }
inline void ContainerBrowserLinked::enable() inline void ContainerBrowserLinked::enable()
{ {
m_cont->setContainerBrowser(this); m_cont->setContainerBrowser(this);
...@@ -181,13 +183,11 @@ inline ContainerBrowserCellMarked<CELL>::ContainerBrowserCellMarked(AttribMap& m ...@@ -181,13 +183,11 @@ inline ContainerBrowserCellMarked<CELL>::ContainerBrowserCellMarked(AttribMap& m
m_cont = &(m.getAttributeContainer<CELL>()); m_cont = &(m.getAttributeContainer<CELL>());
} }
template <unsigned int CELL> template <unsigned int CELL>
inline ContainerBrowserCellMarked<CELL>::~ContainerBrowserCellMarked() inline ContainerBrowserCellMarked<CELL>::~ContainerBrowserCellMarked()
{ {
} }
template <unsigned int CELL> template <unsigned int CELL>
inline unsigned int ContainerBrowserCellMarked<CELL>::begin() const inline unsigned int ContainerBrowserCellMarked<CELL>::begin() const
{ {
...@@ -226,5 +226,4 @@ inline void ContainerBrowserCellMarked<CELL>::disable() ...@@ -226,5 +226,4 @@ inline void ContainerBrowserCellMarked<CELL>::disable()
m_cont->setContainerBrowser(NULL); m_cont->setContainerBrowser(NULL);
} }
} // namespace CGoGN } // namespace CGoGN
This diff is collapsed.
This diff is collapsed.
...@@ -50,7 +50,7 @@ namespace CGoGN ...@@ -50,7 +50,7 @@ namespace CGoGN
class AttributeHandlerGen ; class AttributeHandlerGen ;
class DartMarkerGen ; class DartMarkerGen ;
class CellMarkerGen ; class CellMarkerGen ;
template<unsigned int CELL> class CellMarkerBase ; //template<typename MAP, unsigned int CELL> class CellMarkerBase ;
class GenericMap class GenericMap
{ {
...@@ -62,10 +62,9 @@ class GenericMap ...@@ -62,10 +62,9 @@ class GenericMap
template<typename T> friend class VolumeAutoAttribute ; template<typename T> friend class VolumeAutoAttribute ;
friend class DartMarkerGen ; friend class DartMarkerGen ;
friend class CellMarkerGen ; friend class CellMarkerGen ;
template<unsigned int CELL> friend class CellMarkerBase ; template<typename MAP, unsigned int CELL> friend class CellMarkerBase ;
protected: protected:
/** /**
* Attributes Containers * Attributes Containers
*/ */
...@@ -109,7 +108,6 @@ protected: ...@@ -109,7 +108,6 @@ protected:
std::vector<DartMarkerGen*> dartMarkers[NB_THREAD] ; std::vector<DartMarkerGen*> dartMarkers[NB_THREAD] ;
std::vector<CellMarkerGen*> cellMarkers[NB_THREAD] ; std::vector<CellMarkerGen*> cellMarkers[NB_THREAD] ;
public: public:
static const unsigned int UNKNOWN_ATTRIB = AttributeContainer::UNKNOWN ; static const unsigned int UNKNOWN_ATTRIB = AttributeContainer::UNKNOWN ;
...@@ -165,17 +163,19 @@ public: ...@@ -165,17 +163,19 @@ public:
* @param d * @param d
* @return index of dart (depends on map implementation) * @return index of dart (depends on map implementation)
*/ */
virtual unsigned int dartIndex(Dart d) const ; // virtual unsigned int dartIndex(Dart d) const = 0;
/** /**
* @return the number of darts in the map * get the Dart of index in topological table
*/ */
virtual unsigned int getNbDarts() ; // virtual Dart indexDart(unsigned int index) const = 0;
/** /**
* return true if the dart d refers to a valid index * @return the number of darts in the map
*/ */
bool isDartValid(Dart d) ; virtual unsigned int getNbDarts() ;
// AttributeContainer& getDartContainer() = 0;
/**************************************** /****************************************
* EMBEDDING MANAGEMENT * * EMBEDDING MANAGEMENT *
...@@ -189,35 +189,6 @@ public: ...@@ -189,35 +189,6 @@ public:
bool isOrbitEmbedded(unsigned int orbit) const ; bool isOrbitEmbedded(unsigned int orbit) const ;
/**
* get the cell index of the given dimension associated to dart d
* @return EMBNULL if the orbit of d is not attached to any cell
*/
template<unsigned int ORBIT>
unsigned int getEmbedding(Dart d) const;
/**
* Set the cell index of the given dimension associated to dart d
*/
template <unsigned int ORBIT>
void setDartEmbedding(Dart d, unsigned int emb) ;
/**
* Set the cell index of the given dimension associated to dart d
* !!! WARNING !!! use only on freshly inserted darts (no unref is done on old embedding) !!! WARNING !!!
*/
template <unsigned int ORBIT>
void initDartEmbedding(Dart d, unsigned int emb) ;
/**
* Copy the index of the cell associated to a dart over an other dart
* @param orbit the id of orbit embedding
* @param dest the dart to overwrite
* @param src the dart to copy
*/
template <unsigned int ORBIT>
void copyDartEmbedding(Dart dest, Dart src) ;
/** /**
* Allocation of some place in attrib table * Allocation of some place in attrib table
* @param orbit the orbit of embedding * @param orbit the orbit of embedding
...@@ -226,47 +197,6 @@ public: ...@@ -226,47 +197,6 @@ public:
template <unsigned int ORBIT> template <unsigned int ORBIT>
unsigned int newCell() ; unsigned int newCell() ;
/**
* Set the index of the associated cell to all the darts of an orbit
* @param orbit orbit to embed
* @param d a dart of the topological vertex
* @param em index of attribute to store as embedding
*/
template <unsigned int ORBIT>
void setOrbitEmbedding(Dart d, unsigned int em) ;
/**
* Set the index of the associated cell to all the darts of an orbit
* !!! WARNING !!! use only on freshly inserted darts (no unref is done on old embedding)!!! WARNING !!!
*/
template <unsigned int ORBIT>
void initOrbitEmbedding(Dart d, unsigned int em) ;
/**
* Associate an new cell to all darts of an orbit
* @param orbit orbit to embed
* @param d a dart of the topological cell
* @return index of the attribute in table
*/
template <unsigned int ORBIT>
unsigned int setOrbitEmbeddingOnNewCell(Dart d) ;
/**
* Associate an new cell to all darts of an orbit
* !!! WARNING !!! use only on freshly inserted darts (no unref is done on old embedding)!!! WARNING !!!
*/
template <unsigned int ORBIT>
unsigned int initOrbitEmbeddingNewCell(Dart d) ;
/**
* Copy the cell associated to a dart over an other dart
* @param orbit attribute orbit to use
* @param d the dart to overwrite (dest)
* @param e the dart to copy (src)
*/
template <unsigned int ORBIT>
void copyCell(Dart d, Dart e) ;
/** /**
* Line of attributes i is overwritten with line j * Line of attributes i is overwritten with line j
* @param orbit attribute orbit to use * @param orbit attribute orbit to use
...@@ -284,13 +214,6 @@ public: ...@@ -284,13 +214,6 @@ public:
template <unsigned int ORBIT> template <unsigned int ORBIT>
void initCell(unsigned int i) ; void initCell(unsigned int i) ;
/**
* Traverse the map and embed all orbits of the given dimension with a new cell
* @param realloc if true -> all the orbits are embedded on new cells, if false -> already embedded orbits are not impacted
*/
template <unsigned int ORBIT>
void initAllOrbitsEmbedding(bool realloc = false) ;
/**************************************** /****************************************
* QUICK TRAVERSAL MANAGEMENT * * QUICK TRAVERSAL MANAGEMENT *
****************************************/ ****************************************/
...@@ -440,14 +363,6 @@ public: ...@@ -440,14 +363,6 @@ public:
/**************************************** /****************************************
* SAVE & LOAD * * SAVE & LOAD *
****************************************/ ****************************************/
public:
/**
* check if an xml node has a given name
* @param node the xml node
* @param name the name
* @ return true if node has the good name
*/
// bool chechXmlNode(xmlNodePtr node, const std::string& name) ;
/** /**
* update the pointer of embedding vector after loading * update the pointer of embedding vector after loading
...@@ -459,38 +374,24 @@ public: ...@@ -459,38 +374,24 @@ public:
*/ */
virtual void update_topo_shortcuts(); virtual void update_topo_shortcuts();
/**
* Save map in a XML file
* @param filename the file name
* @return true if OK
*/
// bool saveMapXml(const std::string& filename, bool compress = false) ;
/**
* Load map from a XML file
* @param filename the file name
* @return true if OK
*/
// bool loadMapXml(const std::string& filename, bool compress = false) ;
/** /**
* Save map in a binary file * Save map in a binary file
* @param filename the file name * @param filename the file name
* @return true if OK * @return true if OK
*/ */
bool saveMapBin(const std::string& filename) const; virtual bool saveMapBin(const std::string& filename) const = 0;
/** /**
* Load map from a binary file * Load map from a binary file
* @param filename the file name * @param filename the file name
* @return true if OK * @return true if OK
*/ */
bool loadMapBin(const std::string& filename) ; virtual bool loadMapBin(const std::string& filename) = 0 ;
/** /**
* copy from another map (of same type) * copy from another map (of same type)
*/ */
bool copyFrom(const GenericMap& map) ; virtual bool copyFrom(const GenericMap& map) = 0 ;
/** /**
* Dump attributes types and names per orbit * Dump attributes types and names per orbit
...@@ -511,11 +412,11 @@ public: ...@@ -511,11 +412,11 @@ public:
* DARTS TRAVERSALS * * DARTS TRAVERSALS *
****************************************/ ****************************************/
// /** /**
// * Apply a functor on each dart of the map * Apply a functor on each dart of the map
// * @param f a ref to the functor obj * @param f a ref to the functor obj
// */ */
// bool foreach_dart(FunctorType& f) ; bool foreach_dart(FunctorType& f) ;
virtual Dart begin() const; virtual Dart begin() const;
virtual Dart end() const; virtual Dart end() const;
......
...@@ -90,10 +90,10 @@ inline unsigned int GenericMap::getNbDarts() ...@@ -90,10 +90,10 @@ inline unsigned int GenericMap::getNbDarts()
return m_attribs[DART].size() ; return m_attribs[DART].size() ;
} }
inline bool GenericMap::isDartValid(Dart d) //inline bool GenericMap::isDartValid(Dart d)
{ //{
return !d.isNil() && m_attribs[DART].used(dartIndex(d)) ; // return !d.isNil() && m_attribs[DART].used(dartIndex(d)) ;
} //}
/**************************************** /****************************************
* EMBEDDING MANAGEMENT * * EMBEDDING MANAGEMENT *
...@@ -110,61 +110,6 @@ inline bool GenericMap::isOrbitEmbedded(unsigned int orbit) const ...@@ -110,61 +110,6 @@ inline bool GenericMap::isOrbitEmbedded(unsigned int orbit) const
return (orbit == DART) || (m_embeddings[orbit] != NULL) ; return (orbit == DART) || (m_embeddings[orbit] != NULL) ;
} }
template <unsigned int ORBIT>
inline unsigned int GenericMap::getEmbedding(Dart d) const
{
assert(isOrbitEmbedded<ORBIT>() || !"Invalid parameter: orbit not embedded");