https://gitlab.opengeosys.org/ogs/ogs.git
Raw File
Tip revision: 3a8def12a0b045c884d64d126e9819118a3c2e3a authored by Dmitry Yu. Naumov on 15 July 2023, 14:07:51 UTC
Merge branch 'RefactorMeshLibElementRules' into 'master'
Tip revision: 3a8def1
TriRule.cpp
/**
 * \file
 * \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
 */

#include "TriRule.h"

#include "MathLib/GeometricBasics.h"
#include "MeshLib/Node.h"

namespace MeshLib
{
double TriRule::computeVolume(Node const* const* _nodes)
{
    return MathLib::calcTriangleArea(*_nodes[0], *_nodes[1], *_nodes[2]);
}

bool TriRule::isPntInElement(Node const* const* nodes,
                             MathLib::Point3d const& pnt, double eps)
{
    return MathLib::isPointInTriangle(pnt, *nodes[0], *nodes[1], *nodes[2],
                                      eps);
}

ElementErrorCode TriRule::validate(const Element* e)
{
    ElementErrorCode error_code;
    error_code[ElementErrorFlag::ZeroVolume] = hasZeroVolume(*e);
    error_code[ElementErrorFlag::NodeOrder] = !e->testElementNodeOrder();
    return error_code;
}

}  // end namespace MeshLib
back to top