ICF 3.0.5.47
Technical documentation of ICF Libraries
CPolyline.h
Go to the documentation of this file.
1/********************************************************************************
2** This file is part of the ICF Framework. Copyright (C) Witold Gantzke & Kirill Lepskiy
3** ICF Framework may be used under the terms of the LGPL License v. 2.1 by the Free Software Foundation.
4********************************************************************************/
5
6#pragma once
7
8
9// ICF includes
10#include <i2d/CLine2d.h>
11#include <i2d/CPolygon.h>
12
13
14namespace i2d
15{
16
17
22class CPolyline: public CPolygon
23{
24public:
26
27 static QByteArray GetTypeName();
28
29 CPolyline();
30
31 virtual bool IsClosed() const;
32
36 virtual void SetClosed(bool state = true);
37
41 virtual int GetSegmentsCount() const;
42
46 virtual i2d::CLine2d GetSegmentLine(int segmentIndex) const;
47
51 virtual double GetLength() const;
52
56 virtual i2d::CVector2d GetKneeVector(int nodeIndex) const;
57
61 bool GetAdjacentNodes(double atPositionNormalized, i2d::CVector2d& previous, i2d::CVector2d& next, double& alpha) const;
62
66 bool GetAdjacentNodes(const i2d::CVector2d& position, i2d::CVector2d& previous, i2d::CVector2d& next) const;
67
71 bool GetAdjacentNodeIndices(double position, int& previousIndex, int& nextIndex, double& alpha) const;
72
76 bool GetAdjacentNodeIndices(const i2d::CVector2d& position, int& previousIndex, int& nextIndex) const;
77
81 bool GetAdjacentLine(double position, i2d::CLine2d& line, double& alpha) const;
82
86 bool GetAdjacentLine(const i2d::CVector2d& position, i2d::CLine2d& line) const;
87
91 bool GetInterpolatedPosition(double position, i2d::CVector2d& output) const;
93
94 // reimplemented (iser::ISerializable)
95 bool Serialize(iser::IArchive& archive) override;
96
97 // reimplemented (iser::IObject)
98 QByteArray GetFactoryId() const override;
99
100 // reimplemented istd::IChangeable
101 bool CopyFrom(const IChangeable& object, CompatibilityMode mode = CM_WITHOUT_REFS) override;
102 std::unique_ptr<istd::IChangeable> CloneMe(CompatibilityMode mode = CM_WITHOUT_REFS) const override;
103 bool IsEqual(const IChangeable& object) const override;
104
105private:
106 bool m_isClosed;
107};
108
109
110// public inline methods
111
113{
114 m_isClosed = false;
115}
116
117
118inline bool CPolyline::IsClosed() const
119{
120 return m_isClosed;
121}
122
123
124} // namespace i2d
125
126
Definition of a line in 2D-space.
Definition CLine2d.h:26
Definition of the data model for a polygon.
Definition CPolygon.h:24
2D-object representing a polyline.
Definition CPolyline.h:23
i2d::CVector2d GetInterpolatedPosition(double position) const
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 double GetLength() const
Get length of this polyline.
bool GetInterpolatedPosition(double position, i2d::CVector2d &output) const
Get position on this polyline in order to normal position [0..1].
QByteArray GetFactoryId() const override
virtual i2d::CLine2d GetSegmentLine(int segmentIndex) const
Return number of line segments.
std::unique_ptr< istd::IChangeable > CloneMe(CompatibilityMode mode=CM_WITHOUT_REFS) const override
Make a copy of this object.
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.
bool IsEqual(const IChangeable &object) const override
virtual void SetClosed(bool state=true)
Set polyline to be opened or closed.
bool Serialize(iser::IArchive &archive) override
Load or store state of this object as a archive stream.
CPolygon BaseClass
Definition CPolyline.h:25
bool GetAdjacentLine(const i2d::CVector2d &position, i2d::CLine2d &line) const
Get adjacent segment by position on line, and by position of arbitrary point.
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:118
virtual int GetSegmentsCount() const
Return number of line segments.
bool CopyFrom(const IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS) override
static QByteArray GetTypeName()
Definition of position or mathematical vector on 2D plane.
Definition CVector2d.h:29
Represent input/output persistence archive.
Definition IArchive.h:33
CompatibilityMode
Control how relationship betweeen objects are interpreted.
@ CM_WITHOUT_REFS
External references are simple ignored.
Contains the 2D objects.
Definition CAffine2d.h:15

© Witold Gantzke and Kirill Lepskiy