Merge branch 'release'
[engrid.git] / src / celllayeriterator.cpp
bloba470acd2fba421dedb130ebf705435bfed037362
1 //
2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + +
4 // + This file is part of enGrid. +
5 // + +
6 // + Copyright 2008-2010 enGits GmbH +
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 "celllayeriterator.h"
25 void CellLayerIterator::operate()
27 QVector<vtkIdType> surf_cells, surf_nodes;
28 QVector<int> _surf_nodes;
30 custom_iteration = true;
31 getAllCells(cells, m_Grid);
32 getCells();
34 getSurfaceCells(m_BoundaryCodes, surf_cells, m_Grid);
35 getNodesFromCells(surf_cells, surf_nodes, m_Grid);
36 createNodeMapping(surf_nodes, _surf_nodes, m_Grid);
38 // create first layer
39 item.resize(surf_cells.size());
40 pair.resize(surf_cells.size());
41 for (int i_scell = 0; i_scell < surf_cells.size(); ++i_scell) {
42 vtkIdType id_cell1 = surf_cells[i_scell];
43 pair[i_scell].item1 = id_cell1;
44 EG_GETPTS(pts, id_cell1, m_Grid);
45 bool ok = false;
46 if (Npts > 0) {
47 foreach (int i_cells_a, n2c[_nodes[pts[0]]]) {
48 vtkIdType id_cell_a = cells[i_cells_a];
49 if (!isSurface(id_cell_a, m_Grid)) {
50 ok = true;
51 for (int i = 1; i < Npts; ++i) {
52 if (ok) {
53 ok = false;
54 foreach (int i_cells_b, n2c[_nodes[pts[i]]]) {
55 vtkIdType id_cell_b = cells[i_cells_b];
56 if (id_cell_a == id_cell_b) {
57 ok = true;
58 break;
64 if (ok) {
65 pair[i_scell].item2 = id_cell_a;
66 pair[i_scell].terminate = false;
67 break;
71 if (!ok) {
72 EG_BUG;
76 mark2.fill(false, cells.size());
78 first_layer = true;
80 while (pair.size() > 0) {
81 mark1.fill(false, cells.size());
82 pass1();
83 for (int i = 0; i < pair.size(); ++i) {
84 if (!pair[i].terminate) {
85 mark1[_cells[pair[i].item2]] = true;
88 for (int i = 0; i < pair.size(); ++i) {
89 if (pair[i].terminate) {
90 mark1[_cells[pair[i].item2]] = false;
94 int N = 0;
95 for (int i = 0; i < cells.size(); ++i) {
96 if (mark1[i]) {
97 ++N;
100 item.resize(N);
103 int j = 0;
104 for (int i = 0; i < cells.size(); ++i) {
105 if (mark1[i]) {
106 item[j] = cells[i];
107 ++j;
111 pass2();
112 for (int i = 0; i < item.size(); ++i) {
113 mark2[_cells[item[i]]] = true;
116 int N = 0;
117 for (int i = 0; i < item.size(); ++i) {
118 for (int j = 0; j < c2c[_cells[item[i]]].size(); ++j) {
119 if (c2c[_cells[item[i]]][j] >= 0) {
120 if (!mark2[c2c[_cells[item[i]]][j]]) {
121 ++N;
126 pair.resize(N);
127 N = 0;
128 for (int i = 0; i < item.size(); ++i) {
129 for (int j = 0; j < c2c[_cells[item[i]]].size(); ++j) {
130 if (c2c[_cells[item[i]]][j] >= 0) {
131 if (!mark2[c2c[_cells[item[i]]][j]]) {
132 pair[N].item1 = item[i];
133 pair[N].item2 = cells[c2c[_cells[item[i]]][j]];
134 pair[N].terminate = false;
135 ++N;
141 first_layer = false;