OGS
ElementValueModification.h
Go to the documentation of this file.
1
15#pragma once
16
17#include <vector>
18
19#include "MeshLib/Mesh.h"
20#include "MeshLib/MeshEnums.h"
21
22namespace MeshLib
23{
24// forward declarations
25class Mesh;
26template <typename T>
27class PropertyVector;
28} // namespace MeshLib
29
30namespace MeshToolsLib
31{
32
37{
38public:
41 static std::size_t condense(MeshLib::Mesh& mesh);
42
46 static bool replace(MeshLib::Mesh& mesh, int const old_value,
47 int const new_value, bool replace_if_exists = false);
48
49 static bool replace(MeshLib::Mesh& mesh, std::string const& property_name,
50 int const old_value, int const new_value,
51 bool replace_if_exists = false);
52
55 static std::size_t setByElementType(MeshLib::Mesh& mesh,
56 MeshLib::MeshElemType ele_type,
57 int const new_value);
58
59private:
62 template <typename T>
63 static std::vector<T> getSortedPropertyValues(
64 MeshLib::PropertyVector<T> const& property_vector)
65 {
66 std::vector<T> value_mapping;
67 const std::size_t n_property_values(property_vector.size());
68 for (std::size_t i = 0; i < n_property_values; ++i)
69 {
70 bool exists(false);
71 T const& value(property_vector[i]);
72 std::size_t const size(value_mapping.size());
73 for (std::size_t j = 0; j < size; ++j)
74 {
75 if (value == value_mapping[j])
76 {
77 exists = true;
78 break;
79 }
80 }
81 if (!exists)
82 {
83 value_mapping.push_back(value);
84 }
85 }
86
87 std::sort(value_mapping.begin(), value_mapping.end());
88 return value_mapping;
89 }
90};
91
92} // namespace MeshToolsLib
Definition of mesh-related Enumerations.
Definition of the Mesh class.
std::size_t size() const
A set of methods for manipulating mesh element values.
static std::vector< T > getSortedPropertyValues(MeshLib::PropertyVector< T > const &property_vector)
static std::size_t setByElementType(MeshLib::Mesh &mesh, MeshLib::MeshElemType ele_type, int const new_value)
static bool replace(MeshLib::Mesh &mesh, int const old_value, int const new_value, bool replace_if_exists=false)
static std::size_t condense(MeshLib::Mesh &mesh)
MeshElemType
Types of mesh elements supported by OpenGeoSys. Values are from VTKCellType enum.
Definition MeshEnums.h:27