Commit d0555531 authored by Sylvain Thery's avatar Sylvain Thery

Made Collector thread safe

parent 9c4f8a7c
...@@ -53,6 +53,7 @@ protected: ...@@ -53,6 +53,7 @@ protected:
typedef typename PFP::REAL REAL; typedef typename PFP::REAL REAL;
typename PFP::MAP& map; typename PFP::MAP& map;
unsigned int m_thread;
Dart centerDart; Dart centerDart;
...@@ -62,7 +63,7 @@ protected: ...@@ -62,7 +63,7 @@ protected:
std::vector<Dart> border; std::vector<Dart> border;
public: public:
Collector(typename PFP::MAP& m); Collector(typename PFP::MAP& m, unsigned int thread =0);
inline void init(Dart d) inline void init(Dart d)
{ {
...@@ -122,9 +123,8 @@ template <typename PFP> ...@@ -122,9 +123,8 @@ template <typename PFP>
class Collector_OneRing : public Collector<PFP> class Collector_OneRing : public Collector<PFP>
{ {
public: public:
Collector_OneRing(typename PFP::MAP& m) : Collector_OneRing(typename PFP::MAP& m, unsigned int thread=0):
Collector<PFP>(m) Collector<PFP>(m, thread) {}
{}
void collectAll(Dart d); void collectAll(Dart d);
void collectBorder(Dart d); void collectBorder(Dart d);
}; };
...@@ -145,11 +145,10 @@ protected: ...@@ -145,11 +145,10 @@ protected:
const VertexAttribute<typename PFP::VEC3>& position; const VertexAttribute<typename PFP::VEC3>& position;
typename PFP::REAL radius; typename PFP::REAL radius;
typename PFP::REAL area; typename PFP::REAL area;
unsigned int m_thread;
public: public:
Collector_WithinSphere(typename PFP::MAP& m, const VertexAttribute<typename PFP::VEC3>& p, typename PFP::REAL r = 0, unsigned int thread=0) : Collector_WithinSphere(typename PFP::MAP& m, const VertexAttribute<typename PFP::VEC3>& p, typename PFP::REAL r = 0, unsigned int thread=0) :
Collector<PFP>(m), Collector<PFP>(m, thread),
position(p), position(p),
radius(r), radius(r),
area(0), area(0),
...@@ -188,8 +187,9 @@ public: ...@@ -188,8 +187,9 @@ public:
typename PFP::MAP& m, typename PFP::MAP& m,
const VertexAttribute<typename PFP::VEC3>& p, const VertexAttribute<typename PFP::VEC3>& p,
const VertexAttribute<typename PFP::VEC3>& n, const VertexAttribute<typename PFP::VEC3>& n,
typename PFP::REAL a typename PFP::REAL a,
) : Collector<PFP>(m), position(p), normal(n), angleThreshold(a) unsigned int thread=0
) : Collector<PFP>(m,thread), position(p), normal(n), angleThreshold(a)
{} {}
inline void setAngleThreshold(typename PFP::REAL a) { angleThreshold = a; } inline void setAngleThreshold(typename PFP::REAL a) { angleThreshold = a; }
inline typename PFP::REAL getAngleThreshold() const { return angleThreshold; } inline typename PFP::REAL getAngleThreshold() const { return angleThreshold; }
......
...@@ -39,7 +39,7 @@ namespace Selection ...@@ -39,7 +39,7 @@ namespace Selection
*********************************************************/ *********************************************************/
template <typename PFP> template <typename PFP>
Collector<PFP>::Collector(typename PFP::MAP& m) : map(m) Collector<PFP>::Collector(typename PFP::MAP& m, unsigned int thread) : map(m), m_thread(thread)
{} {}
template <typename PFP> template <typename PFP>
...@@ -295,9 +295,9 @@ void Collector_NormalAngle<PFP>::collectAll(Dart d) ...@@ -295,9 +295,9 @@ void Collector_NormalAngle<PFP>::collectAll(Dart d)
this->insideFaces.reserve(32); this->insideFaces.reserve(32);
this->border.reserve(32); this->border.reserve(32);
CellMarkerStore<VERTEX> vm(this->map); // mark the collected inside-vertices CellMarkerStore<VERTEX> vm(this->map, m_thread); // mark the collected inside-vertices
CellMarkerStore<EDGE> em(this->map); // mark the collected inside-edges + border-edges CellMarkerStore<EDGE> em(this->map, m_thread); // mark the collected inside-edges + border-edges
CellMarkerStore<FACE> fm(this->map); // mark the collected inside-faces + border-faces CellMarkerStore<FACE> fm(this->map, m_thread); // mark the collected inside-faces + border-faces
this->insideVertices.push_back(this->centerDart); this->insideVertices.push_back(this->centerDart);
vm.mark(this->centerDart); vm.mark(this->centerDart);
...@@ -360,8 +360,8 @@ void Collector_NormalAngle<PFP>::collectBorder(Dart d) ...@@ -360,8 +360,8 @@ void Collector_NormalAngle<PFP>::collectBorder(Dart d)
this->border.reserve(128); this->border.reserve(128);
this->insideVertices.reserve(128); this->insideVertices.reserve(128);
CellMarkerStore<VERTEX> vm(this->map); // mark the collected inside-vertices CellMarkerStore<VERTEX> vm(this->map, m_thread); // mark the collected inside-vertices
CellMarkerStore<EDGE> em(this->map); // mark the collected inside-edges + border-edges CellMarkerStore<EDGE> em(this->map, m_thread); // mark the collected inside-edges + border-edges
this->insideVertices.push_back(this->centerDart); this->insideVertices.push_back(this->centerDart);
vm.mark(this->centerDart); vm.mark(this->centerDart);
......
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