got keys + clicks :)
[engrid.git] / celllayeriterator.cpp
blobf4e88f552b5170b096df1aca4adf199b9a60406e
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 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
25 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
26 // + +
27 // + This file is part of enGrid. +
28 // + +
29 // + Copyright 2008 Oliver Gloth +
30 // + +
31 // + enGrid is free software: you can redistribute it and/or modify +
32 // + it under the terms of the GNU General Public License as published by +
33 // + the Free Software Foundation, either version 3 of the License, or +
34 // + (at your option) any later version. +
35 // + +
36 // + enGrid is distributed in the hope that it will be useful, +
37 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
38 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
39 // + GNU General Public License for more details. +
40 // + +
41 // + You should have received a copy of the GNU General Public License +
42 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
43 // + +
44 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
46 #include "celllayeriterator.h"
48 void CellLayerIterator::operate()
50 QVector<vtkIdType> surf_cells, surf_nodes;
51 QVector<int> _surf_nodes;
53 custom_iteration = true;
54 getAllCells(cells, grid);
55 getCells();
57 getSurfaceCells(boundary_codes, surf_cells, grid);
58 getNodesFromCells(surf_cells, surf_nodes, grid);
59 createNodeMapping(surf_nodes, _surf_nodes, grid);
61 // create first layer
62 item.resize(surf_cells.size());
63 pair.resize(surf_cells.size());
64 for (int i_scell = 0; i_scell < surf_cells.size(); ++i_scell) {
65 vtkIdType id_cell1 = surf_cells[i_scell];
66 pair[i_scell].item1 = id_cell1;
67 EG_GETPTS(pts, id_cell1, grid);
68 bool ok = false;
69 if (Npts > 0) {
70 foreach (int i_cells_a, n2c[_nodes[pts[0]]]) {
71 vtkIdType id_cell_a = cells[i_cells_a];
72 if (!isSurface(id_cell_a, grid)) {
73 ok = true;
74 for (int i = 1; i < Npts; ++i) {
75 if (ok) {
76 ok = false;
77 foreach (int i_cells_b, n2c[_nodes[pts[i]]]) {
78 vtkIdType id_cell_b = cells[i_cells_b];
79 if (id_cell_a == id_cell_b) {
80 ok = true;
81 break;
87 if (ok) {
88 pair[i_scell].item2 = id_cell_a;
89 pair[i_scell].terminate = false;
90 break;
94 if (!ok) {
95 EG_BUG;
99 mark2.fill(false, cells.size());
101 first_layer = true;
103 while (pair.size() > 0) {
104 mark1.fill(false, cells.size());
105 pass1();
106 for (int i = 0; i < pair.size(); ++i) {
107 if (!pair[i].terminate) {
108 mark1[_cells[pair[i].item2]] = true;
111 for (int i = 0; i < pair.size(); ++i) {
112 if (pair[i].terminate) {
113 mark1[_cells[pair[i].item2]] = false;
117 int N = 0;
118 for (int i = 0; i < cells.size(); ++i) {
119 if (mark1[i]) {
120 ++N;
123 item.resize(N);
126 int j = 0;
127 for (int i = 0; i < cells.size(); ++i) {
128 if (mark1[i]) {
129 item[j] = cells[i];
130 ++j;
134 pass2();
135 for (int i = 0; i < item.size(); ++i) {
136 mark2[_cells[item[i]]] = true;
139 int N = 0;
140 for (int i = 0; i < item.size(); ++i) {
141 for (int j = 0; j < c2c[_cells[item[i]]].size(); ++j) {
142 if (c2c[_cells[item[i]]][j] >= 0) {
143 if (!mark2[c2c[_cells[item[i]]][j]]) {
144 ++N;
149 pair.resize(N);
150 N = 0;
151 for (int i = 0; i < item.size(); ++i) {
152 for (int j = 0; j < c2c[_cells[item[i]]].size(); ++j) {
153 if (c2c[_cells[item[i]]][j] >= 0) {
154 if (!mark2[c2c[_cells[item[i]]][j]]) {
155 pair[N].item1 = item[i];
156 pair[N].item2 = cells[c2c[_cells[item[i]]][j]];
157 pair[N].terminate = false;
158 ++N;
164 first_layer = false;