Commit c416716f authored by Basile Sauvage's avatar Basile Sauvage

modif mineure organisation du code

parent fd814d57
......@@ -355,20 +355,21 @@ public:
void collectBorder(Dart d) ;
};
/*********************************************************
* Collector Dijkstra
* Collector Dijkstra_Vertices
*********************************************************/
/*
* collect all primitives of the connected component containing "centerDart"
* within a distance < maxDist (the shortest path follows edges)
* the edge length is specified in edge_cost attribute
*/
template <typename PFP>
class Collector_Dijkstra : public Collector<PFP>
class Collector_Dijkstra_Vertices : public Collector<PFP>
{
protected:
const VertexAttribute<typename PFP::VEC3>& position;
const EdgeAttribute<typename PFP::REAL>& edge_cost;
typename PFP::REAL maxDist;
typedef struct
......@@ -384,44 +385,38 @@ protected:
std::multimap<float,Dart> front ;
public:
Collector_Dijkstra(typename PFP::MAP& m, const VertexAttribute<typename PFP::VEC3>& p, typename PFP::REAL d = 0, unsigned int thread=0) :
Collector_Dijkstra_Vertices(typename PFP::MAP& m, const EdgeAttribute<typename PFP::REAL>& c, typename PFP::REAL d = 0, unsigned int thread=0) :
Collector<PFP>(m,thread),
position(p),
edge_cost(c),
maxDist(d)
{
vertexInfo = m.template addAttribute<VertexInfo, VERTEX>("vertexInfo");
}
~Collector_Dijkstra(){
~Collector_Dijkstra_Vertices(){
this->map.removeAttribute(vertexInfo);
}
inline void init (Dart d) {Collector<PFP>::init(d); front.clear();}
inline void setMaxDistance(typename PFP::REAL d) { maxDist = d; }
inline typename PFP::REAL getMaxDist() const { return maxDist; }
inline const VertexAttribute<typename PFP::VEC3>& getPosition() const { return position; }
void collectAll(Dart d);
void collectBorder(Dart d);
private :
inline float edgeLength (Dart d);
// inline Dart oppositeVertex (Dart d);
};
/*********************************************************
* Collector Dijkstra_Vertices
* Collector Dijkstra
*********************************************************/
/*
* collect all primitives of the connected component containing "centerDart"
* within a distance < maxDist (the shortest path follows edges)
* the edge length is specified in edge_cost attribute
*/
template <typename PFP>
class Collector_Dijkstra_Vertices : public Collector<PFP>
class Collector_Dijkstra : public Collector<PFP>
{
protected:
const EdgeAttribute<typename PFP::REAL>& edge_cost;
const VertexAttribute<typename PFP::VEC3>& position;
typename PFP::REAL maxDist;
typedef struct
......@@ -437,28 +432,30 @@ protected:
std::multimap<float,Dart> front ;
public:
Collector_Dijkstra_Vertices(typename PFP::MAP& m, const EdgeAttribute<typename PFP::REAL>& c, typename PFP::REAL d = 0, unsigned int thread=0) :
Collector_Dijkstra(typename PFP::MAP& m, const VertexAttribute<typename PFP::VEC3>& p, typename PFP::REAL d = 0, unsigned int thread=0) :
Collector<PFP>(m,thread),
edge_cost(c),
position(p),
maxDist(d)
{
vertexInfo = m.template addAttribute<VertexInfo, VERTEX>("vertexInfo");
}
~Collector_Dijkstra_Vertices(){
~Collector_Dijkstra(){
this->map.removeAttribute(vertexInfo);
}
inline void init (Dart d) {Collector<PFP>::init(d); front.clear();}
inline void setMaxDistance(typename PFP::REAL d) { maxDist = d; }
inline typename PFP::REAL getMaxDist() const { return maxDist; }
// inline const VertexAttribute<typename PFP::VEC3>& getPosition() const { return position; }
inline const VertexAttribute<typename PFP::VEC3>& getPosition() const { return position; }
void collectAll(Dart d);
void collectBorder(Dart d);
//private :
// inline float edgeLength (Dart d);
private :
inline float edgeLength (Dart d);
// inline Dart oppositeVertex (Dart d);
};
} // namespace Selection
} // namespace Algo
......
......@@ -805,13 +805,12 @@ void Collector_Triangles<PFP>::collectBorder(Dart d)
this->insideFaces.clear();
}
/*********************************************************
* Collector Dijkstra
* Collector Dijkstra_Vertices
*********************************************************/
template <typename PFP>
void Collector_Dijkstra<PFP>::collectAll(Dart dinit)
void Collector_Dijkstra_Vertices<PFP>::collectAll(Dart dinit)
{
init(dinit);
......@@ -836,7 +835,7 @@ void Collector_Dijkstra<PFP>::collectAll(Dart dinit)
{
if (vi.valid) // probably useless (because of distance test) but faster
{
float dist = d + edgeLength(f);
float dist = d + edge_cost[f];
if (dist < vi.it->first)
{
front.erase(vi.it);
......@@ -846,7 +845,7 @@ void Collector_Dijkstra<PFP>::collectAll(Dart dinit)
}
else
{
vi.it = front.insert(std::pair<float,Dart>(d + edgeLength(f), f));
vi.it = front.insert(std::pair<float,Dart>(d + edge_cost[f], f));
vi.valid=true;
vmReached.mark(f);
}
......@@ -897,7 +896,7 @@ void Collector_Dijkstra<PFP>::collectAll(Dart dinit)
}
template <typename PFP>
void Collector_Dijkstra<PFP>::collectBorder(Dart dinit)
void Collector_Dijkstra_Vertices<PFP>::collectBorder(Dart dinit)
{
init(dinit);
......@@ -922,7 +921,7 @@ void Collector_Dijkstra<PFP>::collectBorder(Dart dinit)
{
if (vi.valid) // probably useless (because of distance test) but faster
{
float dist = d + edgeLength(f);
float dist = d + edge_cost[f];
if (dist < vi.it->first)
{
front.erase(vi.it);
......@@ -932,7 +931,7 @@ void Collector_Dijkstra<PFP>::collectBorder(Dart dinit)
}
else
{
vi.it = front.insert(std::pair<float,Dart>(d + edgeLength(f), f));
vi.it = front.insert(std::pair<float,Dart>(d + edge_cost[f], f));
vi.valid=true;
vmReached.mark(f);
}
......@@ -969,19 +968,13 @@ void Collector_Dijkstra<PFP>::collectBorder(Dart dinit)
this->insideVertices.clear();
}
template <typename PFP>
inline float Collector_Dijkstra<PFP>::edgeLength (Dart d)
{
typename PFP::VEC3 v = Algo::Geometry::vectorOutOfDart<PFP>(this->map, d, this->position);
return v.norm();
}
/*********************************************************
* Collector Dijkstra_Vertices
* Collector Dijkstra
*********************************************************/
template <typename PFP>
void Collector_Dijkstra_Vertices<PFP>::collectAll(Dart dinit)
void Collector_Dijkstra<PFP>::collectAll(Dart dinit)
{
init(dinit);
......@@ -1006,7 +999,7 @@ void Collector_Dijkstra_Vertices<PFP>::collectAll(Dart dinit)
{
if (vi.valid) // probably useless (because of distance test) but faster
{
float dist = d + edge_cost[f];
float dist = d + edgeLength(f);
if (dist < vi.it->first)
{
front.erase(vi.it);
......@@ -1016,7 +1009,7 @@ void Collector_Dijkstra_Vertices<PFP>::collectAll(Dart dinit)
}
else
{
vi.it = front.insert(std::pair<float,Dart>(d + edge_cost[f], f));
vi.it = front.insert(std::pair<float,Dart>(d + edgeLength(f), f));
vi.valid=true;
vmReached.mark(f);
}
......@@ -1067,7 +1060,7 @@ void Collector_Dijkstra_Vertices<PFP>::collectAll(Dart dinit)
}
template <typename PFP>
void Collector_Dijkstra_Vertices<PFP>::collectBorder(Dart dinit)
void Collector_Dijkstra<PFP>::collectBorder(Dart dinit)
{
init(dinit);
......@@ -1092,7 +1085,7 @@ void Collector_Dijkstra_Vertices<PFP>::collectBorder(Dart dinit)
{
if (vi.valid) // probably useless (because of distance test) but faster
{
float dist = d + edge_cost[f];
float dist = d + edgeLength(f);
if (dist < vi.it->first)
{
front.erase(vi.it);
......@@ -1102,7 +1095,7 @@ void Collector_Dijkstra_Vertices<PFP>::collectBorder(Dart dinit)
}
else
{
vi.it = front.insert(std::pair<float,Dart>(d + edge_cost[f], f));
vi.it = front.insert(std::pair<float,Dart>(d + edgeLength(f), f));
vi.valid=true;
vmReached.mark(f);
}
......@@ -1139,6 +1132,14 @@ void Collector_Dijkstra_Vertices<PFP>::collectBorder(Dart dinit)
this->insideVertices.clear();
}
template <typename PFP>
inline float Collector_Dijkstra<PFP>::edgeLength (Dart d)
{
typename PFP::VEC3 v = Algo::Geometry::vectorOutOfDart<PFP>(this->map, d, this->position);
return v.norm();
}
} // namespace Selection
} // namespace Algo
......
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