b311480e |
1 | // Created on: 1995-05-04 |
2 | // Created by: Laurent BOURESCHE |
3 | // Copyright (c) 1995-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
17 | #include <ChFiDS_ElSpine.ixx> |
18 | #include <Geom_BSplineCurve.hxx> |
19 | #include <ElCLib.hxx> |
20 | #include <Precision.hxx> |
21 | |
22 | |
23 | //======================================================================= |
24 | //function : ChFiDS_ElSpine |
25 | //purpose : |
26 | //======================================================================= |
27 | |
28 | ChFiDS_ElSpine::ChFiDS_ElSpine():periodic(0) |
29 | { |
30 | } |
31 | |
32 | |
33 | //======================================================================= |
34 | //function : FirstParameter |
35 | //purpose : |
36 | //======================================================================= |
37 | |
38 | Standard_Real ChFiDS_ElSpine::FirstParameter() const |
39 | { |
40 | return pfirst; |
41 | } |
42 | |
43 | |
44 | //======================================================================= |
45 | //function : LastParameter |
46 | //purpose : |
47 | //======================================================================= |
48 | |
49 | Standard_Real ChFiDS_ElSpine::LastParameter() const |
50 | { |
51 | return plast; |
52 | } |
53 | |
54 | //======================================================================= |
55 | //function : Continuity |
56 | //purpose : |
57 | //======================================================================= |
58 | |
59 | GeomAbs_Shape ChFiDS_ElSpine::Continuity() const |
60 | { |
61 | return curve.Continuity(); |
62 | } |
63 | |
64 | //======================================================================= |
65 | //function : NbIntervals |
66 | //purpose : |
67 | //======================================================================= |
68 | |
69 | Standard_Integer ChFiDS_ElSpine::NbIntervals(const GeomAbs_Shape S) |
70 | { |
71 | return curve.NbIntervals(S); |
72 | } |
73 | |
74 | //======================================================================= |
75 | //function : Intervals |
76 | //purpose : |
77 | //======================================================================= |
78 | |
79 | void ChFiDS_ElSpine::Intervals(TColStd_Array1OfReal& T,const GeomAbs_Shape S) |
80 | { |
81 | curve.Intervals(T,S); |
82 | } |
83 | |
84 | //======================================================================= |
85 | //function : Trim |
86 | //purpose : |
87 | //======================================================================= |
88 | |
89 | Handle(Adaptor3d_HCurve) ChFiDS_ElSpine::Trim(const Standard_Real First, |
90 | const Standard_Real Last, |
91 | const Standard_Real Tol) const |
92 | { |
93 | return curve.Trim(First,Last,Tol); |
94 | } |
95 | |
96 | //======================================================================= |
97 | //function : Resolution |
98 | //purpose : |
99 | //======================================================================= |
100 | |
101 | Standard_Real ChFiDS_ElSpine::Resolution(const Standard_Real R3d) const |
102 | { |
103 | return curve.Resolution(R3d); |
104 | } |
105 | |
106 | |
107 | //======================================================================= |
108 | //function : Resolution |
109 | //purpose : |
110 | //======================================================================= |
111 | |
112 | GeomAbs_CurveType ChFiDS_ElSpine::GetType() const |
113 | { |
114 | return curve.GetType(); |
115 | } |
116 | |
117 | |
118 | //======================================================================= |
119 | //function : IsPeriodic |
120 | //purpose : |
121 | //======================================================================= |
122 | |
123 | Standard_Boolean ChFiDS_ElSpine::IsPeriodic() const |
124 | { |
125 | return periodic; |
126 | } |
127 | |
128 | |
129 | //======================================================================= |
130 | //function : SetPeriodic |
131 | //purpose : |
132 | //======================================================================= |
133 | |
134 | void ChFiDS_ElSpine::SetPeriodic(const Standard_Boolean I) |
135 | { |
136 | periodic = I; |
137 | period = plast - pfirst; |
138 | } |
139 | |
140 | |
141 | |
142 | //======================================================================= |
143 | //function : Period |
144 | //purpose : |
145 | //======================================================================= |
146 | |
147 | Standard_Real ChFiDS_ElSpine::Period() const |
148 | { |
149 | if(!periodic) Standard_Failure::Raise("ElSpine non periodique"); |
150 | return period; |
151 | } |
152 | |
153 | |
154 | //======================================================================= |
155 | //function : Value |
156 | //purpose : |
157 | //======================================================================= |
158 | |
159 | gp_Pnt ChFiDS_ElSpine::Value(const Standard_Real AbsC) const |
160 | { |
161 | return curve.Value(AbsC); |
162 | } |
163 | |
164 | |
165 | //======================================================================= |
166 | //function : D0 |
167 | //purpose : |
168 | //======================================================================= |
169 | |
170 | void ChFiDS_ElSpine::D0(const Standard_Real AbsC, gp_Pnt& P) const |
171 | { |
172 | curve.D0(AbsC,P); |
173 | } |
174 | |
175 | |
176 | //======================================================================= |
177 | //function : D1 |
178 | //purpose : |
179 | //======================================================================= |
180 | |
181 | void ChFiDS_ElSpine::D1(const Standard_Real AbsC, gp_Pnt& P, gp_Vec& V1) |
182 | const |
183 | { |
184 | curve.D1(AbsC,P,V1); |
185 | } |
186 | |
187 | |
188 | //======================================================================= |
189 | //function : D2 |
190 | //purpose : |
191 | //======================================================================= |
192 | |
193 | void ChFiDS_ElSpine::D2(const Standard_Real AbsC, |
194 | gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const |
195 | { |
196 | curve.D2(AbsC,P,V1,V2); |
197 | } |
198 | |
199 | //======================================================================= |
200 | //function : D3 |
201 | //purpose : |
202 | //======================================================================= |
203 | |
204 | void ChFiDS_ElSpine::D3(const Standard_Real AbsC, |
205 | gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const |
206 | { |
207 | curve.D3(AbsC,P,V1,V2,V3); |
208 | } |
209 | |
210 | |
211 | //======================================================================= |
212 | //function : FirstParameter |
213 | //purpose : |
214 | //======================================================================= |
215 | |
216 | void ChFiDS_ElSpine::FirstParameter(const Standard_Real P) |
217 | { |
218 | pfirst = P; |
219 | } |
220 | |
221 | |
222 | //======================================================================= |
223 | //function : LastParameter |
224 | //purpose : |
225 | //======================================================================= |
226 | |
227 | void ChFiDS_ElSpine::LastParameter(const Standard_Real P) |
228 | { |
229 | plast = P; |
230 | } |
231 | |
232 | |
233 | //======================================================================= |
234 | //function : SetOrigin |
235 | //purpose : |
236 | //======================================================================= |
237 | |
238 | void ChFiDS_ElSpine::SetOrigin(const Standard_Real O) |
239 | { |
240 | if(!periodic) Standard_Failure::Raise("Elspine non periodique"); |
241 | Handle(Geom_BSplineCurve) bs = Handle(Geom_BSplineCurve)::DownCast(curve.Curve()); |
242 | if(!bs.IsNull()) { |
243 | bs->SetOrigin(O,Precision::PConfusion()); |
244 | curve.Load(bs); |
245 | } |
246 | } |
247 | |
248 | //======================================================================= |
249 | //function : SetFirstPointAndTgt |
250 | //purpose : |
251 | //======================================================================= |
252 | |
253 | void ChFiDS_ElSpine::SetFirstPointAndTgt(const gp_Pnt& P, |
254 | const gp_Vec& T) |
255 | { |
256 | ptfirst = P; |
257 | tgfirst = T; |
258 | } |
259 | |
260 | //======================================================================= |
261 | //function : SetLastPointAndTgt |
262 | //purpose : |
263 | //======================================================================= |
264 | |
265 | void ChFiDS_ElSpine::SetLastPointAndTgt(const gp_Pnt& P, |
266 | const gp_Vec& T) |
267 | { |
268 | ptlast = P; |
269 | tglast = T; |
270 | } |
271 | |
272 | //======================================================================= |
273 | //function : FirstPointAndTgt |
274 | //purpose : |
275 | //======================================================================= |
276 | |
277 | void ChFiDS_ElSpine::FirstPointAndTgt(gp_Pnt& P, |
278 | gp_Vec& T) const |
279 | { |
280 | P = ptfirst; |
281 | T = tgfirst; |
282 | } |
283 | |
284 | //======================================================================= |
285 | //function : LastPointAndTgt |
286 | //purpose : |
287 | //======================================================================= |
288 | |
289 | void ChFiDS_ElSpine::LastPointAndTgt(gp_Pnt& P, |
290 | gp_Vec& T) const |
291 | { |
292 | P = ptlast; |
293 | T = tglast; |
294 | } |
295 | |
296 | //======================================================================= |
297 | //function : SetCurve |
298 | //purpose : |
299 | //======================================================================= |
300 | |
301 | void ChFiDS_ElSpine::SetCurve(const Handle(Geom_Curve)& C) |
302 | { |
303 | curve.Load(C); |
304 | } |
305 | |
306 | //======================================================================= |
307 | //function : Previous |
308 | //purpose : |
309 | //======================================================================= |
310 | |
311 | const Handle(ChFiDS_SurfData)& ChFiDS_ElSpine::Previous() const |
312 | { |
313 | return previous; |
314 | } |
315 | |
316 | |
317 | //======================================================================= |
318 | //function : ChangePrevious |
319 | //purpose : |
320 | //======================================================================= |
321 | |
322 | Handle(ChFiDS_SurfData)& ChFiDS_ElSpine::ChangePrevious() |
323 | { |
324 | return previous; |
325 | } |
326 | |
327 | //======================================================================= |
328 | //function : Next |
329 | //purpose : |
330 | //======================================================================= |
331 | |
332 | const Handle(ChFiDS_SurfData)& ChFiDS_ElSpine::Next() const |
333 | { |
334 | return next; |
335 | } |
336 | |
337 | |
338 | //======================================================================= |
339 | //function : ChangeNext |
340 | //purpose : |
341 | //======================================================================= |
342 | |
343 | Handle(ChFiDS_SurfData)& ChFiDS_ElSpine::ChangeNext() |
344 | { |
345 | return next; |
346 | } |
347 | |
348 | // -- |
349 | // -- The following methods must be called when GetType returned |
350 | // -- the corresponding type. |
351 | // -- |
352 | |
353 | //======================================================================= |
354 | //function : Line |
355 | //purpose : |
356 | //======================================================================= |
357 | |
358 | gp_Lin ChFiDS_ElSpine::Line() const |
359 | { |
360 | return curve.Line(); |
361 | } |
362 | |
363 | //======================================================================= |
364 | //function : Circle |
365 | //purpose : |
366 | //======================================================================= |
367 | |
368 | gp_Circ ChFiDS_ElSpine::Circle() const |
369 | { |
370 | return curve.Circle(); |
371 | } |
372 | |
373 | //======================================================================= |
374 | //function : Ellipse |
375 | //purpose : |
376 | //======================================================================= |
377 | |
378 | gp_Elips ChFiDS_ElSpine::Ellipse() const |
379 | { |
380 | return curve.Ellipse(); |
381 | } |
382 | |
383 | //======================================================================= |
384 | //function : Hyperbola |
385 | //purpose : |
386 | //======================================================================= |
387 | |
388 | gp_Hypr ChFiDS_ElSpine::Hyperbola() const |
389 | { |
390 | return curve.Hyperbola(); |
391 | } |
392 | |
393 | //======================================================================= |
394 | //function : Parabola |
395 | //purpose : |
396 | //======================================================================= |
397 | |
398 | gp_Parab ChFiDS_ElSpine::Parabola() const |
399 | { |
400 | return curve.Parabola(); |
401 | } |
402 | |
403 | //======================================================================= |
404 | //function : Bezier |
405 | //purpose : |
406 | //======================================================================= |
407 | |
408 | Handle(Geom_BezierCurve) ChFiDS_ElSpine::Bezier() const |
409 | { |
410 | return curve.Bezier(); |
411 | } |
412 | |
413 | //======================================================================= |
414 | //function : BSpline |
415 | //purpose : |
416 | //======================================================================= |
417 | |
418 | Handle(Geom_BSplineCurve) ChFiDS_ElSpine::BSpline() const |
419 | { |
420 | return curve.BSpline(); |
421 | } |