limited volume meshing to boundary layer only
[engrid-github.git] / src / libengrid / deletetetras.cpp
blob3699ced2e2e60ec5e8b06680db26f49f40ffdfc7
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 EG_GET_CELL(id_cell, m_Grid);
62 QVector<vtkIdType> new_pts(num_pts);
63 for (int i = 0; i < num_pts; ++i) {
64 new_pts[i] = old2new[pts[i]];
66 vtkIdType cellType = m_Grid->GetCellType(id_cell);
67 vtkIdType id_new = new_grid->InsertNextCell(cellType, num_pts, new_pts.data());
68 copyCellData(m_Grid, id_cell, new_grid, id_new);
70 makeCopy(new_grid, m_Grid);