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