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_MeshPrimitives_h 00034 #define NAN_INCLUDED_MeshPrimitives_h 00035 00036 #include "MT_Vector3.h" 00037 #include "CTR_TaggedIndex.h" 00038 #include "CTR_UHeap.h" 00039 #include <vector> 00040 00041 typedef CTR_TaggedIndex<24,0x00ffffff> LOD_VertexInd; 00042 typedef CTR_TaggedIndex<24,0x00ffffff> LOD_EdgeInd; 00043 typedef CTR_TaggedIndex<24,0x00ffffff> LOD_FaceInd; 00044 typedef CTR_TaggedIndex<24,0x00ffffff> LOD_HeapInd; 00045 00046 class LOD_Vertex { 00047 public : 00048 MT_Vector3 pos; 00049 std::vector<LOD_EdgeInd> m_edges; 00050 bool m_select_tag; 00051 00052 LOD_Vertex( 00053 ) ; 00054 00055 bool 00056 RemoveEdge( 00057 LOD_EdgeInd e 00058 ); 00059 00060 void 00061 AddEdge( 00062 LOD_EdgeInd e 00063 ); 00064 00065 void 00066 SwapEdge( 00067 LOD_EdgeInd e_old, 00068 LOD_EdgeInd e_new 00069 ); 00070 00071 bool 00072 SelectTag( 00073 ) const; 00074 00075 void 00076 SetSelectTag( 00077 bool tag 00078 ); 00079 00080 bool 00081 Degenerate( 00082 ); 00083 00084 void 00085 CopyPosition( 00086 float *float_ptr 00087 ); 00088 00089 private : 00090 00091 00092 }; 00093 00094 class LOD_Edge : public CTR_UHeapable { 00095 public : 00096 LOD_VertexInd m_verts[2]; 00097 LOD_FaceInd m_faces[2]; 00098 00099 LOD_Edge ( 00100 ); 00101 00102 bool operator == ( 00103 LOD_Edge & rhs 00104 ); 00105 00106 // Elementary helper methods 00108 00109 LOD_FaceInd 00110 OpFace( 00111 LOD_FaceInd f 00112 ) const ; 00113 00114 void 00115 SwapFace( 00116 LOD_FaceInd old_f, 00117 LOD_FaceInd new_f 00118 ) ; 00119 00120 00121 // return the half edge face - the half edge is defined 00122 // by the {vertex,edge} tuple. 00123 00124 LOD_FaceInd 00125 HalfEdgeFace( 00126 LOD_VertexInd vi 00127 ); 00128 00129 00130 LOD_VertexInd 00131 OpVertex( 00132 LOD_VertexInd vi 00133 ); 00134 00135 // replace the vertex v_old with vertex v_new 00136 // error if v_old is not one of the original vertices 00137 00138 void 00139 SwapVertex( 00140 LOD_VertexInd v_old, 00141 LOD_VertexInd v_new 00142 ) ; 00143 00144 bool 00145 SelectTag( 00146 ) const ; 00147 00148 void 00149 SetSelectTag( 00150 bool tag 00151 ); 00152 00153 int 00154 OpenTag( 00155 ) const; 00156 00157 void 00158 SetOpenTag( 00159 int tag 00160 ) ; 00161 00162 bool 00163 Degenerate( 00164 ) const; 00165 00166 bool 00167 BoundaryEdge( 00168 ) const { 00169 return (m_faces[0].IsEmpty() || m_faces[1].IsEmpty()); 00170 }; 00171 00172 00173 }; 00174 00175 class LOD_TriFace { 00176 public: 00177 00178 LOD_VertexInd m_verts[3]; 00179 00180 LOD_TriFace( 00181 ); 00182 00183 // Elementary helper methods 00185 00186 void 00187 SwapVertex( 00188 LOD_VertexInd old_v, 00189 LOD_VertexInd new_v 00190 ); 00191 00192 bool 00193 SelectTag( 00194 ) const; 00195 00196 void 00197 SetSelectTag( 00198 bool tag 00199 ); 00200 00201 int 00202 OpenTag( 00203 ); 00204 void 00205 SetOpenTag( 00206 int tag 00207 ); 00208 00209 bool 00210 Degenerate( 00211 ); 00212 00213 void 00214 CopyVerts( 00215 int * index_ptr 00216 ); 00217 00218 }; 00219 00220 #endif 00221