OGS
CoordinateSystem.cpp
Go to the documentation of this file.
1 
10 #include "CoordinateSystem.h"
11 
13 #include "MeshLib/Node.h"
14 
15 namespace MeshLib
16 {
18 {
19  GeoLib::AABB const aabb(ele.getNodes(),
20  ele.getNodes() + ele.getNumberOfNodes());
21  CoordinateSystem const bboxCoordSys(getCoordinateSystem(aabb));
22  if (bboxCoordSys.getDimension() >= ele.getDimension())
23  {
24  _type = bboxCoordSys.getType();
25  }
26  else
27  { // e.g. zero volume elements
28  if (ele.getDimension() >= 1)
29  {
31  }
32  if (ele.getDimension() >= 2)
33  {
35  }
36  if (ele.getDimension() == 3)
37  {
39  }
40  }
41 }
42 
44  const GeoLib::AABB& bbox) const
45 {
46  unsigned char coords = 0;
47 
48  auto const& bbox_min = bbox.getMinPoint();
49  auto const& bbox_max = bbox.getMaxPoint();
50  Eigen::Vector3d const pt_diff = bbox_max - bbox_min;
51 
52  // The axis aligned bounding box is a from the right half-open interval.
53  // Therefore, the difference between the particular coordinates of the
54  // points is modified by the unit in the last place towards zero.
55  if (std::nexttoward(std::abs(pt_diff[0]), 0.0) > .0)
56  {
57  coords |= CoordinateSystemType::X;
58  }
59  if (std::nexttoward(std::abs(pt_diff[1]), 0.0) > .0)
60  {
61  coords |= CoordinateSystemType::Y;
62  }
63  if (std::nexttoward(std::abs(pt_diff[2]), 0.0) > .0)
64  {
65  coords |= CoordinateSystemType::Z;
66  }
67 
68  return coords;
69 }
70 
71 } // namespace MeshLib
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:49
Eigen::Vector3d const & getMinPoint() const
Definition: AABB.h:174
Eigen::Vector3d const & getMaxPoint() const
Definition: AABB.h:181
Coordinate systems.
unsigned char getType() const
get this coordinate type
CoordinateSystem(unsigned char coord)
User provided coordinate system.
unsigned char getCoordinateSystem(const GeoLib::AABB &bbox) const
unsigned getDimension() const
get dimension size
virtual Node *const * getNodes() const =0
Get array of element nodes.
virtual unsigned getNumberOfNodes() const =0
virtual constexpr unsigned getDimension() const =0
Get dimension of the mesh element.