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 "deletetetras.h"
25 void DeleteTetras::operate()
27 cout
<< "deleting tetrahedral cells" << endl
;
28 EG_VTKSP(vtkUnstructuredGrid
, new_grid
);
29 QVector
<vtkIdType
> tetras
, cells
, nodes
;
33 foreach (vtkIdType id_cell
, m_Part
.getCells()) {
34 if (m_Grid
->GetCellType(id_cell
) == VTK_TETRA
) {
40 foreach (vtkIdType id_cell
, m_Part
.getCells()) {
41 if (m_Grid
->GetCellType(id_cell
) == VTK_TETRA
) {
48 getRestCells(m_Grid
, tetras
, cells
);
49 getNodesFromCells(cells
, nodes
, m_Grid
);
50 allocateGrid(new_grid
, cells
.size(), nodes
.size());
51 QVector
<vtkIdType
> old2new(m_Grid
->GetNumberOfPoints(), -1);
54 foreach (vtkIdType id_node
, nodes
) {
56 m_Grid
->GetPoints()->GetPoint(id_node
, x
.data());
57 new_grid
->GetPoints()->SetPoint(id_new
, x
.data());
58 copyNodeData(m_Grid
, id_node
, new_grid
, id_new
);
59 old2new
[id_node
] = id_new
;
63 foreach (vtkIdType id_cell
, cells
) {
64 vtkIdType
*pts
, N_pts
;
65 m_Grid
->GetCellPoints(id_cell
, N_pts
, pts
);
66 QVector
<vtkIdType
> new_pts(N_pts
);
67 for (int i
= 0; i
< N_pts
; ++i
) {
68 new_pts
[i
] = old2new
[pts
[i
]];
70 vtkIdType cellType
= m_Grid
->GetCellType(id_cell
);
71 vtkIdType id_new
= new_grid
->InsertNextCell(cellType
, N_pts
, new_pts
.data());
72 copyCellData(m_Grid
, id_cell
, new_grid
, id_new
);
74 makeCopy(new_grid
, m_Grid
);