Merge branch 'master' of ssh://swordfish/srv/www/htdocs/git/engrid
[engrid.git] / src / deletetetras.cpp
blob720bb3f86ff9da4ed77c05f85382d2f6ceb95de8
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;
32 int N = 0;
33 foreach (vtkIdType id_cell, m_Part.getCells()) {
34 if (m_Grid->GetCellType(id_cell) == VTK_TETRA) {
35 ++N;
38 tetras.resize(N);
39 N = 0;
40 foreach (vtkIdType id_cell, m_Part.getCells()) {
41 if (m_Grid->GetCellType(id_cell) == VTK_TETRA) {
42 tetras[N] = id_cell;
43 ++N;
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);
53 vtkIdType id_new = 0;
54 foreach (vtkIdType id_node, nodes) {
55 vec3_t x;
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;
60 ++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);