|
Blender
V2.59
|
00001 /* 00002 * $Id: LOD_ManMesh2.h 35147 2011-02-25 10:47:28Z jesterking $ 00003 * ***** BEGIN GPL LICENSE BLOCK ***** 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License 00007 * as published by the Free Software Foundation; either version 2 00008 * of the License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software Foundation, 00017 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 * 00019 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00020 * All rights reserved. 00021 * 00022 * The Original Code is: all of this file. 00023 * 00024 * Contributor(s): none yet. 00025 * 00026 * ***** END GPL LICENSE BLOCK ***** 00027 */ 00028 00034 #ifndef NAN_INCLUDED_ManMesh2_h 00035 #define NAN_INCLUDED_ManMesh2_h 00036 00037 #include "LOD_MeshPrimitives.h" 00038 #include "MEM_SmartPtr.h" 00039 #include <vector> 00040 00041 template <class HeapType> class CTR_UHeap; 00042 00043 class LOD_ExternBufferEditor; 00044 00045 class LOD_ManMesh2 // Manifold 2 dimensional mesh 00046 { 00047 00048 public: 00049 00050 static 00051 LOD_ManMesh2 * 00052 New( 00053 ); 00054 00055 // take ownership of the vertices. 00056 00057 bool 00058 SetVertices( 00059 MEM_SmartPtr<std::vector<LOD_Vertex> > verts 00060 ); 00061 00062 // Add a triangle to the mesh 00063 00064 void 00065 AddTriangle( 00066 int verts[3] 00067 ); 00068 00069 void 00070 ConnectTriangle( 00071 LOD_FaceInd fi, 00072 std::vector<LOD_EdgeInd> & new_edges 00073 ); 00074 00075 // geometry access 00077 00078 std::vector<LOD_Vertex> & 00079 VertexSet( 00080 ) const ; 00081 00082 std::vector<LOD_TriFace> & 00083 FaceSet( 00084 ) const ; 00085 00086 std::vector<LOD_Edge> & 00087 EdgeSet( 00088 ) const; 00089 00090 ~LOD_ManMesh2( 00091 ); 00092 00093 // local geometry queries 00095 00096 // face queries 00098 00099 void 00100 FaceVertices( 00101 LOD_FaceInd f, 00102 std::vector<LOD_VertexInd> &output 00103 ); 00104 00105 void 00106 FaceEdges( 00107 LOD_FaceInd f, 00108 std::vector<LOD_EdgeInd> &output 00109 ); 00110 00111 // edge queries 00113 00114 void 00115 EdgeVertices( 00116 LOD_EdgeInd e, 00117 std::vector<LOD_VertexInd> &output 00118 ); 00119 00120 void 00121 EdgeFaces( 00122 LOD_EdgeInd e, 00123 std::vector<LOD_FaceInd> &output 00124 ); 00125 00126 // vertex queries 00128 00129 void 00130 VertexEdges( 00131 LOD_VertexInd v, 00132 std::vector<LOD_EdgeInd> &output 00133 ); 00134 00135 void 00136 VertexFaces( 00137 LOD_VertexInd v, 00138 std::vector<LOD_FaceInd> &output 00139 ); 00140 00141 void 00142 SetBBox( 00143 MT_Vector3 bbox_min, 00144 MT_Vector3 bbox_max 00145 ); 00146 00147 MT_Vector3 00148 BBoxMin( 00149 ) const { 00150 return m_bbox_min; 00151 }; 00152 00153 MT_Vector3 00154 BBoxMax( 00155 ) const { 00156 return m_bbox_max; 00157 }; 00158 00159 // Remove a primitive from the mesh 00161 00162 // These methods assume you have correctly 00163 // tidied up the index pointers in other primitives, 00164 // so that nothing refers to this object any more 00165 00166 // These methods exchange the primitive with the 00167 // last primitive in the vector. It modifies everything 00168 // pointing to the last primitive correctly. 00169 00170 // FIXME refactor extern editor out of primitive deletion 00171 // insead return a vector of primitives that need to be 00172 // modified and do this externally 00173 00174 void 00175 DeleteVertex( 00176 LOD_ExternBufferEditor & extern_editor, 00177 LOD_VertexInd v 00178 ); 00179 00180 void 00181 DeleteEdge( 00182 LOD_EdgeInd e, 00183 CTR_UHeap<LOD_Edge> *heap 00184 ); 00185 00186 void 00187 DeleteFace( 00188 LOD_ExternBufferEditor & extern_editor, 00189 LOD_FaceInd f 00190 ); 00191 00192 // Sanity Check routines 00194 00195 // Make sure the edge sets and the vertex sets are 00196 // consistent 00197 00198 void 00199 SC_TriFace( 00200 LOD_FaceInd f 00201 ); 00202 00203 // basic sanity checking of an edge list bails out if there are more than 1024 00204 // edges 00205 00206 void 00207 SC_EdgeList( 00208 LOD_EdgeInd e 00209 ); 00210 00211 00212 // Check to see that the edges of v1 and v2 are unique. 00213 00214 bool 00215 SC_UniqueEdge( 00216 LOD_EdgeInd e 00217 ); 00218 00219 00220 private : 00221 00222 00223 // Returns the edge index of the edge from v1 to v2. 00224 // Does this by searching the edge sets of v1 - but not v2. 00225 // If you are paranoid you should check both and make sure the 00226 // indices are the same. If the edge doe not exist edgeInd is empty. 00227 00228 LOD_EdgeInd 00229 FindEdge( 00230 const LOD_VertexInd v1, 00231 const LOD_VertexInd v2 00232 ); 00233 00234 // Insert an edge into the mesh 00235 // Tie up the ptrs and create space for the edge 00236 // returns manifold errors - need to sort out memory edges 00237 00238 bool 00239 InsertEdge( 00240 const LOD_VertexInd v1, 00241 const LOD_VertexInd v2, 00242 const LOD_FaceInd f, 00243 std::vector<LOD_EdgeInd> &new_edges 00244 ); 00245 00246 00247 private : 00248 00249 LOD_ManMesh2( 00250 ); 00251 00252 MEM_SmartPtr< std::vector<LOD_Vertex> > m_verts; 00253 MEM_SmartPtr< std::vector<LOD_TriFace> > m_faces; 00254 MEM_SmartPtr< std::vector<LOD_Edge> > m_edges; 00255 00256 // not sure of these descrtiptions of the mesh should 00257 // reside in this class coz may lead to very bloated interface. 00258 00259 MT_Vector3 m_bbox_min; 00260 MT_Vector3 m_bbox_max; 00261 00262 00263 }; 00264 00265 #endif 00266