OGS
CoordinateSystem.cpp
Go to the documentation of this file.
1
10#include "CoordinateSystem.h"
11
12#include <cmath>
13
14#include "GeoLib/AABB.h"
16#include "MeshLib/Node.h"
17
18namespace
19{
20unsigned char getCoordinateSystem(GeoLib::AABB const& bbox)
21{
22 unsigned char coords = 0;
23
24 auto const [bbox_min, bbox_max] = bbox.getMinMaxPoints();
25 Eigen::Vector3d const pt_diff = bbox_max - bbox_min;
26
27 // The axis aligned bounding box is a from the right half-open interval.
28 // Therefore, the difference between the particular coordinates of the
29 // points is modified by the unit in the last place towards zero.
30 if (std::nexttoward(std::abs(pt_diff[0]), 0.0) > .0)
31 {
33 }
34 if (std::nexttoward(std::abs(pt_diff[1]), 0.0) > .0)
35 {
37 }
38 if (std::nexttoward(std::abs(pt_diff[2]), 0.0) > .0)
39 {
41 }
42
43 return coords;
44}
45} // namespace
46
47namespace MeshLib
48{
50{
51 GeoLib::AABB const aabb(ele.getNodes(),
52 ele.getNodes() + ele.getNumberOfNodes());
53 CoordinateSystem const bboxCoordSys(getCoordinateSystem(aabb));
54 if (bboxCoordSys.getDimension() >= ele.getDimension())
55 {
56 _type = bboxCoordSys.getType();
57 }
58 else
59 { // e.g. zero volume elements
60 if (ele.getDimension() >= 1)
61 {
63 }
64 if (ele.getDimension() >= 2)
65 {
67 }
68 if (ele.getDimension() == 3)
69 {
71 }
72 }
73}
74
76 : _type(getCoordinateSystem(bbox))
77{
78}
79
80} // namespace MeshLib
Definition of the AABB class.
Definition of the Element class.
Definition of the Node class.
Class AABB is an axis aligned bounding box around a given set of geometric points of (template) type ...
Definition AABB.h:56
MinMaxPoints getMinMaxPoints() const
Definition AABB.h:174
unsigned char getType() const
get this coordinate type
CoordinateSystem(unsigned char coord)
User provided coordinate system.
unsigned getDimension() const
get dimension size
virtual unsigned getNumberOfNodes() const =0
virtual constexpr unsigned getDimension() const =0
Get dimension of the mesh element.
virtual Node *const * getNodes() const =0
Get array of element nodes.
unsigned char getCoordinateSystem(GeoLib::AABB const &bbox)