From e7c965621932c512a665c89c2cacc3501c606e9e Mon Sep 17 00:00:00 2001 From: cignoni Date: Thu, 28 Aug 2008 07:19:04 +0000 Subject: [PATCH] Corrected the ImportLocal function for most of the optional classess. Previous version did not check for the availability of the optional component before trying to import it. --- vcg/simplex/faceplus/component_ocf.h | 44 +++++++++++++++++++++------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/vcg/simplex/faceplus/component_ocf.h b/vcg/simplex/faceplus/component_ocf.h index a2f14a0d..0632aa60 100644 --- a/vcg/simplex/faceplus/component_ocf.h +++ b/vcg/simplex/faceplus/component_ocf.h @@ -392,9 +392,13 @@ public: } template - void ImportLocal(const LeftF & leftF){VFp(0) = NULL; VFp(1) = NULL; VFp(2) = NULL; - VFi(0) = -1; VFi(1) = -1; VFi(2) = -1; - T::ImportLocal(leftF);} + void ImportLocal(const LeftF & leftF){ + if(leftF.Base().VFAdjacencyEnabled){ + VFp(0) = NULL; VFp(1) = NULL; VFp(2) = NULL; + VFi(0) = -1; VFi(1) = -1; VFi(2) = -1; + } + T::ImportLocal(leftF); + } static bool HasVFAdjacency() { return true; } static bool HasVFAdjacencyOcf() { return true; } @@ -431,9 +435,13 @@ public: typename T::FacePointer const FFp2( const int j ) const { return FFp((j+2)%3);} template - void ImportLocal(const LeftF & leftF){FFp(0) = NULL; FFp(1) = NULL; FFp(2) = NULL; - FFi(0) = -1; FFi(1) = -1; FFi(2) = -1; - T::ImportLocal(leftF);} + void ImportLocal(const LeftF & leftF){ + if(leftF.Base().FFAdjacencyEnabled) { + FFp(0) = NULL; FFp(1) = NULL; FFp(2) = NULL; + FFi(0) = -1; FFi(1) = -1; FFi(2) = -1; + } + T::ImportLocal(leftF); + } static bool HasFFAdjacency() { return true; } static bool HasFFAdjacencyOcf() { return true; } @@ -458,7 +466,11 @@ public: return (*this).Base().NV[(*this).Index()]; } template - void ImportLocal(const LeftF & leftF){N() = leftF.cN(); T::ImportLocal(leftF);} + void ImportLocal(const LeftF & leftF){ + if((*this).Base().NormalEnabled && leftF.Base().NormalEnabled) + N() = leftF.cN(); + T::ImportLocal(leftF); + } }; @@ -481,7 +493,11 @@ public: } template - void ImportLocal(const LeftF & leftF){C() = leftF.C(); T::ImportLocal(leftF);} + void ImportLocal(const LeftF & leftF){ + if((*this).Base().ColorEnabled && leftF.Base().ColorEnabled) + C() = leftF.C(); + T::ImportLocal(leftF); + } static bool HasFaceColor() { return true; } static bool HasFaceColorOcf() { return true; } }; @@ -503,7 +519,11 @@ public: } ; template - void ImportLocal(const LeftF & leftF){IMark() = leftF.IMark(); T::ImportLocal(leftF);} + void ImportLocal(const LeftF & leftF){ + if((*this).Base().MarkEnabled && leftF.Base().MarkEnabled) + IMark() = leftF.IMark(); + T::ImportLocal(leftF); + } static bool HasFaceMark() { return true; } static bool HasFaceMarkOcf() { return true; } inline void InitIMark() { IMark() = 0; } @@ -518,7 +538,11 @@ public: TexCoordType &WT(const int i) { assert((*this).Base().WedgeTexEnabled); return (*this).Base().WTV[(*this).Index()].wt[i]; } TexCoordType const &cWT(const int i) const { assert((*this).Base().WedgeTexEnabled); return (*this).Base().WTV[(*this).Index()].wt[i]; } template - void ImportLocal(const LeftF & leftF){WT(0) = leftF.cWT(0); WT(1) = leftF.cWT(1); WT(2) = leftF.cWT(2); TT::ImportLocal(leftF);} + void ImportLocal(const LeftF & leftF){ + if(this->Base().WedgeTexEnabled && leftF.Base().WedgeTexEnabled) + { WT(0) = leftF.cWT(0); WT(1) = leftF.cWT(1); WT(2) = leftF.cWT(2); } + TT::ImportLocal(leftF); + } static bool HasWedgeTexCoord() { return true; } static bool HasWedgeTexCoordOcf() { return true; } };