compiles on openSUSE 15.4 part 2
[engrid-github.git] / src / libengrid / meshqualityfaceorientation.cpp
blobc28c3a19b69728dbf7fa38ee431752ba1a57c219
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 "meshqualityfaceorientation.h"
22 #include "engrid.h"
23 #include "geometrytools.h"
24 #include "guimainwindow.h"
26 void MeshQualityFaceOrientation::operate()
28 using namespace GeometryTools;
29 EG_VTKDCC(vtkDoubleArray, cell_mesh_quality, m_Grid, "cell_mesh_quality");
30 EG_VTKDCC(vtkIntArray, cell_code, m_Grid, "cell_code");
31 EG_FORALL_CELLS(id_cell, m_Grid) {
32 if (isSurface(id_cell, m_Grid)) {
33 vec3_t x_face = cellCentre(m_Grid, id_cell);
34 vec3_t n_face = cellNormal(m_Grid, id_cell);
35 n_face.normalise();
36 CadInterface* cad_interface = GuiMainWindow::pointer()->getCadInterface(cell_code->GetValue(id_cell), true);
37 if (cad_interface) {
38 if (cad_interface->shootRayAvailable()) {
39 cad_interface->project(x_face, n_face);
40 } else {
41 EG_GET_CELL(id_cell, m_Grid);
42 cad_interface->snapNode(pts[0], x_face);
44 if (cad_interface->failed()) {
45 cell_mesh_quality->SetValue(id_cell, 1.0);
46 } else {
47 vec3_t n_surf = cad_interface->getLastNormal();
48 double mq = 0.5*(n_surf*n_face + 1);
49 cell_mesh_quality->SetValue(id_cell, mq);
51 } else {
52 cell_mesh_quality->SetValue(id_cell, 1.0);
54 } else {
55 cell_mesh_quality->SetValue(id_cell, 1.0);
58 computeNodesFromCells();