From cdff675b820e4067d27423f11712713ac0c3468d Mon Sep 17 00:00:00 2001 From: Oliver Gloth Date: Tue, 7 May 2013 19:43:13 +0200 Subject: [PATCH] mesh quality based on face orientation --- src/libengrid/meshqualityfaceorientation.cpp | 51 ++++++++++++++++++++++++++++ src/libengrid/meshqualityfaceorientation.h | 37 ++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 src/libengrid/meshqualityfaceorientation.cpp create mode 100644 src/libengrid/meshqualityfaceorientation.h diff --git a/src/libengrid/meshqualityfaceorientation.cpp b/src/libengrid/meshqualityfaceorientation.cpp new file mode 100644 index 0000000..a5eea0d --- /dev/null +++ b/src/libengrid/meshqualityfaceorientation.cpp @@ -0,0 +1,51 @@ +// +// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// + + +// + This file is part of enGrid. + +// + + +// + Copyright 2008-2013 enGits GmbH + +// + + +// + enGrid is free software: you can redistribute it and/or modify + +// + it under the terms of the GNU General Public License as published by + +// + the Free Software Foundation, either version 3 of the License, or + +// + (at your option) any later version. + +// + + +// + enGrid is distributed in the hope that it will be useful, + +// + but WITHOUT ANY WARRANTY; without even the implied warranty of + +// + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + +// + GNU General Public License for more details. + +// + + +// + You should have received a copy of the GNU General Public License + +// + along with enGrid. If not, see . + +// + + +// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// +#include "meshqualityfaceorientation.h" +#include "geometrytools.h" +#include "guimainwindow.h" + +void MeshQualityFaceOrientation::operate() +{ + using namespace GeometryTools; + EG_VTKDCC(vtkDoubleArray, cell_mesh_quality, m_Grid, "cell_mesh_quality"); + EG_VTKDCC(vtkIntArray, cell_code, m_Grid, "cell_code"); + EG_FORALL_CELLS(id_cell, m_Grid) { + if (isSurface(id_cell, m_Grid)) { + vec3_t x_face = cellCentre(m_Grid, id_cell); + vec3_t n_face = cellNormal(m_Grid, id_cell); + n_face.normalise(); + SurfaceProjection* proj = GuiMainWindow::pointer()->getSurfProj(cell_code->GetValue(id_cell), true); + if (proj) { + proj->snapNode(x_face, -1); + vec3_t n_surf = proj->lastProjNormal(); + double mq = 0.5*(n_surf*n_face + 1); + cell_mesh_quality->SetValue(id_cell, mq); + } else { + cell_mesh_quality->SetValue(id_cell, 1.0); + } + } else { + cell_mesh_quality->SetValue(id_cell, 1.0); + } + } + computeNodesFromCells(); +} diff --git a/src/libengrid/meshqualityfaceorientation.h b/src/libengrid/meshqualityfaceorientation.h new file mode 100644 index 0000000..5896c79 --- /dev/null +++ b/src/libengrid/meshqualityfaceorientation.h @@ -0,0 +1,37 @@ +// +// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// + + +// + This file is part of enGrid. + +// + + +// + Copyright 2008-2013 enGits GmbH + +// + + +// + enGrid is free software: you can redistribute it and/or modify + +// + it under the terms of the GNU General Public License as published by + +// + the Free Software Foundation, either version 3 of the License, or + +// + (at your option) any later version. + +// + + +// + enGrid is distributed in the hope that it will be useful, + +// + but WITHOUT ANY WARRANTY; without even the implied warranty of + +// + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + +// + GNU General Public License for more details. + +// + + +// + You should have received a copy of the GNU General Public License + +// + along with enGrid. If not, see . + +// + + +// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// +#ifndef MESHQUALITYFACEORIENTATION_H +#define MESHQUALITYFACEORIENTATION_H + +#include "meshquality.h" + +class MeshQualityFaceOrientation : public MeshQuality +{ + +protected: // methods + + virtual void operate(); + +}; + +#endif // MESHQUALITYFACEORIENTATION_H -- 2.11.4.GIT