Skip to content
Snippets Groups Projects
Commit f1e348e7 authored by Karsten Rink's avatar Karsten Rink
Browse files

included surface extraction from 3d meshes into gui

parent 146abb40
No related branches found
No related tags found
No related merge requests found
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
#include "MshItem.h" #include "MshItem.h"
#include "MshModel.h" #include "MshModel.h"
#include "OGSError.h" #include "OGSError.h"
#include "MshEditor.h"
#include "ImportFileTypes.h" #include "ImportFileTypes.h"
#include <QHeaderView> #include <QHeaderView>
...@@ -87,41 +89,33 @@ void MshView::removeMesh() ...@@ -87,41 +89,33 @@ void MshView::removeMesh()
emit requestMeshRemoval(index); emit requestMeshRemoval(index);
} }
/*
// Removed functionality. Do we still need this?
void MshView::removeAllMeshes()
{
TreeItem* root = static_cast<MshModel*>(this->model())->getItem(QModelIndex());
int nChildren = root->childCount() - 1;
for (int i = nChildren; i >= 0; i--)
emit requestMeshRemoval(this->model()->index(i, 0, QModelIndex()));
}
*/
void MshView::contextMenuEvent( QContextMenuEvent* event ) void MshView::contextMenuEvent( QContextMenuEvent* event )
{ {
QModelIndex index = this->selectionModel()->currentIndex(); QModelIndex index = this->selectionModel()->currentIndex();
MshItem* item = dynamic_cast<MshItem*>(static_cast<TreeItem*>(index.internalPointer())); MshItem* item = dynamic_cast<MshItem*>(static_cast<TreeItem*>(index.internalPointer()));
bool is_3D_mesh (item->getMesh()->getDimension() == 3);
if (item) if (item)
{ {
QMenu menu; QMenu menu;
QAction* editMeshAction = menu.addAction("Edit mesh..."); QAction* editMeshAction = menu.addAction("Edit mesh...");
QAction* checkMeshAction = menu.addAction("Check mesh quality..."); QAction* checkMeshAction = menu.addAction("Check mesh quality...");
//QAction* saveMeshAction = menu.addAction("Save mesh..."); QAction* surfaceMeshAction (NULL);
if (is_3D_mesh)
surfaceMeshAction = menu.addAction("Extract surface");
menu.addSeparator(); menu.addSeparator();
QMenu direct_cond_menu("DIRECT Conditions"); QMenu direct_cond_menu("DIRECT Conditions");
menu.addMenu(&direct_cond_menu); menu.addMenu(&direct_cond_menu);
QAction* addDirectAction = direct_cond_menu.addAction("Add..."); QAction* addDirectAction = direct_cond_menu.addAction("Add...");
QAction* loadDirectAction = direct_cond_menu.addAction("Load..."); QAction* loadDirectAction = direct_cond_menu.addAction("Load...");
menu.addSeparator(); //menu.addSeparator();
//QAction* removeMeshAction = menu.addAction("Remove mesh");
connect(editMeshAction, SIGNAL(triggered()), this, SLOT(openMshEditDialog())); connect(editMeshAction, SIGNAL(triggered()), this, SLOT(openMshEditDialog()));
connect(checkMeshAction, SIGNAL(triggered()), this, SLOT(checkMeshQuality())); connect(checkMeshAction, SIGNAL(triggered()), this, SLOT(checkMeshQuality()));
//connect(saveMeshAction, SIGNAL(triggered()), this, SLOT(writeMeshToFile())); if (is_3D_mesh)
connect(surfaceMeshAction, SIGNAL(triggered()), this, SLOT(extractSurfaceMesh()));
connect(addDirectAction, SIGNAL(triggered()), this, SLOT(addDIRECTSourceTerms())); connect(addDirectAction, SIGNAL(triggered()), this, SLOT(addDIRECTSourceTerms()));
connect(loadDirectAction, SIGNAL(triggered()), this, SLOT(loadDIRECTSourceTerms())); connect(loadDirectAction, SIGNAL(triggered()), this, SLOT(loadDIRECTSourceTerms()));
//connect(removeMeshAction, SIGNAL(triggered()), this, SLOT(removeMesh()));
menu.exec(event->globalPos()); menu.exec(event->globalPos());
} }
} }
...@@ -139,6 +133,17 @@ void MshView::openMshEditDialog() ...@@ -139,6 +133,17 @@ void MshView::openMshEditDialog()
meshEdit.exec(); meshEdit.exec();
} }
void MshView::extractSurfaceMesh()
{
QModelIndex index = this->selectionModel()->currentIndex();
if (!index.isValid())
return;
const MeshLib::Mesh* mesh = static_cast<MshModel*>(this->model())->getMesh(index);
const double dir[3] = {0, 0, 1};
static_cast<MshModel*>(this->model())->addMesh( MeshLib::MshEditor::getMeshSurface(*mesh, dir) );
}
int MshView::writeToFile() const int MshView::writeToFile() const
{ {
QModelIndex index = this->selectionModel()->currentIndex(); QModelIndex index = this->selectionModel()->currentIndex();
......
...@@ -64,14 +64,13 @@ private slots: ...@@ -64,14 +64,13 @@ private slots:
void addDIRECTSourceTerms(); void addDIRECTSourceTerms();
void extractSurfaceMesh();
void loadDIRECTSourceTerms(); void loadDIRECTSourceTerms();
/// Remove the currently selected mesh. /// Remove the currently selected mesh.
void removeMesh(); void removeMesh();
/// Remove all currently loaded meshes.
//void removeAllMeshes();
/// Calls the FileDialog to save a mesh to a file. /// Calls the FileDialog to save a mesh to a file.
int writeToFile() const; int writeToFile() const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment