OpenMesh
|
00001 /*===========================================================================*\ 00002 * * 00003 * OpenMesh * 00004 * Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen * 00005 * www.openmesh.org * 00006 * * 00007 *---------------------------------------------------------------------------* 00008 * This file is part of OpenMesh. * 00009 * * 00010 * OpenMesh is free software: you can redistribute it and/or modify * 00011 * it under the terms of the GNU Lesser General Public License as * 00012 * published by the Free Software Foundation, either version 3 of * 00013 * the License, or (at your option) any later version with the * 00014 * following exceptions: * 00015 * * 00016 * If other files instantiate templates or use macros * 00017 * or inline functions from this file, or you compile this file and * 00018 * link it with other files to produce an executable, this file does * 00019 * not by itself cause the resulting executable to be covered by the * 00020 * GNU Lesser General Public License. This exception does not however * 00021 * invalidate any other reasons why the executable file might be * 00022 * covered by the GNU Lesser General Public License. * 00023 * * 00024 * OpenMesh is distributed in the hope that it will be useful, * 00025 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00027 * GNU Lesser General Public License for more details. * 00028 * * 00029 * You should have received a copy of the GNU LesserGeneral Public * 00030 * License along with OpenMesh. If not, * 00031 * see <http://www.gnu.org/licenses/>. * 00032 * * 00033 \*===========================================================================*/ 00034 00035 /*===========================================================================*\ 00036 * * 00037 * $Revision: 362 $ * 00038 * $Date: 2011-01-26 10:21:12 +0100 (Mi, 26 Jan 2011) $ * 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_; // points related to this pm 00063 std::vector<OpenMesh::Vec3ui> triangles_; // base mesh 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