1 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + This file is part of enGrid. +
5 // + Copyright 2008-2014 enGits GmbH +
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. +
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. +
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/>. +
20 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
21 #include "correctsurfaceorientation.h"
22 #include <vtkSmartPointer.h>
24 void CorrectSurfaceOrientation::pass1()
26 for (int i
= 0; i
< pair
.size(); ++i
) {
27 pair
[i
].terminate
= false;
28 if (pair
[i
].item1
>= 0) {
29 vtkSmartPointer
<vtkIdList
> pts1
= vtkSmartPointer
<vtkIdList
>::New();
30 vtkSmartPointer
<vtkIdList
> pts2
= vtkSmartPointer
<vtkIdList
>::New();
31 m_Grid
->GetCellPoints(pair
[i
].item1
, pts1
);
32 m_Grid
->GetCellPoints(pair
[i
].item2
, pts2
);
33 vtkIdType num_pts1
= pts1
->GetNumberOfIds();
34 vtkIdType num_pts2
= pts2
->GetNumberOfIds();
37 for (int j1
= 0; j1
< num_pts1
; ++j1
) {
38 for (int j2
= 0; j2
< num_pts2
; ++j2
) {
39 vtkIdType node_11
= pts1
->GetId(j1
);
40 vtkIdType node_21
= pts2
->GetId(j2
);
41 vtkIdType node_12
, node_22
;
42 if (j1
< num_pts1
- 1) node_12
= pts1
->GetId(j1
+ 1);
43 else node_12
= pts1
->GetId(0);
44 if (j2
< num_pts2
- 1) node_22
= pts2
->GetId(j2
+ 1);
45 else node_22
= pts2
->GetId(0);
46 if ((node_11
== node_22
) && (node_12
== node_21
)) {
53 m_Grid
->GetCells()->ReverseCellAtId(pair
[i
].item2
);
54 // QVector<vtkIdType> nodes(num_pts2);
55 // for (vtkIdType j = 0; j < num_pts2; ++j) nodes[j] = pts2->GetId(j);
56 // for (vtkIdType j = 0; j < num_pts2; ++j) pts2->SetId(num_pts2 - j - 1, nodes[j]);