Skip to content
Snippets Groups Projects
Commit 2c5c023a authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

Merge pull request #575 from rinkk/SurfaceExtractionDialog

Surface extraction dialog
parents d86ca1c3 5da5d20b
No related branches found
No related tags found
No related merge requests found
......@@ -38,6 +38,7 @@ set( SOURCES
StationTabWidget.cpp
StationTreeModel.cpp
StationTreeView.cpp
SurfaceExtractionDialog.cpp
)
# Moc Header files
......@@ -76,6 +77,7 @@ set( MOC_HEADERS
StationTabWidget.h
StationTreeModel.h
StationTreeView.h
SurfaceExtractionDialog.h
)
# Header files
......@@ -115,6 +117,7 @@ set( UIS
NewProcess.ui
SaveMesh.ui
StationTabWidgetBase.ui
SurfaceExtraction.ui
)
# Put filter in a folder
......
......@@ -25,6 +25,7 @@
#include "MeshLib/Node.h"
#include "MeshLayerEditDialog.h"
#include "MeshValueEditDialog.h"
#include "SurfaceExtractionDialog.h"
#include "MshItem.h"
#include "MshModel.h"
#include "OGSError.h"
......@@ -120,7 +121,7 @@ void MshView::contextMenuEvent( QContextMenuEvent* event )
QAction* tetgenExportAction (nullptr);
if (mesh_dim==3)
{
surfaceMeshAction = menu.addAction("Extract surface");
surfaceMeshAction = menu.addAction("Extract surface...");
tetgenExportAction = menu.addAction("Export to TetGen...");
}
QAction* mesh2geoAction (nullptr);
......@@ -187,8 +188,17 @@ void MshView::extractSurfaceMesh()
return;
const MeshLib::Mesh* mesh = static_cast<MshModel*>(this->model())->getMesh(index);
const MathLib::Vector3 dir(0, 0, -1);
static_cast<MshModel*>(this->model())->addMesh( MeshLib::MeshSurfaceExtraction::getMeshSurface(*mesh, dir, 89) );
SurfaceExtractionDialog dlg;
if (dlg.exec() != QDialog::Accepted)
return;
MathLib::Vector3 const& dir (dlg.getNormal());
int const tolerance (dlg.getTolerance());
MeshLib::Mesh* sfc_mesh (MeshLib::MeshSurfaceExtraction::getMeshSurface(*mesh, dir, tolerance));
if (sfc_mesh != nullptr)
static_cast<MshModel*>(this->model())->addMesh(sfc_mesh);
else
OGSError::box(" No surfaces found to extract\n using the specified parameters.");
}
void MshView::convertMeshToGeometry()
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SurfaceExtraction</class>
<widget class="QDialog" name="SurfaceExtraction">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>214</height>
</rect>
</property>
<property name="windowTitle">
<string>Extract surfaces...</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="verticalSpacing">
<number>2</number>
</property>
<item row="0" column="2">
<widget class="QLineEdit" name="yNormalEdit">
<property name="minimumSize">
<size>
<width>70</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>70</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string notr="true">0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="surfaceNormalLabel">
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Surface Normal:</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLineEdit" name="zNormalEdit">
<property name="minimumSize">
<size>
<width>70</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>70</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string notr="true">-1</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="1" colspan="3">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="xNormalEdit">
<property name="minimumSize">
<size>
<width>70</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>70</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string notr="true">0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="toleranceLabel">
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string>Tolerance:</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLabel" name="degreesLabel">
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string>Degrees</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="4">
<widget class="QLabel" name="surfaceNormalExplLabel">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>(The vector (0,0,0) will return the complete boundary)</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing</set>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QSpinBox" name="degreesSpinBox">
<property name="minimumSize">
<size>
<width>70</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>70</width>
<height>16777215</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="maximum">
<number>90</number>
</property>
<property name="value">
<number>90</number>
</property>
</widget>
</item>
<item row="3" column="0" colspan="4">
<widget class="QLabel" name="toleranceExplLabel">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>(Allowed deviation from given surface normal)</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing</set>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>xNormalEdit</tabstop>
<tabstop>yNormalEdit</tabstop>
<tabstop>zNormalEdit</tabstop>
<tabstop>degreesSpinBox</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>SurfaceExtraction</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>SurfaceExtraction</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
/**
* \file SurfaceExtractionDialog.cpp
* \author Karsten Rink
* \date 2015-01-29
* \brief Implementation of the SaveMeshDialog class.
*
* \copyright
* Copyright (c) 2012-2015, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#include "SurfaceExtractionDialog.h"
#include <QDoubleValidator>
SurfaceExtractionDialog::SurfaceExtractionDialog(QDialog* parent)
: QDialog(parent), _tolerance(90), _dir(0,0,-1)
{
setupUi(this);
this->xNormalEdit->setValidator(new QDoubleValidator(-1, 1, 3, xNormalEdit));
this->yNormalEdit->setValidator(new QDoubleValidator(-1, 1, 3, yNormalEdit));
this->zNormalEdit->setValidator(new QDoubleValidator(-1, 1, 3, zNormalEdit));
}
void SurfaceExtractionDialog::accept()
{
_dir = MathLib::Vector3(xNormalEdit->text().toDouble(),
yNormalEdit->text().toDouble(),
zNormalEdit->text().toDouble());
_tolerance = degreesSpinBox->text().toInt();
this->done(QDialog::Accepted);
}
/**
* \file SurfaceExtractionDialog.h
* \author Karsten Rink
* \date 2015-01-29
* \brief Definition of the SurfaceExtractionDialog class.
*
* \copyright
* Copyright (c) 2012-2015, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#ifndef SURFACEEXTRACTIONDIALOG_H
#define SURFACEEXTRACTIONDIALOG_H
#include "ui_SurfaceExtraction.h"
#include <QDialog>
#include "MathLib/Vector3.h"
namespace MeshLib {
class Mesh;
}
/**
* \brief A dialog window for managing properties for writing meshes to files.
*/
class SurfaceExtractionDialog : public QDialog, private Ui_SurfaceExtraction
{
Q_OBJECT
public:
SurfaceExtractionDialog(QDialog* parent = 0);
~SurfaceExtractionDialog() {}
int getTolerance() const { return _tolerance; }
MathLib::Vector3 const& getNormal() const { return _dir; }
private slots:
/// Instructions if the OK-Button has been pressed.
void accept();
/// Instructions if the Cancel-Button has been pressed.
void reject() { this->done(QDialog::Rejected); };
private:
int _tolerance;
MathLib::Vector3 _dir;
};
#endif //SURFACEEXTRACTIONDIALOG_H
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