OGS
CoordinateSystem.h
Go to the documentation of this file.
1 
10 #pragma once
11 
12 #include <cmath>
13 
14 #include "GeoLib/AABB.h"
15 
16 namespace MeshLib
17 {
18 class Element;
19 
24 {
25  enum type
26  {
27  X = 0x01,
28  Y = 0x02,
29  Z = 0x04
30  };
31 };
32 
38 class CoordinateSystem final
39 {
40 public:
42  explicit CoordinateSystem(unsigned char coord) : _type(coord) {}
43 
45  explicit CoordinateSystem(const Element& ele);
46 
48  explicit CoordinateSystem(const GeoLib::AABB& bbox)
49  : _type(getCoordinateSystem(bbox))
50  {
51  }
52 
54  unsigned char getType() const { return _type; }
55 
57  unsigned getDimension() const
58  {
59  if (hasZ())
60  {
61  return 3;
62  }
63  if (hasY())
64  {
65  return 2;
66  }
67 
68  return 1;
69  }
70 
72  bool hasX() const { return (_type & CoordinateSystemType::type::X) != 0; }
73 
75  bool hasY() const { return (_type & CoordinateSystemType::type::Y) != 0; }
76 
78  bool hasZ() const { return (_type & CoordinateSystemType::type::Z) != 0; }
79 
80 private:
81  unsigned char getCoordinateSystem(const GeoLib::AABB& bbox) const;
82 
83  unsigned char _type;
84 };
85 
86 } // namespace MeshLib
Definition of the AABB class.
Class AABB is an axis aligned bounding box around a given set of geometric points of (template) type ...
Definition: AABB.h:49
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
bool hasY() const
has Y dimension
unsigned getDimension() const
get dimension size
CoordinateSystem(const GeoLib::AABB &bbox)
Decides a coordinate system from a bounding box.
bool hasX() const
has X dimension
bool hasZ() const
has z dimension
Coordinate system type.