Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __VCG_FACE_PLUS_COMPONENT_OCF
00024 #define __VCG_FACE_PLUS_COMPONENT_OCF
00025 #ifndef __VCG_MESH
00026 #error "This file should not be included alone. It is automatically included by complex.h"
00027 #endif
00028
00029 namespace vcg {
00030 namespace face {
00031
00032
00033
00034
00035
00036 template <class VALUE_TYPE>
00037 class vector_ocf: public std::vector<VALUE_TYPE> {
00038 typedef std::vector<VALUE_TYPE> BaseType;
00039 typedef typename vector_ocf<VALUE_TYPE>::iterator ThisTypeIterator;
00040
00041 public:
00042 vector_ocf():std::vector<VALUE_TYPE>()
00043 {
00044 _ColorEnabled=false;
00045 CurvatureDirEnabled = false;
00046 MarkEnabled=false;
00047 NormalEnabled=false;
00048 QualityEnabled=false;
00049 WedgeTexEnabled=false;
00050 WedgeColorEnabled=false;
00051 WedgeNormalEnabled=false;
00052 VFAdjacencyEnabled=false;
00053 FFAdjacencyEnabled=false;
00054 }
00055
00056
00057 struct AdjTypePack {
00058 typename VALUE_TYPE::FacePointer _fp[3] ;
00059 char _zp[3] ;
00060
00061
00062
00063
00064 AdjTypePack() {
00065 _fp[0]=0;
00066 _fp[1]=0;
00067 _fp[2]=0;
00068 }
00069 };
00070
00071
00072 class WedgeTexTypePack {
00073 public:
00074 WedgeTexTypePack() {
00075 wt[0].U()=.5;wt[0].V()=.5;
00076 wt[1].U()=.5;wt[1].V()=.5;
00077 wt[2].U()=.5;wt[2].V()=.5;
00078 wt[0].N()=-1;
00079 wt[1].N()=-1;
00080 wt[2].N()=-1;
00081 }
00082
00083 typename VALUE_TYPE::TexCoordType wt[3];
00084 };
00085
00086 class WedgeColorTypePack {
00087 public:
00088 WedgeColorTypePack() {
00089 typedef typename VALUE_TYPE::ColorType::ScalarType WedgeColorScalarType;
00090 for (int i=0; i<3; ++i)
00091 {
00092 wc[i][0] = WedgeColorScalarType(255);
00093 wc[i][1] = WedgeColorScalarType(255);
00094 wc[i][2] = WedgeColorScalarType(255);
00095 wc[i][3] = WedgeColorScalarType(255);
00096 }
00097 }
00098
00099 typename VALUE_TYPE::ColorType wc[3];
00100 };
00101
00102 class WedgeNormalTypePack {
00103 public:
00104 WedgeNormalTypePack() {
00105 typedef typename VALUE_TYPE::NormalType::ScalarType WedgeNormalScalarType;
00106 for (int i=0; i<3; ++i)
00107 {
00108 wn[i][0] = WedgeNormalScalarType(0);
00109 wn[i][1] = WedgeNormalScalarType(0);
00110 wn[i][2] = WedgeNormalScalarType(1);
00111 }
00112 }
00113
00114 typename VALUE_TYPE::NormalType wn[3];
00115 };
00116
00117
00119
00120
00121 void push_back(const VALUE_TYPE & v)
00122 {
00123 BaseType::push_back(v);
00124 BaseType::back()._ovp = this;
00125 if (QualityEnabled) QV.push_back(0);
00126 if (_ColorEnabled) CV.push_back(vcg::Color4b(vcg::Color4b::White));
00127 if (MarkEnabled) MV.push_back(0);
00128 if (NormalEnabled) NV.push_back(typename VALUE_TYPE::NormalType());
00129 if (CurvatureDirEnabled) CDV.push_back(typename VALUE_TYPE::CurvatureDirType());
00130 if (VFAdjacencyEnabled) AV.push_back(AdjTypePack());
00131 if (FFAdjacencyEnabled) AF.push_back(AdjTypePack());
00132 if (WedgeTexEnabled) WTV.push_back(WedgeTexTypePack());
00133 if (WedgeColorEnabled) WCV.push_back(WedgeColorTypePack());
00134 if (WedgeNormalEnabled) WNV.push_back(WedgeNormalTypePack());
00135 }
00136 void pop_back();
00137 void resize(size_t _size)
00138 {
00139 size_t oldsize = BaseType::size();
00140 BaseType::resize(_size);
00141 if(oldsize<_size){
00142 ThisTypeIterator firstnew = BaseType::begin();
00143 advance(firstnew,oldsize);
00144 _updateOVP(firstnew,(*this).end());
00145 }
00146 if (QualityEnabled) QV.resize(_size,0);
00147 if (_ColorEnabled) CV.resize(_size);
00148 if (MarkEnabled) MV.resize(_size);
00149 if (NormalEnabled) NV.resize(_size);
00150 if (CurvatureDirEnabled)CDV.resize(_size);
00151 if (VFAdjacencyEnabled) AV.resize(_size);
00152 if (FFAdjacencyEnabled) AF.resize(_size);
00153 if (WedgeTexEnabled) WTV.resize(_size,WedgeTexTypePack());
00154 if (WedgeColorEnabled) WCV.resize(_size);
00155 if (WedgeNormalEnabled) WNV.resize(_size);
00156 }
00157 void reserve(size_t _size)
00158 {
00159 BaseType::reserve(_size);
00160
00161 if (QualityEnabled) QV.reserve(_size);
00162 if (_ColorEnabled) CV.reserve(_size);
00163 if (MarkEnabled) MV.reserve(_size);
00164 if (NormalEnabled) NV.reserve(_size);
00165 if (CurvatureDirEnabled)CDV.reserve(_size);
00166 if (VFAdjacencyEnabled) AV.reserve(_size);
00167 if (FFAdjacencyEnabled) AF.reserve(_size);
00168 if (WedgeTexEnabled) WTV.reserve(_size);
00169 if (WedgeColorEnabled) WCV.reserve(_size);
00170 if (WedgeNormalEnabled) WNV.reserve(_size);
00171
00172 if( BaseType::empty()) return ;
00173
00174 ThisTypeIterator oldbegin=(*this).begin();
00175 if(oldbegin!=(*this).begin()) _updateOVP((*this).begin(),(*this).end());
00176 }
00177
00178 void _updateOVP(ThisTypeIterator lbegin, ThisTypeIterator lend)
00179 {
00180 ThisTypeIterator fi;
00181
00182 for(fi=lbegin;fi!=lend;++fi)
00183 (*fi)._ovp=this;
00184 }
00185
00186
00187
00188
00189 void ReorderFace(std::vector<size_t> &newFaceIndex )
00190 {
00191 size_t i=0;
00192 if (QualityEnabled) assert( QV.size() == newFaceIndex.size() );
00193 if (_ColorEnabled) assert( CV.size() == newFaceIndex.size() );
00194 if (MarkEnabled) assert( MV.size() == newFaceIndex.size() );
00195 if (NormalEnabled) assert( NV.size() == newFaceIndex.size() );
00196 if (CurvatureDirEnabled)assert(CDV.size() == newFaceIndex.size() );
00197 if (VFAdjacencyEnabled) assert( AV.size() == newFaceIndex.size() );
00198 if (FFAdjacencyEnabled) assert( AF.size() == newFaceIndex.size() );
00199 if (WedgeTexEnabled) assert(WTV.size() == newFaceIndex.size() );
00200 if (WedgeColorEnabled) assert(WCV.size() == newFaceIndex.size() );
00201 if (WedgeNormalEnabled) assert(WNV.size() == newFaceIndex.size() );
00202
00203 for(i=0;i<newFaceIndex.size();++i)
00204 {
00205 if(newFaceIndex[i] != std::numeric_limits<size_t>::max() )
00206 {
00207 assert(newFaceIndex[i] <= i);
00208 if (QualityEnabled) QV[newFaceIndex[i]] = QV[i];
00209 if (_ColorEnabled) CV[newFaceIndex[i]] = CV[i];
00210 if (MarkEnabled) MV[newFaceIndex[i]] = MV[i];
00211 if (NormalEnabled) NV[newFaceIndex[i]] = NV[i];
00212 if (CurvatureDirEnabled) CDV[newFaceIndex[i]] = CDV[i];
00213 if (VFAdjacencyEnabled) AV[newFaceIndex[i]] = AV[i];
00214 if (FFAdjacencyEnabled) AF[newFaceIndex[i]] = AF[i];
00215 if (WedgeTexEnabled) WTV[newFaceIndex[i]] = WTV[i];
00216 if (WedgeColorEnabled) WCV[newFaceIndex[i]] = WCV[i];
00217 if (WedgeNormalEnabled) WNV[newFaceIndex[i]] = WNV[i];
00218 }
00219 }
00220
00221 if (QualityEnabled) QV.resize(BaseType::size(),0);
00222 if (_ColorEnabled) CV.resize(BaseType::size());
00223 if (MarkEnabled) MV.resize(BaseType::size());
00224 if (NormalEnabled) NV.resize(BaseType::size());
00225 if (CurvatureDirEnabled) CDV.resize(BaseType::size());
00226 if (VFAdjacencyEnabled) AV.resize(BaseType::size());
00227 if (FFAdjacencyEnabled) AF.resize(BaseType::size());
00228 if (WedgeTexEnabled) WTV.resize(BaseType::size());
00229 if (WedgeColorEnabled) WCV.resize(BaseType::size());
00230 if (WedgeNormalEnabled) WNV.resize(BaseType::size());
00231 }
00232
00234
00235
00236 bool IsQualityEnabled() const {return QualityEnabled;}
00237 void EnableQuality() {
00238 assert(VALUE_TYPE::HasQualityOcf());
00239 QualityEnabled=true;
00240 QV.resize((*this).size(),0);
00241 }
00242
00243 void DisableQuality() {
00244 assert(VALUE_TYPE::HasQualityOcf());
00245 QualityEnabled=false;
00246 QV.clear();
00247 }
00248
00249 bool IsColorEnabled() const {return _ColorEnabled;}
00250 void EnableColor() {
00251 assert(VALUE_TYPE::HasColorOcf());
00252 _ColorEnabled=true;
00253 CV.resize((*this).size(),vcg::Color4b::White);
00254 }
00255
00256 void DisableColor() {
00257 assert(VALUE_TYPE::HasColorOcf());
00258 _ColorEnabled=false;
00259 CV.clear();
00260 }
00261
00262 bool IsMarkEnabled() const {return MarkEnabled;}
00263 void EnableMark() {
00264 assert(VALUE_TYPE::HasMarkOcf());
00265 MarkEnabled=true;
00266 MV.resize((*this).size(),0);
00267 }
00268
00269 void DisableMark() {
00270 assert(VALUE_TYPE::HasMarkOcf());
00271 MarkEnabled=false;
00272 MV.clear();
00273 }
00274
00275 bool IsNormalEnabled() const {return NormalEnabled;}
00276 void EnableNormal() {
00277 assert(VALUE_TYPE::HasNormalOcf());
00278 NormalEnabled=true;
00279 NV.resize((*this).size());
00280 }
00281
00282 void DisableNormal() {
00283 assert(VALUE_TYPE::HasNormalOcf());
00284 NormalEnabled=false;
00285 NV.clear();
00286 }
00287
00288 bool IsCurvatureDirEnabled() const {return CurvatureDirEnabled;}
00289 void EnableCurvatureDir() {
00290 assert(VALUE_TYPE::HasCurvatureDirOcf());
00291 CurvatureDirEnabled=true;
00292 CDV.resize((*this).size());
00293 }
00294
00295 void DisableCurvatureDir() {
00296 assert(VALUE_TYPE::HasCurvatureDirOcf());
00297 CurvatureDirEnabled=false;
00298 CDV.clear();
00299 }
00300
00301
00302 bool IsVFAdjacencyEnabled() const {return VFAdjacencyEnabled;}
00303 void EnableVFAdjacency() {
00304 assert(VALUE_TYPE::HasVFAdjacencyOcf());
00305 VFAdjacencyEnabled=true;
00306 AV.resize((*this).size());
00307 }
00308
00309 void DisableVFAdjacency() {
00310 assert(VALUE_TYPE::HasVFAdjacencyOcf());
00311 VFAdjacencyEnabled=false;
00312 AV.clear();
00313 }
00314
00315
00316 bool IsFFAdjacencyEnabled() const {return FFAdjacencyEnabled;}
00317 void EnableFFAdjacency() {
00318 assert(VALUE_TYPE::HasFFAdjacencyOcf());
00319 FFAdjacencyEnabled=true;
00320 AF.resize((*this).size());
00321 }
00322
00323 void DisableFFAdjacency() {
00324 assert(VALUE_TYPE::HasFFAdjacencyOcf());
00325 FFAdjacencyEnabled=false;
00326 AF.clear();
00327 }
00328
00329 bool IsWedgeTexCoordEnabled() const {return WedgeTexEnabled;}
00330 void EnableWedgeTexCoord() {
00331 assert(VALUE_TYPE::HasWedgeTexCoordOcf());
00332 WedgeTexEnabled=true;
00333 WTV.resize((*this).size(),WedgeTexTypePack());
00334 }
00335
00336 void DisableWedgeTexCoord() {
00337 assert(VALUE_TYPE::HasWedgeTexCoordOcf());
00338 WedgeTexEnabled=false;
00339 WTV.clear();
00340 }
00341
00342 bool IsWedgeColorEnabled() const {return WedgeColorEnabled;}
00343 void EnableWedgeColor() {
00344 assert(VALUE_TYPE::HasWedgeColorOcf());
00345 WedgeColorEnabled=true;
00346 WCV.resize((*this).size(),WedgeColorTypePack());
00347 }
00348
00349 void DisableWedgeColor() {
00350 assert(VALUE_TYPE::HasWedgeColorOcf());
00351 WedgeColorEnabled=false;
00352 WCV.clear();
00353 }
00354
00355 bool IsWedgeNormalEnabled() const {return WedgeNormalEnabled;}
00356 void EnableWedgeNormal() {
00357 assert(VALUE_TYPE::HasWedgeNormalOcf());
00358 WedgeNormalEnabled=true;
00359 WNV.resize((*this).size(),WedgeNormalTypePack());
00360 }
00361
00362 void DisableWedgeNormal() {
00363 assert(VALUE_TYPE::HasWedgeNormalOcf());
00364 WedgeNormalEnabled=false;
00365 WNV.clear();
00366 }
00367
00368 public:
00369 std::vector<typename VALUE_TYPE::ColorType> CV;
00370 std::vector<typename VALUE_TYPE::CurvatureDirType> CDV;
00371 std::vector<int> MV;
00372 std::vector<typename VALUE_TYPE::NormalType> NV;
00373 std::vector<float> QV;
00374 std::vector<class WedgeColorTypePack> WCV;
00375 std::vector<class WedgeNormalTypePack> WNV;
00376 std::vector<class WedgeTexTypePack> WTV;
00377 std::vector<struct AdjTypePack> AV;
00378 std::vector<struct AdjTypePack> AF;
00379
00380 bool _ColorEnabled;
00381 bool CurvatureDirEnabled;
00382 bool MarkEnabled;
00383 bool NormalEnabled;
00384 bool QualityEnabled;
00385 bool WedgeColorEnabled;
00386 bool WedgeNormalEnabled;
00387 bool WedgeTexEnabled;
00388 bool VFAdjacencyEnabled;
00389 bool FFAdjacencyEnabled;
00390 };
00391
00392
00393
00394 template <class T> class VFAdjOcf: public T {
00395 public:
00396 typename T::FacePointer &VFp(const int j) {
00397 assert((*this).Base().VFAdjacencyEnabled);
00398 return (*this).Base().AV[(*this).Index()]._fp[j];
00399 }
00400
00401 typename T::FacePointer cVFp(const int j) const {
00402 if(! (*this).Base().VFAdjacencyEnabled ) return 0;
00403 else return (*this).Base().AV[(*this).Index()]._fp[j];
00404 }
00405
00406 char &VFi(const int j) {
00407 assert((*this).Base().VFAdjacencyEnabled);
00408 return (*this).Base().AV[(*this).Index()]._zp[j];
00409 }
00410
00411 char cVFi(const int j) const {
00412 assert((*this).Base().VFAdjacencyEnabled);
00413 return (*this).Base().AV[(*this).Index()]._zp[j];
00414 }
00415
00416 template <class RightFaceType>
00417 void ImportData(const RightFaceType & rightF){
00418 T::ImportData(rightF);
00419 }
00420 static bool HasVFAdjacency() { return true; }
00421 static bool HasVFAdjacencyOcf() { return true; }
00422
00423 private:
00424 };
00425
00426
00427 template <class T> class FFAdjOcf: public T {
00428 public:
00429 typename T::FacePointer &FFp(const int j) {
00430 assert((*this).Base().FFAdjacencyEnabled);
00431 return (*this).Base().AF[(*this).Index()]._fp[j];
00432 }
00433
00434 typename T::FacePointer cFFp(const int j) const {
00435 if(! (*this).Base().FFAdjacencyEnabled ) return 0;
00436 else return (*this).Base().AF[(*this).Index()]._fp[j];
00437 }
00438
00439 char &FFi(const int j) {
00440 assert((*this).Base().FFAdjacencyEnabled);
00441 return (*this).Base().AF[(*this).Index()]._zp[j];
00442 }
00443 char cFFi(const int j) const {
00444 assert((*this).Base().FFAdjacencyEnabled);
00445 return (*this).Base().AF[(*this).Index()]._zp[j];
00446 }
00447
00448 typename T::FacePointer &FFp1( const int j ) { return FFp((j+1)%3);}
00449 typename T::FacePointer &FFp2( const int j ) { return FFp((j+2)%3);}
00450 typename T::FacePointer cFFp1( const int j ) const { return FFp((j+1)%3);}
00451 typename T::FacePointer cFFp2( const int j ) const { return FFp((j+2)%3);}
00452
00453 typename T::FacePointer &Neigh( const int j ) { return FFp(j);}
00454 typename T::FacePointer cNeigh( const int j ) const { return cFFp(j);}
00455 unsigned int SizeNeigh(){return 3;}
00456
00457 template <class RightFaceType>
00458 void ImportData(const RightFaceType & rightF){
00459 T::ImportData(rightF);
00460 }
00461 static bool HasFFAdjacency() { return true; }
00462 static bool HasFFAdjacencyOcf() { return true; }
00463 };
00464
00465
00466 template <class A, class T> class NormalOcf: public T {
00467 public:
00468 typedef A NormalType;
00469 inline bool IsNormalEnabled( ) const { return this->Base().IsNormalEnabled(); }
00470 static bool HasNormal() { return true; }
00471 static bool HasNormalOcf() { return true; }
00472
00473 NormalType &N() {
00474
00475 assert((*this).Base().NormalEnabled);
00476 return (*this).Base().NV[(*this).Index()]; }
00477 NormalType cN() const {
00478
00479 assert((*this).Base().NormalEnabled);
00480 return (*this).Base().NV[(*this).Index()]; }
00481
00482 template <class RightFaceType>
00483 void ImportData(const RightFaceType & rightF){
00484 if((*this).IsNormalEnabled() && rightF.IsNormalEnabled())
00485 N() = rightF.cN();
00486 T::ImportData(rightF);
00487 }
00488 };
00489
00490 template <class T> class Normal3sOcf: public NormalOcf<vcg::Point3s, T> {};
00491 template <class T> class Normal3fOcf: public NormalOcf<vcg::Point3f, T> {};
00492 template <class T> class Normal3dOcf: public NormalOcf<vcg::Point3d, T> {};
00493
00494
00495 template <class S>
00496 struct CurvatureDirOcfBaseType{
00497 typedef Point3<S> CurVecType;
00498 typedef S CurScalarType;
00499 CurvatureDirOcfBaseType () {}
00500 CurVecType max_dir,min_dir;
00501 CurScalarType k1,k2;
00502 };
00503
00504 template <class A, class T> class CurvatureDirOcf: public T {
00505 public:
00506 typedef A CurvatureDirType;
00507 typedef typename CurvatureDirType::CurVecType CurVecType;
00508 typedef typename CurvatureDirType::CurScalarType CurScalarType;
00509
00510 inline bool IsCurvatureDirEnabled( ) const { return this->Base().IsCurvatureDirEnabled(); }
00511 static bool HasCurvatureDir() { return true; }
00512 static bool HasCurvatureDirOcf() { return true; }
00513
00514 CurVecType &PD1() { assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CDV[(*this).Index()].max_dir; }
00515 CurVecType &PD2() { assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CDV[(*this).Index()].min_dir; }
00516 CurVecType cPD1() const { assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CDV[(*this).Index()].max_dir; }
00517 CurVecType cPD2() const { assert((*this).Base().CurvatureDirEnabled); return (*this).Base().CDV[(*this).Index()].min_dir; }
00518
00519 CurScalarType &K1() { assert((*this).Base().NormalEnabled); return (*this).Base().CDV[(*this).Index()].k1; }
00520 CurScalarType &K2() { assert((*this).Base().NormalEnabled); return (*this).Base().CDV[(*this).Index()].k2; }
00521 CurScalarType cK1() const { assert((*this).Base().NormalEnabled); return (*this).Base().CDV[(*this).Index()].k1; }
00522 CurScalarType cK2() const { assert((*this).Base().NormalEnabled); return (*this).Base().CDV[(*this).Index()].k2; }
00523
00524 template <class RightFaceType>
00525 void ImportData(const RightFaceType & rightF){
00526 if((*this).IsCurvatureDirEnabled() && rightF.IsCurvatureDirEnabled()) {
00527 PD1().Import(rightF.cPD1());
00528 PD2().Import(rightF.cPD2());
00529 K1() = rightF.cK1();
00530 K2() = rightF.cK2();
00531 }
00532 T::ImportData(rightF);
00533 }
00534
00535 };
00536
00537 template <class T> class CurvatureDirfOcf: public CurvatureDirOcf<CurvatureDirOcfBaseType<float>, T> {
00538 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvatureDirfOcf"));T::Name(name);}
00539 };
00540 template <class T> class CurvatureDirdOcf: public CurvatureDirOcf<CurvatureDirOcfBaseType<double>, T> {
00541 public: static void Name(std::vector<std::string> & name){name.push_back(std::string("CurvatureDirdOcf"));T::Name(name);}
00542 };
00543
00545 template <class A, class T> class QualityOcf: public T {
00546 public:
00547 typedef A QualityType;
00548 QualityType &Q() {
00549 assert((*this).Base().QualityEnabled);
00550 return (*this).Base().QV[(*this).Index()];
00551 }
00552 QualityType cQ() const {
00553 assert((*this).Base().QualityEnabled);
00554 return (*this).Base().QV[(*this).Index()];
00555 }
00556
00557 template <class RightFaceType>
00558 void ImportData(const RightFaceType & rightF){
00559 if((*this).IsQualityEnabled() && rightF.IsQualityEnabled())
00560 Q() = rightF.cQ();
00561 T::ImportData(rightF);
00562 }
00563 inline bool IsQualityEnabled( ) const { return this->Base().IsQualityEnabled(); }
00564 static bool HasQuality() { return true; }
00565 static bool HasQualityOcf() { return true; }
00566 };
00567
00568 template <class T> class QualityfOcf: public QualityOcf<float, T> {};
00569
00571 template <class A, class T> class ColorOcf: public T {
00572 public:
00573 typedef A ColorType;
00574 ColorType &C() {
00575 assert((*this).Base()._ColorEnabled);
00576 return (*this).Base().CV[(*this).Index()];
00577 }
00578 ColorType cC() const {
00579 assert((*this).Base()._ColorEnabled);
00580 return (*this).Base().CV[(*this).Index()];
00581 }
00582
00583 template <class RightFaceType>
00584 void ImportData(const RightFaceType & rightF){
00585 if((*this).IsColorEnabled() && rightF.IsColorEnabled())
00586 C() = rightF.cC();
00587 T::ImportData(rightF);
00588 }
00589 inline bool IsColorEnabled() const { return this->Base().IsColorEnabled();}
00590 static bool HasColor() { return true; }
00591 static bool HasColorOcf() { return true; }
00592 };
00593
00594 template <class T> class Color4bOcf: public ColorOcf<vcg::Color4b, T> {};
00595
00597 template <class T> class MarkOcf: public T {
00598 public:
00599 inline int &IMark() {
00600 assert((*this).Base().MarkEnabled);
00601 return (*this).Base().MV[(*this).Index()];
00602 }
00603 inline int cIMark() const {
00604 assert((*this).Base().MarkEnabled);
00605 return (*this).Base().MV[(*this).Index()];
00606 }
00607
00608 template <class RightFaceType>
00609 void ImportData(const RightFaceType & rightF){
00610 if((*this).IsMarkEnabled() && rightF.IsMarkEnabled())
00611 IMark() = rightF.cIMark();
00612 T::ImportData(rightF);
00613 }
00614 inline bool IsMarkEnabled( ) const { return this->Base().IsMarkEnabled(); }
00615 static bool HasMark() { return true; }
00616 static bool HasMarkOcf() { return true; }
00617 inline void InitIMark() { IMark() = 0; }
00618 };
00619
00621 template <class A, class TT> class WedgeTexCoordOcf: public TT {
00622 public:
00623 WedgeTexCoordOcf(){ }
00624 typedef A TexCoordType;
00625 TexCoordType &WT(const int i) { assert((*this).Base().WedgeTexEnabled); return (*this).Base().WTV[(*this).Index()].wt[i]; }
00626 TexCoordType cWT(const int i) const { assert((*this).Base().WedgeTexEnabled); return (*this).Base().WTV[(*this).Index()].wt[i]; }
00627 template <class RightFaceType>
00628 void ImportData(const RightFaceType & rightF){
00629 if(this->IsWedgeTexCoordEnabled() && rightF.IsWedgeTexCoordEnabled())
00630 { WT(0) = rightF.cWT(0); WT(1) = rightF.cWT(1); WT(2) = rightF.cWT(2); }
00631 TT::ImportData(rightF);
00632 }
00633 inline bool IsWedgeTexCoordEnabled( ) const { return this->Base().IsWedgeTexCoordEnabled(); }
00634 static bool HasWedgeTexCoord() { return true; }
00635 static bool HasWedgeTexCoordOcf() { return true; }
00636 };
00637
00638 template <class T> class WedgeTexCoordfOcf: public WedgeTexCoordOcf<TexCoord2<float,1>, T> {};
00639
00641 template <class A, class TT> class WedgeColorOcf: public TT {
00642 public:
00643 WedgeColorOcf(){ }
00644 typedef A WedgeColorType;
00645 WedgeColorType &WC(const int i) { assert((*this).Base().WedgeColorEnabled); return (*this).Base().WCV[(*this).Index()].wc[i]; }
00646 const WedgeColorType cWC(const int i) const { assert((*this).Base().WedgeColorEnabled); return (*this).Base().WCV[(*this).Index()].wc[i]; }
00647 template <class RightFaceType>
00648 void ImportData(const RightFaceType & rightF){
00649 if(this->IsWedgeColorEnabled() && rightF.IsWedgeColorEnabled())
00650 { WC(0) = rightF.cWC(0); WC(1) = rightF.cWC(1); WC(2) = rightF.cWC(2); }
00651 TT::ImportData(rightF);
00652 }
00653 inline bool IsWedgeColorEnabled( ) const { return this->Base().IsWedgeColorEnabled(); }
00654 static bool HasWedgeColor() { return true; }
00655 static bool HasWedgeColorOcf() { return true; }
00656 };
00657
00658 template <class T> class WedgeColor4bOcf: public WedgeColorOcf<vcg::Color4b, T> {};
00659
00661 template <class A, class TT> class WedgeNormalOcf: public TT {
00662 public:
00663 WedgeNormalOcf(){ }
00664 typedef A WedgeNormalType;
00665 WedgeNormalType &WN(const int i) { assert((*this).Base().WedgeNormalEnabled); return (*this).Base().WNV[(*this).Index()].wn[i]; }
00666 WedgeNormalType const &cWN(const int i) const { assert((*this).Base().WedgeNormalEnabled); return (*this).Base().WNV[(*this).Index()].wn[i]; }
00667 template <class RightFaceType>
00668 void ImportData(const RightFaceType & rightF){
00669 if(this->IsWedgeNormalEnabled() && rightF.IsWedgeNormalEnabled())
00670 { WN(0) = rightF.cWN(0); WN(1) = rightF.cWN(1); WN(2) = rightF.cWN(2); }
00671 TT::ImportData(rightF);
00672 }
00673 inline bool IsWedgeNormalEnabled( ) const { return this->Base().IsWedgeNormalEnabled(); }
00674 static bool HasWedgeNormal() { return true; }
00675 static bool HasWedgeNormalOcf() { return true; }
00676 };
00677
00678 template <class T> class WedgeNormal3sOcf: public WedgeNormalOcf<vcg::Point3s, T> {};
00679 template <class T> class WedgeNormal3fOcf: public WedgeNormalOcf<vcg::Point3f, T> {};
00680 template <class T> class WedgeNormal3dOcf: public WedgeNormalOcf<vcg::Point3d, T> {};
00681
00683 template < class T> class InfoOcf: public T {
00684 public:
00685
00686
00687 inline InfoOcf &operator=(const InfoOcf & ) {
00688 assert(0); return *this;
00689 }
00690
00691
00692 vector_ocf<typename T::FaceType> &Base() const { return *_ovp;}
00693
00694 template <class RightFaceType>
00695 void ImportData(const RightFaceType & rightF){T::ImportData(rightF);}
00696
00697 static bool HasColorOcf() { return false; }
00698 static bool HasCurvatureDirOcf() { return false; }
00699 static bool HasMarkOcf() { return false; }
00700 static bool HasNormalOcf() { return false; }
00701 static bool HasQualityOcf() { return false; }
00702 static bool HasWedgeTexCoordOcf() { return false; }
00703 static bool HasWedgeColorOcf() { return false; }
00704 static bool HasWedgeNormalOcf() { return false; }
00705 static bool HasFFAdjacencyOcf() { return false; }
00706 static bool HasVFAdjacencyOcf() { return false; }
00707
00708
00709
00710
00711
00712
00713
00714 inline size_t Index() const {
00715 typename T::FaceType const *tp=static_cast<typename T::FaceType const *>(this);
00716 size_t tt2=tp- &*(_ovp->begin());
00717 return tt2;
00718 }
00719 public:
00720
00721
00722
00723 vector_ocf<typename T::FaceType> *_ovp;
00724 };
00725
00726 }
00727
00728 template < class, class,class,class > class TriMesh;
00729
00730 namespace tri
00731 {
00732 template < class FaceType >
00733 bool FaceVectorHasVFAdjacency(const face::vector_ocf<FaceType> &fv)
00734 {
00735 if(FaceType::HasVFAdjacencyOcf()) return fv.IsVFAdjacencyEnabled();
00736 else return FaceType::HasVFAdjacency();
00737 }
00738 template < class FaceType >
00739 bool FaceVectorHasFFAdjacency(const face::vector_ocf<FaceType> &fv)
00740 {
00741 if(FaceType::HasFFAdjacencyOcf()) return fv.IsFFAdjacencyEnabled();
00742 else return FaceType::HasFFAdjacency();
00743 }
00744 template < class FaceType >
00745 bool FaceVectorHasPerWedgeTexCoord(const face::vector_ocf<FaceType> &fv)
00746 {
00747 if(FaceType::HasWedgeTexCoordOcf()) return fv.IsWedgeTexCoordEnabled();
00748 else return FaceType::HasWedgeTexCoord();
00749 }
00750 template < class FaceType >
00751 bool FaceVectorHasPerFaceColor(const face::vector_ocf<FaceType> &fv)
00752 {
00753 if(FaceType::HasColorOcf()) return fv.IsColorEnabled();
00754 else return FaceType::HasColor();
00755 }
00756 template < class FaceType >
00757 bool FaceVectorHasPerFaceQuality(const face::vector_ocf<FaceType> &fv)
00758 {
00759 if(FaceType::HasQualityOcf()) return fv.IsQualityEnabled();
00760 else return FaceType::HasQuality();
00761 }
00762 template < class FaceType >
00763 bool FaceVectorHasPerFaceMark(const face::vector_ocf<FaceType> &fv)
00764 {
00765 if(FaceType::HasMarkOcf()) return fv.IsMarkEnabled();
00766 else return FaceType::HasMark();
00767 }
00768 template < class FaceType >
00769 bool FaceVectorHasPerFaceCurvatureDir(const face::vector_ocf<FaceType> &fv)
00770 {
00771 if(FaceType::HasCurvatureDirOcf()) return fv.IsCurvatureDirEnabled();
00772 else return FaceType::HasCurvatureDir();
00773 }
00774 template < class FaceType >
00775 bool FaceVectorHasPerFaceNormal(const face::vector_ocf<FaceType> &fv)
00776 {
00777 if(FaceType::HasNormalOcf()) return fv.IsNormalEnabled();
00778 else return FaceType::HasNormal();
00779 }
00780 template < class FaceType >
00781 void ReorderFace( std::vector<size_t> &newFaceIndex, face::vector_ocf< FaceType > &faceVec)
00782 {
00783 faceVec.ReorderFace(newFaceIndex);
00784 }
00785
00786 }
00787 }
00788 #endif