CSplineSegment.h
Go to the documentation of this file.
1 #ifndef i2d_CSplineSegment_included
2 #define i2d_CSplineSegment_included
3 
4 
5 // ACF includes
6 #include <istd/IChangeable.h>
7 
8 #include <i2d/CVector2d.h>
9 
10 
11 namespace i2d
12 {
13 
14 
15 class CSplineSegment: virtual public istd::IChangeable
16 {
17 public:
22  virtual i2d::CVector2d GetPointInSegment(double position) const;
23 
28  virtual i2d::CVector2d GetDerivationInSegment(double position) const;
29 
33  virtual i2d::CVector2d GetDerivationBegin() const;
34 
38  virtual i2d::CVector2d GetDerivationEnd() const;
39 
43  virtual i2d::CVector2d GetPointBegin() const;
44 
48  virtual i2d::CVector2d GetPointEnd() const;
49 
53  virtual i2d::CVector2d GetBezierPointBegin() const;
54 
58  virtual i2d::CVector2d GetBezierPointEnd() const;
59 
63  virtual bool IsCloserThan(const i2d::CVector2d position, double distance) const;
64 
68  virtual void GetHalfSegmentFirst(CSplineSegment& result) const;
69 
73  virtual void GetHalfSegmentSecond(CSplineSegment& result) const;
74 
75  // acces to members
76  const i2d::CVector2d& A() const;
77  void A(const i2d::CVector2d& value);
78  const i2d::CVector2d& B() const;
79  void B(const i2d::CVector2d& value);
80  const i2d::CVector2d& C() const;
81  void C(const i2d::CVector2d& value);
82  const i2d::CVector2d& D() const;
83  void D(const i2d::CVector2d& value);
84 
85  // reimplemented (istd::IChangeable)
86  virtual int GetSupportedOperations() const;
87  virtual bool CopyFrom(const IChangeable& object, CompatibilityMode mode = CM_WITHOUT_REFS);
89 
90 private:
91  i2d::CVector2d m_a;
92  i2d::CVector2d m_b;
93  i2d::CVector2d m_c;
94  i2d::CVector2d m_d;
95 };
96 
97 
99 {
100  return ((m_a * position + m_b) * position + m_c) * position + m_d;
101 }
102 
103 
105 {
106  return (m_a * (3 * position) + m_b * 2) * position + m_c;
107 }
108 
109 
111 {
112  return m_c;
113 }
114 
115 
117 {
118  return m_a * 3 + m_b * 2 + m_c;
119 }
120 
121 
123 {
124  return m_d;
125 }
126 
127 
129 {
130  return m_a + m_b + m_c + m_d;
131 }
132 
133 
135 {
136  return m_d + m_c / 3;
137 }
138 
139 
141 {
142  return m_c + m_d + (m_b - m_c) / 3;
143 }
144 
145 
147 {
148  result.m_a = m_a * 0.125;
149  result.m_b = m_b * 0.25;
150  result.m_c = m_c * 0.5;
151  result.m_d = m_d;
152 }
153 
154 
156 {
157  result.m_a = m_a * 0.125;
158  result.m_b = m_a * 0.375 + m_b * 0.25;
159  result.m_c = m_a * 0.375 + (m_b + m_c) * 0.5;
160  result.m_d = m_a * 0.125 + m_b * 0.25 + m_c * 0.5 + m_d;
161 }
162 
163 
164 // acces to members
165 
166 inline const i2d::CVector2d& CSplineSegment::A() const
167 {
168  return m_a;
169 }
170 
171 
172 inline void CSplineSegment::A(const i2d::CVector2d& value)
173 {
174  m_a = value;
175 }
176 
177 
178 inline const i2d::CVector2d& CSplineSegment::B() const
179 {
180  return m_b;
181 }
182 
183 
184 inline void CSplineSegment::B(const i2d::CVector2d& value)
185 {
186  m_b = value;
187 }
188 
189 
190 inline const i2d::CVector2d& CSplineSegment::C() const
191 {
192  return m_c;
193 }
194 
195 
196 inline void CSplineSegment::C(const i2d::CVector2d& value)
197 {
198  m_c = value;
199 }
200 
201 
202 inline const i2d::CVector2d& CSplineSegment::D() const
203 {
204  return m_d;
205 }
206 
207 
208 inline void CSplineSegment::D(const i2d::CVector2d& value)
209 {
210  m_d = value;
211 }
212 
213 
214 } // namespace i2d
215 
216 
217 #endif // !i2d_CSplineSegment_included
virtual bool IsCloserThan(const i2d::CVector2d position, double distance) const
Check, if segment is closer than specifier distance.
virtual i2d::CVector2d GetDerivationInSegment(double position) const
Get derivation.
virtual void GetHalfSegmentFirst(CSplineSegment &result) const
Get a first half segment.
External references are simple ignored.
Definition: IChangeable.h:197
CompatibilityMode
Control how relationship betweeen objects are interpreted.
Definition: IChangeable.h:186
virtual i2d::CVector2d GetBezierPointBegin() const
Get first Bezier's control point.
virtual i2d::CVector2d GetPointInSegment(double position) const
Get point.
virtual i2d::CVector2d GetBezierPointEnd() const
Get second Bezier's control point.
virtual i2d::CVector2d GetPointEnd() const
Get end point.
virtual i2d::CVector2d GetDerivationBegin() const
Get derivation in begin point.
virtual i2d::CVector2d GetPointBegin() const
Get begin point.
virtual bool CopyFrom(const IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS)
Common interface for data model objects, which can be changed.
Definition: IChangeable.h:24
const i2d::CVector2d & C() const
virtual int GetSupportedOperations() const
Get set of flags for supported operations.
const i2d::CVector2d & B() const
Definition of position or mathematical vector on 2D plane.
Definition: CVector2d.h:28
const i2d::CVector2d & A() const
virtual istd::IChangeable * CloneMe(CompatibilityMode mode=CM_WITHOUT_REFS) const
Make a copy of this object.
const i2d::CVector2d & D() const
virtual void GetHalfSegmentSecond(CSplineSegment &result) const
Get a second half segment.
virtual i2d::CVector2d GetDerivationEnd() const
Get derivation in end point.

© 2007-2017 Witold Gantzke and Kirill Lepskiy