From 23ed036afe0b8005b387460e73a0c2eb907089c6 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 | 4 ++-- include/Algo/Export/export.hpp | 22 ++++++++++++-------- include/Algo/Import/import2tablesSurface.hpp | 3 +++ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/include/Algo/Export/export.h b/include/Algo/Export/export.h index 34bb9fcb..6919b374 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 exportPlySLFgeneric(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 typename PFP::TVEC3& position, const char* filename, const FunctorSelect& good = allDarts) ; /** * export the map into a PLYSLF file (K. Vanhoey generic format). @@ -91,7 +91,7 @@ bool exportPlySLFgeneric(typename PFP::MAP& map, const char* filename, const typ * @return true */ template -bool exportPlyPTMgeneric(typename PFP::MAP& map, const char* filename, const typename PFP::TVEC3& position, const unsigned int& nbCoefs, const FunctorSelect& good = allDarts) ; +bool exportPlyPTMgeneric(typename PFP::MAP& map, const typename PFP::TVEC3& position, const char* filename, const unsigned int& nbCoefs, const FunctorSelect& good = allDarts) ; /** * export the map into a PLYPTMgeneric file (K. Vanhoey generic format) diff --git a/include/Algo/Export/export.hpp b/include/Algo/Export/export.hpp index 111fe524..f10aa730 100644 --- a/include/Algo/Export/export.hpp +++ b/include/Algo/Export/export.hpp @@ -180,7 +180,7 @@ bool exportOFF(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons } template -bool exportPlyPTMgeneric(typename PFP::MAP& map, const char* filename, const typename PFP::TVEC3& position, const FunctorSelect& good) +bool exportPlyPTMgeneric(typename PFP::MAP& map, const typename PFP::TVEC3& position, const char* filename, const FunctorSelect& good) { typedef typename PFP::MAP MAP; typedef typename PFP::VEC3 VEC3; @@ -322,7 +322,7 @@ bool exportPlyPTMgeneric(typename PFP::MAP& map, const char* filename, const typ } template -bool exportPlySLFgeneric(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 typename PFP::TVEC3& position, const char* filename, const FunctorSelect& good) { typedef typename PFP::MAP MAP; typedef typename PFP::VEC3 VEC3; @@ -375,21 +375,25 @@ bool exportPlySLFgeneric(typename PFP::MAP& map, const char* filename, const typ } TVEC3 frame[3] ; - TVEC3 coefs[nbCoefs] ; + std::vector coefs ; frame[0] = map.template getAttribute(VERTEX, "frame_T") ; frame[1] = map.template getAttribute(VERTEX, "frame_B") ; frame[2] = map.template getAttribute(VERTEX, "frame_N") ; - for (unsigned i = 0 ; i < nbCoefs ; ++i) - { + + unsigned int i = 0 ; + do { std::stringstream name ; - name << "SLFcoefs_" << i ; - coefs[i] = map.template getAttribute(VERTEX,name.str()) ; - } + name << "SLFcoefs_" << i++ ; + coefs.push_back(map.template getAttribute(VERTEX, name.str())) ; + } while (coefs[i-1].isValid()) ; + const unsigned int nbCoefs = i - 1 ; // last valid one is i-2 + + for(unsigned int coefI = 0 ; coefI < nbCoefs ; ++coefI) + assert(coefs[coefI].isValid()) ; std::string file(filename) ; size_t pos = file.rfind(".") ; // position of "." in filename - std::cout << file << " ; " << pos << std::endl ; std::string extension = file.substr(pos) ; out << "ply" << std::endl ; diff --git a/include/Algo/Import/import2tablesSurface.hpp b/include/Algo/Import/import2tablesSurface.hpp index 699cd830..47af3098 100644 --- a/include/Algo/Import/import2tablesSurface.hpp +++ b/include/Algo/Import/import2tablesSurface.hpp @@ -58,6 +58,9 @@ ImportSurfacique::ImportType MeshTablesSurface::getFileType(const std::stri if ((filename.rfind(".plyptm")!=std::string::npos) || (filename.rfind(".PLYGEN")!=std::string::npos)) return ImportSurfacique::PLYPTM; + if ((filename.rfind(".plyPTMext")!=std::string::npos) || (filename.rfind(".plySHreal")!=std::string::npos)) + return ImportSurfacique::PLYSLFgeneric; + if ((filename.rfind(".ply")!=std::string::npos) || (filename.rfind(".PLY")!=std::string::npos)) return ImportSurfacique::PLY; -- GitLab