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 #include <string.h>
00050
00051
00052 using OpenMesh::VDPM::VHierarchy;
00053 using OpenMesh::VDPM::VHierarchyNodeHandleContainer;
00054
00055
00056 class ServerSideVDPM
00057 {
00058 private:
00059
00060 char name_[256];
00061
00062 std::vector<OpenMesh::Vec3f> points_;
00063 std::vector<OpenMesh::Vec3ui> triangles_;
00064 VHierarchy vhierarchy_;
00065
00066 unsigned int n_base_vertices_;
00067 unsigned int n_base_faces_;
00068 unsigned int n_details_;
00069 unsigned char tree_id_bits_;
00070
00071 public:
00072
00073 ServerSideVDPM() { clear(); }
00074 void clear();
00075
00076 const char* name() const { return name_; }
00077
00078 void get_name(char _name[256]) { strcpy(_name, name_); }
00079 void set_name(const char _name[256]) { strcpy(name_, _name); }
00080
00081
00082 std::string
00083 basename(const std::string& _f)
00084 {
00085 std::string::size_type dot = _f.rfind("/");
00086 if (dot == std::string::npos)
00087 return std::string(_f);
00088 return std::string(_f.substr(dot+1, _f.length()-(dot+1)));
00089 }
00090
00091
00092 bool is_same_name(const char _name[256])
00093 {
00094 return (basename( name_ ) == basename( _name ));
00095 }
00096
00097 OpenMesh::VertexHandle add_vertex(const OpenMesh::Vec3f &p);
00098 OpenMesh::FaceHandle add_face(const unsigned int _triangle[3]);
00099
00100 const OpenMesh::Vec3f& point(OpenMesh::VertexHandle _vertex_handle) const
00101 {
00102 return points_[_vertex_handle.idx()];
00103 }
00104
00105 OpenMesh::Vec3f& point(OpenMesh::VertexHandle _vertex_handle)
00106 {
00107 return points_[_vertex_handle.idx()];
00108 }
00109
00110 const VHierarchy& vhierarchy() const { return vhierarchy_; }
00111 VHierarchy& vhierarchy() { return vhierarchy_; }
00112
00113 void vhierarchy_roots(VHierarchyNodeHandleContainer &roots) const;
00114
00115 unsigned int n_base_vertices() const { return n_base_vertices_; }
00116 unsigned int n_base_faces() const { return n_base_faces_; }
00117 unsigned int n_details() const { return n_details_; }
00118
00119 bool open_vd_prog_mesh(const char *_filename);
00120 };
00121
00122 std::ostream& operator << ( std::ostream& _os, const ServerSideVDPM& _o );
00123
00124
00125 typedef std::vector<ServerSideVDPM> ServerSideVDPMContainer;
00126 typedef std::list<ServerSideVDPM> ServerSideVDPMList;
00127
00128 #endif //OPENMESH_APP_SERVERSIDEVDPM_HH defined
00129