Home | History | Annotate | Download | only in src
      1 /*
      2  * Mesh.h
      3  *
      4  *  Created on: Apr 9, 2014
      5  *      Author: edgar
      6  */
      7 
      8 #ifndef MESH_H_
      9 #define MESH_H_
     10 
     11 #include <iostream>
     12 #include <opencv2/core/core.hpp>
     13 
     14 
     15 // --------------------------------------------------- //
     16 //                 TRIANGLE CLASS                      //
     17 // --------------------------------------------------- //
     18 
     19 class Triangle {
     20 public:
     21 
     22   explicit Triangle(int id, cv::Point3f V0, cv::Point3f V1, cv::Point3f V2);
     23   virtual ~Triangle();
     24 
     25   cv::Point3f getV0() const { return v0_; }
     26   cv::Point3f getV1() const { return v1_; }
     27   cv::Point3f getV2() const { return v2_; }
     28 
     29 private:
     30   /** The identifier number of the triangle */
     31   int id_;
     32   /** The three vertices that defines the triangle */
     33   cv::Point3f v0_, v1_, v2_;
     34 };
     35 
     36 
     37 // --------------------------------------------------- //
     38 //                     RAY CLASS                       //
     39 // --------------------------------------------------- //
     40 
     41 class Ray {
     42 public:
     43 
     44   explicit Ray(cv::Point3f P0, cv::Point3f P1);
     45   virtual ~Ray();
     46 
     47   cv::Point3f getP0() { return p0_; }
     48   cv::Point3f getP1() { return p1_; }
     49 
     50 private:
     51   /** The two points that defines the ray */
     52   cv::Point3f p0_, p1_;
     53 };
     54 
     55 
     56 // --------------------------------------------------- //
     57 //                OBJECT MESH CLASS                    //
     58 // --------------------------------------------------- //
     59 
     60 class Mesh
     61 {
     62 public:
     63 
     64   Mesh();
     65   virtual ~Mesh();
     66 
     67   std::vector<std::vector<int> > getTrianglesList() const { return list_triangles_; }
     68   cv::Point3f getVertex(int pos) const { return list_vertex_[pos]; }
     69   int getNumVertices() const { return num_vertexs_; }
     70 
     71   void load(const std::string path_file);
     72 
     73 private:
     74   /** The identification number of the mesh */
     75   int id_;
     76   /** The current number of vertices in the mesh */
     77   int num_vertexs_;
     78   /** The current number of triangles in the mesh */
     79   int num_triangles_;
     80   /* The list of triangles of the mesh */
     81   std::vector<cv::Point3f> list_vertex_;
     82   /* The list of triangles of the mesh */
     83   std::vector<std::vector<int> > list_triangles_;
     84 };
     85 
     86 #endif /* OBJECTMESH_H_ */
     87