made partial checkboxes for VMD definitions functional
[engrid.git] / correctsurfaceorientation.cpp
bloba7ccd37bf84e61ff0d553eed459028215dc778a4
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 "correctsurfaceorientation.h"
25 void CorrectSurfaceOrientation::pass1()
27 for (int i = 0; i < pair.size(); ++i) {
28 pair[i].terminate = false;
29 if (pair[i].item1 >= 0) {
30 vtkIdType Npts1, *pts1;
31 vtkIdType Npts2, *pts2;
32 grid->GetCellPoints(pair[i].item1, Npts1, pts1);
33 grid->GetCellPoints(pair[i].item2, Npts2, pts2);
34 bool ok = false;
35 for (int j1 = 0; j1 < Npts1; ++j1) {
36 for (int j2 = 0; j2 < Npts2; ++j2) {
37 vtkIdType node_11 = pts1[j1];
38 vtkIdType node_21 = pts2[j2];
39 vtkIdType node_12, node_22;
40 if (j1 < Npts1 - 1) node_12 = pts1[j1 + 1];
41 else node_12 = pts1[0];
42 if (j2 < Npts2 - 1) node_22 = pts2[j2 + 1];
43 else node_22 = pts2[0];
44 if ((node_11 == node_22) && (node_12 == node_21)) {
45 ok = true;
46 break;
50 if (!ok) {
51 QVector<vtkIdType> nodes(Npts2);
52 for (vtkIdType j = 0; j < Npts2; ++j) nodes[j] = pts2[j];
53 for (vtkIdType j = 0; j < Npts2; ++j) pts2[Npts2 - j - 1] = nodes[j];