Skip to content
Snippets Groups Projects
Commit 667ccd82 authored by Karsten Rink's avatar Karsten Rink Committed by Tom Fischer
Browse files

usability

parent 65d6fe8e
No related branches found
No related tags found
No related merge requests found
......@@ -7,46 +7,20 @@
<x>0</x>
<y>0</y>
<width>350</width>
<height>220</height>
<height>250</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>220</height>
<height>250</height>
</size>
</property>
<property name="windowTitle">
<string>Add layer to mesh</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="QGroupBox" name="layerBox">
<property name="title">
<string>Add layer</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="topButton">
<property name="text">
<string>at the top of the mesh</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="bottomButton">
<property name="text">
<string>at the bottom of the mesh</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="5" column="0" colspan="2">
<item row="7" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -60,7 +34,7 @@
<widget class="QLineEdit" name="thicknessEdit">
<property name="maximumSize">
<size>
<width>150</width>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
......@@ -92,7 +66,7 @@
</property>
</widget>
</item>
<item row="4" column="0">
<item row="6" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -105,8 +79,68 @@
</property>
</spacer>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="nameEdit">
<property name="text">
<string>ResultAddLayer</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="nameLabel">
<property name="text">
<string>Name of new mesh</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QGroupBox" name="layerBox">
<property name="title">
<string>Add layer</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="topButton">
<property name="text">
<string>at the top of the mesh</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="bottomButton">
<property name="text">
<string>at the bottom of the mesh</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<tabstops>
<tabstop>topButton</tabstop>
<tabstop>bottomButton</tabstop>
<tabstop>thicknessEdit</tabstop>
<tabstop>nameEdit</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
......
......@@ -14,17 +14,23 @@
#include "AddLayerToMeshDialog.h"
#include "OGSError.h"
#include "StrictDoubleValidator.h"
AddLayerToMeshDialog::AddLayerToMeshDialog(QDialog* parent)
: QDialog(parent)
{
setupUi(this);
StrictDoubleValidator* thickness_validator = new StrictDoubleValidator(0, 1000000, 7, this);
this->thicknessEdit->setValidator (thickness_validator);
}
void AddLayerToMeshDialog::accept()
{
if (this->thicknessEdit->text().isEmpty() ||
if (this->nameEdit->text().isEmpty())
OGSError::box("Please enter a name for the new Mesh.");
else if (this->thicknessEdit->text().isEmpty() ||
this->thicknessEdit->text().toDouble() <= 0)
OGSError::box("Thickness needs to be larger 0");
else
......
......@@ -18,6 +18,7 @@
#include "ui_AddLayerToMesh.h"
#include <QDialog>
#include <QLineEdit>
/**
* \brief A dialog window for adding a layer to the top or bottom of a mesh
......@@ -29,10 +30,14 @@ class AddLayerToMeshDialog : public QDialog, private Ui_AddLayerToMesh
public:
AddLayerToMeshDialog(QDialog* parent = nullptr);
/// Returns if the top layer button is selected (if false, bottom is selected)
bool isTopLayer() { return this->topButton->isChecked(); };
/// Returns if the top layer button is selected (if false, bottom is selected).
bool isTopLayer() const { return this->topButton->isChecked(); };
double getThickness() { return this->thicknessEdit->text().toDouble(); };
/// Returns the thickness of the new layer.
double getThickness() const { return this->thicknessEdit->text().toDouble(); };
/// Returns the name of the new mesh.
std::string getName() const { return this->nameEdit->text().toStdString(); };
private slots:
/// Instructions if the OK-Button has been pressed.
......
......@@ -119,7 +119,7 @@ void MshView::contextMenuEvent( QContextMenuEvent* event )
QMenu direct_cond_menu("DIRECT Conditions");
QAction* editMeshAction = menu.addAction("Edit mesh...");
QAction* editValuesAction = menu.addAction("Edit material groups...");
QAction* addLayerAction = menu.addAction("Add top layer...");
QAction* addLayerAction = menu.addAction("Add layer...");
QAction* meshQualityAction = menu.addAction("Calculate element quality...");
QAction* surfaceMeshAction (nullptr);
QAction* tetgenExportAction (nullptr);
......@@ -201,7 +201,8 @@ void MshView::openAddLayerDialog()
return;
double const thickness (dlg.getThickness());
MeshLib::Mesh* result = MeshLib::addLayerToMesh(*mesh, thickness, dlg.isTopLayer());
MeshLib::Mesh* result =
MeshLib::addLayerToMesh(*mesh, thickness, dlg.getName(), dlg.isTopLayer());
if (result != nullptr)
static_cast<MshModel*>(this->model())->addMesh(result);
......
......@@ -62,7 +62,9 @@ int main (int argc, char* argv[])
MeshLib::Mesh * subsfc_mesh(FileIO::readMeshFromFile(mesh_arg.getValue()));
INFO("done.");
MeshLib::Mesh* result (MeshLib::addTopLayerToMesh(*subsfc_mesh, layer_thickness_arg.getValue()));
std::unique_ptr<MeshLib::Mesh> result (MeshLib::addTopLayerToMesh(
*subsfc_mesh, layer_thickness_arg.getValue(), mesh_out_arg.getValue()
));
INFO("Writing mesh \"%s\" ... ", mesh_out_arg.getValue().c_str());
FileIO::VtuInterface mesh_io(result.get(), vtkXMLWriter::Binary);
......
......@@ -55,67 +55,23 @@ MeshLib::Element* extrudeElement(std::vector<MeshLib::Node*> const& subsfc_nodes
return nullptr;
}
/*
std::array<MeshLib::Node*, 6> prism_nodes;
prism_nodes[0] = subsfc_nodes[sfc_elem->getNode(0)->getID()];
prism_nodes[1] = subsfc_nodes[sfc_elem->getNode(1)->getID()];
prism_nodes[2] = subsfc_nodes[sfc_elem->getNode(2)->getID()];
prism_nodes[3] = subsfc_nodes[
subsfc_sfc_id_map.at(sfc_elem->getNode(0)->getID())];
prism_nodes[4] = subsfc_nodes[
subsfc_sfc_id_map.at(sfc_elem->getNode(1)->getID())];
prism_nodes[5] = subsfc_nodes[
subsfc_sfc_id_map.at(sfc_elem->getNode(2)->getID())];
return new MeshLib::Prism(prism_nodes);
}
MeshLib::Hex* extrudeElement(std::vector<MeshLib::Node*> const& subsfc_nodes,
MeshLib::Quad const*const sfc_elem,
std::map<std::size_t, std::size_t> const& subsfc_sfc_id_map)
{
std::array<MeshLib::Node*, 8> hex_nodes;
hex_nodes[0] = subsfc_nodes[sfc_elem->getNode(0)->getID()];
hex_nodes[1] = subsfc_nodes[sfc_elem->getNode(1)->getID()];
hex_nodes[2] = subsfc_nodes[sfc_elem->getNode(2)->getID()];
hex_nodes[3] = subsfc_nodes[sfc_elem->getNode(3)->getID()];
hex_nodes[4] = subsfc_nodes[
subsfc_sfc_id_map.at(sfc_elem->getNode(0)->getID())];
hex_nodes[5] = subsfc_nodes[
subsfc_sfc_id_map.at(sfc_elem->getNode(1)->getID())];
hex_nodes[6] = subsfc_nodes[
subsfc_sfc_id_map.at(sfc_elem->getNode(2)->getID())];
hex_nodes[7] = subsfc_nodes[
subsfc_sfc_id_map.at(sfc_elem->getNode(3)->getID())];
return new MeshLib::Hex(hex_nodes);
}
MeshLib::Quad* extrudeElement(std::vector<MeshLib::Node*> const& subsfc_nodes,
MeshLib::Line const*const sfc_elem,
std::map<std::size_t, std::size_t> const& subsfc_sfc_id_map)
{
std::array<MeshLib::Node*, 4> quad_nodes;
quad_nodes[0] = subsfc_nodes[sfc_elem->getNode(1)->getID()];
quad_nodes[1] = subsfc_nodes[sfc_elem->getNode(0)->getID()];
quad_nodes[2] = subsfc_nodes[
subsfc_sfc_id_map.at(sfc_elem->getNode(0)->getID())];
quad_nodes[3] = subsfc_nodes[
subsfc_sfc_id_map.at(sfc_elem->getNode(1)->getID())];
return new MeshLib::Quad(quad_nodes);
}
*/
MeshLib::Mesh* addTopLayerToMesh(MeshLib::Mesh const& mesh, double thickness)
MeshLib::Mesh* addTopLayerToMesh(MeshLib::Mesh const& mesh,
double thickness,
std::string const& name)
{
return addLayerToMesh(mesh, thickness, true);
return addLayerToMesh(mesh, thickness, name, true);
}
MeshLib::Mesh* addBottomLayerToMesh(MeshLib::Mesh const& mesh, double thickness)
MeshLib::Mesh* addBottomLayerToMesh(MeshLib::Mesh const& mesh,
double thickness,
std::string const& name)
{
return addLayerToMesh(mesh, thickness, false);
return addLayerToMesh(mesh, thickness, name, false);
}
MeshLib::Mesh* addLayerToMesh(MeshLib::Mesh const& mesh, double thickness, bool on_top)
MeshLib::Mesh* addLayerToMesh(MeshLib::Mesh const& mesh, double thickness,
std::string const& name,
bool on_top)
{
INFO("Extracting top surface of mesh \"%s\" ... ", mesh.getName().c_str());
int const flag = (on_top) ? -1 : 1;
......@@ -174,7 +130,7 @@ MeshLib::Mesh* addLayerToMesh(MeshLib::Mesh const& mesh, double thickness, bool
}
}
return new MeshLib::Mesh("Result", subsfc_nodes, subsfc_elements, subsfc_props);
return new MeshLib::Mesh(name, subsfc_nodes, subsfc_elements, subsfc_props);
}
} // namespace MeshLib
......@@ -25,11 +25,22 @@ class Mesh;
class Node;
class Element;
MeshLib::Mesh* addTopLayerToMesh(MeshLib::Mesh const& mesh, double thickness);
MeshLib::Mesh* addBottomLayerToMesh(MeshLib::Mesh const& mesh, double thickness);
MeshLib::Mesh* addLayerToMesh(MeshLib::Mesh const& mesh, double thickness, bool on_top);
/// Adds a layer on top of the mesh
MeshLib::Mesh* addTopLayerToMesh(MeshLib::Mesh const& mesh,
double thickness,
std::string const& name);
/// Adds a layer at the bottom of the mesh
MeshLib::Mesh* addBottomLayerToMesh(MeshLib::Mesh const& mesh,
double thickness,
std::string const& name);
/// Adds a layer to the mesh. If on_top is true, the layer is added on top,
/// if it is false, the layer is added at the bottom.
MeshLib::Mesh* addLayerToMesh(MeshLib::Mesh const& mesh,
double thickness,
std::string const& name,
bool on_top);
} // end namespace MeshLib
......
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