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_FACE_PLUS
00027 #define __VCG_FACE_PLUS
00028 
00029 namespace vcg {
00030 
00031 /*------------------------------------------------------------------*/
00032 /*
00033 The base class of all the recusive definition chain. It is just a container of the typenames of the various simplexes.
00034 These typenames must be known form all the derived classes.
00035 */
00036 
00037 template <class UserTypes>
00038                 class FaceTypeHolder: public UserTypes {
00039   public:
00040 
00041     template <class LeftF>
00042     void ImportData(const LeftF & ){}
00043     static void Name(std::vector<std::string> & /* name */){}
00044 
00045 
00046  // prot
00047         inline int VN()  const { return 3;}
00048         inline int Prev(const int & i) const { return (i+(3-1))%3;}
00049         inline int Next(const int & i) const { return (i+1)%3;}
00050     inline void Alloc(const int & ){}
00051     inline void Dealloc(){}
00052 };
00053 
00054 /* The base class form which we start to add our components.
00055 it has the empty definition for all the standard members (coords, color flags)
00056 Note:
00057 in order to avoid both virtual classes and ambiguous definitions all
00058 the subsequent overrides must be done in a sequence of derivation.
00059 
00060 In other words we cannot derive and add in a single derivation step
00061 (with multiple ancestor), both the real (non-empty) normal and color but
00062 we have to build the type a step a time (deriving from a single ancestor at a time).
00063 
00064 
00065 */
00066 template <class UserTypes>
00067 class FaceBase: public
00068             face::EmptyCore< FaceTypeHolder <UserTypes> > {
00069 };
00070 
00071 
00072 /* The Real Big Face class;
00073 
00074 The class __FaceArityMax__ is the one that is the Last to be derived,
00075 and therefore is the only one to know the real members
00076 (after the many overrides) so all the functions with common behaviour
00077 using the members defined in the various Empty/nonEmpty component classes
00078 MUST be defined here.
00079 
00080 I.e. IsD() that uses the overridden Flags() member must be defined here.
00081 
00082 */
00083 
00084 template < class UserTypes,
00085           template <typename> class A, template <typename> class B,
00086           template <typename> class C, template <typename> class D,
00087           template <typename> class E, template <typename> class F,
00088           template <typename> class G, template <typename> class H,
00089           template <typename> class I, template <typename> class J,
00090           template <typename> class K, template <typename> class L >
00091                     class FaceArityMax: public L<Arity11<FaceBase<UserTypes>, A, B, C, D, E, F, G, H, I, J, K> > {
00092 
00093 public:
00094     typedef typename  FaceArityMax::ScalarType ScalarType;
00095 // ----- Flags stuff -----
00096 
00097     enum {
00098 
00099         DELETED     = 0x00000001,               // Face is deleted from the mesh
00100         NOTREAD     = 0x00000002,               // Face of the mesh is not readable
00101         NOTWRITE    = 0x00000004,               // Face of the mesh is not writable
00102     VISITED     = 0x00000010,           // Face has been visited. Usualy this is a per-algorithm used bit.
00103         SELECTED    = 0x00000020,               // Face is selected. Algorithms should try to work only on selected face (if explicitly requested)
00104         // Border _flags, it is assumed that BORDERi = BORDER0<<i
00105         BORDER0     = 0x00000040,
00106         BORDER1     = 0x00000080,
00107         BORDER2     = 0x00000100,
00108         BORDER012     = BORDER0 | BORDER1 | BORDER2 ,
00109         // Face Orientation Flags, used efficiently compute point face distance
00110         NORMX                           = 0x00000200,
00111         NORMY                           = 0x00000400,
00112         NORMZ                           = 0x00000800,
00113         // Crease _flags,  it is assumed that CREASEi = CREASE0<<i
00114         CREASE0    = 0x00008000,
00115         CREASE1    = 0x00010000,
00116         CREASE2    = 0x00020000,
00117         // Faux edges. (semantics: when a mesh is polygonal, edges which are inside a polygonal face are "faux"
00118         FAUX0       = 0x00040000,
00119         FAUX1       = 0x00080000,
00120         FAUX2       = 0x00100000,
00121         FAUX012     = FAUX0 | FAUX1 | FAUX2 ,
00122         // First user bit
00123         USER0       = 0x00200000
00124             };
00125 
00126 
00128     bool IsD() const {return (this->cFlags() & DELETED) != 0;}
00130     bool IsR() const {return (this->cFlags() & NOTREAD) == 0;}
00132     bool IsW() const {return (this->cFlags() & NOTWRITE)== 0;}
00134     bool IsRW() const {return (this->cFlags() & (NOTREAD | NOTWRITE)) == 0;}
00136     bool IsS() const {return (this->cFlags() & SELECTED) != 0;}
00138     bool IsV() const {return (this->cFlags() & VISITED) != 0;}
00139 
00143     void SetFlags(int flagp) {this->Flags()=flagp;}
00144 
00148     void ClearFlags() {this->Flags()=0;}
00149 
00151     void SetD() {this->Flags() |=DELETED;}
00153     void ClearD() {this->Flags() &=(~DELETED);}
00155     void SetR() {this->Flags() &=(~NOTREAD);}
00157     void ClearR() {this->Flags() |=NOTREAD;}
00159     void SetW() {this->Flags() &=(~NOTWRITE);}
00161     void ClearW() {this->Flags() |=NOTWRITE;}
00163     void SetS()         {this->Flags() |=SELECTED;}
00165   void ClearS() {this->Flags() &= ~SELECTED;}
00167     void SetV()         {this->Flags() |=VISITED;}
00169   void ClearV() {this->Flags() &= ~VISITED;}
00170 
00172     bool IsB(int i) const {return (this->cFlags() & (BORDER0<<i)) != 0;}
00174   void SetB(int i)              {this->Flags() |=(BORDER0<<i);}
00176     void ClearB(int i)  {this->Flags() &= (~(BORDER0<<i));}
00177 
00179     bool IsCrease(int i) const {return (this->cFlags() & (CREASE0<<i)) != 0;}
00181     void SetCrease(int i){this->Flags() |=(CREASE0<<i);}
00183     void ClearCrease(int i)     {this->Flags() &= (~(CREASE0<<i));}
00184 
00188     bool IsF(int i) const {return (this->cFlags() & (FAUX0<<i) ) != 0;}
00189     bool IsAnyF() const {return (this->cFlags() & (FAUX0|FAUX1|FAUX2)) != 0;}
00191     void SetF(int i)            {this->Flags() |=(FAUX0<<i);}
00193     void ClearF(int i)  {this->Flags() &= (~(FAUX0<<i));}
00194     void ClearAllF() { this->Flags() &= (~(FAUX0|FAUX1|FAUX2)); }
00195 
00197     static int &FirstUnusedBitFlag()
00198     {
00199       static int b =USER0;
00200       return b;
00201     }
00202 
00204     static inline int NewBitFlag()
00205     {
00206       int bitForTheUser = FirstUnusedBitFlag();
00207       FirstUnusedBitFlag()=FirstUnusedBitFlag()<<1;
00208       return bitForTheUser;
00209     }
00210 
00212     // Note you must deallocate bit in the inverse order of the allocation (as in a stack)
00213     static inline bool DeleteBitFlag(int bitval)
00214     {
00215       if(FirstUnusedBitFlag()>>1==bitval) {
00216         FirstUnusedBitFlag() = FirstUnusedBitFlag()>>1;
00217         return true;
00218       }
00219       assert(0);
00220       return false;
00221     }
00222 
00224     bool IsUserBit(int userBit){return (this->Flags() & userBit) != 0;}
00225 
00227     void SetUserBit(int userBit){this->Flags() |=userBit;}
00228 
00230     void ClearUserBit(int userBit){this->Flags() &= (~userBit);}
00231 
00232 
00233   void GetBBox(Box3<ScalarType>& bb ) const
00234   {
00235     if(this->IsD()) {
00236         bb.SetNull();
00237         return;
00238       }
00239         bb.Set(this->cP(0));
00240         bb.Add(this->cP(1));
00241         bb.Add(this->cP(2));
00242   }
00243 
00244 
00245 };
00246 
00247 
00248 /*
00249 
00250 These are the three main classes that are used by the library user to define its own Facees.
00251 The user MUST specify the names of all the type involved in a generic complex.
00252 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.
00253 Typical usage example:
00254 
00255 A Face with coords, flags and normal for use in a standard trimesh:
00256 
00257 class MyFaceNf   : public FaceSimp2< VertProto, EdgeProto, MyFaceNf, face::Flag, face::Normal3f  > {};
00258 
00259 
00260 A Face with coords, and normal for use in a tetrahedral mesh AND in a standard trimesh:
00261 
00262 class TetraFace   : public FaceSimp3< VertProto, EdgeProto, TetraFace, TetraProto, face::Coord3d, face::Normal3f  > {};
00263 
00264 
00265 A summary of the components that can be added to a face (see components.h for details):
00266 
00267 VertexRef
00268 NormalFromVert, WedgeNormal
00269 Normal3s, Normal3f, Normal3d
00270 WedgeTexCoord2s, WedgeTexCoord2f, WedgeTexCoord2d
00271 BitFlags
00272 WedgeColor, Color4b
00273 Qualitys, Qualityf, Qualityd
00274 Mark                                            //Incremental mark (int)
00275 VFAdj                                           //Topology vertex face adjacency
00276                                                  (pointers to next face in the ring of the vertex
00277 FFAdj                                           //topology: face face adj
00278                                                   pointers to adjacent faces
00279 
00280 */
00281 
00282 template <class UserTypes,
00283           template <typename> class A = DefaultDeriver, template <typename> class B = DefaultDeriver,
00284           template <typename> class C = DefaultDeriver, template <typename> class D = DefaultDeriver,
00285           template <typename> class E = DefaultDeriver, template <typename> class F = DefaultDeriver,
00286           template <typename> class G = DefaultDeriver, template <typename> class H = DefaultDeriver,
00287           template <typename> class I = DefaultDeriver, template <typename> class J = DefaultDeriver,
00288           template <typename> class K = DefaultDeriver, template <typename> class L = DefaultDeriver >
00289                             class Face: public FaceArityMax<UserTypes, A, B, C, D, E, F, G, H, I, J, K, L>  {
00290                             public: typedef AllTypes::AFaceType IAm; typedef UserTypes TypesPool;};
00291 
00292 
00293 }// end namespace
00294 #endif
00295 


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