fixed edge display for volume cells
[engrid-github.git] / src / libengrid / guicreatehexcore.cpp
blob8aed6936394aeb38d83983afbab0aa18dd947182
1 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 // + +
3 // + This file is part of enGrid. +
4 // + +
5 // + Copyright 2008-2014 enGits GmbH +
6 // + +
7 // + enGrid is free software: you can redistribute it and/or modify +
8 // + it under the terms of the GNU General Public License as published by +
9 // + the Free Software Foundation, either version 3 of the License, or +
10 // + (at your option) any later version. +
11 // + +
12 // + enGrid is distributed in the hope that it will be useful, +
13 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
14 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
15 // + GNU General Public License for more details. +
16 // + +
17 // + You should have received a copy of the GNU General Public License +
18 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
19 // + +
20 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
22 #include "guicreatehexcore.h"
24 GuiCreateHexCore::GuiCreateHexCore()
26 connect(m_Ui.checkBoxExternalMesh, SIGNAL(toggled(bool)), this, SLOT(toggleExternalMesh(bool)));
29 void GuiCreateHexCore::before()
31 vec3_t x1( 1e99, 1e99, 1e99);
32 vec3_t x2(-1e99, -1e99, -1e99);
33 for (vtkIdType id_node = 0; id_node < m_Grid->GetNumberOfPoints(); ++id_node) {
34 vec3_t x;
35 m_Grid->GetPoint(id_node, x.data());
36 for (int i = 0; i < 3; ++i) {
37 x1[i] = min(x1[i], x[i]);
38 x2[i] = max(x2[i], x[i]);
41 double xmin = min(x1[0], min(x1[1], x1[2]));
42 double xmax = max(x2[0], max(x2[1], x2[2]));
43 m_X1 = vec3_t(xmin, xmin, xmin);
44 m_X2 = vec3_t(xmax, xmax, xmax);
45 m_X10 = m_X1;
46 m_X20 = m_X2;
47 m_Xi = 0.5*(x1 + x2);
48 m_Xi0 = m_Xi;
49 toggleExternalMesh(false);
52 void GuiCreateHexCore::toggleExternalMesh(bool external_mesh)
54 vec3_t xc = 0.5*(m_X10 + m_X20);
55 if (external_mesh) {
56 m_X1 = xc + 10*(m_X10 - xc);
57 m_X2 = xc + 10*(m_X20 - xc);
58 m_Xi = 0.9*m_X1 + 0.1*m_Xi0;
59 } else {
60 m_X1 = xc + 1.2*(m_X10 - xc);
61 m_X2 = xc + 1.2*(m_X20 - xc);
62 m_Xi = m_Xi0;
64 setDouble(m_Xi[0], m_Ui.lineEditCiX);
65 setDouble(m_Xi[1], m_Ui.lineEditCiY);
66 setDouble(m_Xi[2], m_Ui.lineEditCiZ);
67 setDouble(m_X1[0], m_Ui.lineEditX1);
68 setDouble(m_X1[1], m_Ui.lineEditY1);
69 setDouble(m_X1[2], m_Ui.lineEditZ1);
70 setDouble(m_X2[0], m_Ui.lineEditX2);
71 setDouble(m_X2[1], m_Ui.lineEditY2);
72 setDouble(m_X2[2], m_Ui.lineEditZ2);
75 void GuiCreateHexCore::operate()
77 m_Xi = vec3_t(m_Ui.lineEditCiX->text().toDouble(), m_Ui.lineEditCiY->text().toDouble(), m_Ui.lineEditCiZ->text().toDouble());
78 m_X1 = vec3_t(m_Ui.lineEditX1->text().toDouble(), m_Ui.lineEditY1->text().toDouble(), m_Ui.lineEditZ1->text().toDouble());
79 m_X2 = vec3_t(m_Ui.lineEditX2->text().toDouble(), m_Ui.lineEditY2->text().toDouble(), m_Ui.lineEditZ2->text().toDouble());
80 int num_levels = m_Ui.spinBoxNumInitialRefinement->value();
81 CreateHexCore create_hex_core(m_X1, m_X2, m_Xi, num_levels);
82 create_hex_core.setNumBreakOutLayers(m_Ui.spinBoxNumBreakOutLayers->value());
83 create_hex_core();