fixed edge display for volume cells
[engrid-github.git] / src / libengrid / deletetetras.cpp
blob32bf0156a12a81ec109ce2701d09093a288fb078
1 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 // + +
3 // + This file is part of enGrid. +
4 // + +
5 // + Copyright 2008-2014 enGits GmbH +
6 // + +
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. +
11 // + +
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. +
16 // + +
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/>. +
19 // + +
20 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
21 #include "deletetetras.h"
23 void DeleteTetras::operate()
25 EG_VTKSP(vtkUnstructuredGrid, new_grid);
26 QVector<vtkIdType> tetras, cells, nodes;
29 int N = 0;
30 foreach (vtkIdType id_cell, m_Part.getCells()) {
31 if (m_Grid->GetCellType(id_cell) == VTK_TETRA) {
32 ++N;
35 tetras.resize(N);
36 N = 0;
37 foreach (vtkIdType id_cell, m_Part.getCells()) {
38 if (m_Grid->GetCellType(id_cell) == VTK_TETRA) {
39 tetras[N] = id_cell;
40 ++N;
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);
50 vtkIdType id_new = 0;
51 foreach (vtkIdType id_node, nodes) {
52 vec3_t x;
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;
57 ++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);