2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 // + This file is part of enGrid. +
6 // + Copyright 2008 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 "vtkEgExtractVolumeCells.h"
25 vtkStandardNewMacro(vtkEgExtractVolumeCells
);
27 vtkEgExtractVolumeCells::vtkEgExtractVolumeCells()
38 void vtkEgExtractVolumeCells::ExecuteEg()
40 QSet
<vtkIdType
> ex_cells
;
41 for (vtkIdType id_cell
= 0; id_cell
< input
->GetNumberOfCells(); ++id_cell
) {
42 if (isVolume(id_cell
, input
)) {
44 vtkIdType type_cell
= input
->GetCellType(id_cell
);
45 if (!tetra
&& type_cell
== VTK_TETRA
) select
= false;
46 if (!pyramid
&& type_cell
== VTK_PYRAMID
) select
= false;
47 if (!wedge
&& type_cell
== VTK_WEDGE
) select
= false;
48 if (!hexa
&& type_cell
== VTK_HEXAHEDRON
) select
= false;
52 input
->GetCellPoints(id_cell
, N_pts
, pts
);
53 for (int i_pts
= 0; i_pts
< N_pts
; ++i_pts
) {
55 input
->GetPoints()->GetPoint(pts
[i_pts
],x
.data());
63 ex_cells
.insert(id_cell
);
67 QVector
<vtkIdType
> cells(ex_cells
.size());
68 qCopy(ex_cells
.begin(), ex_cells
.end(), cells
.begin());
69 QVector
<vtkIdType
> nodes
;
71 getNodesFromCells(cells
, nodes
, input
);
72 createNodeMapping(nodes
, _nodes
, input
);
73 allocateGrid(output
, cells
.size(), nodes
.size());
74 vtkIdType cellId
, nodeId
;
75 foreach(nodeId
, nodes
) {
77 input
->GetPoints()->GetPoint(nodeId
, x
.data());
78 output
->GetPoints()->SetPoint(_nodes
[nodeId
], x
.data());
80 foreach(cellId
, cells
) {
83 input
->GetCellPoints(cellId
, Npts
, pts
);
84 vtkIdType
*new_pts
= new vtkIdType
[Npts
];
85 for (int i
= 0; i
< Npts
; ++i
) {
86 new_pts
[i
] = _nodes
[pts
[i
]];
88 vtkIdType newId
= output
->InsertNextCell(input
->GetCellType(cellId
), Npts
, new_pts
);
89 copyCellData(input
, cellId
, output
, newId
);