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_BSP_MeshPrimitives 00034 #define NAN_INCLUDED_BSP_MeshPrimitives 00035 00036 #include "CTR_TaggedIndex.h" 00037 #include "MT_Vector3.h" 00038 #include "MT_Plane3.h" 00039 00040 #include <vector> 00041 00042 typedef CTR_TaggedIndex<24,0x00ffffff> BSP_VertexInd; 00043 typedef CTR_TaggedIndex<24,0x00ffffff> BSP_EdgeInd; 00044 typedef CTR_TaggedIndex<24,0x00ffffff> BSP_FaceInd; 00045 typedef CTR_TaggedIndex<24,0x00ffffff> BSP_FragInd; 00046 00047 00048 typedef std::vector<BSP_VertexInd> BSP_VertexList; 00049 typedef std::vector<BSP_EdgeInd> BSP_EdgeList; 00050 typedef std::vector<BSP_FaceInd> BSP_FaceList; 00051 00057 enum BSP_Classification{ 00058 e_unclassified = 0, 00059 e_classified_in = 1, 00060 e_classified_out = 2, 00061 e_classified_on = 4, 00062 e_classified_spanning = 7 00063 }; 00064 00095 class BSP_MVertex { 00096 public : 00097 MT_Point3 m_pos; 00098 BSP_EdgeList m_edges; 00099 00109 bool m_select_tag; 00110 int m_open_tag; 00111 00112 BSP_MVertex( 00113 ); 00114 00115 BSP_MVertex( 00116 const MT_Point3 & pos 00117 ); 00118 00119 BSP_MVertex & 00120 operator = ( 00121 const BSP_MVertex & other 00122 ) { 00123 m_pos = other.m_pos; 00124 m_edges = other.m_edges; 00125 m_select_tag = other.m_select_tag; 00126 m_open_tag = other.m_open_tag; 00127 return (*this); 00128 }; 00129 00130 bool 00131 RemoveEdge( 00132 BSP_EdgeInd e 00133 ); 00134 00135 void 00136 AddEdge( 00137 BSP_EdgeInd e 00138 ); 00139 00140 void 00141 SwapEdge( 00142 BSP_EdgeInd e_old, 00143 BSP_EdgeInd e_new 00144 ); 00145 00155 int 00156 OpenTag( 00157 ) const; 00158 00159 void 00160 SetOpenTag( 00161 int tag 00162 ); 00163 00164 bool 00165 SelectTag( 00166 ) const; 00167 00168 void 00169 SetSelectTag( 00170 bool tag 00171 ); 00172 }; 00173 00174 class BSP_MEdge { 00175 public : 00176 BSP_VertexInd m_verts[2]; 00177 BSP_FaceList m_faces; 00178 00179 BSP_MEdge( 00180 ); 00181 00182 bool operator == ( 00183 BSP_MEdge & rhs 00184 ); 00185 00186 void 00187 SwapFace( 00188 BSP_FaceInd old_f, 00189 BSP_FaceInd new_f 00190 ); 00191 00192 BSP_VertexInd 00193 OpVertex( 00194 BSP_VertexInd vi 00195 ) const; 00196 00197 bool 00198 SelectTag( 00199 ) const; 00200 00201 void 00202 SetSelectTag( 00203 bool tag 00204 ); 00205 00212 int 00213 OpenTag( 00214 ) const; 00215 00216 void 00217 SetOpenTag( 00218 int tag 00219 ) ; 00220 }; 00221 00222 class BSP_MFace { 00223 public : 00224 00225 BSP_VertexList m_verts; 00226 00227 // We also store the plane equation of this 00228 // face. Generating on the fly during tree 00229 // construction can lead to a lot of numerical errors. 00230 // because the polygon size can get very small. 00231 00232 MT_Plane3 m_plane; 00233 00234 int m_open_tag; 00235 unsigned int m_orig_face; 00236 00237 BSP_MFace( 00238 ); 00239 00240 // Invert the face , done by reversing the vertex order 00241 // and inverting the face normal. 00242 00243 void 00244 Invert( 00245 ); 00246 00259 bool 00260 SelectTag( 00261 ) const; 00262 00263 void 00264 SetSelectTag( 00265 bool tag 00266 ); 00267 00268 int 00269 OpenTag( 00270 ) const; 00271 00272 void 00273 SetOpenTag( 00274 int tag 00275 ) ; 00276 00277 }; 00278 00279 #endif 00280