Commit fda249b0 authored by Basile Sauvage's avatar Basile Sauvage

correction du collector_Dijkstra

parent 299e096a
......@@ -273,6 +273,7 @@ public:
void collectBorder(Dart d);
private :
inline float edgeLength (Dart d);
// inline Dart oppositeVertex (Dart d);
};
......
......@@ -476,15 +476,16 @@ void Collector_NormalAngle_Triangles<PFP>::collectAll(Dart d)
if (!vm.isMarked(it))
{
vm.mark(it);
if ( !this->map.isBoundaryVertex(it))
{
Traversor2VF<typename PFP::MAP> tf (this->map, it);
Dart it2 = tf.begin();
while ( (it2 != tf.end()) && fminside.isMarked(it2))
it2=tf.next();
if (it2 == tf.end())
this->insideVertices.push_back(it);
}
this->insideVertices.push_back(it);
// if ( !this->map.isBoundaryVertex(it))
// {
// Traversor2VF<typename PFP::MAP> tf (this->map, it);
// Dart it2 = tf.begin();
// while ( (it2 != tf.end()) && fminside.isMarked(it2))
// it2=tf.next();
// if (it2 == tf.end())
// this->insideVertices.push_back(it);
// }
}
}
}
......@@ -579,7 +580,7 @@ void Collector_Dijkstra<PFP>::collectAll(Dart dinit){
VertexInfo& vi (vertexInfo[f]);
if (vmReached.isMarked(f))
{
if (vi.valid) // probably useless but faster
if (vi.valid) // probably useless (because of distance test) but faster
{
float dist = d + edgeLength(f);
if (dist < vi.it->first)
......@@ -600,11 +601,117 @@ void Collector_Dijkstra<PFP>::collectAll(Dart dinit){
}
while ( !front.empty())
{
vmReached.unmark(front.begin()->second);
front.erase(front.begin());
}
CellMarkerStore<EDGE> em (this->map);
CellMarkerStore<FACE> fm (this->map);
for (std::vector<Dart>::iterator e_it = this->insideVertices.begin(); e_it != this->insideVertices.end() ; e_it++)
{
// collect insideEdges
Traversor2VE<typename PFP::MAP> te (this->map, *e_it);
for (Dart e = te.begin(); e != te.end(); e=te.next())
{
if ( !em.isMarked(e) && vmReached.isMarked(this->map.phi2(e)) )
{ // opposite vertex is inside -> inside edge
this->insideEdges.push_back(e);
em.mark(e);
}
}
// collect insideFaces and border
Traversor2VF<typename PFP::MAP> tf (this->map, *e_it);
for (Dart f = tf.begin(); f != tf.end(); f=tf.next())
{
if ( !fm.isMarked(f) )
{
fm.mark(f);
Traversor2FV<typename PFP::MAP> tv (this->map, f);
Dart v = tv.begin();
while ( v != tv.end() && vmReached.isMarked(v) ) {v=tv.next();}
if ( v == tv.end() )
this->insideFaces.push_back(f);
else
this->border.push_back(f);
}
}
}
}
template <typename PFP>
void Collector_Dijkstra<PFP>::collectBorder(Dart d){
void Collector_Dijkstra<PFP>::collectBorder(Dart dinit){
init(dinit);
CellMarkerStore<VERTEX> vmReached (this->map);
vertexInfo[this->centerDart].it = front.insert(std::pair<float,Dart>(0.0, this->centerDart));
vertexInfo[this->centerDart].valid = true;
vmReached.mark(this->centerDart);
while ( !front.empty() && front.begin()->first < this->maxDist)
{
Dart e = front.begin()->second;
float d = front.begin()->first;
front.erase(vertexInfo[e].it);
vertexInfo[e].valid=false;
this->insideVertices.push_back(e);
Traversor2VVaE<typename PFP::MAP> tv (this->map, e);
for (Dart f = tv.begin(); f != tv.end(); f=tv.next())
{
VertexInfo& vi (vertexInfo[f]);
if (vmReached.isMarked(f))
{
if (vi.valid) // probably useless (because of distance test) but faster
{
float dist = d + edgeLength(f);
if (dist < vi.it->first)
{
front.erase(vi.it);
vi.it = front.insert(std::pair<float,Dart>(dist, f));
}
}
}
else
{
vi.it = front.insert(std::pair<float,Dart>(d + edgeLength(f), f));
vi.valid=true;
vmReached.mark(f);
}
}
}
while ( !front.empty())
{
vmReached.unmark(front.begin()->second);
front.erase(front.begin());
}
CellMarkerStore<FACE> fm (this->map);
for (std::vector<Dart>::iterator e_it = this->insideVertices.begin(); e_it != this->insideVertices.end() ; e_it++)
{
// collect border
Traversor2VF<typename PFP::MAP> tf (this->map, *e_it);
for (Dart f = tf.begin(); f != tf.end(); f=tf.next())
{
if ( !fm.isMarked(f) )
{
fm.mark(f);
Traversor2FV<typename PFP::MAP> tv (this->map, f);
Dart v = tv.begin();
while ( v != tv.end() && vmReached.isMarked(v) ) {v=tv.next();}
if ( v != tv.end() )
this->border.push_back(f);
}
}
}
this->insideVertices.clear();
}
template <typename PFP>
......@@ -613,6 +720,10 @@ inline float Collector_Dijkstra<PFP>::edgeLength (Dart d){
return v.norm();
}
//template <typename PFP>
//inline Dart Collector_Dijkstra<PFP>::oppositeVertex(Dart d){
// return this->map.ph1(d);
//}
} // namespace Selection
......
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