2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 // + This file is part of enGrid. +
6 // + Copyright 2008,2009 Oliver Gloth +
8 // + enGrid is free software: you can redistribute it and/or modify +
9 // + it under the terms of the GNU General Public License as published by +
10 // + the Free Software Foundation, either version 3 of the License, or +
11 // + (at your option) any later version. +
13 // + enGrid is distributed in the hope that it will be useful, +
14 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
15 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
16 // + GNU General Public License for more details. +
18 // + You should have received a copy of the GNU General Public License +
19 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 #include "guinormalextrusion.h"
24 #include "vtkEgNormalExtrusion.h"
25 #include "containertricks.h"
27 void GuiNormalExtrusion::before()
29 populateBoundaryCodes(ui
.listWidget
);
32 void GuiNormalExtrusion::operate()
34 EG_VTKSP(vtkEgNormalExtrusion
, extr
);
37 if (ui
.radioButtonSimple
->isChecked()) {
38 y
.resize(ui
.lineEditSimpleNumLayers
->text().toInt() + 1);
39 double h
= ui
.lineEditSimpleHeight
->text().toDouble();
40 double f
= ui
.lineEditSimpleIncrease
->text().toDouble();
42 for (int i
= 1; i
< y
.size(); ++i
) {
46 } else if (ui
.radioButtonFixedHeights
->isChecked()) {
47 y
.resize(ui
.lineEditFixedHeightsNumLayers
->text().toInt() + 1);
48 QVector
<double> x(y
.size());
49 for (int i
= 0; i
< x
.size(); ++i
) {
50 x
[i
] = i
*1.0/(x
.size() - 1);
53 clinit(A
[0]) = pow(x
[1],5.0), pow(x
[1],3.0), x
[1];
54 clinit(A
[1]) = pow(x
[x
.size() - 2],5.0), pow(x
[x
.size() - 2],3.0), x
[x
.size() - 2];
55 clinit(A
[2]) = pow(x
[x
.size() - 1],5.0), pow(x
[x
.size() - 1],3.0), x
[x
.size() - 1];
57 h
[0] = ui
.lineEditFixedHeightsHeightFirst
->text().toDouble();
58 h
[2] = ui
.lineEditFixedHeightsTotalHeight
->text().toDouble();
59 h
[1] = h
[2] - ui
.lineEditFixedHeightsHeightLast
->text().toDouble();
60 mat3_t AI
= A
.inverse();
62 for (int i
= 0; i
< y
.size(); ++i
) {
63 y
[i
] = coeff
[0]*pow(x
[i
],5.0) + coeff
[1]*pow(x
[i
],3.0) + coeff
[2]*x
[i
];
66 EG_ERR_RETURN("unable to compute layer heights");
73 if (ui
.radioButtonFixed
->isChecked()) {
74 extr
->SetNormal(vec3_t(ui
.lineEditFixedNX
->text().toDouble(),
75 ui
.lineEditFixedNY
->text().toDouble(),
76 ui
.lineEditFixedNZ
->text().toDouble()));
77 double min_dist
= ui
.lineEditFixedDist
->text().toDouble();
82 extr
->SetMinDist(min_dist
);
85 if (ui
.radioButtonCylinder
->isChecked()) {
86 extr
->SetCylindrical();
87 extr
->SetOrigin(vec3_t(ui
.lineEditCylinderX0
->text().toDouble(),
88 ui
.lineEditCylinderY0
->text().toDouble(),
89 ui
.lineEditCylinderZ0
->text().toDouble()));
90 extr
->SetAxis(vec3_t(ui
.lineEditCylinderNX
->text().toDouble(),
91 ui
.lineEditCylinderNY
->text().toDouble(),
92 ui
.lineEditCylinderNZ
->text().toDouble()));
94 if (ui
.radioButtonRotation
->isChecked()) {
96 extr
->SetOrigin(vec3_t(ui
.lineEditCylinderX0
->text().toDouble(),
97 ui
.lineEditCylinderY0
->text().toDouble(),
98 ui
.lineEditCylinderZ0
->text().toDouble()));
99 extr
->SetAxis(vec3_t(ui
.lineEditCylinderNX
->text().toDouble(),
100 ui
.lineEditCylinderNY
->text().toDouble(),
101 ui
.lineEditCylinderNZ
->text().toDouble()));
105 getSelectedItems(ui
.listWidget
, bcs
);
106 extr
->SetBoundaryCodes(bcs
);
107 EG_VTKSP(vtkUnstructuredGrid
,ug
);
111 makeCopy(extr
->GetOutput(), grid
);