Blender  V2.59
BSP_MeshPrimitives.h
Go to the documentation of this file.
00001 /*
00002  * $Id: BSP_MeshPrimitives.h 35145 2011-02-25 10:44:20Z jesterking $
00003  * ***** BEGIN GPL LICENSE BLOCK *****
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software Foundation,
00017  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018  *
00019  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00020  * All rights reserved.
00021  *
00022  * The Original Code is: all of this file.
00023  *
00024  * Contributor(s): none yet.
00025  *
00026  * ***** END GPL LICENSE BLOCK *****
00027  */
00028 
00034 #ifndef NAN_INCLUDED_BSP_MeshPrimitives
00035 #define NAN_INCLUDED_BSP_MeshPrimitives
00036 
00037 #include "CTR_TaggedIndex.h"
00038 #include "MT_Vector3.h"
00039 #include "MT_Plane3.h"
00040 
00041 #include <vector>
00042 
00043 typedef CTR_TaggedIndex<24,0x00ffffff> BSP_VertexInd;
00044 typedef CTR_TaggedIndex<24,0x00ffffff> BSP_EdgeInd;
00045 typedef CTR_TaggedIndex<24,0x00ffffff> BSP_FaceInd;
00046 typedef CTR_TaggedIndex<24,0x00ffffff> BSP_FragInd;
00047 
00048 
00049 typedef std::vector<BSP_VertexInd> BSP_VertexList;
00050 typedef std::vector<BSP_EdgeInd> BSP_EdgeList;
00051 typedef std::vector<BSP_FaceInd> BSP_FaceList;
00052 
00058 enum BSP_Classification{
00059         e_unclassified = 0,
00060         e_classified_in = 1,
00061         e_classified_out = 2,
00062         e_classified_on = 4,
00063         e_classified_spanning = 7
00064 };
00065 
00096 class BSP_MVertex {
00097 public :
00098         MT_Point3 m_pos;
00099         BSP_EdgeList m_edges;
00100         
00110         bool m_select_tag;
00111         int m_open_tag;
00112 
00113         BSP_MVertex(
00114         );
00115 
00116         BSP_MVertex(
00117                 const MT_Point3 & pos
00118         );
00119 
00120                 BSP_MVertex &
00121         operator = (
00122                 const BSP_MVertex & other
00123         ) {
00124                 m_pos = other.m_pos;
00125                 m_edges = other.m_edges;
00126                 m_select_tag = other.m_select_tag;
00127                 m_open_tag = other.m_open_tag;
00128                 return (*this);
00129         };
00130 
00131                 bool
00132         RemoveEdge(
00133                 BSP_EdgeInd e
00134         );      
00135 
00136                 void
00137         AddEdge(
00138                 BSP_EdgeInd e
00139         );
00140 
00141                 void
00142         SwapEdge(
00143                 BSP_EdgeInd e_old,
00144                 BSP_EdgeInd e_new
00145         );
00146 
00156                 int
00157         OpenTag(
00158         ) const;
00159 
00160                 void
00161         SetOpenTag(
00162                 int tag
00163         );
00164                 
00165                 bool
00166         SelectTag(
00167         ) const;
00168 
00169                 void
00170         SetSelectTag(
00171                 bool tag        
00172         );
00173 };
00174 
00175 class BSP_MEdge {
00176 public :
00177         BSP_VertexInd m_verts[2];
00178         BSP_FaceList m_faces;
00179 
00180         BSP_MEdge(
00181         );
00182 
00183         bool operator == (
00184                 BSP_MEdge & rhs
00185         );
00186 
00187                 void
00188         SwapFace(
00189                 BSP_FaceInd old_f,
00190                 BSP_FaceInd new_f
00191         );
00192 
00193         BSP_VertexInd
00194         OpVertex(
00195                 BSP_VertexInd vi
00196         ) const;
00197 
00198                 bool
00199         SelectTag(
00200         ) const;
00201 
00202                 void
00203         SetSelectTag(
00204                 bool tag        
00205         );
00206         
00213                 int
00214         OpenTag(
00215         ) const;
00216 
00217                 void
00218         SetOpenTag(
00219                 int tag
00220         ) ;
00221 };
00222 
00223 class BSP_MFace {
00224 public :
00225 
00226         BSP_VertexList m_verts;
00227 
00228         // We also store the plane equation of this
00229         // face. Generating on the fly during tree
00230         // construction can lead to a lot of numerical errors.
00231         // because the polygon size can get very small.
00232 
00233         MT_Plane3 m_plane;
00234 
00235         int m_open_tag;
00236         unsigned int m_orig_face;
00237 
00238         BSP_MFace(
00239         );
00240 
00241         // Invert the face , done by reversing the vertex order 
00242         // and inverting the face normal.
00243 
00244                 void
00245         Invert(
00246         );
00247 
00260                 bool
00261         SelectTag(
00262         ) const;
00263 
00264                 void
00265         SetSelectTag(
00266                 bool tag        
00267         );      
00268 
00269                 int
00270         OpenTag(
00271         ) const;
00272 
00273                 void
00274         SetOpenTag(
00275                 int tag
00276         ) ;
00277 
00278 };
00279 
00280 #endif
00281