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_EDGE_PLUS
00027 #define __VCG_EDGE_PLUS
00028 namespace vcg {
00029 /*------------------------------------------------------------------*/ 
00030 /* 
00031 The base class of all the recusive definition chain. It is just a container of the typenames of the various simplexes.
00032 These typenames must be known form all the derived classes.
00033 */
00034 
00035 template <class UserTypes>
00036                                 class EdgeTypeHolder: public UserTypes{
00037   public:
00038 
00039         template < class LeftV>
00040         void ImportData(const LeftV  & /* left */ ) { }
00041   static void Name(std::vector<std::string> & /*name*/){}
00042 
00043 };
00044 
00045 /* The base class form which we start to add our components.
00046 it has the empty definition for all the standard members (coords, color flags)
00047 Note:
00048 in order to avoid both virtual classes and ambiguous definitions all 
00049 the subsequent overrides must be done in a sequence of derivation.
00050 
00051 In other words we cannot derive and add in a single derivation step 
00052 (with multiple ancestor), both the real (non-empty) normal and color but 
00053 we have to build the type a step a time (deriving from a single ancestor at a time). 
00054 
00055 
00056 */ 
00057 //template <class UserTypes>
00058 //                class EdgeBase: public                  edge::EmptyCore<
00059 //                                    edge::EmptyVEAdj<
00060 //                                                                        edge::EmptyCore<
00061 //                                                                                                                                              edge::EmptyEHAdj<
00062 //                                                                                                                                              edge::EmptyBitFlags<
00063 //                                                                                                                                              edge::EmptyVertexRef<
00064 //                                                                                                                                              EdgeTypeHolder < UserTypes> >  > > > > >{};
00065 
00066 
00067 /* The Real Big Edge class;
00068 
00069 The class __VertexArityMax__ is the one that is the Last to be derived,
00070 and therefore is the only one to know the real members 
00071 (after the many overrides) so all the functions with common behaviour 
00072 using the members defined in the various Empty/nonEmpty component classes 
00073 MUST be defined here. 
00074 
00075 I.e. IsD() that uses the overridden Flags() member must be defined here.
00076 
00077 */
00078 
00079 template <class UserTypes,
00080           template <typename> class A, template <typename> class B, 
00081           template <typename> class C, template <typename> class D, 
00082           template <typename> class E, template <typename> class F,
00083           template <typename> class G, template <typename> class H,
00084           template <typename> class I, template <typename> class J >
00085 class EdgeArityMax: public Arity10<edge::EmptyCore<UserTypes>, A, B, C, D, E, F, G, H, I, J> {
00086 
00087 // ----- Flags stuff -----
00088 public:
00089   
00090 
00091         enum { 
00092                 
00093                 DELETED    = 0x0001,            // This bit indicate that the edge is deleted from the mesh
00094                 NOTREAD    = 0x0002,            // This bit indicate that the edge of the mesh is not readable
00095                 NOTWRITE   = 0x0004,            // This bit indicate that the edge is not modifiable
00096                 MODIFIED   = 0x0008,            // This bit indicate that the edge is modified
00097                 VISITED    = 0x0010,            // This bit can be used to mark the visited edge
00098                 SELECTED   = 0x0020,            // This bit can be used to select 
00099                 BORDER     = 0x0100,    // Border Flag
00100                 USER0      = 0x0200                     // First user bit
00101                         };
00102 
00103         bool IsD() const {return (this->Flags() & DELETED) != 0;} 
00104         bool IsR() const {return (this->Flags() & NOTREAD) == 0;} 
00105         bool IsW() const {return (this->Flags() & NOTWRITE)== 0;}
00106         bool IsRW() const {return (this->Flags() & (NOTREAD | NOTWRITE)) == 0;}
00107         bool IsS() const {return (this->Flags() & SELECTED) != 0;}
00108         bool IsB() const {return (this->Flags() & BORDER) != 0;}
00109         bool IsV() const {return (this->Flags() & VISITED) != 0;}
00110         
00111 
00115         void SetFlags(int flagp) {this->Flags()=flagp;}
00116 
00120         void ClearFlags() {this->Flags()=0;}
00121         void SetD() {this->Flags() |=DELETED;}
00122         void ClearD() {this->Flags() &=(~DELETED);}
00123         void SetR() {this->Flags() &=(~NOTREAD);}
00124         void ClearR() {this->Flags() |=NOTREAD;}
00125         void ClearW() {this->Flags() |=NOTWRITE;}
00126         void SetW() {this->Flags() &=(~NOTWRITE);}
00127         void SetS()             {this->Flags() |=SELECTED;}
00128         void ClearS()   {this->Flags() &= ~SELECTED;}
00129         void SetB()             {this->Flags() |=BORDER;}
00130         void ClearB()   {this->Flags() &=~BORDER;}
00131         void SetV()             {this->Flags() |=VISITED;}
00132         void ClearV()   {this->Flags() &=~VISITED;}
00133         
00135         static int &FirstUnusedBitFlag()
00136         {
00137           static int b =USER0;
00138           return b;
00139         }
00140 
00142         static inline int NewBitFlag()
00143         {
00144           int bitForTheUser = FirstUnusedBitFlag();
00145           FirstUnusedBitFlag()=FirstUnusedBitFlag()<<1;
00146           return bitForTheUser;
00147         }
00148 
00150         // Note you must deallocate bit in the inverse order of the allocation (as in a stack)
00151         static inline bool DeleteBitFlag(int bitval)
00152         {
00153           if(FirstUnusedBitFlag()>>1==bitval) {
00154                 FirstUnusedBitFlag() = FirstUnusedBitFlag()>>1;
00155                 return true;
00156           }
00157           assert(0);
00158           return false;
00159         }
00160 
00162         bool IsUserBit(int userBit){return (this->Flags() & userBit) != 0;}
00163 
00165         void SetUserBit(int userBit){this->Flags() |=userBit;}
00166 
00168         void ClearUserBit(int userBit){this->Flags() &= (~userBit);}
00169 
00170  template<class BoxType>
00171   void GetBBox( BoxType & bb ) const {  
00172         bb.SetNull();
00173         bb.Add(this->cP(0));  
00174         bb.Add(this->cP(1));  
00175         }
00176 
00177           };
00178 
00179           
00180 /*
00181 
00182 These are the three main classes that are used by the library user to define its own edges.
00183 The user MUST specify the names of all the type involved in a generic complex.
00184 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.
00185 Typical usage example:
00186 
00187 A vertex with coords, flags and normal for use in a standard trimesh:
00188 
00189 class VertexNf   : public VertexSimp2< VertexNf, EdgeProto, FaceProto, vert::Coord3d, vert::Flag, vert::Normal3f  > {};
00190 
00191 
00192 A vertex with coords, and normal for use in a tetrahedral mesh AND in a standard trimesh:
00193 
00194 class TetraVertex   : public VertexSimp3< TetraVertex, EdgeProto, FaceProto, TetraProto, vert::Coord3d, vert::Normal3f  > {};
00195 
00196 
00197 A summary of the available vertex attributes (see component.h for more details):
00198           
00199 Coord3f,  Coord3d, 
00200 Normal3s,  Normal3f,  Normal3d
00201 Mark                              //a int component (incremental mark)
00202 BitFlags
00203 TexCoord2s,  TexCoord2f,  TexCoord2d
00204 Color4b
00205 Qualitys, Qualityf, Qualityd
00206 VFAdj                             //topology (vertex->face adjacency)
00207 */
00208 
00209 template <class UserTypes,
00210           template <typename> class A = DefaultDeriver, template <typename> class B = DefaultDeriver,
00211           template <typename> class C = DefaultDeriver, template <typename> class D = DefaultDeriver,
00212           template <typename> class E = DefaultDeriver, template <typename> class F = DefaultDeriver,
00213           template <typename> class G = DefaultDeriver, template <typename> class H = DefaultDeriver,
00214           template <typename> class I = DefaultDeriver, template <typename> class J = DefaultDeriver >
00215                             class Edge: public EdgeArityMax<UserTypes, A, B, C, D, E, F, G, H, I, J>  {
00216                                                 public: typedef AllTypes::AEdgeType IAm; typedef UserTypes TypesPool;};
00217 
00218 }// end namespace
00219 #endif


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