OGS
MeshInformation.cpp
Go to the documentation of this file.
1 
15 #include "MeshInformation.h"
16 
17 #include "Elements/Element.h"
19 
20 namespace
21 {
22 template <typename T>
24 {
25  auto const bounds = MeshLib::MeshInformation::getValueBounds(property);
26  if (!bounds.has_value())
27  {
28  INFO("\t{:s}: Could not get value bounds for property vector.",
29  property.getPropertyName());
30  return;
31  }
32  INFO("\t{:s}: ({:d} values) [{}, {}]", property.getPropertyName(),
33  property.size(), bounds->first, bounds->second);
34 }
35 } // namespace
36 
37 namespace MeshLib
38 {
40 {
41  const std::vector<MeshLib::Node*>& nodes(mesh.getNodes());
42  return GeoLib::AABB(nodes.begin(), nodes.end());
43 }
44 
45 std::map<MeshElemType, unsigned> MeshInformation::getNumberOfElementTypes(
46  const MeshLib::Mesh& mesh)
47 {
48  std::map<MeshElemType, unsigned> n_element_types;
49  const std::vector<MeshLib::Element*>& elements(mesh.getElements());
50  for (auto element : elements)
51  {
52  MeshElemType t = element->getGeomType();
53  n_element_types[t]++;
54  }
55  return n_element_types;
56 }
57 
59 {
60  auto const& nr_ele_types =
62 
63  INFO("Number of elements in the mesh:");
64  for (auto entry : nr_ele_types)
65  {
66  INFO("\t{:s}s: {:d}",
68  static_cast<MeshLib::MeshElemType>(entry.first)),
69  entry.second);
70  }
71 }
72 
74 {
75  auto const& properties = mesh.getProperties();
76  INFO("There are {:d} properties in the mesh:", properties.size());
77 
78  for (auto [name, property] : properties)
79  {
80  if (auto p = dynamic_cast<PropertyVector<double>*>(property))
81  {
82  printBounds(*p);
83  }
84  else if (auto p = dynamic_cast<PropertyVector<float>*>(property))
85  {
86  printBounds(*p);
87  }
88  else if (auto p = dynamic_cast<PropertyVector<int>*>(property))
89  {
90  printBounds(*p);
91  }
92  else if (auto p = dynamic_cast<PropertyVector<unsigned>*>(property))
93  {
94  printBounds(*p);
95  }
96  else if (auto p = dynamic_cast<PropertyVector<long>*>(property))
97  {
98  printBounds(*p);
99  }
100  else if (auto p = dynamic_cast<PropertyVector<long long>*>(property))
101  {
102  printBounds(*p);
103  }
104  else if (auto p =
105  dynamic_cast<PropertyVector<unsigned long>*>(property))
106  {
107  printBounds(*p);
108  }
109  else if (auto p = dynamic_cast<PropertyVector<unsigned long long>*>(
110  property))
111  {
112  printBounds(*p);
113  }
114  else if (auto p = dynamic_cast<PropertyVector<std::size_t>*>(property))
115  {
116  printBounds(*p);
117  }
118  else if (auto p = dynamic_cast<PropertyVector<char>*>(property))
119  {
120  printBounds(*p);
121  }
122  else
123  {
124  INFO(
125  "\t{:s}: Could not get value bounds for property vector of "
126  "type '{:s}'.",
127  name, typeid(*p).name());
128  }
129  }
130 }
131 
133 {
134  MeshLib::MeshValidation validation(mesh);
135 
136  unsigned const n_holes(MeshLib::MeshValidation::detectHoles(mesh));
137  if (n_holes > 0)
138  {
139  INFO("{:d} hole(s) detected within the mesh", n_holes);
140  }
141  else
142  {
143  INFO("No holes found within the mesh.");
144  }
145 }
146 
147 } // namespace MeshLib
Definition of the Element class.
void INFO(char const *fmt, Args const &... args)
Definition: Logging.h:32
Definition of the MeshInformation class.
Definition of the MeshValidation class.
Class AABB is an axis aligned bounding box around a given set of geometric points of (template) type ...
Definition: AABB.h:49
static std::map< MeshElemType, unsigned > getNumberOfElementTypes(const MeshLib::Mesh &mesh)
static std::optional< std::pair< T, T > > const getValueBounds(PropertyVector< T > const &property)
static void writePropertyVectorInformation(const MeshLib::Mesh &mesh)
writes out property vector information
static GeoLib::AABB getBoundingBox(const MeshLib::Mesh &mesh)
Returns the bounding box of the mesh.
static void writeMeshValidationResults(MeshLib::Mesh &mesh)
static void writeAllNumbersOfElementTypes(const MeshLib::Mesh &mesh)
writes all numbers of element types
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
Definition: Mesh.h:95
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition: Mesh.h:98
Properties & getProperties()
Definition: Mesh.h:123
std::string const & getPropertyName() const
std::size_t size() const
std::string MeshElemType2String(const MeshElemType t)
Given a MeshElemType this returns the appropriate string.
Definition: MeshEnums.cpp:21
MeshElemType
Types of mesh elements supported by OpenGeoSys. Values are from VTKCellType enum.
Definition: MeshEnums.h:27
void printBounds(MeshLib::PropertyVector< T > const &property)
A collection of methods for testing mesh quality and correctness.
static unsigned detectHoles(MeshLib::Mesh const &mesh)