Commit adcec296 authored by Sylvain Thery's avatar Sylvain Thery Committed by Pierre Kraemer

ajout des fonctions de markage des brins du bord

parent 9416a673
......@@ -32,64 +32,6 @@
namespace CGoGN
{
// Marker Functors
/********************************************************/
template <typename MAP>
class FunctorMarker : public FunctorMap<MAP>
{
protected:
Mark m_mark ;
AttributeMultiVector<Mark>* m_markTable ;
public:
FunctorMarker(MAP& map, Mark m, AttributeMultiVector<Mark>* mTable) : FunctorMap<MAP>(map), m_mark(m), m_markTable(mTable)
{}
// Mark getMark() { return m_mark ; }
} ;
template <typename MAP>
class FunctorMark : public FunctorMarker<MAP>
{
public:
FunctorMark(MAP& map, Mark m, AttributeMultiVector<Mark>* mTable) : FunctorMarker<MAP>(map, m, mTable)
{}
bool operator()(Dart d)
{
this->m_markTable->operator[](d.index).setMark(this->m_mark) ;
return false ;
}
} ;
template <typename MAP>
class FunctorMarkStore : public FunctorMarker<MAP>
{
protected:
std::vector<unsigned int>& m_markedDarts ;
public:
FunctorMarkStore(MAP& map, Mark m, AttributeMultiVector<Mark>* mTable, std::vector<unsigned int>& marked) :
FunctorMarker<MAP>(map, m, mTable),
m_markedDarts(marked)
{}
bool operator()(Dart d)
{
this->m_markTable->operator[](d.index).setMark(this->m_mark) ;
m_markedDarts.push_back(d.index) ;
return false ;
}
} ;
template <typename MAP>
class FunctorUnmark : public FunctorMarker<MAP>
{
public:
FunctorUnmark(MAP& map, Mark m, AttributeMultiVector<Mark>* mTable) : FunctorMarker<MAP>(map, m, mTable)
{}
bool operator()(Dart d)
{
this->m_markTable->operator[](d.index).unsetMark(this->m_mark) ;
return false ;
}
} ;
/**
* generic class that allows the marking of darts
......
......@@ -27,6 +27,7 @@
#include "Topology/generic/dart.h"
#include "Topology/generic/marker.h"
#include "Container/attributeMultiVector.h"
#include <vector>
namespace CGoGN
......@@ -174,6 +175,67 @@ public:
}
};
// Marker Functors
/********************************************************/
template <typename MAP>
class FunctorMarker : public FunctorMap<MAP>
{
protected:
Mark m_mark ;
AttributeMultiVector<Mark>* m_markTable ;
public:
FunctorMarker(MAP& map, Mark m, AttributeMultiVector<Mark>* mTable) : FunctorMap<MAP>(map), m_mark(m), m_markTable(mTable)
{}
// Mark getMark() { return m_mark ; }
} ;
template <typename MAP>
class FunctorMark : public FunctorMarker<MAP>
{
public:
FunctorMark(MAP& map, Mark m, AttributeMultiVector<Mark>* mTable) : FunctorMarker<MAP>(map, m, mTable)
{}
bool operator()(Dart d)
{
this->m_markTable->operator[](d.index).setMark(this->m_mark) ;
return false ;
}
} ;
template <typename MAP>
class FunctorMarkStore : public FunctorMarker<MAP>
{
protected:
std::vector<unsigned int>& m_markedDarts ;
public:
FunctorMarkStore(MAP& map, Mark m, AttributeMultiVector<Mark>* mTable, std::vector<unsigned int>& marked) :
FunctorMarker<MAP>(map, m, mTable),
m_markedDarts(marked)
{}
bool operator()(Dart d)
{
this->m_markTable->operator[](d.index).setMark(this->m_mark) ;
m_markedDarts.push_back(d.index) ;
return false ;
}
} ;
template <typename MAP>
class FunctorUnmark : public FunctorMarker<MAP>
{
public:
FunctorUnmark(MAP& map, Mark m, AttributeMultiVector<Mark>* mTable) : FunctorMarker<MAP>(map, m, mTable)
{}
bool operator()(Dart d)
{
this->m_markTable->operator[](d.index).unsetMark(this->m_mark) ;
return false ;
}
} ;
} //namespace CGoGN
#endif
......@@ -403,6 +403,42 @@ public:
* print attributes name of map in std::cout (for debugging)
*/
void viewAttributesTables();
protected:
/// boundary marker
Mark m_boundaryMarker;
/**
* mark a dart as belonging to boundary
*/
void boundaryMark(Dart d);
/**
* unmark a dart from the boundary
*/
void boundaryUnmark(Dart d);
/**
* test if a dart belong to the boundary
*/
bool isBoundaryMarked(Dart d);
/**
* mark an orbit of dart as belonging to boundary
*/
void boundaryMarkOrbit(unsigned int orbit, Dart d);
/**
* unmark an orbit of dart from the boundary
*/
void boundaryUnmarkOrbit(unsigned int orbit, Dart d);
/**
* clear all boundary markers
*/
void boundaryUnmarkAll();
} ;
......
......@@ -78,10 +78,16 @@ GenericMap::GenericMap() : m_nbThreads(1)
m_markTables[i][j] = NULL ;
}
}
// get & lock marker for boundary
m_boundaryMarker = m_marksets[DART][0].getNewMark();
}
GenericMap::~GenericMap()
{
// release marker for boundary
m_marksets[DART][0].releaseMark(m_boundaryMarker);
for(unsigned int i = 0; i < NB_ORBITS; ++i)
{
if(isOrbitEmbedded(i))
......@@ -641,4 +647,44 @@ void GenericMap::viewAttributesTables()
}
void GenericMap::boundaryMark(Dart d)
{
m_markTables[DART][0]->operator[](d.index).setMark(m_boundaryMarker);
}
void GenericMap::boundaryUnmark(Dart d)
{
m_markTables[DART][0]->operator[](d.index).unsetMark(m_boundaryMarker);
}
bool GenericMap::isBoundaryMarked(Dart d)
{
return m_markTables[DART][0]->operator[](d.index).testMark(m_boundaryMarker);
}
void GenericMap::boundaryMarkOrbit(unsigned int orbit, Dart d)
{
FunctorMark<GenericMap> fm(*this, m_boundaryMarker, m_markTables[DART][0]) ;
foreach_dart_of_orbit(orbit, d, fm, 0) ;
}
void GenericMap::boundaryUnmarkOrbit(unsigned int orbit, Dart d)
{
FunctorUnmark<GenericMap> fm(*this, m_boundaryMarker, m_markTables[DART][0]) ;
foreach_dart_of_orbit(orbit, d, fm, 0) ;
}
void GenericMap::boundaryUnmarkAll()
{
AttributeContainer& cont = getAttributeContainer(DART) ;
for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i))
m_markTables[DART][0]->operator[](i).unsetMark(m_boundaryMarker);
}
} // namespace CGoGN
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