1 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + This file is part of enGrid. +
5 // + Copyright 2008-2014 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 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
21 #include "deletetetras.h"
23 void DeleteTetras::operate()
25 EG_VTKSP(vtkUnstructuredGrid
, new_grid
);
26 QVector
<vtkIdType
> tetras
, cells
, nodes
;
30 foreach (vtkIdType id_cell
, m_Part
.getCells()) {
31 if (m_Grid
->GetCellType(id_cell
) == VTK_TETRA
) {
37 foreach (vtkIdType id_cell
, m_Part
.getCells()) {
38 if (m_Grid
->GetCellType(id_cell
) == VTK_TETRA
) {
45 getRestCells(m_Grid
, tetras
, cells
);
46 getNodesFromCells(cells
, nodes
, m_Grid
);
47 allocateGrid(new_grid
, cells
.size(), nodes
.size());
48 QVector
<vtkIdType
> old2new(m_Grid
->GetNumberOfPoints(), -1);
51 foreach (vtkIdType id_node
, nodes
) {
53 m_Grid
->GetPoints()->GetPoint(id_node
, x
.data());
54 new_grid
->GetPoints()->SetPoint(id_new
, x
.data());
55 copyNodeData(m_Grid
, id_node
, new_grid
, id_new
);
56 old2new
[id_node
] = id_new
;
60 foreach (vtkIdType id_cell
, cells
) {
61 vtkIdType
*pts
, N_pts
;
62 m_Grid
->GetCellPoints(id_cell
, N_pts
, pts
);
63 QVector
<vtkIdType
> new_pts(N_pts
);
64 for (int i
= 0; i
< N_pts
; ++i
) {
65 new_pts
[i
] = old2new
[pts
[i
]];
67 vtkIdType cellType
= m_Grid
->GetCellType(id_cell
);
68 vtkIdType id_new
= new_grid
->InsertNextCell(cellType
, N_pts
, new_pts
.data());
69 copyCellData(m_Grid
, id_cell
, new_grid
, id_new
);
71 makeCopy(new_grid
, m_Grid
);