Commit 5f5ac19b authored by Mike Kremer's avatar Mike Kremer
Browse files

Always set object's name to filename.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@8337 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 53f63875
......@@ -445,7 +445,7 @@ bool FileOFFPlugin::readOFFFile(QString _filename, OFFImporter& _importer) {
QPushButton *triButton = msgBox.addButton(tr("Open as triangle mesh"), QMessageBox::ActionRole);
QPushButton *polyButton = msgBox.addButton(tr("Open as poly mesh"), QMessageBox::ActionRole);
DataType type;
DataType type = DATA_TRIANGLE_MESH;
switch (triMeshControl) {
case TYPEAUTODETECT:
......@@ -483,12 +483,12 @@ bool FileOFFPlugin::readOFFFile(QString _filename, OFFImporter& _importer) {
}
return _importer.isBinary() ? parseBinary(ifile, _importer, type) : parseASCII(ifile, _importer, type);
return _importer.isBinary() ? parseBinary(ifile, _importer, type, _filename) : parseASCII(ifile, _importer, type, _filename);
}
//-----------------------------------------------------------------------------------------------------
bool FileOFFPlugin::parseASCII(std::istream& _in, OFFImporter& _importer, DataType _type) {
bool FileOFFPlugin::parseASCII(std::istream& _in, OFFImporter& _importer, DataType _type, QString& _objectName) {
unsigned int idx;
unsigned int nV, nF, dummy;
......@@ -511,6 +511,12 @@ bool FileOFFPlugin::parseASCII(std::istream& _in, OFFImporter& _importer, DataTy
return false;
}
// Set object's name to match file name
QStringList filename = _objectName.split("/");
if(filename.size() > 0) {
object->setName(filename.at(filename.size()-1));
}
// Set initial object
_importer.addObject(object);
......@@ -736,14 +742,14 @@ int FileOFFPlugin::getColorType(std::string& _line, bool _texCoordsAvailable) co
//-----------------------------------------------------------------------------------------------------
bool FileOFFPlugin::parseBinary(std::istream& _in, OFFImporter& _importer, DataType _type) {
bool FileOFFPlugin::parseBinary(std::istream& _in, OFFImporter& _importer, DataType _type, QString& _objectName) {
unsigned int idx;
unsigned int nV, nF, dummy;
float dummy_f;
OpenMesh::Vec3f v, n;
OpenMesh::Vec3f c;
float alpha;
float alpha = 1.0f;
OpenMesh::Vec2f t;
std::vector<VertexHandle> vhandles;
VertexHandle vh;
......@@ -758,6 +764,12 @@ bool FileOFFPlugin::parseBinary(std::istream& _in, OFFImporter& _importer, DataT
return false;
}
// Set object's name to match file name
QStringList filename = _objectName.split("/");
if(filename.size() > 0) {
object->setName(filename.at(filename.size()-1));
}
// Set initial object
_importer.addObject(object);
......
......@@ -142,10 +142,10 @@ class FileOFFPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInte
bool readOFFFile(QString _filename, OFFImporter& _importer);
/// Parse ascii OFF file
bool parseASCII(std::istream& _in, OFFImporter& _importer, DataType _type);
bool parseASCII(std::istream& _in, OFFImporter& _importer, DataType _type, QString& _objectName);
/// Parse binary OFF file
bool parseBinary(std::istream& _in, OFFImporter& _importer, DataType _type);
bool parseBinary(std::istream& _in, OFFImporter& _importer, DataType _type, QString& _objectName);
/// Get color type
int getColorType(std::string& _line, bool _texCoordsAvailable) const;
......
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