OGS
MeshLib::CoordinateSystem Class Referencefinal

Detailed Description

Coordinate systems.

Definition at line 38 of file CoordinateSystem.h.

#include <CoordinateSystem.h>

Public Member Functions

 CoordinateSystem (unsigned char coord)
 User provided coordinate system. More...
 
 CoordinateSystem (const Element &ele)
 Decides for a given element. More...
 
 CoordinateSystem (const GeoLib::AABB &bbox)
 Decides a coordinate system from a bounding box. More...
 
unsigned char getType () const
 get this coordinate type More...
 
unsigned getDimension () const
 get dimension size More...
 
bool hasX () const
 has X dimension More...
 
bool hasY () const
 has Y dimension More...
 
bool hasZ () const
 has z dimension More...
 

Private Member Functions

unsigned char getCoordinateSystem (const GeoLib::AABB &bbox) const
 

Private Attributes

unsigned char _type
 

Constructor & Destructor Documentation

◆ CoordinateSystem() [1/3]

MeshLib::CoordinateSystem::CoordinateSystem ( unsigned char  coord)
inlineexplicit

User provided coordinate system.

Definition at line 42 of file CoordinateSystem.h.

42 : _type(coord) {}

◆ CoordinateSystem() [2/3]

MeshLib::CoordinateSystem::CoordinateSystem ( const Element ele)
explicit

Decides for a given element.

Definition at line 17 of file CoordinateSystem.cpp.

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 }
Class AABB is an axis aligned bounding box around a given set of geometric points of (template) type ...
Definition: AABB.h:49
CoordinateSystem(unsigned char coord)
User provided coordinate system.
unsigned char getCoordinateSystem(const GeoLib::AABB &bbox) const

References _type, getCoordinateSystem(), getDimension(), MeshLib::Element::getDimension(), MeshLib::Element::getNodes(), MeshLib::Element::getNumberOfNodes(), getType(), MeshLib::CoordinateSystemType::X, MeshLib::CoordinateSystemType::Y, and MeshLib::CoordinateSystemType::Z.

◆ CoordinateSystem() [3/3]

MeshLib::CoordinateSystem::CoordinateSystem ( const GeoLib::AABB bbox)
inlineexplicit

Decides a coordinate system from a bounding box.

Definition at line 48 of file CoordinateSystem.h.

49  : _type(getCoordinateSystem(bbox))
50  {
51  }

Member Function Documentation

◆ getCoordinateSystem()

unsigned char MeshLib::CoordinateSystem::getCoordinateSystem ( const GeoLib::AABB bbox) const
private

Definition at line 43 of file CoordinateSystem.cpp.

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 }
Eigen::Vector3d const & getMinPoint() const
Definition: AABB.h:174
Eigen::Vector3d const & getMaxPoint() const
Definition: AABB.h:181

References GeoLib::AABB::getMaxPoint(), GeoLib::AABB::getMinPoint(), MeshLib::CoordinateSystemType::X, MeshLib::CoordinateSystemType::Y, and MeshLib::CoordinateSystemType::Z.

Referenced by CoordinateSystem().

◆ getDimension()

unsigned MeshLib::CoordinateSystem::getDimension ( ) const
inline

get dimension size

Definition at line 57 of file CoordinateSystem.h.

58  {
59  if (hasZ())
60  {
61  return 3;
62  }
63  if (hasY())
64  {
65  return 2;
66  }
67 
68  return 1;
69  }
bool hasY() const
has Y dimension
bool hasZ() const
has z dimension

References hasY(), and hasZ().

Referenced by CoordinateSystem().

◆ getType()

unsigned char MeshLib::CoordinateSystem::getType ( ) const
inline

get this coordinate type

Definition at line 54 of file CoordinateSystem.h.

54 { return _type; }

References _type.

Referenced by CoordinateSystem().

◆ hasX()

bool MeshLib::CoordinateSystem::hasX ( ) const
inline

has X dimension

Definition at line 72 of file CoordinateSystem.h.

72 { return (_type & CoordinateSystemType::type::X) != 0; }

References _type.

◆ hasY()

bool MeshLib::CoordinateSystem::hasY ( ) const
inline

has Y dimension

Definition at line 75 of file CoordinateSystem.h.

75 { return (_type & CoordinateSystemType::type::Y) != 0; }

References _type.

Referenced by getDimension().

◆ hasZ()

bool MeshLib::CoordinateSystem::hasZ ( ) const
inline

has z dimension

Definition at line 78 of file CoordinateSystem.h.

78 { return (_type & CoordinateSystemType::type::Z) != 0; }

References _type.

Referenced by getDimension().

Member Data Documentation

◆ _type

unsigned char MeshLib::CoordinateSystem::_type
private

Definition at line 83 of file CoordinateSystem.h.

Referenced by CoordinateSystem(), getType(), hasX(), hasY(), and hasZ().


The documentation for this class was generated from the following files: