OGS
MeshInformation.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <array>
7#include <limits>
8#include <map>
9#include <optional>
10#include <range/v3/algorithm/minmax.hpp>
11#include <string>
12
13#include "GeoLib/AABB.h"
14#include "MeshLib/Mesh.h"
15#include "MeshLib/Node.h"
16#include "MeshLib/Properties.h"
17
18namespace MeshToolsLib
19{
24{
25public:
28 template <typename T>
29 static std::optional<std::pair<T, T>> const getValueBounds(
30 MeshLib::PropertyVector<T> const& property)
31 {
32 if (property.empty())
33 {
34 INFO("Mesh property vector '{:s}' is empty.",
35 property.getPropertyName());
36 return std::nullopt;
37 }
38
39 auto [min, max] = ranges::minmax(property);
40 return {{min, max}};
41 }
42
44 static GeoLib::AABB getBoundingBox(const MeshLib::Mesh& mesh);
45
55 static std::map<MeshLib::MeshElemType, unsigned> getNumberOfElementTypes(
56 const MeshLib::Mesh& mesh);
57
59 static void writeAllNumbersOfElementTypes(const MeshLib::Mesh& mesh);
60
62 static void writePropertyVectorInformation(const MeshLib::Mesh& mesh);
63
67
69 static std::vector<int> getMaterialIDs(const MeshLib::Mesh& mesh);
70};
71
72} // namespace MeshToolsLib
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:28
Class AABB is an axis aligned bounding box around a given set of geometric points of (template) type ...
Definition AABB.h:45
std::string const & getPropertyName() const
constexpr bool empty() const
A set of tools for extracting information from a mesh.
static GeoLib::AABB getBoundingBox(const MeshLib::Mesh &mesh)
Returns the bounding box of the mesh.
static void writeMeshValidationResults(MeshLib::Mesh &mesh)
static std::optional< std::pair< T, T > > const getValueBounds(MeshLib::PropertyVector< T > const &property)
static std::vector< int > getMaterialIDs(const MeshLib::Mesh &mesh)
writes out a list of all material IDs that occur in the mesh.
static void writeAllNumbersOfElementTypes(const MeshLib::Mesh &mesh)
writes all numbers of element types
static std::map< MeshLib::MeshElemType, unsigned > getNumberOfElementTypes(const MeshLib::Mesh &mesh)
static void writePropertyVectorInformation(const MeshLib::Mesh &mesh)
writes out property vector information