1 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + This file is part of enGrid. +
5 // + Copyright 2008-2016 enGits GmbH +
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. +
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. +
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/>. +
20 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
22 #include "padsurface.h"
23 #include "meshpartition.h"
24 #include "geometrytools.h"
26 PadSurface::PadSurface()
33 void PadSurface::operate()
35 MeshPartition
part(m_Grid
);
37 QList
<QVector
<vec3_t
> > quads
;
38 foreach (vtkIdType id_cell
, part
.getCells()) {
39 vec3_t n
= GeometryTools::cellNormal(m_Grid
, id_cell
);
41 EG_GET_CELL(id_cell
, m_Grid
);
42 QVector
<vec3_t
> x(num_pts
+ 1);
43 for (int i
= 0; i
< num_pts
; ++i
) {
44 m_Grid
->GetPoint(pts
[i
], x
[i
].data());
47 for (int i
= 0; i
< num_pts
; ++i
) {
48 if (part
.c2cGG(id_cell
, i
) < 0) {
49 vec3_t b
= x
[i
+1] - x
[i
];
50 double L
= m_Distance
;
55 vec3_t a
= b
.cross(n
);
56 QVector
<vec3_t
> xn(4);
58 xn
[1] = x
[i
] - L
*b
+ L
*a
;
59 xn
[2] = x
[i
+1] + L
*b
+ L
*a
;
65 EG_VTKSP(vtkUnstructuredGrid
, grid
);
66 allocateGrid(grid
, quads
.size(), 4*quads
.size());
67 vtkIdType start_id
= 0;
69 EG_VTKDCC(vtkIntArray
, cell_code
, grid
, "cell_code");
70 foreach (QVector
<vec3_t
> quad
, quads
) {
71 for (int i
= 0; i
< 4; ++i
) {
72 grid
->GetPoints()->SetPoint(start_id
+ i
, quad
[i
].data());
73 pts
[i
] = start_id
+ i
;
75 vtkIdType id_cell
= grid
->InsertNextCell(VTK_QUAD
, 4, pts
);
76 cell_code
->SetValue(id_cell
, m_NewBC
);
79 MeshPartition
new_part(grid
, true);
80 part
.concatenatePartition(new_part
);