ACF $AcfVersion:0$
CPolyline.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ACF-Commercial
2#pragma once
3
4
5// ACF includes
6#include <i2d/CLine2d.h>
7#include <i2d/CPolygon.h>
8
9
10namespace i2d
11{
12
13
18class CPolyline: public CPolygon
19{
20public:
22
23 static QByteArray GetTypeName();
24
25 CPolyline();
26
27 virtual bool IsClosed() const;
28
32 virtual void SetClosed(bool state = true);
33
37 virtual int GetSegmentsCount() const;
38
42 virtual i2d::CLine2d GetSegmentLine(int segmentIndex) const;
43
47 virtual double GetLength() const;
48
52 virtual i2d::CVector2d GetKneeVector(int nodeIndex) const;
53
57 bool GetAdjacentNodes(double atPositionNormalized, i2d::CVector2d& previous, i2d::CVector2d& next, double& alpha) const;
58
62 bool GetAdjacentNodes(const i2d::CVector2d& position, i2d::CVector2d& previous, i2d::CVector2d& next) const;
63
67 bool GetAdjacentNodeIndices(double position, int& previousIndex, int& nextIndex, double& alpha) const;
68 bool GetAdjacentNodeIndices(double position, int& previousIndex, int& nextIndex) const;
69
73 bool GetAdjacentNodeIndices(const i2d::CVector2d& position, int& previousIndex, int& nextIndex) const;
74
78 bool GetAdjacentLine(double position, i2d::CLine2d& line, double& alpha) const;
79
83 bool GetAdjacentLine(const i2d::CVector2d& position, i2d::CLine2d& line) const;
84
88 bool GetInterpolatedPosition(double position, i2d::CVector2d& output) const;
90
91 // reimplemented (iser::ISerializable)
92 virtual bool Serialize(iser::IArchive& archive) override;
93
94 // reimplemented (iser::IObject)
95 virtual QByteArray GetFactoryId() const override;
96
97 // reimplemented (istd::IChangeable)
98 virtual bool CopyFrom(const IChangeable& object, CompatibilityMode mode = CM_WITHOUT_REFS) override;
100 virtual bool IsEqual(const IChangeable& object) const override;
101
102private:
103 bool m_isClosed;
104};
105
106
107// public inline methods
108
110{
111 m_isClosed = false;
112}
113
114
115inline bool CPolyline::IsClosed() const
116{
117 return m_isClosed;
118}
119
120
121} // namespace i2d
122
123
124
125
Definition of a line in 2D-space.
Definition CLine2d.h:25
Definition of the data model for a polygon.
Definition CPolygon.h:20
2D-object representing a polyline.
Definition CPolyline.h:19
virtual istd::TUniqueInterfacePtr< istd::IChangeable > CloneMe(CompatibilityMode mode=CM_WITHOUT_REFS) const override
Make a copy of this object.
i2d::CVector2d GetInterpolatedPosition(double position) const
virtual bool Serialize(iser::IArchive &archive) override
Load or store state of this object as a archive stream.
bool GetAdjacentNodeIndices(const i2d::CVector2d &position, int &previousIndex, int &nextIndex) const
Get adjacent node indices by position on line, and position of arbitrary point.
bool GetAdjacentNodes(double atPositionNormalized, i2d::CVector2d &previous, i2d::CVector2d &next, double &alpha) const
Get adjacent nodes by position on line, and by position of arbitrary point.
bool GetAdjacentNodeIndices(double position, int &previousIndex, int &nextIndex, double &alpha) const
Get adjacent node indices by position on line, and position of arbitrary point.
virtual bool IsEqual(const IChangeable &object) const override
virtual double GetLength() const
Get length of this polyline.
virtual QByteArray GetFactoryId() const override
bool GetInterpolatedPosition(double position, i2d::CVector2d &output) const
Get position on this polyline in order to normal position [0..1].
virtual i2d::CLine2d GetSegmentLine(int segmentIndex) const
Return number of line segments.
virtual bool CopyFrom(const IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS) override
bool GetAdjacentNodes(const i2d::CVector2d &position, i2d::CVector2d &previous, i2d::CVector2d &next) const
Get adjacent nodes by position on line, and by position of arbitrary point.
virtual void SetClosed(bool state=true)
Set polyline to be opened or closed.
bool GetAdjacentLine(const i2d::CVector2d &position, i2d::CLine2d &line) const
Get adjacent segment by position on line, and by position of arbitrary point.
CPolygon BaseClass
Definition CPolyline.h:21
bool GetAdjacentLine(double position, i2d::CLine2d &line, double &alpha) const
Get adjacent segment by position on line, and by position of arbitrary point.
virtual i2d::CVector2d GetKneeVector(int nodeIndex) const
Return vector for knee, that has the same angle to both neighbor segments.
virtual bool IsClosed() const
Definition CPolyline.h:115
virtual int GetSegmentsCount() const
Return number of line segments.
static QByteArray GetTypeName()
bool GetAdjacentNodeIndices(double position, int &previousIndex, int &nextIndex) const
Definition of position or mathematical vector on 2D plane.
Definition CVector2d.h:29
Represents an input/output persistence archive for object serialization.
Definition IArchive.h:164
CompatibilityMode
Control how relationship betweeen objects are interpreted.
@ CM_WITHOUT_REFS
External references are simple ignored.
Unique ownership smart pointer for interface types.
Contains the 2D objects.
Definition CAffine2d.h:11