2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 // + This file is part of enGrid. +
6 // + Copyright 2008-2013 enGits GmbH +
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 "guimirrormesh.h"
24 #include "guimainwindow.h"
26 void GuiMirrorMesh::operate()
29 x0
[0] = m_Ui
.lineEditX0
->text().toDouble();
30 x0
[1] = m_Ui
.lineEditY0
->text().toDouble();
31 x0
[2] = m_Ui
.lineEditZ0
->text().toDouble();
32 n
[0] = m_Ui
.lineEditNX
->text().toDouble();
33 n
[1] = m_Ui
.lineEditNY
->text().toDouble();
34 n
[2] = m_Ui
.lineEditNZ
->text().toDouble();
36 EG_VTKSP(vtkUnstructuredGrid
, mirror_grid
);
37 EgVtkObject::allocateGrid(mirror_grid
, m_Grid
->GetNumberOfCells(), m_Grid
->GetNumberOfPoints());
38 for (vtkIdType id_node
= 0; id_node
< m_Grid
->GetNumberOfPoints(); ++id_node
) {
40 m_Grid
->GetPoint(id_node
, x
.data());
42 vec3_t xm
= x
- 2*h
*n
;
43 mirror_grid
->GetPoints()->SetPoint(id_node
, xm
.data());
44 copyNodeData(m_Grid
, id_node
, mirror_grid
, id_node
);
46 vtkIdType id_new_cell
;
47 for (vtkIdType id_cell
= 0; id_cell
< m_Grid
->GetNumberOfCells(); ++id_cell
) {
48 vtkIdType N_pts
, *pts
;
49 m_Grid
->GetCellPoints(id_cell
, N_pts
, pts
);
50 QVector
<vtkIdType
> new_pts(N_pts
);
51 vtkIdType cell_type
= m_Grid
->GetCellType(id_cell
);
52 if (cell_type
== VTK_TETRA
) {
57 } else if (cell_type
== VTK_WEDGE
) {
64 } else if (cell_type
== VTK_HEXAHEDRON
) {
73 } else if (cell_type
== VTK_PYRAMID
) {
76 for (int i
= 0; i
< N_pts
; ++i
) {
77 new_pts
[i
] = pts
[N_pts
- i
- 1];
80 id_new_cell
= mirror_grid
->InsertNextCell(m_Grid
->GetCellType(id_cell
), N_pts
, new_pts
.data());
81 copyCellData(m_Grid
, id_cell
, mirror_grid
, id_new_cell
);
83 MeshPartition
part1(m_Grid
, true);
84 MeshPartition
part2(mirror_grid
, true);
85 double tol
= m_Ui
.lineEditTolerance
->text().toDouble();
86 if (m_Ui
.radioButtonRelative
->isChecked()) {
89 part1
.addPartition(part2
, tol
);
91 eliminateDuplicateCells();
92 GuiMainWindow::pointer()->updateBoundaryCodes(false);