From a06adb1c1b0bee33f12c01fee7a716971d9ee4cb Mon Sep 17 00:00:00 2001 From: Kenneth Vanhoey Date: Fri, 2 Mar 2012 20:22:18 +0100 Subject: [PATCH] =?UTF-8?q?export=20pour=20SLF=20generique=20(rangement=20?= =?UTF-8?q?=C3=A0=20venir)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/Algo/Export/export.h | 2 +- include/Algo/Export/export.hpp | 2 +- include/Algo/Import/import2tables.h | 5 ++-- include/Algo/Import/import2tablesSurface.hpp | 28 +++++++++++--------- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/include/Algo/Export/export.h b/include/Algo/Export/export.h index 0dab9fa7..34bb9fcb 100644 --- a/include/Algo/Export/export.h +++ b/include/Algo/Export/export.h @@ -76,7 +76,7 @@ bool exportTrian(typename PFP::MAP& map, const typename PFP::TVEC3& position, ch * @return true */ template -bool exportPlySLF(typename PFP::MAP& map, const char* filename, const typename PFP::TVEC3& position, const unsigned int& nbCoefs, const FunctorSelect& good = allDarts) ; +bool exportPlySLFgeneric(typename PFP::MAP& map, const char* filename, const typename PFP::TVEC3& position, const unsigned int& nbCoefs, const FunctorSelect& good = allDarts) ; /** * export the map into a PLYSLF file (K. Vanhoey generic format). diff --git a/include/Algo/Export/export.hpp b/include/Algo/Export/export.hpp index c40ff67b..111fe524 100644 --- a/include/Algo/Export/export.hpp +++ b/include/Algo/Export/export.hpp @@ -322,7 +322,7 @@ bool exportPlyPTMgeneric(typename PFP::MAP& map, const char* filename, const typ } template -bool exportPlySLF(typename PFP::MAP& map, const char* filename, const typename PFP::TVEC3& position, const unsigned int& nbCoefs, const FunctorSelect& good) +bool exportPlySLFgeneric(typename PFP::MAP& map, const char* filename, const typename PFP::TVEC3& position, const unsigned int& nbCoefs, const FunctorSelect& good) { typedef typename PFP::MAP MAP; typedef typename PFP::VEC3 VEC3; diff --git a/include/Algo/Import/import2tables.h b/include/Algo/Import/import2tables.h index 91837428..bfd4f301 100644 --- a/include/Algo/Import/import2tables.h +++ b/include/Algo/Import/import2tables.h @@ -52,7 +52,7 @@ namespace Import namespace ImportSurfacique { - enum ImportType { UNKNOWNSURFACE, TRIAN, TRIANBGZ, MESHBIN, PLY, PLYPTM, PLYPTMgeneric, OFF, OBJ, VRML, AHEM }; + enum ImportType { UNKNOWNSURFACE, TRIAN, TRIANBGZ, MESHBIN, PLY, PLYPTM, PLYSLFgeneric, OFF, OBJ, VRML, AHEM }; } namespace ImportVolumique @@ -116,7 +116,8 @@ public: bool importPly(const std::string& filename, std::vector& attrNames); bool importPlyPTM(const std::string& filename, std::vector& attrNames); - bool importPlyPTMgeneric(const std::string& filename, std::vector& attrNames); + bool importPlySLFgeneric(const std::string& filename, std::vector& attrNames); + #ifdef WITH_ASSIMP bool importASSIMP(const std::string& filename, std::vector& attrNames); #endif diff --git a/include/Algo/Import/import2tablesSurface.hpp b/include/Algo/Import/import2tablesSurface.hpp index d8e1e1a2..699cd830 100644 --- a/include/Algo/Import/import2tablesSurface.hpp +++ b/include/Algo/Import/import2tablesSurface.hpp @@ -107,9 +107,9 @@ bool MeshTablesSurface::importMesh(const std::string& filename, std::vector CGoGNout << "TYPE: PLYPTM" << CGoGNendl; return importPlyPTM(filename, attrNames); break; - case ImportSurfacique::PLYPTMgeneric: - CGoGNout << "TYPE: PLYPTMgeneric" << CGoGNendl; - return importPlyPTMgeneric(filename, attrNames); + case ImportSurfacique::PLYSLFgeneric: + CGoGNout << "TYPE: PLYSLFgeneric" << CGoGNendl; + return importPlySLFgeneric(filename, attrNames); break; case ImportSurfacique::OBJ: CGoGNout << "TYPE: OBJ" << CGoGNendl; @@ -616,26 +616,28 @@ bool MeshTablesSurface::importPly(const std::string& filename, std::vector< } /** - * Import plyPTM (K Vanhoey generic format). - * It can handle bivariable polynomials of any degree and returns the appropriate attrNames + * Import plySLF (K Vanhoey generic format). + * It can handle bivariable polynomials and spherical harmonics of any degree and returns the appropriate attrNames * @param filename the file to import; * @param attrNames reference that will be filled with the attribute names - * the number of attrNames returned depends on the degree of the polynomials : + * the number of attrNames returned depends on the degree of the polynomials / level of the SH : * - 1 attrName for geometric position (VEC3) : name = "position" ; * - 3 attrNames for local frame (3xVEC3) : names are "Frame_T" (Tangent), "Frame_B" (Binormal) and "Frame_N" (Normal) ; * - N attrNames for the function coefficients (NxVEC3) : N RGB coefficients being successively the constants, the linears (v then u), the quadratics, etc. : : a0 + a1*v + a2*u + a3*u*v + a4*v^2 + a5*u^2. - * Their names are : "colorPTM_a" (where is a number from 0 to N-1). + * Their names are : "SLFcoefs_" (where is a number from 0 to N-1). * N = 1 for constant polynomial, * N = 3 for linear polynomial, * N = 6 for quadratic polynomial, * N = 10 for cubic degree polynomial, * N = 15 for 4th degree polynomial, + * + * N = l*l for SH of level l, * ... * - K remaining attrNames named "remainderNo" where k is an integer from 0 to K-1. * @return bool : success. */ template -bool MeshTablesSurface::importPlyPTMgeneric(const std::string& filename, std::vector& attrNames) +bool MeshTablesSurface::importPlySLFgeneric(const std::string& filename, std::vector& attrNames) { // Open file std::ifstream fp(filename.c_str(), std::ios::in) ; @@ -710,13 +712,13 @@ bool MeshTablesSurface::importPlyPTMgeneric(const std::string& filename, st attrNames.push_back(frame[1].name()) ; attrNames.push_back(frame[2].name()) ; - AttributeHandler *colorPTM = new AttributeHandler[nbCoefsPerPol] ; + AttributeHandler *SLFcoefs = new AttributeHandler[nbCoefsPerPol] ; for (unsigned int i = 0 ; i < nbCoefsPerPol ; ++i) { std::stringstream name ; - name << "colorPTM_a" << i ; - colorPTM[i] = m_map.template addAttribute(VERTEX, name.str()) ; - attrNames.push_back(colorPTM[i].name()) ; + name << "SLFcoefs_" << i ; + SLFcoefs[i] = m_map.template addAttribute(VERTEX, name.str()) ; + attrNames.push_back(SLFcoefs[i].name()) ; } AttributeHandler *remainders = new AttributeHandler[nbRemainders] ; @@ -748,7 +750,7 @@ bool MeshTablesSurface::importPlyPTMgeneric(const std::string& filename, st frame[k][id][l] = properties[3+(3*k+l)] ; for (unsigned int k = 0 ; k < 3 ; ++k) // coefficients for (unsigned int l = 0 ; l < nbCoefsPerPol ; ++l) - colorPTM[l][id][k] = properties[12+(nbCoefsPerPol*k+l)] ; + SLFcoefs[l][id][k] = properties[12+(nbCoefsPerPol*k+l)] ; unsigned int cur = 12+3*nbCoefsPerPol ; for (unsigned int k = 0 ; k < nbRemainders ; ++k) // remaining data remainders[k][id] = properties[cur + k] ; -- GitLab