added cell_code text display
[engrid.git] / deletetetras.cpp
blobcdc3312da72f83f540e57439d29d7a3a0b94f3fc
1 //
2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + +
4 // + This file is part of enGrid. +
5 // + +
6 // + Copyright 2008,2009 Oliver Gloth +
7 // + +
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. +
12 // + +
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. +
17 // + +
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/>. +
20 // + +
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, _nodes;
30 getAllCellsOfType(VTK_TETRA, tetras, grid);
31 getRestCells(grid, tetras, cells);
32 getNodesFromCells(cells, nodes, grid);
33 allocateGrid(new_grid, cells.size(), nodes.size());
34 QVector<vtkIdType> old2new(grid->GetNumberOfPoints(), -1);
36 vtkIdType id_new = 0;
37 foreach (vtkIdType id_node, nodes) {
38 vec3_t x;
39 grid->GetPoints()->GetPoint(id_node, x.data());
40 new_grid ->GetPoints()->SetPoint(id_new, x.data());
41 copyNodeData(grid, id_node, new_grid, id_new);
42 old2new[id_node] = id_new;
43 ++id_new;
46 foreach (vtkIdType id_cell, cells) {
47 vtkIdType *pts, N_pts;
48 grid->GetCellPoints(id_cell, N_pts, pts);
49 QVector<vtkIdType> new_pts(N_pts);
50 for (int i = 0; i < N_pts; ++i) {
51 new_pts[i] = old2new[pts[i]];
53 vtkIdType cellType = grid->GetCellType(id_cell);
54 vtkIdType id_new = new_grid->InsertNextCell(cellType, N_pts, new_pts.data());
55 copyCellData(grid, id_cell, new_grid, id_new);
57 makeCopy(new_grid, grid);