Commit 1131b86a authored by Martin Schultz's avatar Martin Schultz
Browse files

refs #2421

* offloader uses float optimization


git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@20899 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 5a47143b
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
#include <QFileInfo> #include <QFileInfo>
#include <QSettings> #include <QSettings>
#include <QPushButton> #include <QPushButton>
#include <time.h>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
#include <OpenMesh/Core/Utils/color_cast.hh> #include <OpenMesh/Core/Utils/color_cast.hh>
#include <OpenFlipper/ACGHelper/DrawModeConverter.hh> #include <OpenFlipper/ACGHelper/DrawModeConverter.hh>
#include <OpenFlipper/Utils/FileIO/NumberParsing.hh>
// Defines for the type handling drop down box // Defines for the type handling drop down box
#define TYPEAUTODETECT 0 #define TYPEAUTODETECT 0
...@@ -71,6 +72,11 @@ ...@@ -71,6 +72,11 @@
#define TYPEPOLY 2 #define TYPEPOLY 2
#define TYPETRIANGLE 3 #define TYPETRIANGLE 3
using namespace Utils;
//-----------------------------------------------------------------------------
// help functions
/// Constructor /// Constructor
FileOFFPlugin::FileOFFPlugin() FileOFFPlugin::FileOFFPlugin()
: loadOptions_(0), : loadOptions_(0),
...@@ -628,14 +634,18 @@ bool FileOFFPlugin::parseASCII(std::istream& _in, OFFImporter& _importer, DataTy ...@@ -628,14 +634,18 @@ bool FileOFFPlugin::parseASCII(std::istream& _in, OFFImporter& _importer, DataTy
for (uint i=0; i<nV && !_in.eof(); ++i) { for (uint i=0; i<nV && !_in.eof(); ++i) {
// Always read VERTEX // Always read VERTEX
_in >> v[0] >> v[1] >> v[2]; v[0] = getFloat(_in);
v[1] = getFloat(_in);
v[2] = getFloat(_in);
const VertexHandle vh = _importer.addVertex(v); const VertexHandle vh = _importer.addVertex(v);
// perhaps read NORMAL // perhaps read NORMAL
if ( _importer.hasVertexNormals() ){ if ( _importer.hasVertexNormals() ){
_in >> n[0] >> n[1] >> n[2]; n[0] = getFloat(_in);
n[1] = getFloat(_in);
n[2] = getFloat(_in);
if(userReadOptions_ & OFFImporter::VERTEXNORMAL) { if(userReadOptions_ & OFFImporter::VERTEXNORMAL) {
int nid = _importer.addNormal(n); int nid = _importer.addNormal(n);
...@@ -659,14 +669,21 @@ bool FileOFFPlugin::parseASCII(std::istream& _in, OFFImporter& _importer, DataTy ...@@ -659,14 +669,21 @@ bool FileOFFPlugin::parseASCII(std::istream& _in, OFFImporter& _importer, DataTy
case 1 : sstr >> trash; break; //one int (isn't handled atm) case 1 : sstr >> trash; break; //one int (isn't handled atm)
case 2 : sstr >> trash; sstr >> trash; break; //corrupt format (ignore) case 2 : sstr >> trash; sstr >> trash; break; //corrupt format (ignore)
// rgb int // rgb int
case 3 : sstr >> c3[0]; sstr >> c3[1]; sstr >> c3[2]; case 3 :
sstr >> c3[0];
sstr >> c3[1];
sstr >> c3[2];
if ( userReadOptions_ & OFFImporter::VERTEXCOLOR ) { if ( userReadOptions_ & OFFImporter::VERTEXCOLOR ) {
int cidx = _importer.addColor( OpenMesh::color_cast<PolyMesh::Color>( c3 ) ); int cidx = _importer.addColor( OpenMesh::color_cast<PolyMesh::Color>( c3 ) );
_importer.setVertexColor(vh, cidx); _importer.setVertexColor(vh, cidx);
} }
break; break;
// rgba int // rgba int
case 4 : sstr >> c4[0]; sstr >> c4[1]; sstr >> c4[2]; sstr >> c4[3]; case 4 :
sstr >> c4[0];
sstr >> c4[1];
sstr >> c4[2];
sstr >> c4[3];
if ( userReadOptions_ & OFFImporter::VERTEXCOLOR ) { if ( userReadOptions_ & OFFImporter::VERTEXCOLOR ) {
int cidx = _importer.addColor( OpenMesh::color_cast<PolyMesh::Color>( c4 ) ); int cidx = _importer.addColor( OpenMesh::color_cast<PolyMesh::Color>( c4 ) );
_importer.setVertexColor(vh, cidx); _importer.setVertexColor(vh, cidx);
...@@ -674,14 +691,21 @@ bool FileOFFPlugin::parseASCII(std::istream& _in, OFFImporter& _importer, DataTy ...@@ -674,14 +691,21 @@ bool FileOFFPlugin::parseASCII(std::istream& _in, OFFImporter& _importer, DataTy
} }
break; break;
// rgb floats // rgb floats
case 5 : sstr >> c3f[0]; sstr >> c3f[1]; sstr >> c3f[2]; case 5 :
c3f[0] = getFloat(sstr);
c3f[1] = getFloat(sstr);
c3f[2] = getFloat(sstr);
if ( userReadOptions_ & OFFImporter::VERTEXCOLOR ) { if ( userReadOptions_ & OFFImporter::VERTEXCOLOR ) {
int cidx = _importer.addColor( OpenMesh::color_cast<PolyMesh::Color>(c3f) ); int cidx = _importer.addColor( OpenMesh::color_cast<PolyMesh::Color>(c3f) );
_importer.setVertexColor(vh, cidx); _importer.setVertexColor(vh, cidx);
} }
break; break;
// rgba floats // rgba floats
case 6 : sstr >> c4f[0]; sstr >> c4f[1]; sstr >> c4f[2]; sstr >> c4f[3]; case 6 :
c4f[0] = getFloat(sstr);
c4f[1] = getFloat(sstr);
c4f[2] = getFloat(sstr);
c4f[3] = getFloat(sstr);
if ( userReadOptions_ & OFFImporter::VERTEXCOLOR ) { if ( userReadOptions_ & OFFImporter::VERTEXCOLOR ) {
int cidx = _importer.addColor( OpenMesh::color_cast<PolyMesh::Color>(c4f) ); int cidx = _importer.addColor( OpenMesh::color_cast<PolyMesh::Color>(c4f) );
_importer.setVertexColor(vh, cidx); _importer.setVertexColor(vh, cidx);
...@@ -697,7 +721,8 @@ bool FileOFFPlugin::parseASCII(std::istream& _in, OFFImporter& _importer, DataTy ...@@ -697,7 +721,8 @@ bool FileOFFPlugin::parseASCII(std::istream& _in, OFFImporter& _importer, DataTy
//perhaps read TEXTURE COORDS //perhaps read TEXTURE COORDS
if ( _importer.hasTextureCoords() ){ if ( _importer.hasTextureCoords() ){
sstr >> t[0]; sstr >> t[1]; t[0] = getFloat(sstr);
t[1] = getFloat(sstr);
if ( userReadOptions_ & OFFImporter::VERTEXTEXCOORDS ) { if ( userReadOptions_ & OFFImporter::VERTEXTEXCOORDS ) {
int tcidx = _importer.addTexCoord(t); int tcidx = _importer.addTexCoord(t);
_importer.setVertexTexCoord(vh, tcidx); _importer.setVertexTexCoord(vh, tcidx);
...@@ -769,14 +794,21 @@ bool FileOFFPlugin::parseASCII(std::istream& _in, OFFImporter& _importer, DataTy ...@@ -769,14 +794,21 @@ bool FileOFFPlugin::parseASCII(std::istream& _in, OFFImporter& _importer, DataTy
case 1 : sstr >> trash; break; //one int (isn't handled atm) case 1 : sstr >> trash; break; //one int (isn't handled atm)
case 2 : sstr >> trash; sstr >> trash; break; //corrupt format (ignore) case 2 : sstr >> trash; sstr >> trash; break; //corrupt format (ignore)
// rgb int // rgb int
case 3 : sstr >> c3[0]; sstr >> c3[1]; sstr >> c3[2]; case 3 :
sstr >> c3[0];
sstr >> c3[1];
sstr >> c3[2];
if ( userReadOptions_ & OFFImporter::FACECOLOR ) { if ( userReadOptions_ & OFFImporter::FACECOLOR ) {
int cidx = _importer.addColor( OpenMesh::color_cast<PolyMesh::Color>( c3 ) ); int cidx = _importer.addColor( OpenMesh::color_cast<PolyMesh::Color>( c3 ) );
_importer.setFaceColor(fh, cidx); _importer.setFaceColor(fh, cidx);
} }
break; break;
// rgba int // rgba int
case 4 : sstr >> c4[0]; sstr >> c4[1]; sstr >> c4[2]; sstr >> c4[3]; case 4 :
sstr >> c4[0];
sstr >> c4[1];
sstr >> c4[2];
sstr >> c4[3];
if ( userReadOptions_ & OFFImporter::FACECOLOR ) { if ( userReadOptions_ & OFFImporter::FACECOLOR ) {
int cidx = _importer.addColor( OpenMesh::color_cast<PolyMesh::Color>( c4 ) ); int cidx = _importer.addColor( OpenMesh::color_cast<PolyMesh::Color>( c4 ) );
_importer.setFaceColor(fh, cidx); _importer.setFaceColor(fh, cidx);
...@@ -784,14 +816,21 @@ bool FileOFFPlugin::parseASCII(std::istream& _in, OFFImporter& _importer, DataTy ...@@ -784,14 +816,21 @@ bool FileOFFPlugin::parseASCII(std::istream& _in, OFFImporter& _importer, DataTy
} }
break; break;
// rgb floats // rgb floats
case 5 : sstr >> c3f[0]; sstr >> c3f[1]; sstr >> c3f[2]; case 5 :
c3f[0] = getFloat(sstr);
c3f[1] = getFloat(sstr);
c3f[2] = getFloat(sstr);
if ( userReadOptions_ & OFFImporter::FACECOLOR ) { if ( userReadOptions_ & OFFImporter::FACECOLOR ) {
int cidx = _importer.addColor( OpenMesh::color_cast<PolyMesh::Color>(c3f) ); int cidx = _importer.addColor( OpenMesh::color_cast<PolyMesh::Color>(c3f) );
_importer.setFaceColor(fh, cidx); _importer.setFaceColor(fh, cidx);
} }
break; break;
// rgba floats // rgba floats
case 6 : sstr >> c4f[0]; sstr >> c4f[1]; sstr >> c4f[2]; sstr >> c4f[3]; case 6 :
c4f[0] = getFloat(sstr);
c4f[1] = getFloat(sstr);
c4f[2] = getFloat(sstr);
c4f[3] = getFloat(sstr);
if ( userReadOptions_ & OFFImporter::FACECOLOR ) { if ( userReadOptions_ & OFFImporter::FACECOLOR ) {
int cidx = _importer.addColor( OpenMesh::color_cast<PolyMesh::Color>(c4f) ); int cidx = _importer.addColor( OpenMesh::color_cast<PolyMesh::Color>(c4f) );
_importer.setFaceColor(fh, cidx); _importer.setFaceColor(fh, cidx);
...@@ -1145,7 +1184,6 @@ bool FileOFFPlugin::extendedFaceColorTest(std::istream& _in, uint _nV, uint _nF, ...@@ -1145,7 +1184,6 @@ bool FileOFFPlugin::extendedFaceColorTest(std::istream& _in, uint _nV, uint _nF,
//----------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------
int FileOFFPlugin::loadObject(QString _filename) { int FileOFFPlugin::loadObject(QString _filename) {
OFFImporter importer; OFFImporter importer;
// Parse file // Parse file
...@@ -1206,7 +1244,6 @@ int FileOFFPlugin::loadObject(QString _filename) { ...@@ -1206,7 +1244,6 @@ int FileOFFPlugin::loadObject(QString _filename) {
forceTriangleMesh_ = false; forceTriangleMesh_ = false;
forcePolyMesh_ = false; forcePolyMesh_ = false;
return object->id(); return object->id();
} }
......
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