1 /* 2 * Mesh.cpp 3 * 4 * Created on: Apr 9, 2014 5 * Author: edgar 6 */ 7 8 #include "Mesh.h" 9 #include "CsvReader.h" 10 11 12 // --------------------------------------------------- // 13 // TRIANGLE CLASS // 14 // --------------------------------------------------- // 15 16 /** The custom constructor of the Triangle Class */ 17 Triangle::Triangle(int id, cv::Point3f V0, cv::Point3f V1, cv::Point3f V2) 18 { 19 id_ = id; v0_ = V0; v1_ = V1; v2_ = V2; 20 } 21 22 /** The default destructor of the Class */ 23 Triangle::~Triangle() 24 { 25 // TODO Auto-generated destructor stub 26 } 27 28 29 // --------------------------------------------------- // 30 // RAY CLASS // 31 // --------------------------------------------------- // 32 33 /** The custom constructor of the Ray Class */ 34 Ray::Ray(cv::Point3f P0, cv::Point3f P1) { 35 p0_ = P0; p1_ = P1; 36 } 37 38 /** The default destructor of the Class */ 39 Ray::~Ray() 40 { 41 // TODO Auto-generated destructor stub 42 } 43 44 45 // --------------------------------------------------- // 46 // OBJECT MESH CLASS // 47 // --------------------------------------------------- // 48 49 /** The default constructor of the ObjectMesh Class */ 50 Mesh::Mesh() : list_vertex_(0) , list_triangles_(0) 51 { 52 id_ = 0; 53 num_vertexs_ = 0; 54 num_triangles_ = 0; 55 } 56 57 /** The default destructor of the ObjectMesh Class */ 58 Mesh::~Mesh() 59 { 60 // TODO Auto-generated destructor stub 61 } 62 63 64 /** Load a CSV with *.ply format **/ 65 void Mesh::load(const std::string path) 66 { 67 68 // Create the reader 69 CsvReader csvReader(path); 70 71 // Clear previous data 72 list_vertex_.clear(); 73 list_triangles_.clear(); 74 75 // Read from .ply file 76 csvReader.readPLY(list_vertex_, list_triangles_); 77 78 // Update mesh attributes 79 num_vertexs_ = (int)list_vertex_.size(); 80 num_triangles_ = (int)list_triangles_.size(); 81 82 } 83