base.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 * VCGLib                                                            o o     *
00003 * Visual and Computer Graphics Library                            o     o   *
00004 *                                                                _   O  _   *
00005 * Copyright(C) 2004                                                \/)\/    *
00006 * Visual Computing Lab                                            /\/|      *
00007 * ISTI - Italian National Research Council                           |      *
00008 *                                                                    \      *
00009 * All rights reserved.                                                      *
00010 *                                                                           *
00011 * This program is free software; you can redistribute it and/or modify      *   
00012 * it under the terms of the GNU General Public License as published by      *
00013 * the Free Software Foundation; either version 2 of the License, or         *
00014 * (at your option) any later version.                                       *
00015 *                                                                           *
00016 * This program is distributed in the hope that it will be useful,           *
00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
00019 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)          *
00020 * for more details.                                                         *
00021 *                                                                           *
00022 ****************************************************************************/
00023 #ifndef __VCG_MESH
00024 #error "This file should not be included alone. It is automatically included by complex.h"
00025 #endif
00026 #ifndef __VCG_VERTEX_PLUS
00027 #define __VCG_VERTEX_PLUS
00028 
00029 namespace vcg {
00030 
00031 
00032 /* The base class form which we start to add our components.
00033 it has the empty definition for all the standard members (coords, color flags)
00034 Note:
00035 in order to avoid both virtual classes and ambiguous definitions all 
00036 the subsequent overrides must be done in a sequence of derivation.
00037 
00038 In other words we cannot derive and add in a single derivation step 
00039 (with multiple ancestor), both the real (non-empty) normal and color but 
00040 we have to build the type a step a time (deriving from a single ancestor at a time). 
00041 
00042  The Real Big Vertex class;
00043 
00044 The class __VertexArityMax__ is the one that is the Last to be derived,
00045 and therefore is the only one to know the real members 
00046 (after the many overrides) so all the functions with common behaviour 
00047 using the members defined in the various Empty/nonEmpty component classes 
00048 MUST be defined here. 
00049 
00050 I.e. IsD() that uses the overridden Flags() member must be defined here.
00051 
00052 */
00053 
00054 template <class UserTypes,
00055           template <typename> class A, template <typename> class B,
00056           template <typename> class C, template <typename> class D,
00057           template <typename> class E, template <typename> class F,
00058           template <typename> class G, template <typename> class H,
00059           template <typename> class I, template <typename> class J,
00060           template <typename> class K, template <typename> class L>
00061 class VertexArityMax: public Arity12<vertex::EmptyCore<UserTypes>, A, B, C, D, E, F, G, H, I, J, K, L> {
00062 
00063 // ----- Flags stuff -----
00064 public:
00065 
00066 
00067 
00068         enum { 
00069                 
00070                 DELETED    = 0x0001,            // This bit indicate that the vertex is deleted from the mesh
00071                 NOTREAD    = 0x0002,            // This bit indicate that the vertex of the mesh is not readable
00072                 NOTWRITE   = 0x0004,            // This bit indicate that the vertex is not modifiable
00073                 MODIFIED   = 0x0008,            // This bit indicate that the vertex is modified
00074                 VISITED    = 0x0010,            // This bit can be used to mark the visited vertex
00075                 SELECTED   = 0x0020,            // This bit can be used to select 
00076                 BORDER     = 0x0100,    // Border Flag
00077                 USER0      = 0x0200                     // First user bit
00078   };
00079         
00080     bool IsD() const {return (this->cFlags() & DELETED) != 0;} 
00081     bool IsR() const {return (this->cFlags() & NOTREAD) == 0;} 
00082     bool IsW() const {return (this->cFlags() & NOTWRITE)== 0;}
00083     bool IsRW() const {return (this->cFlags() & (NOTREAD | NOTWRITE)) == 0;}
00084     bool IsS() const {return (this->cFlags() & SELECTED) != 0;}
00085     bool IsB() const {return (this->cFlags() & BORDER) != 0;}
00086     bool IsV() const {return (this->cFlags() & VISITED) != 0;}
00087         
00088 
00092         void SetFlags(int flagp) {this->Flags()=flagp;}
00093 
00097         void ClearFlags() {this->Flags()=0;}
00098         void SetD() {this->Flags() |=DELETED;}
00099         void ClearD() {this->Flags() &=(~DELETED);}
00100         void SetR() {this->Flags() &=(~NOTREAD);}
00101         void ClearR() {this->Flags() |=NOTREAD;}
00102         void ClearW() {this->Flags() |=NOTWRITE;}
00103         void SetW() {this->Flags() &=(~NOTWRITE);}
00104         void SetS()             {this->Flags() |=SELECTED;}
00105         void ClearS()   {this->Flags() &= ~SELECTED;}
00106         void SetB()             {this->Flags() |=BORDER;}
00107         void ClearB()   {this->Flags() &=~BORDER;}
00108         void SetV()             {this->Flags() |=VISITED;}
00109         void ClearV()   {this->Flags() &=~VISITED;}
00110         
00112         static int &FirstUnusedBitFlag()
00113         {
00114           static int b =USER0;
00115           return b;
00116         }
00117 
00119         static inline int NewBitFlag()
00120         {
00121           int bitForTheUser = FirstUnusedBitFlag();
00122           FirstUnusedBitFlag()=FirstUnusedBitFlag()<<1;
00123           return bitForTheUser;
00124         }
00125 
00127         // Note you must deallocate bit in the inverse order of the allocation (as in a stack)
00128         static inline bool DeleteBitFlag(int bitval)
00129         {
00130           if(FirstUnusedBitFlag()>>1==bitval) {
00131                 FirstUnusedBitFlag() = FirstUnusedBitFlag()>>1;
00132                 return true;
00133           }
00134           assert(0);
00135           return false;
00136         }
00137 
00139         bool IsUserBit(int userBit){return (this->Flags() & userBit) != 0;}
00140 
00142         void SetUserBit(int userBit){this->Flags() |=userBit;}
00143 
00145         void ClearUserBit(int userBit){this->Flags() &= (~userBit);}
00146 
00147  template<class BoxType>
00148   void GetBBox( BoxType & bb ) const
00149   {       bb.Set(this->cP());  }
00150 
00151           };
00152 
00153           
00154 /*
00155 
00156 These are the three main classes that are used by the library user to define its own vertexes.
00157 The user MUST specify the names of all the type involved in a generic complex.
00158 so for example when defining a vertex of a trimesh you must know the name of the type of the edge and of the face.
00159 Typical usage example:
00160 
00161 A vertex with coords, flags and normal for use in a standard trimesh:
00162 
00163 class VertexNf   : public VertexSimp2< VertexNf, EdgeProto, FaceProto, vert::Coord3d, vert::Flag, vert::Normal3f  > {};
00164 
00165 
00166 A vertex with coords, and normal for use in a tetrahedral mesh AND in a standard trimesh:
00167 
00168 class TetraVertex   : public VertexSimp3< TetraVertex, EdgeProto, FaceProto, TetraProto, vert::Coord3d, vert::Normal3f  > {};
00169 
00170 
00171 A summary of the available vertex attributes (see component.h for more details):
00172           
00173 Coord3f,  Coord3d, 
00174 Normal3s,  Normal3f,  Normal3d
00175 Mark                              //a int component (incremental mark)
00176 BitFlags
00177 TexCoord2s,  TexCoord2f,  TexCoord2d
00178 Color4b
00179 Qualitys, Qualityf, Qualityd
00180 VFAdj                             //topology (vertex->face adjacency)
00181 */
00182 
00183 template <class UserTypes,
00184           template <typename> class A = DefaultDeriver, template <typename> class B = DefaultDeriver,
00185           template <typename> class C = DefaultDeriver, template <typename> class D = DefaultDeriver,
00186           template <typename> class E = DefaultDeriver, template <typename> class F = DefaultDeriver,
00187           template <typename> class G = DefaultDeriver, template <typename> class H = DefaultDeriver,
00188                                         template <typename> class I = DefaultDeriver, template <typename> class J = DefaultDeriver,
00189                                         template <typename> class K = DefaultDeriver, template <typename> class L = DefaultDeriver>
00190                                                         class Vertex: public VertexArityMax<UserTypes, A, B, C, D, E, F, G, H, I, J, K, L>  {
00191                          public: typedef AllTypes::AVertexType IAm; typedef UserTypes TypesPool;};
00192 
00193 }// end namespace
00194 #endif


shape_reconstruction
Author(s): Roberto Martín-Martín
autogenerated on Sat Jun 8 2019 18:29:08