2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 // + This file is part of enGrid. +
6 // + Copyright 2008-2013 enGits GmbH +
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. +
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. +
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/>. +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 #include "checksurfaceintegrity.h"
24 // #include "egvtkobject.h"
25 #include "geometrytools.h"
26 using namespace GeometryTools
;
28 CheckSurfaceIntegrity::CheckSurfaceIntegrity() : SurfaceOperation()
33 void CheckSurfaceIntegrity::operate()
35 bool ok
= isWaterTight();
37 cout
<< "The mesh is OK!" << endl
;
39 cout
<< "The mesh is not water-tight" << endl
;
40 for (int i
= 0; i
< m_NumCells
.size(); ++i
) {
41 if (m_NumCells
[i
] > 0) {
42 cout
<< " " << m_NumCells
[i
] << " edges with " << i
<< " faces" << endl
;
45 cout
<< "bad cells:" << endl
;
46 foreach (vtkIdType id_cell
, m_BadCells
) {
47 cout
<< id_cell
<< " ";
53 bool CheckSurfaceIntegrity::isWaterTight()
57 m_NumCells
.fill(0, 1000);
59 l2g_t nodes
= getPartNodes();
60 g2l_t _nodes
= getPartLocalNodes();
61 l2l_t n2n
= getPartN2N();
62 l2g_t cells
= getPartCells();
65 foreach(vtkIdType id_node1
, nodes
) {
67 m_Grid
->GetPoints()->GetPoint(id_node1
, x
.data());
69 qDebug()<<"point "<<id_node1
<<" is NAN or INF";
71 foreach(int i_node2
, n2n
[_nodes
[id_node1
]]) {
72 vtkIdType id_node2
= nodes
[i_node2
];
73 QSet
<vtkIdType
> edge_cells
;
74 int N
= getEdgeCells(id_node1
, id_node2
, edge_cells
);
80 m_Nmin
= min(m_Nmin
, N
);
81 m_Nmax
= max(m_Nmax
, N
);
87 if (edge_cells
.size() != 2) {
88 m_BadCells
.unite(edge_cells
);
93 foreach(vtkIdType id_cell
, cells
) {
94 if(cellVA(m_Grid
, id_cell
)<=0) {
95 qDebug()<<"cell "<<id_cell
<<" is empty.";
99 if (m_Nmin
== 2 && m_Nmax
== 2) {