fixed edge display for volume cells
[engrid-github.git] / src / libengrid / correctsurfaceorientation.cpp
blobe2a2bfb2db9e87c0a7b3986d8ff21069ff967772
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 "correctsurfaceorientation.h"
23 void CorrectSurfaceOrientation::pass1()
25 for (int i = 0; i < pair.size(); ++i) {
26 pair[i].terminate = false;
27 if (pair[i].item1 >= 0) {
28 vtkIdType Npts1, *pts1;
29 vtkIdType Npts2, *pts2;
30 m_Grid->GetCellPoints(pair[i].item1, Npts1, pts1);
31 m_Grid->GetCellPoints(pair[i].item2, Npts2, pts2);
32 bool ok = false;
33 for (int j1 = 0; j1 < Npts1; ++j1) {
34 for (int j2 = 0; j2 < Npts2; ++j2) {
35 vtkIdType node_11 = pts1[j1];
36 vtkIdType node_21 = pts2[j2];
37 vtkIdType node_12, node_22;
38 if (j1 < Npts1 - 1) node_12 = pts1[j1 + 1];
39 else node_12 = pts1[0];
40 if (j2 < Npts2 - 1) node_22 = pts2[j2 + 1];
41 else node_22 = pts2[0];
42 if ((node_11 == node_22) && (node_12 == node_21)) {
43 ok = true;
44 break;
48 if (!ok) {
49 QVector<vtkIdType> nodes(Npts2);
50 for (vtkIdType j = 0; j < Npts2; ++j) nodes[j] = pts2[j];
51 for (vtkIdType j = 0; j < Npts2; ++j) pts2[Npts2 - j - 1] = nodes[j];