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 /****************************************************************************
00024   History
00025 
00026 $Log: not supported by cvs2svn $
00027 Revision 1.1  2007/05/09 10:31:53  ganovelli
00028 added
00029 
00030 
00031 
00032 ****************************************************************************/
00033 #ifndef __VCG_TETRA_PLUS
00034 #define __VCG_TETRA_PLUS
00035 
00036 #include <vcg/space/point3.h>
00037 #include <vcg/space/texcoord2.h>
00038 #include <vcg/space/color4.h>
00039 #include <vcg/simplex/tetrahedron/component.h>
00040 
00041 namespace vcg {
00042 
00043 /*------------------------------------------------------------------*/ 
00044 /* 
00045 The base class of all the recusive definition chain. It is just a container of the typenames of the various simplexes.
00046 These typenames must be known form all the derived classes.
00047 */
00048 
00049 template <class BVT, class BET, class BFT, class BTT>
00050 class TetraTypeHolder{
00051   public:
00052   typedef BVT VertexType;
00053   typedef typename VertexType::CoordType CoordType;
00054   typedef typename VertexType::ScalarType ScalarType;
00055   typedef BET EdgeType;
00056   typedef BFT FaceType;
00057   typedef BTT TetraType;
00058   typedef BVT *VertPointer;
00059   typedef BET *EdgePointer;
00060   typedef BFT *FacePointer;
00061   typedef BTT *TetraPointer;
00062   static void Name(std::vector<std::string> & name){}
00063 
00064 
00065  // prot
00066  
00067 };
00068 
00069 /* The base class form which we start to add our components.
00070 it has the empty definition for all the standard members (coords, color flags)
00071 Note:
00072 in order to avoid both virtual classes and ambiguous definitions all 
00073 the subsequent overrides must be done in a sequence of derivation.
00074 
00075 In other words we cannot derive and add in a single derivation step 
00076 (with multiple ancestor), both the real (non-empty) normal and color but 
00077 we have to build the type a step a time (deriving from a single ancestor at a time). 
00078 
00079 
00080 */ 
00081 template <class BVT, class BET=DumET, class BFT=DumFT, class BTT=DumTT>
00082 class TetraBase: public  tetra::EmptyVertexRef<
00083                          tetra::EmptyAdj<
00084                          TetraTypeHolder <BVT, BET, BFT, BTT> > > {
00085 };
00086 
00087 
00088 
00089 // Metaprogramming Core
00090 
00091 template <class BVT, class BET, class BFT,class BTT,
00092           template <typename> class A> 
00093           class TetraArity1: public A<TetraBase<BVT,BET,BFT,BTT> > {};
00094 
00095 template <class BVT, class BET, typename BFT, class BTT,
00096           template <typename> class A, template <typename> class B> 
00097           class TetraArity2: public B<TetraArity1<BVT,BET,BFT,BTT, A> > {};
00098 
00099 template <class BVT, class BET, typename BFT,class BTT,
00100           template <typename> class A, template <typename> class B, 
00101           template <typename> class C > 
00102           class TetraArity3: public C<TetraArity2<BVT,BET,BFT,BTT, A, B> > {};
00103 
00104 template <class BVT, class BET, typename BFT,class BTT,
00105           template <typename> class A, template <typename> class B, 
00106           template <typename> class C, template <typename> class D> 
00107           class TetraArity4: public D<TetraArity3<BVT,BET,BFT,BTT, A, B, C> > {};
00108 
00109 template <class BVT, class BET, typename BFT,class BTT,
00110           template <typename> class A, template <typename> class B, 
00111           template <typename> class C, template <typename> class D,
00112           template <typename> class E > 
00113           class TetraArity5: public E<TetraArity4<BVT,BET,BFT,BTT, A, B, C, D> > {};
00114 
00115 template <class BVT, class BET, typename BFT,class BTT,
00116           template <typename> class A, template <typename> class B, 
00117           template <typename> class C, template <typename> class D,
00118           template <typename> class E, template <typename> class F > 
00119           class TetraArity6: public F<TetraArity5<BVT,BET,BFT,BTT, A, B, C, D, E> > {};
00120 
00121 template <class BVT, class BET, typename BFT,class BTT,
00122           template <typename> class A, template <typename> class B, 
00123           template <typename> class C, template <typename> class D,
00124           template <typename> class E, template <typename> class F, 
00125           template <typename> class G  > 
00126           class TetraArity7: public G<TetraArity6<BVT,BET,BFT,BTT, A, B, C, D, E, F> > {};
00127 
00128 template <class BVT, class BET, typename BFT,class BTT,
00129           template <typename> class A, template <typename> class B, 
00130           template <typename> class C, template <typename> class D,
00131           template <typename> class E, template <typename> class F, 
00132           template <typename> class G, template <typename> class H  > 
00133           class TetraArity8: public H<TetraArity7<BVT,BET,BFT,BTT, A, B, C, D, E, F, G> > {};
00134 
00135 /* The Real Big Face class;
00136 
00137 The class __FaceArityMax__ is the one that is the Last to be derived,
00138 and therefore is the only one to know the real members 
00139 (after the many overrides) so all the functions with common behaviour 
00140 using the members defined in the various Empty/nonEmpty component classes 
00141 MUST be defined here. 
00142 
00143 I.e. IsD() that uses the overridden Flags() member must be defined here.
00144 
00145 */
00146 
00147 template <class BVT, class BET, typename BFT,class BTT,
00148           template <typename> class A, template <typename> class B, 
00149           template <typename> class C, template <typename> class D, 
00150           template <typename> class E, template <typename> class F,
00151           template <typename> class G, template <typename> class H,
00152           template <typename> class I  > 
00153           class TetraArityMax: public I<TetraArity8<BVT,BET,BFT,BTT, A, B, C, D, E, F, G, H> > {
00154 
00155 // ----- Flags stuff -----
00156 public:
00157   
00158         enum { 
00159                 
00160                 DELETED     = 0x00000001,               // Face is deleted from the mesh
00161                 NOTREAD     = 0x00000002,               // Face of the mesh is not readable
00162                 NOTWRITE    = 0x00000004,               // Face of the mesh is not writable
00163     VISITED     = 0x00000010,           // Face has been visited. Usualy this is a per-algorithm used bit. 
00164                 SELECTED    = 0x00000020,               // Face is selected. Algorithms should try to work only on selected face (if explicitly requested)
00165                 // Border _flags, it is assumed that BORDERi = BORDER0<<i 
00166                 BORDER0     = 0x00000040,
00167                 BORDER1     = 0x00000080,
00168                 BORDER2     = 0x00000100,
00169                 BORDER3     = 0x00000200,
00170                 // Crease _flags,  it is assumed that FEATUREi = FEATURE0<<i 
00171                 // First user bit
00172                 USER0       = 0x00004000
00173                         };
00174 
00175  
00177         bool IsD() const {return (this->Flags() & DELETED) != 0;}
00179         bool IsR() const {return (this->Flags() & NOTREAD) == 0;}
00181         bool IsW() const {return (this->Flags() & NOTWRITE)== 0;}
00183         bool IsRW() const {return (this->Flags() & (NOTREAD | NOTWRITE)) == 0;}
00185         bool IsS() const {return (this->Flags() & SELECTED) != 0;}
00187         bool IsV() const {return (this->Flags() & VISITED) != 0;}
00188         
00192         void SetFlags(int flagp) {this->Flags()=flagp;}
00193 
00197         void ClearFlags() {this->Flags()=0;}
00198 
00200         void SetD() {this->Flags() |=DELETED;}
00202         void ClearD() {this->Flags() &=(~DELETED);}
00204         void SetR() {this->Flags() &=(~NOTREAD);}
00206         void ClearR() {this->Flags() |=NOTREAD;}
00208         void SetW() {this->Flags() &=(~NOTWRITE);}
00210         void ClearW() {this->Flags() |=NOTWRITE;}
00212         void SetS()             {this->Flags() |=SELECTED;}
00214   void ClearS() {this->Flags() &= ~SELECTED;}
00216         void SetV()             {this->Flags() |=VISITED;}
00218   void ClearV() {this->Flags() &= ~VISITED;}
00219         
00221         bool IsB(int i) const {return (this->Flags() & (BORDER0<<i)) != 0;}
00223   void SetB(int i)              {this->Flags() |=(BORDER0<<i);}
00225         void ClearB(int i)      {this->Flags() &= (~(BORDER0<<i));}
00226         
00228         static int &FirstUnusedBitFlag()
00229         {
00230           static int b =USER0;
00231           return b;
00232         }
00233 
00235         static inline int NewBitFlag()
00236         {
00237           int bitForTheUser = FirstUnusedBitFlag();
00238           FirstUnusedBitFlag()=FirstUnusedBitFlag()<<1;
00239           return bitForTheUser;
00240         }
00241 
00243         // Note you must deallocate bit in the inverse order of the allocation (as in a stack)
00244         static inline bool DeleteBitFlag(int bitval)
00245         {
00246           if(FirstUnusedBitFlag()>>1==bitval) {
00247                 FirstUnusedBitFlag() = FirstUnusedBitFlag()>>1;
00248                 return true;
00249           }
00250           assert(0);
00251           return false;
00252         }
00253 
00255         bool IsUserBit(int userBit){return (this->Flags() & userBit) != 0;}
00256 
00258         void SetUserBit(int userBit){this->Flags() |=userBit;}
00259 
00261         void ClearUserBit(int userBit){this->Flags() &= (~userBit);}
00262 
00263  template<class BoxType>
00264   void GetBBox( BoxType & bb ) const
00265   {
00266           bb.Set(this->P(0));
00267           bb.Add(this->P(1));
00268           bb.Add(this->P(2));
00269   }
00270 
00271 
00272 };
00273 
00274 template < typename T=int>
00275 class TetraDefaultDeriver : public T {};
00276           
00277 /*
00278 
00279 These are the three main classes that are used by the library user to define its own Facees.
00280 The user MUST specify the names of all the type involved in a generic complex.
00281 so for example when defining a Face of a trimesh you must know the name of the type of the edge and of the face.
00282 Typical usage example:
00283 
00284 A Face with coords, flags and normal for use in a standard trimesh:
00285 
00286 class MyFaceNf   : public FaceSimp2< VertProto, EdgeProto, MyFaceNf, face::Flag, face::Normal3f  > {};
00287 
00288 
00289 A Face with coords, and normal for use in a tetrahedral mesh AND in a standard trimesh:
00290 
00291 class TetraFace   : public FaceSimp3< VertProto, EdgeProto, TetraFace, TetraProto, face::Coord3d, face::Normal3f  > {};
00292 
00293 
00294 A summary of the components that can be added to a face (see components.h for details):
00295           
00296 VertexRef
00297 Mark                                            //Incremental mark (int)
00298 VTAdj                                           //Topology vertex face adjacency
00299                                                  (pointers to next face in the ring of the vertex
00300 TTAdj                                           //topology: face face adj
00301                                                   pointers to adjacent faces
00302 
00303 */
00304 
00305 template <class BVT, class BET, class BFT, class BTT,
00306           template <typename> class A = TetraDefaultDeriver, template <typename> class B = TetraDefaultDeriver,
00307           template <typename> class C = TetraDefaultDeriver, template <typename> class D = TetraDefaultDeriver,
00308           template <typename> class E = TetraDefaultDeriver, template <typename> class F = TetraDefaultDeriver,
00309           template <typename> class G = TetraDefaultDeriver, template <typename> class H = TetraDefaultDeriver,
00310           template <typename> class I = TetraDefaultDeriver > 
00311               class TetraSimp3: public TetraArityMax<BVT,BET,BFT,BTT, A, B, C, D, E, F, G, H, I>  {};
00312 class DumTT;
00313 template <class BVT, class BET, class BFT, 
00314           template <typename> class A = TetraDefaultDeriver, template <typename> class B = TetraDefaultDeriver,
00315           template <typename> class C = TetraDefaultDeriver, template <typename> class D = TetraDefaultDeriver,
00316           template <typename> class E = TetraDefaultDeriver, template <typename> class F = TetraDefaultDeriver,
00317           template <typename> class G = TetraDefaultDeriver, template <typename> class H = TetraDefaultDeriver,
00318           template <typename> class I = TetraDefaultDeriver > 
00319               class TetraSimp2: public TetraArityMax<BVT,BET,BFT,DumTT, A, B, C, D, E, F, G, H, I>  {};
00320 
00321 
00322 }// end namespace
00323 #endif
00324 


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