Commit fb4ed6ed authored by Jan Möbius's avatar Jan Möbius

Ask user to reload polymesh if it is actually a triangle mesh

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7157 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 44c31e4d
......@@ -54,6 +54,9 @@
#include "OpenFlipper/widgets/loadWidget/loadWidget.hh"
#include "OpenFlipper/widgets/addEmptyWidget/addEmptyWidget.hh"
#include <OpenFlipper/common/Types.hh>
#include <ObjectTypes/PolyMesh/PolyMesh.hh>
#include <time.h>
void Core::resetScenegraph( bool _resetTrackBall ) {
......@@ -275,6 +278,50 @@ void Core::slotCopyObject( int _oldId , int& _newId ) {
/// Slot for loading a given file
void Core::slotLoad(QString _filename, DataType _type, int& _id) {
_id = loadObject(_type,_filename);
// Check if it is a polymesh
if ( _type == DATA_POLY_MESH ) {
PolyMeshObject* poly = 0;
PluginFunctions::getObject(_id,poly);
if ( poly != 0 ) {
PolyMesh& mesh = *poly->mesh();
bool isTriangleMesh = true;
for ( PolyMesh::FaceIter f_it = mesh.faces_begin(); f_it != mesh.faces_end() ; ++f_it) {
// Count number of vertices for the current face
uint count = 0;
for ( PolyMesh::FaceVertexIter fv_it( mesh,f_it); fv_it; ++fv_it )
++count;
// Check if it is a triangle. If not, this is really a poly mesh
if ( count != 3 ) {
isTriangleMesh = false;
break;
}
}
// Mesh loaded as polymesh is actually a triangle mesh. Ask the user to reload as triangle mesh or keep it as poly mesh.
if ( isTriangleMesh ) {
QMessageBox::StandardButton result = QMessageBox::question ( 0,
tr("TriMesh loaded as PolyMesh"),
tr("You opened the mesh as a poly mesh but actually its a triangle mesh. \nShould it be opened as a triangle mesh?"),
(QMessageBox::Yes | QMessageBox::No ),
QMessageBox::Yes );
// User decided to reload as triangle mesh
if ( result == QMessageBox::Yes ) {
slotDeleteObject(_id);
_id = loadObject(DATA_TRIANGLE_MESH ,_filename);
_type = DATA_TRIANGLE_MESH;
}
}
}
}
if ( _id < 0 )
_id = -1;
else
......
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