Commit 8750e5fd authored by Sylvain Thery's avatar Sylvain Thery

Merge branch 'master' of cgogn:~sauvage/CGoGN

parents 6afbce7f 4b7fbbef
......@@ -17,22 +17,21 @@ namespace Geometry
template <typename PFP>
class VoronoiDiagram {
private :
protected :
typedef typename PFP::REAL REAL;
typedef typename PFP::VEC3 VEC3;
typedef struct
{
typename std::multimap<float,Dart>::iterator it ;
bool valid ;
unsigned int region;
// unsigned int region;
Dart pathOrigin;
static std::string CGoGNnameOfType() { return "VoronoiVertexInfo" ; }
} VoronoiVertexInfo ;
typedef NoMathIOAttribute<VoronoiVertexInfo> VertexInfo ;
typename PFP::MAP& map;
const EdgeAttribute<REAL>& edgeCost; // weights on the graph edges
// const VertexAttribute<VEC3>& position; // positions
VertexAttribute<unsigned int>& regions; // region labels
std::vector<Dart> border;
std::vector<Dart> seeds;
......@@ -46,18 +45,67 @@ public :
~VoronoiDiagram ();
const std::vector<Dart>& getSeeds (){return seeds;}
void setSeeds (const std::vector<Dart>&);
void setRandomSeeds (unsigned int nbseeds);
virtual void setSeeds (const std::vector<Dart>&);
virtual void setRandomSeeds (unsigned int nbseeds);
const std::vector<Dart>& getBorder (){return border;}
void setCost (const EdgeAttribute<REAL>& c);
void computeDiagram ();
void computeDistancesWithinRegion (Dart seed);
private :
void clear ();
protected :
virtual void clear ();
void initFrontWithSeeds();
virtual void collectVertexFromFront(Dart e);
void addVertexToFront(Dart f, float d);
void updateVertexInFront(Dart f, float d);
};
template <typename PFP>
class CentroidalVoronoiDiagram : public VoronoiDiagram<PFP> {
private :
typedef typename PFP::REAL REAL;
typedef typename PFP::VEC3 VEC3;
double globalEnergy;
std::vector<VEC3> energyGrad; // gradient of the region energy at seed
VertexAttribute<REAL>& distances; // distances from the seed
VertexAttribute<Dart>& pathOrigins; // previous vertex on the shortest path from origin
VertexAttribute<REAL>& areaElts; // area element attached to each vertex
public :
CentroidalVoronoiDiagram (typename PFP::MAP& m,
const EdgeAttribute<REAL>& c,
VertexAttribute<unsigned int>& r,
VertexAttribute<REAL>& d,
VertexAttribute<Dart>& o,
VertexAttribute<REAL>& a);
~CentroidalVoronoiDiagram ();
void setSeeds (const std::vector<Dart>&);
void setRandomSeeds (unsigned int nbseeds);
void cumulateEnergy();
void cumulateEnergyAndGradients();
unsigned int moveSeedsOneEdgeNoCheck(); // returns the number of seeds that did move
// move each seed along one edge according to the energy gradient
unsigned int moveSeedsOneEdgeCheck(); // returns the number of seeds that did move
// move each seed along one edge according to the energy gradient + check that the energy decreases
unsigned int moveSeedsToMedioid(); // returns the number of seeds that did move
// move each seed to the medioid of its region
REAL getGlobalEnergy() {return globalEnergy;}
protected :
void clear();
void collectVertexFromFront(Dart e);
REAL cumulateEnergyFromRoot(Dart e);
void cumulateEnergyAndGradientFromSeed(unsigned int numSeed);
Dart selectBestNeighborFromSeed(unsigned int numSeed);
// unsigned int moveSeed(unsigned int numSeed);
};
}// end namespace Geometry
}// end namespace Algo
}// end namespace CGoGN
......
This diff is collapsed.
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