Skip to content
Snippets Groups Projects
Forked from ogs / ogs
23796 commits behind the upstream repository.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
RadiusEdgeRatioMetric.cpp 1.26 KiB
/**
 * \file   RadiusEdgeRatioMetric.cpp
 * \author Karsten Rink
 * \date   2014-09-02
 * \brief  Implementation of the RadiusEdgeRadioMetric class.
 *
 * \copyright
 * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org)
 *            Distributed under a Modified BSD License.
 *              See accompanying file LICENSE.txt or
 *              http://www.opengeosys.org/project/license
 *
 */

#include "RadiusEdgeRatioMetric.h"

#include "Node.h"
#include "MinimalBoundingSphere.h"

namespace MeshLib
{

RadiusEdgeRatioMetric::RadiusEdgeRatioMetric(Mesh const& mesh) 
: ElementQualityMetric(mesh)
{}

void RadiusEdgeRatioMetric::calculateQuality ()
{
    std::vector<MeshLib::Element*> const& elements(_mesh.getElements());
    size_t const nElements (_mesh.getNElements());
    for (size_t k(0); k < nElements; k++)
    {
        Element const& elem (*elements[k]);
        std::size_t const n_nodes (elem.getNNodes());
        std::vector<GeoLib::Point*> pnts(n_nodes);
        std::copy_n(elem.getNodes(), n_nodes, pnts.begin());
        GeoLib::MinimalBoundingSphere const s(pnts);
        double min, max;
        elem.computeSqrEdgeLengthRange(min, max);
        _element_quality_metric[k] = sqrt(min)/(2*s.getRadius());
    }
}

} // end namespace MeshLib