Commit 66f26c13 authored by Kenneth Vanhoey's avatar Kenneth Vanhoey

exportPly is now generic for PFP::REAL

parent b5e50597
......@@ -117,13 +117,13 @@ bool exportPLY(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
// Position property
if (position.isValid())
{
out << "property float32 x" << std::endl ;
out << "property float32 y" << std::endl ;
out << "property float32 z" << std::endl ;
out << "property " << nameOfTypePly(position[0][0]) << 8 * sizeof(position[0][0]) <<" x" << std::endl ;
out << "property " << nameOfTypePly(position[0][1]) << 8 * sizeof(position[0][1]) <<" y" << std::endl ;
out << "property " << nameOfTypePly(position[0][2]) << 8 * sizeof(position[0][2]) <<" z" << std::endl ;
}
// Face element
out << "element face " << facesSize.size() << std::endl ;
out << "property list uint8 uint32 vertex_indices" << std::endl ;
out << "property list uint8 uint" << 8 * sizeof(facesIdx[0][0]) << " vertex_indices" << std::endl ;
out << "end_header" << std::endl ;
if (!binary) // ascii
......@@ -147,7 +147,7 @@ bool exportPLY(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
for(unsigned int i = 0; i < vertices.size(); ++i)
{
Geom::Vec3f v = position[vertices[i]] ;
out.write((char*)(&(v[0])), 3 * sizeof(float)) ;
out.write((char*)(&(v[0])), sizeof(v)) ;
}
// binary faces
......@@ -155,7 +155,7 @@ bool exportPLY(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons
{
unsigned char nbe = facesSize[i] ;
out.write((char*)(&nbe), sizeof(unsigned char)) ;
out.write((char*)(&(facesIdx[i][0])), facesSize[i] * sizeof(float)) ;
out.write((char*)(&(facesIdx[i][0])), facesSize[i] * sizeof(facesIdx[i][0])) ;
}
}
......
......@@ -60,6 +60,35 @@ template <> inline std::string nameOfType(const double& v) { return "double"; }
template <> inline std::string nameOfType(const std::string& v) { return "std::string"; }
// Ply compatibility
template <typename T>
std::string nameOfTypePly(const T& v)
{
return v.CGoGNnameOfType();
}
template <> inline std::string nameOfTypePly(const char& v) { return "int8"; }
template <> inline std::string nameOfTypePly(const short int& v) { return "int16"; }
template <> inline std::string nameOfTypePly(const int& v) { return "int32"; }
template <> inline std::string nameOfTypePly(const long int& v) { return "invalid"; }
template <> inline std::string nameOfTypePly(const unsigned char& v) { return "uint8"; }
template <> inline std::string nameOfType(const unsigned short int& v) { return "uint16"; }
template <> inline std::string nameOfTypePly(const unsigned int& v) { return "uint32"; }
template <> inline std::string nameOfTypePly(const unsigned long int& v) { return "invalid"; }
template <> inline std::string nameOfTypePly(const float& v) { return "float32"; }
template <> inline std::string nameOfTypePly(const double& v) { return "float64"; }
template <> inline std::string nameOfTypePly(const std::string& v) { return "invalid"; }
}
#endif /* NAMETYPES_H_ */
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