00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef OPENMESH_APP_SERVERSIDEVDPM_HH
00043 #define OPENMESH_APP_SERVERSIDEVDPM_HH
00044
00045 #include <OpenMesh/Core/Geometry/VectorT.hh>
00046 #include <OpenMesh/Tools/VDPM/VHierarchy.hh>
00047 #include <vector>
00048 #include <string>
00049
00050
00051 using OpenMesh::VDPM::VHierarchy;
00052 using OpenMesh::VDPM::VHierarchyNodeHandleContainer;
00053
00054
00055 class ServerSideVDPM
00056 {
00057 private:
00058
00059 char name_[256];
00060
00061 std::vector<OpenMesh::Vec3f> points_;
00062 std::vector<OpenMesh::Vec3ui> triangles_;
00063 VHierarchy vhierarchy_;
00064
00065 unsigned int n_base_vertices_;
00066 unsigned int n_base_faces_;
00067 unsigned int n_details_;
00068 unsigned char tree_id_bits_;
00069
00070 public:
00071
00072 ServerSideVDPM() { clear(); }
00073 void clear();
00074
00075 const char* name() const { return name_; }
00076
00077 void get_name(char _name[256]) { strcpy(_name, name_); }
00078 void set_name(const char _name[256]) { strcpy(name_, _name); }
00079
00080
00081 std::string
00082 basename(const std::string& _f)
00083 {
00084 std::string::size_type dot = _f.rfind("/");
00085 if (dot == std::string::npos)
00086 return std::string(_f);
00087 return std::string(_f.substr(dot+1, _f.length()-(dot+1)));
00088 }
00089
00090
00091 bool is_same_name(const char _name[256])
00092 {
00093 return (basename( name_ ) == basename( _name ));
00094 }
00095
00096 OpenMesh::VertexHandle add_vertex(const OpenMesh::Vec3f &p);
00097 OpenMesh::FaceHandle add_face(const unsigned int _triangle[3]);
00098
00099 const OpenMesh::Vec3f& point(OpenMesh::VertexHandle _vertex_handle) const
00100 {
00101 return points_[_vertex_handle.idx()];
00102 }
00103
00104 OpenMesh::Vec3f& point(OpenMesh::VertexHandle _vertex_handle)
00105 {
00106 return points_[_vertex_handle.idx()];
00107 }
00108
00109 const VHierarchy& vhierarchy() const { return vhierarchy_; }
00110 VHierarchy& vhierarchy() { return vhierarchy_; }
00111
00112 void vhierarchy_roots(VHierarchyNodeHandleContainer &roots) const;
00113
00114 unsigned int n_base_vertices() const { return n_base_vertices_; }
00115 unsigned int n_base_faces() const { return n_base_faces_; }
00116 unsigned int n_details() const { return n_details_; }
00117
00118 bool open_vd_prog_mesh(const char *_filename);
00119 };
00120
00121 std::ostream& operator << ( std::ostream& _os, const ServerSideVDPM& _o );
00122
00123
00124 typedef std::vector<ServerSideVDPM> ServerSideVDPMContainer;
00125 typedef std::list<ServerSideVDPM> ServerSideVDPMList;
00126
00127 #endif //OPENMESH_APP_SERVERSIDEVDPM_HH defined
00128