Commit 334d4d7b authored by Jan Möbius's avatar Jan Möbius
Browse files

Correctly write binary header(missing endian), reserve memory before adding data to improve speed

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@11621 383ad7c9-94d9-4d36-a494-682f7c89f535
parent a8ed63b4
......@@ -167,10 +167,13 @@ bool FilePLYPlugin::parseHeader(QString _filename, PLYHeader& _header) {
_header.binary = false;
} else {
_header.binary = true;
if ( dString.find("little") != std::string::npos ) {
_header.bigEndian = false;
} else {
if ( dString.find("big") != std::string::npos ) {
_header.bigEndian = true;
} else {
if ( dString.find("little") == std::string::npos ) {
emit log(LOGWARN,tr("Binary PLY file without endian specification. Assuming little endian."));
}
_header.bigEndian = false;
}
}
......@@ -440,9 +443,13 @@ int FilePLYPlugin::loadTriMeshObject(QString _filename, const PLYHeader _header)
// Get mesh
TriMesh* mesh = object->mesh();
// Reserve Memory to speed up loading
// Euler formula to calculate number of edges (approximation)
mesh->reserve(_header.numVertices,(_header.numVertices+_header.numFaces)/2,_header.numFaces);
if(!_header.binary) {
// Read ascii file
// Read ASCII file
if(!readMeshFileAscii(_filename, mesh, _header)) {
emit log(LOGERR, "Error while reading ascii PLY file!");
emit deleteObject(id);
......@@ -492,9 +499,12 @@ int FilePLYPlugin::loadPolyMeshObject(QString _filename, const PLYHeader _header
// Get mesh
PolyMesh* mesh = object->mesh();
// Reserve Memory to speed up loading
mesh->reserve(_header.numVertices,_header.numVertices * 4,_header.numFaces);
if(!_header.binary) {
// Read ascii file
// Read ASCII file
if(!readMeshFileAscii(_filename, mesh, _header)) {
emit log(LOGERR, "Error while reading ascii PLY file!");
emit deleteObject(id);
......
......@@ -710,7 +710,7 @@ void FilePLYPlugin::writeHeader(std::ofstream& _os, MeshT* _mesh, bool _binary)
// Write general information
_os << "ply\n";
_os << "format " << (_binary ? "binary" : "ascii") << " 1.0\n";
_os << "format " << (_binary ? "binary_little_endian" : "ascii") << " 1.0\n";
_os << "comment =================================\n";
_os << "comment Exported via OpenFlipper " << OpenFlipper::Options::coreVersion().toStdString() << "\n";
_os << "comment www.openflipper.org\n";
......
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