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.12 2008/03/17 11:39:14 ganovelli 00028 added curvature and curvatruredir (compiled .net 2005 and gcc) 00029 00030 Revision 1.11 2008/02/04 21:26:49 ganovelli 00031 added ImportData which imports all local attributes into vertexplus and faceplus. 00032 A local attribute is everything (N(), C(), Q()....) except pointers to other simplices 00033 (i.e. FFAdj, VFAdj, VertexRef) which are set to NULL. 00034 Added some function for const attributes 00035 00036 Revision 1.10 2007/03/12 15:37:21 tarini 00037 Texture coord name change! "TCoord" and "Texture" are BAD. "TexCoord" is GOOD. 00038 00039 Revision 1.9 2007/02/12 19:00:56 ganovelli 00040 added Name(std:vector<std::string>& n) that fills n with the names of the attribute of the vertex type 00041 00042 Revision 1.8 2006/09/28 17:34:11 cignoni 00043 Added Missing GetBBox function 00044 00045 Revision 1.7 2006/02/27 17:42:43 ponchio 00046 Added some documentation. 00047 00048 Revision 1.6 2005/12/05 15:58:10 cignoni 00049 Removed spurious definition of flags in Aritymax that was overriding the correct definition in EmplyBitFlags and BitFlags classes 00050 00051 Revision 1.5 2005/12/02 00:44:41 cignoni 00052 Reformatted and compacted flags code. 00053 00054 Revision 1.4 2005/11/16 22:59:35 cignoni 00055 Standardized name of flags. It is plural becouse each simplex has many flag. 00056 00057 Revision 1.3 2005/11/12 18:36:51 cignoni 00058 Added 'Visited' flag functions 00059 00060 Revision 1.2 lags2004/04/03 13:33:55 cignoni 00061 Missing include 00062 00063 Revision 1.1 2004/03/29 08:36:26 cignoni 00064 First working version! 00065 00066 00067 ****************************************************************************/ 00068 #ifndef __VCG_VERTEX_PLUS 00069 #define __VCG_VERTEX_PLUS 00070 00071 //#include <vcg/space/point3.h> 00072 #include <vcg/space/texcoord2.h> 00073 #include <vcg/space/color4.h> 00074 #include <vcg/complex/all_types.h> 00075 #include <vcg/simplex/vertex/component.h> 00076 //#include <vcg/complex/used_types.h> 00077 #include <vcg/container/derivation_chain.h> 00078 00079 namespace vcg { 00080 00081 /*------------------------------------------------------------------*/ 00082 /* 00083 The base class of all the recusive definition chain. It is just a container of the typenames of the various simplexes. 00084 These typenames must be known form all the derived classes. 00085 */ 00086 // 00087 //template <class BVT, class BET, class BFT, class BTT> 00088 //class VertexTypeHolder{ 00089 // public: 00090 // typedef BVT VertType; 00091 // typedef BET EdgeType; 00092 // typedef BFT FaceType; 00093 // typedef BTT TetraType; 00094 // typedef BVT *VertPointer; 00095 // typedef BET *EdgePointer; 00096 // typedef BFT *FacePointer; 00097 // typedef BTT *TetraPointer; 00098 // template < class LeftV> 00099 // void ImportData(const LeftV & /* left */ ) { } 00100 // static void Name(std::vector<std::string> & /* name */){} 00101 // 00102 //}; 00103 00104 /* The base class form which we start to add our components. 00105 it has the empty definition for all the standard members (coords, color flags) 00106 Note: 00107 in order to avoid both virtual classes and ambiguous definitions all 00108 the subsequent overrides must be done in a sequence of derivation. 00109 00110 In other words we cannot derive and add in a single derivation step 00111 (with multiple ancestor), both the real (non-empty) normal and color but 00112 we have to build the type a step a time (deriving from a single ancestor at a time). 00113 00114 00115 */ 00116 //template <class UserUsedTypes> 00117 //class VertexBase: public vertex::EmptyCore< UserUsedTypes >{ 00118 //}; 00119 00120 00121 /* The Real Big Vertex class; 00122 00123 The class __VertexArityMax__ is the one that is the Last to be derived, 00124 and therefore is the only one to know the real members 00125 (after the many overrides) so all the functions with common behaviour 00126 using the members defined in the various Empty/nonEmpty component classes 00127 MUST be defined here. 00128 00129 I.e. IsD() that uses the overridden Flags() member must be defined here. 00130 00131 */ 00132 00133 template <class UserTypes, 00134 template <typename> class A, template <typename> class B, 00135 template <typename> class C, template <typename> class D, 00136 template <typename> class E, template <typename> class F, 00137 template <typename> class G, template <typename> class H, 00138 template <typename> class I, template <typename> class J, 00139 template <typename> class K, template <typename> class L> 00140 class VertexArityMax: public Arity12<vertex::EmptyCore<UserTypes>, A, B, C, D, E, F, G, H, I, J, K, L> { 00141 00142 // ----- Flags stuff ----- 00143 public: 00144 00145 00146 00147 enum { 00148 00149 DELETED = 0x0001, // This bit indicate that the vertex is deleted from the mesh 00150 NOTREAD = 0x0002, // This bit indicate that the vertex of the mesh is not readable 00151 NOTWRITE = 0x0004, // This bit indicate that the vertex is not modifiable 00152 MODIFIED = 0x0008, // This bit indicate that the vertex is modified 00153 VISITED = 0x0010, // This bit can be used to mark the visited vertex 00154 SELECTED = 0x0020, // This bit can be used to select 00155 BORDER = 0x0100, // Border Flag 00156 USER0 = 0x0200 // First user bit 00157 }; 00158 00159 inline int & UberFlags () { return this->Flags(); } 00160 inline int UberFlags() const { return this->Flags(); } 00161 00162 bool IsD() const {return (this->Flags() & DELETED) != 0;} 00163 bool IsR() const {return (this->Flags() & NOTREAD) == 0;} 00164 bool IsW() const {return (this->Flags() & NOTWRITE)== 0;} 00165 bool IsRW() const {return (this->Flags() & (NOTREAD | NOTWRITE)) == 0;} 00166 bool IsS() const {return (this->Flags() & SELECTED) != 0;} 00167 bool IsB() const {return (this->Flags() & BORDER) != 0;} 00168 bool IsV() const {return (this->Flags() & VISITED) != 0;} 00169 00170 00174 void SetFlags(int flagp) {this->Flags()=flagp;} 00175 00179 void ClearFlags() {this->Flags()=0;} 00180 void SetD() {this->Flags() |=DELETED;} 00181 void ClearD() {this->Flags() &=(~DELETED);} 00182 void SetR() {this->Flags() &=(~NOTREAD);} 00183 void ClearR() {this->Flags() |=NOTREAD;} 00184 void ClearW() {this->Flags() |=NOTWRITE;} 00185 void SetW() {this->Flags() &=(~NOTWRITE);} 00186 void SetS() {this->Flags() |=SELECTED;} 00187 void ClearS() {this->Flags() &= ~SELECTED;} 00188 void SetB() {this->Flags() |=BORDER;} 00189 void ClearB() {this->Flags() &=~BORDER;} 00190 void SetV() {this->Flags() |=VISITED;} 00191 void ClearV() {this->Flags() &=~VISITED;} 00192 00194 static int &LastBitFlag() 00195 { 00196 static int b =USER0; 00197 return b; 00198 } 00199 00201 static inline int NewBitFlag() 00202 { 00203 LastBitFlag()=LastBitFlag()<<1; 00204 return LastBitFlag(); 00205 } 00206 // de-allocate a bit among the flags that can be used by user. 00207 static inline bool DeleteBitFlag(int bitval) 00208 { 00209 if(LastBitFlag()==bitval) { 00210 LastBitFlag()= LastBitFlag()>>1; 00211 return true; 00212 } 00213 assert(0); 00214 return false; 00215 } 00217 bool IsUserBit(int userBit){return (this->Flags() & userBit) != 0;} 00219 void SetUserBit(int userBit){this->Flags() |=userBit;} 00221 void ClearUserBit(int userBit){this->Flags() &= (~userBit);} 00222 00223 template<class BoxType> 00224 void GetBBox( BoxType & bb ) const 00225 { bb.Set(this->P()); } 00226 00227 }; 00228 00229 00230 /* 00231 00232 These are the three main classes that are used by the library user to define its own vertexes. 00233 The user MUST specify the names of all the type involved in a generic complex. 00234 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. 00235 Typical usage example: 00236 00237 A vertex with coords, flags and normal for use in a standard trimesh: 00238 00239 class VertexNf : public VertexSimp2< VertexNf, EdgeProto, FaceProto, vert::Coord3d, vert::Flag, vert::Normal3f > {}; 00240 00241 00242 A vertex with coords, and normal for use in a tetrahedral mesh AND in a standard trimesh: 00243 00244 class TetraVertex : public VertexSimp3< TetraVertex, EdgeProto, FaceProto, TetraProto, vert::Coord3d, vert::Normal3f > {}; 00245 00246 00247 A summary of the available vertex attributes (see component.h for more details): 00248 00249 Coord3f, Coord3d, 00250 Normal3s, Normal3f, Normal3d 00251 Mark //a int component (incremental mark) 00252 BitFlags 00253 TexCoord2s, TexCoord2f, TexCoord2d 00254 Color4b 00255 Qualitys, Qualityf, Qualityd 00256 VFAdj //topology (vertex->face adjacency) 00257 */ 00258 00259 template <class UserTypes, 00260 template <typename> class A = DefaultDeriver, template <typename> class B = DefaultDeriver, 00261 template <typename> class C = DefaultDeriver, template <typename> class D = DefaultDeriver, 00262 template <typename> class E = DefaultDeriver, template <typename> class F = DefaultDeriver, 00263 template <typename> class G = DefaultDeriver, template <typename> class H = DefaultDeriver, 00264 template <typename> class I = DefaultDeriver, template <typename> class J = DefaultDeriver, 00265 template <typename> class K = DefaultDeriver, template <typename> class L = DefaultDeriver> 00266 class Vertex: public VertexArityMax<UserTypes, A, B, C, D, E, F, G, H, I, J, K, L> { 00267 public: typedef AllTypes::AVertexType IAm; typedef UserTypes TypesPool;}; 00268 00269 }// end namespace 00270 #endif