Commit 3a59b72f authored by Dirk Wilden's avatar Dirk Wilden
Browse files

scripting fn for binary saveObject

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@6351 383ad7c9-94d9-4d36-a494-682f7c89f535
parent a14c2911
......@@ -170,8 +170,7 @@ bool FileTriangleMeshPlugin::saveObject(int _id, QString _filename){
PluginFunctions::getObject(_id,object);
if (object == 0){
emit log(LOGERR, "Unable to save " + object->path() + OpenFlipper::Options::dirSeparator() + object->name()
+ " (Could not get object)");
emit log(LOGERR, "Unable to save (Could not get object)");
return false;
}
......@@ -224,6 +223,43 @@ bool FileTriangleMeshPlugin::saveObject(int _id, QString _filename){
}
}
/// Save object with given id
bool FileTriangleMeshPlugin::saveObject(int _id, QString _filename, bool _binary){
BaseObjectData* object;
PluginFunctions::getObject(_id,object);
if (object == 0){
emit log(LOGERR, "Unable to save (Could not get object)");
return false;
}
std::string filename = std::string( _filename.toUtf8() );
if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
object->setName(_filename.section(OpenFlipper::Options::dirSeparator(),-1));
object->path(_filename.section(OpenFlipper::Options::dirSeparator(),0,-2) );
TriMeshObject* triObj = dynamic_cast<TriMeshObject* >( object );
OpenMesh::IO::Options opt = OpenMesh::IO::Options::Default;
if ( _binary )
opt += OpenMesh::IO::Options::Binary;
if (OpenMesh::IO::write_mesh(*triObj->mesh(), filename.c_str(),opt) ){
emit log(LOGINFO, "Saved object to " + object->path() + OpenFlipper::Options::dirSeparator() + object->name() );
return true;
}else{
emit log(LOGERR, "Unable to save " + object->path() + OpenFlipper::Options::dirSeparator() + object->name());
return false;
}
}else{
emit log(LOGERR, "Unable to save (object isn't a triangle mesh)");
return false;
}
}
///return file-extension filters for loading objects
QString FileTriangleMeshPlugin::getLoadFilters() {
return QString( OpenMesh::IO::IOManager().qt_read_filters().c_str() );
......
......@@ -100,6 +100,8 @@ class FileTriangleMeshPlugin : public QObject, BaseInterface, FileInterface, Loa
public slots:
bool saveObject(int _id, QString _filename);
bool saveObject(int _id, QString _filename, bool _binary);
int loadObject(QString _filename);
int addNewTriangleMesh( );
......
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