OGS
MeshEnums.cpp
Go to the documentation of this file.
1
15#include "MeshEnums.h"
16
17#include <boost/algorithm/string/predicate.hpp>
18
19namespace MeshLib
20{
22{
23 if (t == MeshElemType::POINT)
24 {
25 return "Point";
26 }
27 if (t == MeshElemType::LINE)
28 {
29 return "Line";
30 }
31 if (t == MeshElemType::QUAD)
32 {
33 return "Quad";
34 }
36 {
37 return "Hexahedron";
38 }
40 {
41 return "Triangle";
42 }
44 {
45 return "Tetrahedron";
46 }
47 if (t == MeshElemType::PRISM)
48 {
49 return "Prism";
50 }
51 if (t == MeshElemType::PYRAMID)
52 {
53 return "Pyramid";
54 }
55 return "none";
56}
57
59{
60 if (t == MeshElemType::POINT)
61 {
62 return "point";
63 }
64 if (t == MeshElemType::LINE)
65 {
66 return "line";
67 }
68 if (t == MeshElemType::QUAD)
69 {
70 return "quad";
71 }
73 {
74 return "hex";
75 }
77 {
78 return "tri";
79 }
81 {
82 return "tet";
83 }
84 if (t == MeshElemType::PRISM)
85 {
86 return "pris";
87 }
88 if (t == MeshElemType::PYRAMID)
89 {
90 return "pyra";
91 }
92 return "none";
93}
94
95MeshElemType String2MeshElemType(const std::string& s)
96{
97 if (boost::iequals(s, "point"))
98 {
100 }
101 if (boost::iequals(s, "line"))
102 {
103 return MeshElemType::LINE;
104 }
105 if (boost::iequals(s, "quad") || boost::iequals(s, "Quadrilateral"))
106 {
107 return MeshElemType::QUAD;
108 }
109 if (boost::iequals(s, "hex") || boost::iequals(s, "Hexahedron"))
110 {
112 }
113 if (boost::iequals(s, "tri") || boost::iequals(s, "Triangle"))
114 {
116 }
117 if (boost::iequals(s, "tet") || boost::iequals(s, "Tetrahedron"))
118 {
120 }
121 if (boost::iequals(s, "pris") || boost::iequals(s, "Prism"))
122 {
123 return MeshElemType::PRISM;
124 }
125 if (boost::iequals(s, "pyra") || boost::iequals(s, "Pyramid"))
126 {
128 }
130}
131
132std::vector<MeshElemType> getMeshElemTypes()
133{
134 std::vector<MeshElemType> vec;
135 vec.push_back(MeshElemType::POINT);
136 vec.push_back(MeshElemType::LINE);
137 vec.push_back(MeshElemType::QUAD);
138 vec.push_back(MeshElemType::HEXAHEDRON);
139 vec.push_back(MeshElemType::TRIANGLE);
140 vec.push_back(MeshElemType::TETRAHEDRON);
141 vec.push_back(MeshElemType::PRISM);
142 vec.push_back(MeshElemType::PYRAMID);
143 return vec;
144}
145
146std::vector<std::string> getMeshElemTypeStringsShort()
147{
148 std::vector<std::string> vec;
149 auto const& mesh_elem_types = getMeshElemTypes();
150 std::transform(mesh_elem_types.begin(), mesh_elem_types.end(),
151 std::back_inserter(vec),
152 [](auto const& element_type)
153 { return MeshElemType2StringShort(element_type); });
154 return vec;
155}
156
157std::string CellType2String(const CellType t)
158{
159#define RETURN_CELL_TYPE_STR(t, type) \
160 if ((t) == CellType::type) \
161 return #type;
162
180
181 return "none";
182
183#undef RETURN_CELL_TYPE_STR
184}
185
187{
189 {
190 return "ElementSize";
191 }
193 {
194 return "EdgeRatio";
195 }
197 {
198 return "EquiAngleSkew";
199 }
201 {
202 return "RadiusEdgeRatio";
203 }
205 {
206 return "SizeDifference";
207 }
208 return "none";
209}
210
212{
213 if (boost::iequals(s, "ElementSize"))
214 {
216 }
217 if (boost::iequals(s, "EdgeRatio"))
218 {
220 }
221 if (boost::iequals(s, "EquiAngleSkew"))
222 {
224 }
225 if (boost::iequals(s, "RadiusEdgeRatio"))
226 {
228 }
229 if (boost::iequals(s, "SizeDifference"))
230 {
232 }
234}
235
236} // namespace MeshLib
#define RETURN_CELL_TYPE_STR(t, type)
Definition of mesh-related Enumerations.
MeshElemType String2MeshElemType(const std::string &s)
Given a string of the shortened name of the element type, this returns the corresponding MeshElemType...
Definition MeshEnums.cpp:95
CellType
Types of mesh elements supported by OpenGeoSys.
Definition MeshEnums.h:43
MeshLib::MeshQualityType String2MeshQualityType(std::string const &s)
std::string MeshElemType2String(const MeshElemType t)
Given a MeshElemType this returns the appropriate string.
Definition MeshEnums.cpp:21
MeshQualityType
Describes a mesh quality metric.
Definition MeshEnums.h:70
std::vector< MeshElemType > getMeshElemTypes()
Returns a vector of all mesh element types.
std::string MeshElemType2StringShort(const MeshElemType t)
Given a MeshElemType this returns the appropriate string with a short name.
Definition MeshEnums.cpp:58
std::vector< std::string > getMeshElemTypeStringsShort()
Returns a vector of strings of mesh element types.
std::string CellType2String(const CellType t)
Given a MeshElemType this returns the appropriate string.
std::string MeshQualityType2String(const MeshQualityType t)
MeshElemType
Types of mesh elements supported by OpenGeoSys. Values are from VTKCellType enum.
Definition MeshEnums.h:27