From 4cb1fbaaf8580d0d7ed8fd6999270d7b9216238e Mon Sep 17 00:00:00 2001 From: cignoni Date: Sat, 12 Jul 2014 10:52:59 +0000 Subject: [PATCH] Raised the upper limit of the template derivation chain for face --- vcg/simplex/face/base.h | 296 ++++++++++++++++++++-------------------- 1 file changed, 149 insertions(+), 147 deletions(-) diff --git a/vcg/simplex/face/base.h b/vcg/simplex/face/base.h index 01d1b171..83f4aa7e 100644 --- a/vcg/simplex/face/base.h +++ b/vcg/simplex/face/base.h @@ -8,7 +8,7 @@ * \ * * All rights reserved. * * * -* This program is free software; you can redistribute it and/or modify * +* This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * @@ -28,18 +28,18 @@ namespace vcg { -/*------------------------------------------------------------------*/ -/* +/*------------------------------------------------------------------*/ +/* The base class of all the recusive definition chain. It is just a container of the typenames of the various simplexes. These typenames must be known form all the derived classes. */ template - class FaceTypeHolder: public UserTypes { + class FaceTypeHolder: public UserTypes { public: - template - void ImportData(const LeftF & ){} + template + void ImportData(const LeftF & ){} static void Name(std::vector & /* name */){} @@ -47,186 +47,187 @@ template inline int VN() const { return 3;} inline int Prev(const int & i) const { return (i+(3-1))%3;} inline int Next(const int & i) const { return (i+1)%3;} - inline void Alloc(const int & ){} - inline void Dealloc(){} + inline void Alloc(const int & ){} + inline void Dealloc(){} }; /* The base class form which we start to add our components. it has the empty definition for all the standard members (coords, color flags) Note: -in order to avoid both virtual classes and ambiguous definitions all +in order to avoid both virtual classes and ambiguous definitions all the subsequent overrides must be done in a sequence of derivation. -In other words we cannot derive and add in a single derivation step -(with multiple ancestor), both the real (non-empty) normal and color but -we have to build the type a step a time (deriving from a single ancestor at a time). +In other words we cannot derive and add in a single derivation step +(with multiple ancestor), both the real (non-empty) normal and color but +we have to build the type a step a time (deriving from a single ancestor at a time). -*/ +*/ template class FaceBase: public - face::EmptyCore< FaceTypeHolder > { + face::EmptyCore< FaceTypeHolder > { }; /* The Real Big Face class; The class __FaceArityMax__ is the one that is the Last to be derived, -and therefore is the only one to know the real members -(after the many overrides) so all the functions with common behaviour -using the members defined in the various Empty/nonEmpty component classes -MUST be defined here. +and therefore is the only one to know the real members +(after the many overrides) so all the functions with common behaviour +using the members defined in the various Empty/nonEmpty component classes +MUST be defined here. I.e. IsD() that uses the overridden Flags() member must be defined here. */ template < class UserTypes, - template class A, template class B, - template class C, template class D, + template class A, template class B, + template class C, template class D, template class E, template class F, template class G, template class H, - template class I, template class J > - class FaceArityMax: public J, A, B, C, D, E, F, G, H, I> > { + template class I, template class J, + template class K, template class L > + class FaceArityMax: public L, A, B, C, D, E, F, G, H, I, J, K> > { public: - typedef typename FaceArityMax::ScalarType ScalarType; + typedef typename FaceArityMax::ScalarType ScalarType; // ----- Flags stuff ----- - enum { - - DELETED = 0x00000001, // Face is deleted from the mesh - NOTREAD = 0x00000002, // Face of the mesh is not readable - NOTWRITE = 0x00000004, // Face of the mesh is not writable - VISITED = 0x00000010, // Face has been visited. Usualy this is a per-algorithm used bit. - SELECTED = 0x00000020, // Face is selected. Algorithms should try to work only on selected face (if explicitly requested) - // Border _flags, it is assumed that BORDERi = BORDER0<cFlags() & DELETED) != 0;} - /// checks if the Face is readable - bool IsR() const {return (this->cFlags() & NOTREAD) == 0;} - /// checks if the Face is modifiable - bool IsW() const {return (this->cFlags() & NOTWRITE)== 0;} - /// This funcion checks whether the Face is both readable and modifiable - bool IsRW() const {return (this->cFlags() & (NOTREAD | NOTWRITE)) == 0;} - /// checks if the Face is Modified - bool IsS() const {return (this->cFlags() & SELECTED) != 0;} - /// checks if the Face is Modified - bool IsV() const {return (this->cFlags() & VISITED) != 0;} - - /** Set the flag value - @param flagp Valore da inserire nel flag - */ - void SetFlags(int flagp) {this->Flags()=flagp;} + /// checks if the Face is readable + bool IsR() const {return (this->cFlags() & NOTREAD) == 0;} + /// checks if the Face is modifiable + bool IsW() const {return (this->cFlags() & NOTWRITE)== 0;} + /// This funcion checks whether the Face is both readable and modifiable + bool IsRW() const {return (this->cFlags() & (NOTREAD | NOTWRITE)) == 0;} + /// checks if the Face is Modified + bool IsS() const {return (this->cFlags() & SELECTED) != 0;} + /// checks if the Face is Modified + bool IsV() const {return (this->cFlags() & VISITED) != 0;} - /** Set the flag value - @param flagp Valore da inserire nel flag - */ - void ClearFlags() {this->Flags()=0;} + /** Set the flag value + @param flagp Valore da inserire nel flag + */ + void SetFlags(int flagp) {this->Flags()=flagp;} - /// deletes the Face from the mesh - void SetD() {this->Flags() |=DELETED;} - /// un-delete a Face - void ClearD() {this->Flags() &=(~DELETED);} - /// marks the Face as readable - void SetR() {this->Flags() &=(~NOTREAD);} - /// marks the Face as not readable - void ClearR() {this->Flags() |=NOTREAD;} - /// marks the Face as writable - void SetW() {this->Flags() &=(~NOTWRITE);} - /// marks the Face as notwritable - void ClearW() {this->Flags() |=NOTWRITE;} - /// select the Face - void SetS() {this->Flags() |=SELECTED;} - /// Un-select a Face + /** Set the flag value + @param flagp Valore da inserire nel flag + */ + void ClearFlags() {this->Flags()=0;} + + /// deletes the Face from the mesh + void SetD() {this->Flags() |=DELETED;} + /// un-delete a Face + void ClearD() {this->Flags() &=(~DELETED);} + /// marks the Face as readable + void SetR() {this->Flags() &=(~NOTREAD);} + /// marks the Face as not readable + void ClearR() {this->Flags() |=NOTREAD;} + /// marks the Face as writable + void SetW() {this->Flags() &=(~NOTWRITE);} + /// marks the Face as notwritable + void ClearW() {this->Flags() |=NOTWRITE;} + /// select the Face + void SetS() {this->Flags() |=SELECTED;} + /// Un-select a Face void ClearS() {this->Flags() &= ~SELECTED;} - /// select the Face - void SetV() {this->Flags() |=VISITED;} - /// Un-select a Face + /// select the Face + void SetV() {this->Flags() |=VISITED;} + /// Un-select a Face void ClearV() {this->Flags() &= ~VISITED;} - - /// This function checks if the face is selected - bool IsB(int i) const {return (this->cFlags() & (BORDER0<cFlags() & (BORDER0<Flags() |=(BORDER0<Flags() &= (~(BORDER0<Flags() &= (~(BORDER0<cFlags() & (CREASE0<Flags() |=(CREASE0<Flags() &= (~(CREASE0<cFlags() & (CREASE0<Flags() |=(CREASE0<Flags() &= (~(CREASE0<cFlags() & (FAUX0<cFlags() & (FAUX0|FAUX1|FAUX2)) != 0;} - /// This function select the face - void SetF(int i) {this->Flags() |=(FAUX0<Flags() &= (~(FAUX0<Flags() &= (~(FAUX0|FAUX1|FAUX2)); } - - /// Return the first bit that is not still used - static int &FirstUnusedBitFlag() - { - static int b =USER0; - return b; - } + /// This function checks if a given side of the face is a feature/internal edge + /// it is used by some importer to mark internal + /// edges of polygonal faces that have been triangulated + bool IsF(int i) const {return (this->cFlags() & (FAUX0<cFlags() & (FAUX0|FAUX1|FAUX2)) != 0;} + /// This function select the face + void SetF(int i) {this->Flags() |=(FAUX0<Flags() &= (~(FAUX0<Flags() &= (~(FAUX0|FAUX1|FAUX2)); } - /// Allocate a bit among the flags that can be used by user. It updates the FirstUnusedBitFlag. - static inline int NewBitFlag() - { - int bitForTheUser = FirstUnusedBitFlag(); - FirstUnusedBitFlag()=FirstUnusedBitFlag()<<1; - return bitForTheUser; - } + /// Return the first bit that is not still used + static int &FirstUnusedBitFlag() + { + static int b =USER0; + return b; + } - /// De-allocate a pre allocated bit. It updates the FirstUnusedBitFlag. - // Note you must deallocate bit in the inverse order of the allocation (as in a stack) - static inline bool DeleteBitFlag(int bitval) - { - if(FirstUnusedBitFlag()>>1==bitval) { - FirstUnusedBitFlag() = FirstUnusedBitFlag()>>1; - return true; - } - assert(0); - return false; - } + /// Allocate a bit among the flags that can be used by user. It updates the FirstUnusedBitFlag. + static inline int NewBitFlag() + { + int bitForTheUser = FirstUnusedBitFlag(); + FirstUnusedBitFlag()=FirstUnusedBitFlag()<<1; + return bitForTheUser; + } - /// This function checks if the given user bit is true - bool IsUserBit(int userBit){return (this->Flags() & userBit) != 0;} + /// De-allocate a pre allocated bit. It updates the FirstUnusedBitFlag. + // Note you must deallocate bit in the inverse order of the allocation (as in a stack) + static inline bool DeleteBitFlag(int bitval) + { + if(FirstUnusedBitFlag()>>1==bitval) { + FirstUnusedBitFlag() = FirstUnusedBitFlag()>>1; + return true; + } + assert(0); + return false; + } - /// This function set the given user bit - void SetUserBit(int userBit){this->Flags() |=userBit;} + /// This function checks if the given user bit is true + bool IsUserBit(int userBit){return (this->Flags() & userBit) != 0;} - /// This function clear the given user bit - void ClearUserBit(int userBit){this->Flags() &= (~userBit);} + /// This function set the given user bit + void SetUserBit(int userBit){this->Flags() |=userBit;} + + /// This function clear the given user bit + void ClearUserBit(int userBit){this->Flags() &= (~userBit);} void GetBBox(Box3& bb ) const @@ -262,7 +263,7 @@ class TetraFace : public FaceSimp3< VertProto, EdgeProto, TetraFace, TetraProt A summary of the components that can be added to a face (see components.h for details): - + VertexRef NormalFromVert, WedgeNormal Normal3s, Normal3f, Normal3d @@ -283,9 +284,10 @@ template class C = DefaultDeriver, template class D = DefaultDeriver, template class E = DefaultDeriver, template class F = DefaultDeriver, template class G = DefaultDeriver, template class H = DefaultDeriver, - template class I = DefaultDeriver, template class J = DefaultDeriver > - class Face: public FaceArityMax { - public: typedef AllTypes::AFaceType IAm; typedef UserTypes TypesPool;}; + template class I = DefaultDeriver, template class J = DefaultDeriver, + template class K = DefaultDeriver, template class L = DefaultDeriver > + class Face: public FaceArityMax { + public: typedef AllTypes::AFaceType IAm; typedef UserTypes TypesPool;}; }// end namespace