Commit 1141d072 authored by Jan Möbius's avatar Jan Möbius
Browse files

Big endian support in ply reader

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@11550 383ad7c9-94d9-4d36-a494-682f7c89f535
parent ee9b0aa4
......@@ -163,7 +163,17 @@ bool FilePLYPlugin::parseHeader(QString _filename, PLYHeader& _header) {
// Determine file format (either ascii or binary)
// format ascii/binary version
sstr >> dString;
_header.binary = (dString != "ascii");
if ( dString.find("ascii") != std::string::npos ) {
_header.binary = false;
} else {
_header.binary = true;
if ( dString.find("little") != std::string::npos ) {
_header.bigEndian = false;
} else {
_header.bigEndian = true;
}
}
// Skip version
continue;
} else if(dString == "element") {
......@@ -300,7 +310,7 @@ int FilePLYPlugin::loadObject(QString _filename) {
}
// Create header and initialize with binary zeros
PLYHeader header = {0,0,0,0,0,0,0,std::vector<PPair>(),
PLYHeader header = {0,false,0,0,0,0,0,0,std::vector<PPair>(),
0,0,0,0,"","",std::vector<PPair>()};
// Parse header in order to extract important information
......
......@@ -115,6 +115,7 @@ class FilePLYPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInte
typedef std::pair<std::string,std::string> PPair;
struct PLYHeader {
bool binary;
bool bigEndian;
bool isTriangleMesh;
int numVertices;
......@@ -178,16 +179,16 @@ class FilePLYPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInte
/// \brief Helper functions for writing/reading of binary data
template <class T>
void readValue(std::istream& _in, T& _value) const {
void readValue(std::istream& _in, T& _value, bool _bigEndian) const {
T tmp;
OpenMesh::IO::restore(_in , tmp, false); //assuming LSB byte order
OpenMesh::IO::restore(_in , tmp, _bigEndian); //assuming LSB byte order
_value = tmp;
}
template <class T>
void writeValue(std::ostream& _out, T value) const {
void writeValue(std::ostream& _out, T value, bool _bigEndian = false) const {
T tmp = value;
OpenMesh::IO::store(_out, tmp, false);
OpenMesh::IO::store(_out, tmp, _bigEndian);
}
......
This diff is collapsed.
Supports Markdown
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