ActiveLib
Loading...
Searching...
No Matches
PolyPoint.h
1
6#ifndef ACTIVE_GEOMETRY_POLY_POINT
7#define ACTIVE_GEOMETRY_POLY_POINT
8
9#include "Active/Geometry/Point.h"
10
11namespace active::geometry {
12
13 using vertex_id = uint32_t;
14
15 class Line;
16
24 class PolyPoint : public Point {
25 public:
26
27 // MARK: - Types
28
30 using Unique = std::unique_ptr<PolyPoint>;
32 using Shared = std::shared_ptr<PolyPoint>;
34 using Option = std::optional<PolyPoint>;
35
36 // MARK: - Constructors
37
50 PolyPoint(const double& x, const double& y, const double& z = 0.0, double angle = 0.0, vertex_id id = 0) :
51 PolyPoint{Point{x, y, z}, angle, id} {}
58 PolyPoint(const Point& source, double angle = 0.0, vertex_id id = 0);
63 PolyPoint(const PolyPoint& source);
67 virtual ~PolyPoint() = default;
68
73 virtual PolyPoint* clonePtr() const override { return new PolyPoint(*this); }
74
75 // MARK: - Variables
76
78 double sweep = 0.0;
80 vertex_id id = 0;
81
82 // MARK: - Operators
83
89 PolyPoint& operator= (const PolyPoint& source);
95 PolyPoint& operator= (const Point& source) { Point::operator= (source); return *this; }
96
97 // MARK: - Functions (const)
98
103 bool isArc(double prec = math::eps) const { return !math::isZero(sweep, prec); }
109 virtual double lengthFrom2D(const Point& ref) const override;
110
111 // MARK: - Functions (mutating)
116 void setSweep(const Line& ref);
121 void setSweepParallel(const Line& ref);
122 };
123
124}
125
126#endif //ACTIVE_GEOMETRY_POLY_POINT
Class to represent a line.
Definition Line.h:21
Definition Point.h:36
double z
Z coordinate.
Definition Point.h:86
double x
X coordinate.
Definition Point.h:82
Point & operator=(const Point &source)
Definition Point.cpp:78
double y
Y coordinate.
Definition Point.h:84
Definition PolyPoint.h:24
virtual double lengthFrom2D(const Point &ref) const override
Definition PolyPoint.cpp:67
std::shared_ptr< PolyPoint > Shared
Shared pointer.
Definition PolyPoint.h:32
vertex_id id
An optional unique ID for the vertex, e.g. for maintaining links to a specific vertex within a polygo...
Definition PolyPoint.h:80
double sweep
The sweep angle of an edge leading to this point (0.0 = atraight line)
Definition PolyPoint.h:78
void setSweep(const Line &ref)
Definition PolyPoint.cpp:79
PolyPoint(const double &x, const double &y, const double &z=0.0, double angle=0.0, vertex_id id=0)
Definition PolyPoint.h:50
virtual ~PolyPoint()=default
bool isArc(double prec=math::eps) const
Definition PolyPoint.h:103
std::optional< PolyPoint > Option
Optional.
Definition PolyPoint.h:34
std::unique_ptr< PolyPoint > Unique
Unique pointer.
Definition PolyPoint.h:30
PolyPoint()
Definition PolyPoint.h:41
PolyPoint & operator=(const PolyPoint &source)
Definition PolyPoint.cpp:49
virtual PolyPoint * clonePtr() const override
Definition PolyPoint.h:73
void setSweepParallel(const Line &ref)
Definition PolyPoint.cpp:92
Definition Anchor2D.h:11
constexpr double eps
Default length precision (0.01mm)
Definition MathFunctions.h:22