Added getNeighbours functions to class Operation + moved UpdateMeshDensity to class...
[engrid.git] / nodelayeriterator.cpp
blob99178c8b89e41451d1a3f4874b63f75209bc57c9
1 //
2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + +
4 // + This file is part of enGrid. +
5 // + +
6 // + Copyright 2008,2009 Oliver Gloth +
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 "nodelayeriterator.h"
25 void NodeLayerIterator::operate()
27 getCells();
28 getSurfaceCells(boundary_codes, surface_cells, grid);
29 getNodesFromCells(surface_cells, surf_nodes, grid);
30 createNodeMapping(surf_nodes, _surf_nodes, grid);
31 mark2.fill(false, nodes.size());
33 // create pairs for first layer
34 pair.resize(surf_nodes.size());
35 for (int i = 0; i < surf_nodes.size(); ++i) {
36 pair[i].item1 = -1;
37 pair[i].item2 = surf_nodes[i];
38 pair[i].terminate = false;
41 first_layer = true;
42 while (pair.size() > 0) {
43 mark1.fill(false, nodes.size());
44 pass1();
45 for (int i = 0; i < pair.size(); ++i) {
46 if (!pair[i].terminate) {
47 mark1[_nodes[pair[i].item2]] = true;
50 for (int i = 0; i < pair.size(); ++i) {
51 if (pair[i].terminate) {
52 mark1[_nodes[pair[i].item2]] = false;
56 int N = 0;
57 for (int i = 0; i < nodes.size(); ++i) {
58 if (mark1[i]) {
59 ++N;
62 item.resize(N);
65 int j = 0;
66 for (int i = 0; i < nodes.size(); ++i) {
67 if (mark1[i]) {
68 item[j] = nodes[i];
69 ++j;
73 pass2();
74 foreach (vtkIdType nodeId, item) {
75 mark2[_nodes[nodeId]] = true;
78 int N = 0;
79 for (int i = 0; i < item.size(); ++i) {
80 foreach (int j, n2n[_nodes[item[i]]]) {
81 if (!mark2[j]) {
82 ++N;
86 pair.resize(N);
87 N = 0;
88 for (int i = 0; i < item.size(); ++i) {
89 foreach (int j, n2n[_nodes[item[i]]]) {
90 if (!mark2[j]) {
91 pair[N].item1 = item[i];
92 pair[N].item2 = nodes[j];
93 pair[N].terminate = false;
94 ++N;
99 first_layer = false;