|
Blender
V2.59
|
00001 /* 00002 * 00003 * $Id: BOP_Mesh.h 35143 2011-02-25 10:32:33Z jesterking $ 00004 * 00005 * ***** BEGIN GPL LICENSE BLOCK ***** 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation; either version 2 00010 * of the License, or (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software Foundation, 00019 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00020 * 00021 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00022 * All rights reserved. 00023 * 00024 * The Original Code is: all of this file. 00025 * 00026 * Contributor(s): none yet. 00027 * 00028 * ***** END GPL LICENSE BLOCK ***** 00029 */ 00030 00036 #ifndef BOP_MESH_H 00037 #define BOP_MESH_H 00038 00039 #include "BOP_Vertex.h" 00040 #include "BOP_Edge.h" 00041 #include "BOP_Face.h" 00042 #include "DNA_listBase.h" 00043 00044 typedef vector<BOP_Vertex *> BOP_Vertexs; 00045 typedef vector<BOP_Edge *> BOP_Edges; 00046 typedef vector<BOP_Vertex *>::iterator BOP_IT_Vertexs; 00047 typedef vector<BOP_Edge *>::iterator BOP_IT_Edges; 00048 00049 #ifdef HASH 00050 typedef struct EdgeEntry { 00051 struct EdgeEntry *next, *pref; 00052 BOP_Index v1, v2, index; 00053 } EdgeEntry; 00054 #endif 00055 00056 class BOP_Mesh 00057 { 00058 private: 00059 BOP_Vertexs m_vertexs; 00060 BOP_Edges m_edges; 00061 BOP_Faces m_faces; 00062 #ifdef HASH 00063 ListBase *hash; 00064 int hashsize; 00065 #endif 00066 00067 BOP_Index addEdge(BOP_Index v1, BOP_Index v2); 00068 BOP_Edge *getEdge(BOP_Indexs edges, BOP_Index v2); 00069 bool containsFace(BOP_Faces *faces, BOP_Face *face); 00070 00071 bool testEdges(BOP_Faces *faces); 00072 bool testFaces(BOP_Face *faceI, BOP_Face *faceJ); 00073 bool testFace(BOP_Face *face); 00074 00075 public: 00076 BOP_Mesh(); 00077 ~BOP_Mesh(); 00078 00079 BOP_Index addVertex(MT_Point3 point); 00080 BOP_Index addFace(BOP_Face *face); 00081 BOP_Index addFace(BOP_Face3 *face); 00082 BOP_Index addFace(BOP_Face4 *face); 00083 BOP_Vertex* getVertex(BOP_Index v); 00084 BOP_Face*getFace(BOP_Index v); 00085 BOP_Edge* getEdge(BOP_Index v); 00086 BOP_Edge* getEdge(BOP_Face * face, unsigned int edge); 00087 BOP_Edge* getEdge(BOP_Face3 * face, unsigned int edge); 00088 BOP_Edge* getEdge(BOP_Face4 * face, unsigned int edge); 00089 BOP_Edge* getEdge(BOP_Index v1, BOP_Index v2); 00090 bool getIndexEdge(BOP_Index v1, BOP_Index v2, BOP_Index &e); 00091 BOP_Vertexs &getVertexs(); 00092 BOP_Edges &getEdges(); 00093 BOP_Faces &getFaces(); 00094 BOP_Face* getFace(BOP_Index v1, BOP_Index v2, BOP_Index v3); 00095 bool getIndexFace(BOP_Index v1, BOP_Index v2, BOP_Index v3, BOP_Index &f); 00096 unsigned int getNumVertexs(); 00097 unsigned int getNumEdges(); 00098 unsigned int getNumFaces(); 00099 unsigned int getNumVertexs(BOP_TAG tag); 00100 unsigned int getNumFaces(BOP_TAG tag); 00101 BOP_Index replaceVertexIndex(BOP_Index oldIndex, BOP_Index newIndex); 00102 #ifdef HASH 00103 void rehashVertex(BOP_Index oldIndex, BOP_Index newIndex, 00104 BOP_Index otherIndex); 00105 #endif 00106 bool isClosedMesh(); 00107 00108 // Debug functions 00109 void print(); 00110 void printFormat(); 00111 void printFormat(BOP_Faces *faces); 00112 void saveFormat(BOP_Faces *faces, char *filename); 00113 void printFace(BOP_Face *face, int col = 0); 00114 void testPlane(BOP_Face *face); 00115 void testMesh(); 00116 void updatePlanes(); 00117 }; 00118 00119 #endif