https://gitlab.opengeosys.org/ogs/ogs.git
Raw File
Tip revision: e64d5d3ccf3a621499d171cc2d35444ead73b0ec authored by Lars Bilke on 07 January 2023, 20:50:59 UTC
Merge branch 'fixes' into 'master'
Tip revision: e64d5d3
ElementQualityMetric.h
/**
 * \file
 * \author Thomas Fischer
 * \date   2010-12-08
 * \brief  Definition of the ElementQualityMetricBase class.
 *
 * \copyright
 * Copyright (c) 2012-2023, OpenGeoSys Community (http://www.opengeosys.org)
 *            Distributed under a Modified BSD License.
 *              See accompanying file LICENSE.txt or
 *              http://www.opengeosys.org/project/license
 *
 */

#pragma once

#include <vector>

#include "BaseLib/Histogram.h"

#include "MeshLib/Mesh.h"
#include "MeshLib/Elements/Element.h"

namespace MeshLib
{

/**
 * Base class for calculating the quality of mesh element based on a given metric
 */
class ElementQualityMetric
{
public:
    explicit ElementQualityMetric(Mesh const& mesh);

    virtual ~ElementQualityMetric() = default;

    /// Calculates the quality metric for each element of the mesh
    virtual void calculateQuality () = 0;

    /// Returns the result vector
    std::vector<double> const& getElementQuality () const;

    /// Returns a histogram of the quality vector separated into the given number of bins.
    /// If no number of bins is specified, one will be calculated based on the Sturges criterium.
    virtual BaseLib::Histogram<double> getHistogram (std::size_t n_bins = 0) const;

protected:
    double _min = std::numeric_limits<double>::max();
    double _max = 0;
    Mesh const& _mesh;
    std::vector<double> _element_quality_metric;
};
}  // namespace MeshLib
back to top