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 "checksurfaceintegrity.h"
22 // #include "egvtkobject.h"
23 #include "geometrytools.h"
24 using namespace GeometryTools
;
26 CheckSurfaceIntegrity::CheckSurfaceIntegrity() : SurfaceOperation()
31 void CheckSurfaceIntegrity::operate()
33 bool ok
= isWaterTight();
36 cout
<< "The mesh is OK!" << endl
;
38 cout
<< "The mesh has defects!" << endl
;
39 for (int i
= 0; i
< m_NumCells
.size(); ++i
) {
40 if (m_NumCells
[i
] > 0) {
41 cout
<< " " << m_NumCells
[i
] << " edges with " << i
<< " faces" << endl
;
44 cout
<< " " << m_NumEmptyCells
<< " faces are degenerated" << endl
;
49 bool CheckSurfaceIntegrity::isWaterTight()
53 m_NumCells
.fill(0, 1000);
55 l2g_t nodes
= getPartNodes();
56 g2l_t _nodes
= getPartLocalNodes();
57 l2l_t n2n
= getPartN2N();
58 l2g_t cells
= getPartCells();
61 foreach(vtkIdType id_node1
, nodes
) {
63 m_Grid
->GetPoints()->GetPoint(id_node1
, x
.data());
65 qDebug()<<"point "<<id_node1
<<" is NAN or INF";
67 foreach(int i_node2
, n2n
[_nodes
[id_node1
]]) {
68 vtkIdType id_node2
= nodes
[i_node2
];
69 QSet
<vtkIdType
> edge_cells
;
70 int N
= getEdgeCells(id_node1
, id_node2
, edge_cells
);
76 m_NumMin
= min(m_NumMin
, N
);
77 m_NumMax
= max(m_NumMax
, N
);
83 if (edge_cells
.size() != 2) {
84 m_BadCells
.unite(edge_cells
);
90 foreach(vtkIdType id_cell
, cells
) {
91 if (cellVA(m_Grid
, id_cell
) <= 0) {
96 if (m_NumMin
== 2 && m_NumMax
== 2 && m_NumEmptyCells
== 0) {