Newer
Older
* Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*/
#ifndef COORDINATESYSTEMTYPE_H_
#define COORDINATESYSTEMTYPE_H_
#include <cmath>
#include "GeoLib/AABB.h"
#include "MathLib/Vector3.h"
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
namespace MeshLib
{
class Element;
/**
* \brief Coordinate system type
*/
struct CoordinateSystemType
{
enum type
{
X = 0x01,
Y = 0x02,
Z = 0x04
};
};
/**
* \brief Coordinate systems
*
*
*/
class CoordinateSystem
{
public:
/// User provided coordinate system
explicit CoordinateSystem(unsigned char coord) : _type (coord) {}
/// Decides for a given element
explicit CoordinateSystem(const Element &ele);
/// Decides a coordinate system from a bounding box
explicit CoordinateSystem(const GeoLib::AABB &bbox) : _type(getCoordinateSystem(bbox)) {}
/// get this coordinate type
unsigned char getType() const { return _type; }
/// get dimension size
unsigned getDimension() const {
if (hasZ())
return 3;
else if (hasY())
return 2;
else
return 1;
}
/// has X dimension
bool hasX() const { return (_type & CoordinateSystemType::type::X) != 0; }
bool hasY() const { return (_type & CoordinateSystemType::type::Y) != 0; }
bool hasZ() const { return (_type & CoordinateSystemType::type::Z) != 0; }
unsigned char getCoordinateSystem(const GeoLib::AABB &bbox) const;
unsigned char _type;
};
} // MeshLib
#endif // COORDINATESYSTEMTYPE_H_