Commit fd814d57 authored by Basile Sauvage's avatar Basile Sauvage

ajout de Collector_Triangles

parent e4da4b21
......@@ -201,7 +201,7 @@ public:
};
/*********************************************************
* Collector Vertices
* Collector Criterions
*********************************************************/
class CollectorCriterion
{
......@@ -212,31 +212,6 @@ public :
};
/*
* collect all vertices of the connected component containing "centerDart"
* within a distance to centerDart defined by the CollectorCriterion
* (hopefully) it defines a 2-manifold (if inserting border-vertices along the border-edges)
*/
template <typename PFP>
class Collector_Vertices : public Collector<PFP>
{
protected:
CollectorCriterion & crit;
public:
Collector_Vertices(typename PFP::MAP& m, CollectorCriterion& c, unsigned int thread=0) :
Collector<PFP>(m, thread),
crit(c)
{}
void collectAll(Dart d);
void collectBorder(Dart d);
};
/*********************************************************
* Collector Criterions
*********************************************************/
template <typename PFP>
class CollectorCriterion_VertexNormalAngle : public CollectorCriterion
{ // tests if the angle between vertex normals is below some threshold
......@@ -257,6 +232,26 @@ public :
}
};
template <typename PFP>
class CollectorCriterion_TriangleNormalAngle : public CollectorCriterion
{ // tests if the angle between vertex normals is below some threshold
private :
typedef typename PFP::VEC3 VEC3;
typedef typename PFP::REAL REAL;
const FaceAttribute<VEC3> & faceNormals;
REAL threshold;
VEC3 centerNormal;
public :
CollectorCriterion_TriangleNormalAngle(const FaceAttribute<VEC3> & n, REAL th) :
faceNormals(n), threshold(th), centerNormal(0) {}
void init (Dart center) {centerNormal = faceNormals[center];}
bool isInside (Dart d) {
return ( Geom::angle(centerNormal, faceNormals[d]) < threshold);
}
};
template <typename PFP>
class CollectorCriterion_VertexWithinSphere : public CollectorCriterion
{ // tests if the distance between vertices is below some threshold
......@@ -278,6 +273,32 @@ public :
};
/*********************************************************
* Collector Vertices
*********************************************************/
/*
* collect all vertices of the connected component containing "centerDart"
* within a distance to centerDart defined by the CollectorCriterion
* (hopefully) it defines a 2-manifold (if inserting border-vertices along the border-edges)
*/
template <typename PFP>
class Collector_Vertices : public Collector<PFP>
{
protected:
CollectorCriterion & crit;
public:
Collector_Vertices(typename PFP::MAP& m, CollectorCriterion& c, unsigned int thread=0) :
Collector<PFP>(m, thread),
crit(c)
{}
void collectAll(Dart d);
void collectBorder(Dart d);
};
/*********************************************************
* Collector Normal Angle (Triangles)
*********************************************************/
......@@ -286,6 +307,7 @@ public :
* collect all primitives of the connected component containing "centerDart"
* the angle between the included triangles normal vectors and the central normal vector
* stays under a given threshold
* NB : is equivalent to Collector_Triangles with CollectorCriterion_TriangleNormalAngle
*/
template <typename PFP>
class Collector_NormalAngle_Triangles : public Collector<PFP>
......@@ -310,6 +332,30 @@ public:
void collectBorder(Dart d) ;
};
/*********************************************************
* Collector Triangles
*********************************************************/
/*
* collect all triangles of the connected component containing "centerDart"
* within a distance to centerDart defined by the CollectorCriterion
*/
template <typename PFP>
class Collector_Triangles : public Collector<PFP>
{
protected:
CollectorCriterion & crit;
public:
Collector_Triangles(typename PFP::MAP& m, CollectorCriterion& c, unsigned int thread=0) :
Collector<PFP>(m,thread), crit(c)
{}
void collectAll(Dart d) ;
void collectBorder(Dart d) ;
};
/*********************************************************
* Collector Dijkstra
*********************************************************/
......
......@@ -668,6 +668,144 @@ void Collector_NormalAngle_Triangles<PFP>::collectBorder(Dart d)
this->insideFaces.clear();
}
/*********************************************************
* Collector Triangles
*********************************************************/
template <typename PFP>
void Collector_Triangles<PFP>::collectAll(Dart d)
{
typedef typename PFP::VEC3 VEC3;
typedef typename PFP::REAL REAL;
crit.init(d);
this->init(d);
this->insideVertices.reserve(32);
this->insideEdges.reserve(32);
this->insideFaces.reserve(32);
this->border.reserve(32);
CellMarkerStore<FACE> fm(this->map, this->m_thread); // mark the collected inside-faces + front-faces
CellMarkerStore<FACE> fminside(this->map, this->m_thread); // mark the collected inside-faces
std::queue<Dart> front;
front.push(this->centerDart);
fm.mark(this->centerDart);
while ( !front.empty() ) // collect inside faces
{
Dart f = front.front();
front.pop();
if (crit.isInside(f))
{ // collect this face and add adjacent faces to the front
this->insideFaces.push_back(f);
fminside.mark(f);
Traversor2FFaE<typename PFP::MAP> t (this->map, f) ;
for (Dart it = t.begin(); it != t.end(); it=t.next())
{
if (!fm.isMarked(it))
{
front.push(it);
fm.mark(it);
}
}
}
}
CellMarkerStore<VERTEX> vm(this->map, this->m_thread); // mark inside-vertices and border-vertices
CellMarkerStore<EDGE> em(this->map, this->m_thread); // mark inside-edges and border-edges
std::vector<Dart>::iterator f_it;
for (f_it = this->insideFaces.begin(); f_it != this->insideFaces.end(); f_it++)
{ // collect insideVertices, insideEdges, and border
Traversor2FE<typename PFP::MAP> te (this->map, *f_it) ;
for (Dart it = te.begin(); it != te.end(); it=te.next())
{ // collect insideEdges and border
if (!em.isMarked(it))
{
em.mark(it);
if (this->map.isBoundaryEdge(it))
this->border.push_back(it);
else if ( fminside.isMarked(it) && fminside.isMarked(this->map.phi2(it)) )
this->insideEdges.push_back(it);
else
this->border.push_back(it);
}
}
Traversor2FV<typename PFP::MAP> tv (this->map, *f_it) ;
for (Dart it = tv.begin(); it != tv.end(); it=tv.next())
{ // collect insideVertices
if (!vm.isMarked(it))
{
vm.mark(it);
this->insideVertices.push_back(it);
}
}
}
}
template <typename PFP>
void Collector_Triangles<PFP>::collectBorder(Dart d)
{
typedef typename PFP::VEC3 VEC3;
typedef typename PFP::REAL REAL;
crit.init(d);
this->init(d);
this->insideFaces.reserve(32);
this->border.reserve(32);
CellMarkerStore<FACE> fm(this->map, this->m_thread); // mark the collected inside-faces + front-faces
CellMarkerStore<FACE> fminside(this->map, this->m_thread); // mark the collected inside-faces
std::queue<Dart> front;
front.push(this->centerDart);
fm.mark(this->centerDart);
while ( !front.empty() ) // collect inside faces
{
Dart f = front.front();
front.pop();
if (crit.isInside(f) )
{ // collect this face and add adjacent faces to the front
this->insideFaces.push_back(f);
fminside.mark(f);
Traversor2FFaE<typename PFP::MAP> t (this->map, f) ;
for (Dart it = t.begin(); it != t.end(); it=t.next())
{
if (!fm.isMarked(it))
{
front.push(it);
fm.mark(it);
}
}
}
}
CellMarkerStore<EDGE> em(this->map, this->m_thread); // mark inside-edges and border-edges
std::vector<Dart>::iterator f_it;
for (f_it = this->insideFaces.begin(); f_it != this->insideFaces.end(); f_it++)
{ // collect border (edges)
Traversor2FE<typename PFP::MAP> te (this->map, *f_it) ;
for (Dart it = te.begin(); it != te.end(); it=te.next())
{
if (!em.isMarked(it))
{
em.mark(it);
if (this->map.isBoundaryEdge(it))
this->border.push_back(it);
else if ( !fminside.isMarked(it) || !fminside.isMarked(this->map.phi2(it)) )
this->border.push_back(it);
}
}
}
this->insideFaces.clear();
}
/*********************************************************
* Collector Dijkstra
*********************************************************/
......
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