CEdgeLine.h
Go to the documentation of this file.
1 #ifndef iedge_CEdgeLine_included
2 #define iedge_CEdgeLine_included
3 
4 
5 // ACF includes
7 #include "i2d/CObject2dBase.h"
8 #include "i2d/CPolyline.h"
9 #include "i2d/CAffine2d.h"
10 
11 // ACF-Solutions includes
12 #include "iedge/CEdgeNode.h"
13 
14 
15 namespace iedge
16 {
17 
18 
20 {
21 public:
23 
24  CEdgeLine();
25  CEdgeLine(const CEdgeLine& edgeLine);
26 
27  void Clear();
28 
33  const CEdgeNode& GetNode(int index) const;
38  CEdgeNode& GetNodeRef(int index);
39 
45  void SetNode(int index, const CEdgeNode& node);
46 
47  bool IsClosed() const;
48  void SetClosed(bool state = true);
49 
50  int GetNodesCount() const;
51  int GetSegmentsCount() const;
52 
53  double GetTotalLength() const;
54  double GetMinWeight() const;
55  double GetMaxWeight() const;
56 
57  bool InsertNode(const CEdgeNode& node);
58 
66  void CopyFromPolyline(const i2d::CPolyline& polyline, double weight = 1.0, const i2d::CAffine2d* transformPtr = NULL);
73  void CopyToPolyline(i2d::CPolyline& polyline, const i2d::CAffine2d* transformPtr = NULL) const;
74 
75  // reimplemented (i2d::IObject2d)
76  virtual i2d::CVector2d GetCenter() const;
77  virtual void MoveCenterTo(const i2d::CVector2d& position);
78  virtual i2d::CRectangle GetBoundingBox() const;
79  virtual bool Transform(
80  const i2d::ITransformation2d& transformation,
81  i2d::ITransformation2d::ExactnessMode mode = i2d::ITransformation2d::EM_NONE,
82  double* errorFactorPtr = NULL);
83  virtual bool InvTransform(
84  const i2d::ITransformation2d& transformation,
85  i2d::ITransformation2d::ExactnessMode mode = i2d::ITransformation2d::EM_NONE,
86  double* errorFactorPtr = NULL);
87  virtual bool GetTransformed(
88  const i2d::ITransformation2d& transformation,
89  IObject2d& result,
90  i2d::ITransformation2d::ExactnessMode mode = i2d::ITransformation2d::EM_NONE,
91  double* errorFactorPtr = NULL) const;
92  virtual bool GetInvTransformed(
93  const i2d::ITransformation2d& transformation,
94  IObject2d& result,
95  i2d::ITransformation2d::ExactnessMode mode = i2d::ITransformation2d::EM_NONE,
96  double* errorFactorPtr = NULL) const;
97 
98  // reimplemented (iser::ISerializable)
99  virtual bool Serialize(iser::IArchive& archive);
100 
101 protected:
105  void EnsureVolatileValid() const;
106 
107  virtual void CalcVolatile() const;
108 
109  // reimplemented (istd::IChangeable)
110  virtual void OnEndChanges(int changeFlags, istd::IPolymorphic* changeParamsPtr);
111 
112 private:
113  typedef QList<CEdgeNode> Nodes;
114 
115  Nodes m_nodes;
116 
117  bool m_isClosed;
118 
119  mutable bool m_areVolatileValid;
120  mutable double m_totalLength;
121  mutable i2d::CVector2d m_center;
122  mutable double m_minWeight;
123  mutable double m_maxWeight;
124  mutable i2d::CRectangle m_boundingBox;
125 };
126 
127 
128 // inline methods
129 
130 inline int CEdgeLine::GetNodesCount() const
131 {
132  return m_nodes.size();
133 }
134 
135 
136 inline int CEdgeLine::GetSegmentsCount() const
137 {
138  return m_isClosed? m_nodes.size(): m_nodes.size() - 1;
139 }
140 
141 
142 inline double CEdgeLine::GetTotalLength() const
143 {
145 
146  return m_totalLength;
147 }
148 
149 
150 inline double CEdgeLine::GetMinWeight() const
151 {
153 
154  return m_minWeight;
155 }
156 
157 
158 inline double CEdgeLine::GetMaxWeight() const
159 {
161 
162  return m_maxWeight;
163 }
164 
165 
166 inline bool CEdgeLine::IsClosed() const
167 {
168  return m_isClosed;
169 }
170 
171 
172 // protected methods
173 
175 {
176  if (!m_areVolatileValid){
177  CalcVolatile();
178 
179  m_areVolatileValid = true;
180  }
181 }
182 
183 
184 } // namespace iedge
185 
186 
187 #endif // !iedge_CEdgeLine_included
188 
189 
int GetNodesCount() const
Definition: CEdgeLine.h:130
void CopyFromPolyline(const i2d::CPolyline &polyline, double weight=1.0, const i2d::CAffine2d *transformPtr=NULL)
Create this line using polyline object.
void SetNode(int index, const CEdgeNode &node)
Set node at specified index.
virtual bool Serialize(iser::IArchive &archive)
virtual bool GetTransformed(const i2d::ITransformation2d &transformation, IObject2d &result, i2d::ITransformation2d::ExactnessMode mode=i2d::ITransformation2d::EM_NONE, double *errorFactorPtr=NULL) const
virtual i2d::CRectangle GetBoundingBox() const
CEdgeNode & GetNodeRef(int index)
Return reference to node at specified index.
virtual bool InvTransform(const i2d::ITransformation2d &transformation, i2d::ITransformation2d::ExactnessMode mode=i2d::ITransformation2d::EM_NONE, double *errorFactorPtr=NULL)
double GetTotalLength() const
Definition: CEdgeLine.h:142
virtual i2d::CVector2d GetCenter() const
const CEdgeNode & GetNode(int index) const
Return node at specified index.
void EnsureVolatileValid() const
Make sure, that all volatile values are calculated and valid.
Definition: CEdgeLine.h:174
virtual void MoveCenterTo(const i2d::CVector2d &position)
double GetMaxWeight() const
Definition: CEdgeLine.h:158
i2d::CObject2dBase BaseClass
Definition: CEdgeLine.h:22
void CopyToPolyline(i2d::CPolyline &polyline, const i2d::CAffine2d *transformPtr=NULL) const
Copy this line to polyline.
int GetSegmentsCount() const
Definition: CEdgeLine.h:136
bool InsertNode(const CEdgeNode &node)
void SetClosed(bool state=true)
bool IsClosed() const
Definition: CEdgeLine.h:166
double GetMinWeight() const
Definition: CEdgeLine.h:150
Description of single node of the edge.
Definition: CEdgeNode.h:18
virtual bool GetInvTransformed(const i2d::ITransformation2d &transformation, IObject2d &result, i2d::ITransformation2d::ExactnessMode mode=i2d::ITransformation2d::EM_NONE, double *errorFactorPtr=NULL) const
virtual void CalcVolatile() const
virtual bool Transform(const i2d::ITransformation2d &transformation, i2d::ITransformation2d::ExactnessMode mode=i2d::ITransformation2d::EM_NONE, double *errorFactorPtr=NULL)
virtual void OnEndChanges(int changeFlags, istd::IPolymorphic *changeParamsPtr)

© 2007-2011 Witold Gantzke and Kirill Lepskiy