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 "meshqualityfaceorientation.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
);
36 CadInterface
* cad_interface
= GuiMainWindow::pointer()->getCadInterface(cell_code
->GetValue(id_cell
), true);
38 if (cad_interface
->shootRayAvailable()) {
39 cad_interface
->project(x_face
, n_face
);
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);
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
);
52 cell_mesh_quality
->SetValue(id_cell
, 1.0);
55 cell_mesh_quality
->SetValue(id_cell
, 1.0);
58 computeNodesFromCells();