Commit a3d64939 authored by Basile Sauvage's avatar Basile Sauvage

ajout des diag de Voronoi centroidaux (debut)

parent cbbaa4c7
......@@ -17,9 +17,8 @@ namespace Geometry
template <typename PFP>
class VoronoiDiagram {
private :
protected :
typedef typename PFP::REAL REAL;
typedef typename PFP::VEC3 VEC3;
typedef struct
{
......@@ -53,7 +52,7 @@ public :
void computeDiagram ();
private :
protected :
void clear ();
void initFrontWithSeeds();
void collectVertexFromFront(Dart e);
......@@ -61,6 +60,25 @@ private :
void updateVertexInFront(Dart f, float d);
};
template <typename PFP>
class CentroidalVoronoiDiagram : public VoronoiDiagram<PFP> {
private :
typedef typename PFP::REAL REAL;
VertexAttribute<REAL>& distances; // distances from the seed
VertexAttribute<Dart>& pathOrigins; // previous vertex on the shortest path from origin
public :
CentroidalVoronoiDiagram (typename PFP::MAP& m, const EdgeAttribute<REAL>& c, VertexAttribute<unsigned int>& r, VertexAttribute<REAL>& d, VertexAttribute<Dart>& o);
~CentroidalVoronoiDiagram ();
protected :
void clear();
void collectVertexFromFront(Dart e);
};
}// end namespace Geometry
}// end namespace Algo
}// end namespace CGoGN
......
......@@ -7,6 +7,10 @@ namespace Algo
namespace Geometry
{
/***********************************************************
* class VoronoiDiagram
***********************************************************/
template <typename PFP>
VoronoiDiagram<PFP>::VoronoiDiagram (typename PFP::MAP& m, const EdgeAttribute<REAL>& p, VertexAttribute<unsigned int>& r) : map(m), edgeCost (p), regions (r), vmReached(m)
{
......@@ -79,10 +83,10 @@ void VoronoiDiagram<PFP>::setCost (const EdgeAttribute<typename PFP::REAL>& c){
template <typename PFP>
void VoronoiDiagram<PFP>::collectVertexFromFront(Dart e){
front.erase(vertexInfo[e].it);
vertexInfo[e].valid=false;
// regions[e] = vertexInfo[e].region;
regions[e] = regions[vertexInfo[e].pathOrigin];
front.erase(vertexInfo[e].it);
vertexInfo[e].valid=false;
}
template <typename PFP>
......@@ -138,6 +142,37 @@ void VoronoiDiagram<PFP>::computeDiagram ()
}
}
/***********************************************************
* class CentroidalVoronoiDiagram
***********************************************************/
template <typename PFP>
CentroidalVoronoiDiagram<PFP>::CentroidalVoronoiDiagram (typename PFP::MAP& m, const EdgeAttribute<REAL>& c, VertexAttribute<unsigned int>& r, VertexAttribute<REAL>& d, VertexAttribute<Dart>& o) :
VoronoiDiagram<PFP>(m,c,r), distances(d), pathOrigins(o)
{
}
template <typename PFP>
CentroidalVoronoiDiagram<PFP>::~CentroidalVoronoiDiagram ()
{
}
template <typename PFP>
void CentroidalVoronoiDiagram<PFP>::clear ()
{
VoronoiDiagram<PFP>::clear();
distances.setAllValues(0.0);
}
template <typename PFP>
void CentroidalVoronoiDiagram<PFP>::collectVertexFromFront(Dart e){
distances[e] = this->vertexInfo[e].it->first();
pathOrigins[e] = this->vertexInfo[e].pathOrigin;
VoronoiDiagram<PFP>::collectVertexFromFront(e);
}
}// end namespace Geometry
}// end namespace Algo
}// end 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