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