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 "guitransform.h"
24 #include "seedsimpleprismaticlayer.h"
25 #include "gridsmoother.h"
26 #include "createvolumemesh.h"
27 #include "swaptriangles.h"
28 #include "deletetetras.h"
29 #include "deletecells.h"
31 #include "geometrytools.h"
32 using namespace GeometryTools
;
34 /** Set default values */
35 void GuiTransform::before()
37 cout
<<"======================================"<<endl
;
38 cout
<<"void GuiTransform::before()"<<endl
;
39 cout
<<"======================================"<<endl
;
41 ui
.tabWidget
->setCurrentIndex(0);
43 ui
.lineEdit_Translation_X
->setText("0");
44 ui
.lineEdit_Translation_Y
->setText("0");
45 ui
.lineEdit_Translation_Z
->setText("0");
47 ui
.lineEdit_Rotation_Origin_X
->setText("0");
48 ui
.lineEdit_Rotation_Origin_Y
->setText("0");
49 ui
.lineEdit_Rotation_Origin_Z
->setText("0");
50 ui
.lineEdit_Rotation_Direction_X
->setText("1");
51 ui
.lineEdit_Rotation_Direction_Y
->setText("0");
52 ui
.lineEdit_Rotation_Direction_Z
->setText("0");
53 ui
.lineEdit_Rotation_Angle
->setText("0");
54 ui
.AngleInDegrees
->setCheckState(Qt::Checked
);
56 ui
.lineEdit_Scaling_X
->setText("1");
57 ui
.lineEdit_Scaling_Y
->setText("1");
58 ui
.lineEdit_Scaling_Z
->setText("1");
61 /** Apply transformations to the grid ( scaling, translation, rotation ) */
62 void GuiTransform::operate()
64 cout
<<"======================================"<<endl
;
65 cout
<<"void GuiTransform::operate()"<<endl
;
66 cout
<<"======================================"<<endl
;
69 vec3_t
Translation_Vector( ( ui
.lineEdit_Translation_X
->text()).toDouble(),
70 ( ui
.lineEdit_Translation_Y
->text()).toDouble(),
71 ( ui
.lineEdit_Translation_Z
->text()).toDouble());
74 vec3_t
Rotation_Origin_Vector( ( ui
.lineEdit_Rotation_Origin_X
->text()).toDouble(),
75 ( ui
.lineEdit_Rotation_Origin_Y
->text()).toDouble(),
76 ( ui
.lineEdit_Rotation_Origin_Z
->text()).toDouble());
77 vec3_t
Rotation_Direction_Vector( ( ui
.lineEdit_Rotation_Direction_X
->text()).toDouble(),
78 ( ui
.lineEdit_Rotation_Direction_Y
->text()).toDouble(),
79 ( ui
.lineEdit_Rotation_Direction_Z
->text()).toDouble());
80 double Rotation_Angle
= ( ui
.lineEdit_Rotation_Angle
->text()).toDouble();
81 if(ui
.AngleInDegrees
->checkState()) Rotation_Angle
=deg2rad(Rotation_Angle
);
84 vec3_t
Scaling_Vector( ( ui
.lineEdit_Scaling_X
->text()).toDouble(),
85 ( ui
.lineEdit_Scaling_Y
->text()).toDouble(),
86 ( ui
.lineEdit_Scaling_Z
->text()).toDouble());
88 cout
<< "nodes.size()=" << nodes
.size() << endl
;
89 cout
<< "Translation_Vector=" << Translation_Vector
<< endl
;
90 cout
<< "Rotation_Origin_Vector=" << Rotation_Origin_Vector
<< endl
;
91 cout
<< "Rotation_Direction_Vector=" << Rotation_Direction_Vector
<< endl
;
92 cout
<< "Rotation_Angle=" << Rotation_Angle
<< endl
;
93 cout
<< "AngleInDegrees=" << ui
.AngleInDegrees
->checkState() << endl
;
94 cout
<< "Scaling_Vector=" << Scaling_Vector
<< endl
;
96 foreach(vtkIdType id_node
, nodes
)
99 grid
->GetPoint(id_node
, x
.data());
101 x
[0]+=Translation_Vector
[0];
102 x
[1]+=Translation_Vector
[1];
103 x
[2]+=Translation_Vector
[2];
105 Rotation_Direction_Vector
.normalise();
106 x
= Rotation_Origin_Vector
+ GeometryTools::rotate(x
-Rotation_Origin_Vector
,Rotation_Direction_Vector
,Rotation_Angle
);
108 x
[0]*=Scaling_Vector
[0];
109 x
[1]*=Scaling_Vector
[1];
110 x
[2]*=Scaling_Vector
[2];
112 grid
->GetPoints()->SetPoint(id_node
, x
.data());