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