From 90e70ff138235f7acbdecb98fbed73147ff2f2f4 Mon Sep 17 00:00:00 2001 From: Kenneth Vanhoey Date: Wed, 22 Jun 2011 13:52:18 +0200 Subject: [PATCH] adapted comments in localFrame and import2tablesSurface::importPlyPTM and secured localFrame (no more possibility of generating a zero vector) --- include/Algo/Import/import2tablesSurface.hpp | 5 ++--- include/Utils/localFrame.h | 15 ++++++++++++--- include/Utils/localFrame.hpp | 17 +++++++++-------- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/include/Algo/Import/import2tablesSurface.hpp b/include/Algo/Import/import2tablesSurface.hpp index 1b2275c86..e221fbc21 100644 --- a/include/Algo/Import/import2tablesSurface.hpp +++ b/include/Algo/Import/import2tablesSurface.hpp @@ -674,9 +674,8 @@ bool MeshTablesSurface::importPlyPTMgeneric(const std::string& filename, st * @param attrNames : reference that will be filled with the attribute names ; * - 1 attrName for geometric position (VEC3) * - 3 attrNames for local frame (3xVEC3) : Tangent, Bitangent and Normal vector - * - 6 attrNames for the function coefficients (6xVEC3) : 6 RGB coefficients being successively the constants, the linears (v then u) and the quadratics : a0 + a1*v + a2*u + a3*u*v + a4*v^2 + a5*u^2. - * @return bool : success. - * @return bool : success. + * - 6 attrNames for the function coefficients (6xVEC3) : 6 RGB coefficients being successively the quadratic members, the linears and the constants (u then v) : a*u^2 + b*v^2 + c*uv + d*u + e*v +f. + * @return bool : success. */ template bool MeshTablesSurface::importPlyPTM(const std::string& filename, std::vector& attrNames) diff --git a/include/Utils/localFrame.h b/include/Utils/localFrame.h index 4f13c171d..0c860cfe3 100644 --- a/include/Utils/localFrame.h +++ b/include/Utils/localFrame.h @@ -179,9 +179,18 @@ public: // methods } ; private : // private constants - const VEC3 T ; - const VEC3 B ; - const VEC3 N ; + // (T,B,N) can be any orthonormal direct frame + // zeros are not recommended since they can + // generate zero vectors after a dot product + static const REAL Tx = 0.267261 ; + static const REAL Ty = 0.534522 ; + static const REAL Tz = 0.801784 ; + static const REAL Bx = 0.844416 ; + static const REAL By = -0.530776 ; + static const REAL Bz = 0.0723785 ; + static const REAL Nx = 0.464255 ; + static const REAL Ny = 0.657695 ; + static const REAL Nz = -0.593215 ; } ; } // Utils diff --git a/include/Utils/localFrame.hpp b/include/Utils/localFrame.hpp index 902bf5d15..3b31f15bf 100644 --- a/include/Utils/localFrame.hpp +++ b/include/Utils/localFrame.hpp @@ -28,10 +28,7 @@ namespace CGoGN { namespace Utils { template -LocalFrame::LocalFrame(const VEC3& T, const VEC3& B, const VEC3& N) : - T(1,0,0), // (T,B,N) can be any orthonormal direct frame - B(0,1,0), // but has to be initialized exactly the same - N(0,0,1) // in every constructor ! +LocalFrame::LocalFrame(const VEC3& T, const VEC3& B, const VEC3& N) { m_T = T ; m_B = B ; @@ -39,11 +36,11 @@ LocalFrame::LocalFrame(const VEC3& T, const VEC3& B, const VEC3& N) : } template -LocalFrame::LocalFrame(const VEC3& compressedFrame) : - T(1,0,0), // (T,B,N) can be any orthonormal direct frame - B(0,1,0), // but has to be initialized exactly the same - N(0,0,1) // in every constructor !{ +LocalFrame::LocalFrame(const VEC3& compressedFrame) { + const VEC3 T(Tx,Ty,Tz) ; + const VEC3 N(Nx,Ny,Nz) ; + // get known data const REAL& theta1 = compressedFrame[0] ; const REAL& phi = compressedFrame[1] ; @@ -60,6 +57,10 @@ typename Geom::Vector<3,typename PFP::REAL> LocalFrame::getCompressed() con { VEC3 res ; + const VEC3 T(Tx,Ty,Tz) ; + const VEC3 B(Bx,By,Bz) ; + const VEC3 N(Nx,Ny,Nz) ; + REAL& theta1 = res[0] ; REAL& phi = res[1] ; REAL& theta2 = res[2] ; -- GitLab