fixed edge display for volume cells
[engrid-github.git] / src / libengrid / celllayeriterator.cpp
blob4dfad91a85defa1913442ffa8be6240b66571582
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 "celllayeriterator.h"
23 void CellLayerIterator::operate()
25 QVector<vtkIdType> surf_cells, surf_nodes;
26 QVector<int> _surf_nodes;
28 custom_iteration = true;
29 getAllCells(cells, m_Grid);
30 getCells();
32 getSurfaceCells(m_BoundaryCodes, surf_cells, m_Grid);
33 getNodesFromCells(surf_cells, surf_nodes, m_Grid);
34 createNodeMapping(surf_nodes, _surf_nodes, m_Grid);
36 // create first layer
37 item.resize(surf_cells.size());
38 pair.resize(surf_cells.size());
39 for (int i_scell = 0; i_scell < surf_cells.size(); ++i_scell) {
40 vtkIdType id_cell1 = surf_cells[i_scell];
41 pair[i_scell].item1 = id_cell1;
42 EG_GET_CELL(id_cell1, m_Grid);
43 bool ok = false;
44 if (num_pts > 0) {
45 foreach (int i_cells_a, n2c[_nodes[pts[0]]]) {
46 vtkIdType id_cell_a = cells[i_cells_a];
47 if (!isSurface(id_cell_a, m_Grid)) {
48 ok = true;
49 for (int i = 1; i < num_pts; ++i) {
50 if (ok) {
51 ok = false;
52 foreach (int i_cells_b, n2c[_nodes[pts[i]]]) {
53 vtkIdType id_cell_b = cells[i_cells_b];
54 if (id_cell_a == id_cell_b) {
55 ok = true;
56 break;
62 if (ok) {
63 pair[i_scell].item2 = id_cell_a;
64 pair[i_scell].terminate = false;
65 break;
69 if (!ok) {
70 EG_BUG;
74 mark2.fill(false, cells.size());
76 first_layer = true;
78 while (pair.size() > 0) {
79 mark1.fill(false, cells.size());
80 pass1();
81 for (int i = 0; i < pair.size(); ++i) {
82 if (!pair[i].terminate) {
83 mark1[_cells[pair[i].item2]] = true;
86 for (int i = 0; i < pair.size(); ++i) {
87 if (pair[i].terminate) {
88 mark1[_cells[pair[i].item2]] = false;
92 int N = 0;
93 for (int i = 0; i < cells.size(); ++i) {
94 if (mark1[i]) {
95 ++N;
98 item.resize(N);
101 int j = 0;
102 for (int i = 0; i < cells.size(); ++i) {
103 if (mark1[i]) {
104 item[j] = cells[i];
105 ++j;
109 pass2();
110 for (int i = 0; i < item.size(); ++i) {
111 mark2[_cells[item[i]]] = true;
114 int N = 0;
115 for (int i = 0; i < item.size(); ++i) {
116 for (int j = 0; j < c2c[_cells[item[i]]].size(); ++j) {
117 if (c2c[_cells[item[i]]][j] >= 0) {
118 if (!mark2[c2c[_cells[item[i]]][j]]) {
119 ++N;
124 pair.resize(N);
125 N = 0;
126 for (int i = 0; i < item.size(); ++i) {
127 for (int j = 0; j < c2c[_cells[item[i]]].size(); ++j) {
128 if (c2c[_cells[item[i]]][j] >= 0) {
129 if (!mark2[c2c[_cells[item[i]]][j]]) {
130 pair[N].item1 = item[i];
131 pair[N].item2 = cells[c2c[_cells[item[i]]][j]];
132 pair[N].terminate = false;
133 ++N;
139 first_layer = false;