updated to modern VTK
[engrid-github.git] / src / libengrid / cellneighbouriterator.cpp
blob6a20084fda863364a4d6d440e14672cc70bacac6
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 "cellneighbouriterator.h"
23 CellNeighbourIterator::CellNeighbourIterator()
25 start = 0;
29 void CellNeighbourIterator::operate()
31 getCells();
32 pair.resize(1);
33 pair[0].item1 = -1;
34 pair[0].item2 = start;
35 if (_cells[pair[0].item2] < 0) {
36 pair[0].item2 = cells[0];
38 pair[0].terminate = false;
39 mark2.fill(false, cells.size());
40 bool first = true;
41 while (pair.size() > 0) {
42 mark1.fill(false, cells.size());
43 if (!first) {
44 pass1();
45 } else {
46 first = false;
48 for (int i = 0; i < pair.size(); ++i) {
49 if (!pair[i].terminate) {
50 mark1[_cells[pair[i].item2]] = true;
54 int N = 0;
55 for (int i = 0; i < cells.size(); ++i) {
56 if (mark1[i]) {
57 ++N;
60 item.resize(N);
63 int j = 0;
64 for (int i = 0; i < cells.size(); ++i) {
65 if (mark1[i]) {
66 item[j] = cells[i];
67 ++j;
71 pass2();
72 for (int i = 0; i < item.size(); ++i) {
73 mark2[_cells[item[i]]] = true;
76 int N = 0;
77 for (int i = 0; i < item.size(); ++i) {
78 for (int j = 0; j < c2c[_cells[item[i]]].size(); ++j) {
79 if (c2c[_cells[item[i]]][j] >= 0) {
80 if (!mark2[c2c[_cells[item[i]]][j]]) {
81 ++N;
86 pair.resize(N);
87 N = 0;
88 for (int i = 0; i < item.size(); ++i) {
89 for (int j = 0; j < c2c[_cells[item[i]]].size(); ++j) {
90 if (c2c[_cells[item[i]]][j] >= 0) {
91 if (!mark2[c2c[_cells[item[i]]][j]]) {
92 pair[N].item1 = item[i];
93 pair[N].item2 = cells[c2c[_cells[item[i]]][j]];
94 pair[N].terminate = false;
95 ++N;