Merge branch 'release'
[engrid.git] / src / cellneighbouriterator.cpp
blobfc5d5aa4485b5b41c3ba9156e7de902d664d0d84
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 "cellneighbouriterator.h"
25 CellNeighbourIterator::CellNeighbourIterator()
27 start = 0;
31 void CellNeighbourIterator::operate()
33 getCells();
34 pair.resize(1);
35 pair[0].item1 = -1;
36 pair[0].item2 = start;
37 if (_cells[pair[0].item2] < 0) {
38 pair[0].item2 = cells[0];
40 pair[0].terminate = false;
41 mark2.fill(false, cells.size());
42 bool first = true;
43 while (pair.size() > 0) {
44 mark1.fill(false, cells.size());
45 if (!first) {
46 pass1();
47 } else {
48 first = false;
50 for (int i = 0; i < pair.size(); ++i) {
51 if (!pair[i].terminate) {
52 mark1[_cells[pair[i].item2]] = true;
55 for (int i = 0; i < pair.size(); ++i) {
56 if (pair[i].terminate) {
57 mark1[_cells[pair[i].item2]] = false;
61 int N = 0;
62 for (int i = 0; i < cells.size(); ++i) {
63 if (mark1[i]) {
64 ++N;
67 item.resize(N);
70 int j = 0;
71 for (int i = 0; i < cells.size(); ++i) {
72 if (mark1[i]) {
73 item[j] = cells[i];
74 ++j;
78 pass2();
79 for (int i = 0; i < item.size(); ++i) {
80 mark2[_cells[item[i]]] = true;
83 int N = 0;
84 for (int i = 0; i < item.size(); ++i) {
85 for (int j = 0; j < c2c[_cells[item[i]]].size(); ++j) {
86 if (c2c[_cells[item[i]]][j] >= 0) {
87 if (!mark2[c2c[_cells[item[i]]][j]]) {
88 ++N;
93 pair.resize(N);
94 N = 0;
95 for (int i = 0; i < item.size(); ++i) {
96 for (int j = 0; j < c2c[_cells[item[i]]].size(); ++j) {
97 if (c2c[_cells[item[i]]][j] >= 0) {
98 if (!mark2[c2c[_cells[item[i]]][j]]) {
99 pair[N].item1 = item[i];
100 pair[N].item2 = cells[c2c[_cells[item[i]]][j]];
101 pair[N].terminate = false;
102 ++N;