#ifndef __VORONOI_DIAGRAMS_H__ #define __VORONOI_DIAGRAMS_H__ #include #include #include "Topology/generic/traversor2.h" namespace CGoGN { namespace Algo { namespace Geometry { template class VoronoiDiagram { protected : typedef typename PFP::REAL REAL; typedef struct { typename std::multimap::iterator it ; bool valid ; // unsigned int region; Dart pathOrigin; static std::string CGoGNnameOfType() { return "VoronoiVertexInfo" ; } } VoronoiVertexInfo ; typedef NoMathIOAttribute VertexInfo ; typename PFP::MAP& map; const EdgeAttribute& edgeCost; // weights on the graph edges VertexAttribute& regions; // region labels std::vector border; std::vector seeds; VertexAttribute vertexInfo; std::multimap front ; CellMarkerStore vmReached; public : VoronoiDiagram (typename PFP::MAP& m, const EdgeAttribute& c, VertexAttribute& r); ~VoronoiDiagram (); const std::vector& getSeeds (){return seeds;} void setSeeds (const std::vector&); void setRandomSeeds (unsigned int nbseeds); const std::vector& getBorder (){return border;} void setCost (const EdgeAttribute& c); void computeDiagram (); protected : void clear (); void initFrontWithSeeds(); void collectVertexFromFront(Dart e); void addVertexToFront(Dart f, float d); void updateVertexInFront(Dart f, float d); }; template class CentroidalVoronoiDiagram : public VoronoiDiagram { private : typedef typename PFP::REAL REAL; VertexAttribute& distances; // distances from the seed VertexAttribute& pathOrigins; // previous vertex on the shortest path from origin public : CentroidalVoronoiDiagram (typename PFP::MAP& m, const EdgeAttribute& c, VertexAttribute& r, VertexAttribute& d, VertexAttribute& o); ~CentroidalVoronoiDiagram (); protected : void clear(); void collectVertexFromFront(Dart e); }; }// end namespace Geometry }// end namespace Algo }// end namespace CGoGN #include "voronoiDiagrams.hpp" #endif