libmove3d  3.13.0
/home/slemaign/softs-local/BioMove3D-git/graspPlanning/include/gpConvexHull.h
00001 #ifndef GP_CONVEXHULL3D_H
00002 #define GP_CONVEXHULL3D_H
00003 
00004 
00009 
00010 class gpConvexHull;
00011 
00012 
00015 class gpRidge
00016 {
00017   friend class gpConvexHull;
00018 
00019   private:
00020    unsigned int dimension_; 
00021    std::vector<unsigned int> vertices_; 
00022    unsigned int id_; 
00023    bool toporient_; 
00024    int setDimension(unsigned int dimension);
00025    int resize(unsigned int size);
00026   public:
00027    gpRidge();
00028    ~gpRidge();
00029    gpRidge(unsigned int dimension, unsigned int vertex_number);
00030    unsigned int operator [] (const unsigned int i) const;
00031    unsigned int& operator [] (const unsigned int i);
00032    unsigned int nbVertices() { return vertices_.size(); }
00033    unsigned int id() { return id_; }
00034    unsigned int toporient() { return toporient_; }
00035 };
00036 
00037 
00040 class gpFace
00041 {
00042   friend class gpConvexHull;
00043 
00044   private:
00045    unsigned int dimension_; 
00046    std::vector<unsigned int> vertices_; 
00047    unsigned int id_; 
00048 
00049    double offset_; 
00050    std::vector<double> normal_; 
00051 
00052    std::vector<double> center_; 
00053    std::vector<gpRidge> ridges_;
00054 
00055    int setDimension(unsigned int dimension);
00056    int resize(unsigned int size);
00057    int resizeRidgeNumber(unsigned int size);
00058   public:
00059    gpFace();
00060    ~gpFace();
00061    gpFace(unsigned int dimension, unsigned int vertex_number);
00062    unsigned int operator [] (const unsigned int i) const;
00063    unsigned int& operator [] (const unsigned int i);
00064    unsigned int nbVertices() { return vertices_.size(); }
00065    unsigned int nbRidges() { return ridges_.size(); }
00066    std::vector<double> normal() { return normal_; }
00067    std::vector<double> center() { return center_; }
00068    unsigned int id() { return id_; }
00069    double offset() { return offset_; }
00070    std::vector<unsigned int> vertices() { return vertices_; }
00071    int print();
00072    int reverseVertexOrder();
00073    int orderFromRidges();
00074 };
00075 
00076 
00079 class gpVoronoiRidge
00080 {
00081   friend class gpConvexHull;
00082   friend class gpConvexHull2D;
00083   friend class gpConvexHull3D;
00084 
00085   private:
00089    unsigned int site1_id_, site2_id_; 
00090 
00092    std::vector<unsigned int> vertices_;
00093 
00094    std::vector<double> center_;  
00095    std::vector<double> normal_;  
00096 };
00097 
00098 
00101 class gpVoronoiCell
00102 {
00103   friend class gpConvexHull;
00104   friend class gpConvexHull2D;
00105   friend class gpConvexHull3D;
00106 
00107   private:
00109    unsigned int site_id_;
00110 
00112    std::vector< unsigned int > ridges_;
00113 
00114    std::vector<bool> ccw_; 
00115 };
00116 
00122 class gpConvexHull
00123 {
00124   protected:
00125    unsigned int dimension_; 
00126 
00129    bool up_to_date_;
00130 
00131    std::vector< std::vector<double> > points_;  
00133 
00134 
00135    double largest_ball_radius_;
00136 
00137    int reset();
00138 
00139   public:
00140    std::vector<unsigned int> hull_vertices; 
00142 
00143    std::vector<gpFace> hull_faces;
00144 
00146    std::vector< std::vector< double > > voronoi_vertices_;
00147    std::vector<gpVoronoiRidge> voronoi_ridges_;
00148    std::vector<gpVoronoiCell> voronoi_cells_;
00149 
00150    gpConvexHull();
00151    gpConvexHull(const std::vector< std::vector<double> > &points);
00152    virtual ~gpConvexHull();
00153    int setPoints(const std::vector< std::vector<double> > &points);
00154    unsigned int nbVertices() {  return hull_vertices.size(); }
00155    unsigned int nbFaces()    {  return hull_faces.size(); }
00156    int pointCoordinates(unsigned int i, std::vector<double> &coord);
00157 
00158    int compute(bool simplicial_facets, double postMergingCentrumRadius, bool verbose= true);
00159    virtual int voronoi(bool verbose= true);
00160    int draw();
00161    int drawFace(unsigned int face_index);
00162    int print();
00163    double largest_ball_radius();
00164    int isPointInside(std::vector<double> point, bool &inside, double &distance);
00165 };
00166 
00167 
00171 class gpConvexHull3D: public gpConvexHull
00172 {
00173   public:
00174    gpConvexHull3D();
00175    gpConvexHull3D(p3d_vector3 *point_array, unsigned int nbpoints);
00176    int setPoints(p3d_vector3 *point_array, unsigned int nbpoints);
00177    int voronoi(bool verbose= true);
00178    int draw(bool wireframe= false);
00179    int drawFace(unsigned int face_index);
00180 };
00181 
00182 
00186 class gpConvexHull6D: public gpConvexHull
00187 {
00188   public:
00189    gpConvexHull6D(double (*point_array)[6], unsigned int nbpoints_);
00190 };
00191 
00192 int gpSample_polyhedron_convex_hull(struct p3d_polyhedre *polyhedron, double step, std::vector<gpVector3D> &samples);
00193 
00194 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines