00001 00020 #ifndef NTK_MESH_MESH_H 00021 # define NTK_MESH_MESH_H 00022 00023 #include <ntk/core.h> 00024 #include <ntk/camera/calibration.h> 00025 #include <ntk/geometry/pose_3d.h> 00026 00027 #include <vector> 00028 00029 namespace ntk 00030 { 00031 00032 class Face 00033 { 00034 public: 00035 Face(unsigned i1, unsigned i2, unsigned i3) 00036 { indices[0] = i1; indices[1] = i2; indices[2] = i2; } 00037 00038 Face() {} 00039 00040 unsigned indices[3]; 00041 static int numVertices() { return 3; }; 00042 }; 00043 00044 class Mesh 00045 { 00046 public: 00047 std::vector<cv::Point3f> vertices; 00048 std::vector<cv::Vec3b> colors; 00049 std::vector<cv::Point3f> normals; 00050 std::vector<cv::Point2f> texcoords; 00051 std::vector<Face> faces; 00052 cv::Mat3b texture; 00053 00054 public: 00055 cv::Point3f centerize(); 00056 void applyTransform(const Pose3D& pose); 00057 00058 public: 00059 bool hasColors() const { return colors.size() > 0; } 00060 bool hasNormals() const { return normals.size() > 0; } 00061 bool hasTexcoords() const { return texcoords.size() > 0; } 00062 bool hasFaces() const { return faces.size() > 0; } 00063 00064 public: 00065 void clear(); 00066 }; 00067 } // ntk 00068 00069 #endif // NTK_MESH_MESH_H