Commit 897b97cb authored by Kenneth Vanhoey's avatar Kenneth Vanhoey

binary import/export for SLF

parent 877cde77
......@@ -530,9 +530,13 @@ bool exportPlySLFgenericBin(typename PFP::MAP& map, const typename PFP::TVEC3& p
size_t pos = file.rfind(".") ; // position of "." in filename
std::string extension = file.substr(pos) ;
std::string tmp ;
tmp = std::string("ply") ;
out.write(tmp,tmp.length()*sizeof(char)) ;
tmp = std::string("format binary_little_endian 1.0") ;
out.write(tmp,tmp.length()*sizeof(char)) ;
std::stringstream header ;
header << "ply" << std::endl ;
header << "format binary_little_endian 1.0" << std::endl ;
header << "comment ply SLF (K. Vanhoey generic format): SLF_" << ((extension == ".plyPTMext") ? "PTMext" : "SHreal") << std::endl ;
header << "element vertex " << vertices.size() << std::endl ;
header << "property float x" << std::endl ;
......
......@@ -805,25 +805,28 @@ bool MeshTablesSurface<PFP>::importPlySLFgenericBin(const std::string& filename,
return false ;
}
// read "ply"
char* buff = new char[3] ;
fp.read(buff, 3) ;
std::string tag(buff) ;
delete[] buff ;
if (tag != std::string("ply")) // verify file type
{
CGoGNerr << filename << " is not a ply file !" << CGoGNout ;
return false ;
}
// read CHNum
unsigned int CHNum ;
fp.read((char*)&CHNum, sizeof(unsigned int)) ;
char* headerTab = new char[CHNum] ;
std::cout << fp.read(headerTab, CHNum) << std::endl ;
fp.read(headerTab, CHNum) ;
std::stringstream header(headerTab) ;
std::cout << std::string(headerTab) << std::endl ;
// Read quantities : #vertices, #faces, #properties, degree of polynomials
std::string tag ;
header >> tag ;
if (tag != std::string("ply")) // verify file type
{
CGoGNerr << filename << " is not a ply file !" << CGoGNout ;
return false ;
}
do // go to #vertices
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment