0032781: Coding - get rid of unused headers [BRepCheck to ChFiKPart]
[occt.git] / src / ChFiDS / ChFiDS_ElSpine.cxx
1 // Created on: 1995-05-04
2 // Created by: Laurent BOURESCHE
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <Adaptor3d_Curve.hxx>
19 #include <ChFiDS_ElSpine.hxx>
20 #include <ChFiDS_SurfData.hxx>
21 #include <Geom_BezierCurve.hxx>
22 #include <Geom_BSplineCurve.hxx>
23 #include <Geom_Curve.hxx>
24 #include <gp_Ax1.hxx>
25 #include <gp_Circ.hxx>
26 #include <gp_Elips.hxx>
27 #include <gp_Hypr.hxx>
28 #include <gp_Lin.hxx>
29 #include <gp_Parab.hxx>
30 #include <gp_Pnt.hxx>
31 #include <gp_Vec.hxx>
32 #include <Precision.hxx>
33
34 IMPLEMENT_STANDARD_RTTIEXT(ChFiDS_ElSpine, Adaptor3d_Curve)
35
36 //=======================================================================
37 //function : ChFiDS_ElSpine
38 //purpose  : 
39 //=======================================================================
40 ChFiDS_ElSpine::ChFiDS_ElSpine()
41 : pfirst (0.0),
42   plast (0.0),
43   period (0.0),
44   periodic (Standard_False),
45   pfirstsav (Precision::Infinite()),
46   plastsav (Precision::Infinite())
47 {
48 }
49
50 //=======================================================================
51 //function : ShallowCopy
52 //purpose  : 
53 //=======================================================================
54 Handle(Adaptor3d_Curve) ChFiDS_ElSpine::ShallowCopy() const
55 {
56   Handle(ChFiDS_ElSpine) aCopy = new ChFiDS_ElSpine();
57
58   const Handle(Adaptor3d_Curve) aCurve = curve.ShallowCopy();
59   const GeomAdaptor_Curve& aGeomCurve = *(Handle(GeomAdaptor_Curve)::DownCast(aCurve));
60   aCopy->curve = aGeomCurve;
61
62   aCopy->ptfirst              = ptfirst;
63   aCopy->ptlast               = ptlast;
64   aCopy->tgfirst              = tgfirst;
65   aCopy->tglast               = tglast;
66   aCopy->VerticesWithTangents = VerticesWithTangents;
67   aCopy->previous             = previous;
68   aCopy->next                 = next;
69   aCopy->pfirst               = pfirst;
70   aCopy->plast                = plast;
71   aCopy->period               = period;
72   aCopy->periodic             = periodic;
73   aCopy->pfirstsav            = pfirstsav;
74   aCopy->plastsav             = plastsav;
75
76   return aCopy;
77 }
78
79 //=======================================================================
80 //function : FirstParameter
81 //purpose  : 
82 //=======================================================================
83
84 Standard_Real ChFiDS_ElSpine::FirstParameter() const
85 {
86   return pfirst;
87 }
88
89
90 //=======================================================================
91 //function : LastParameter
92 //purpose  : 
93 //=======================================================================
94
95 Standard_Real ChFiDS_ElSpine::LastParameter() const
96 {
97   return plast;
98 }
99
100 //=======================================================================
101 //function : GetSavedFirstParameter
102 //purpose  : 
103 //=======================================================================
104
105 Standard_Real ChFiDS_ElSpine::GetSavedFirstParameter() const
106 {
107   return pfirstsav;
108 }
109
110 //=======================================================================
111 //function : GetSavedLastParameter
112 //purpose  : 
113 //=======================================================================
114
115 Standard_Real ChFiDS_ElSpine::GetSavedLastParameter() const
116 {
117   return plastsav;
118 }
119
120 //=======================================================================
121 //function : Continuity
122 //purpose  : 
123 //=======================================================================
124
125 GeomAbs_Shape ChFiDS_ElSpine::Continuity() const
126 {
127   return curve.Continuity();
128 }
129
130 //=======================================================================
131 //function : NbIntervals
132 //purpose  : 
133 //=======================================================================
134
135 Standard_Integer ChFiDS_ElSpine::NbIntervals(const GeomAbs_Shape S) const
136 {
137   return curve.NbIntervals(S);
138 }
139
140 //=======================================================================
141 //function : Intervals
142 //purpose  : 
143 //=======================================================================
144
145 void ChFiDS_ElSpine::Intervals(TColStd_Array1OfReal& T,const GeomAbs_Shape S) const
146 {
147   curve.Intervals(T,S);
148 }
149
150 //=======================================================================
151 //function : Trim
152 //purpose  : 
153 //=======================================================================
154
155 Handle(Adaptor3d_Curve) ChFiDS_ElSpine::Trim(const Standard_Real First,
156                                             const Standard_Real Last,
157                                             const Standard_Real Tol) const
158 {
159   return curve.Trim(First,Last,Tol);
160 }
161
162 //=======================================================================
163 //function : Resolution
164 //purpose  : 
165 //=======================================================================
166
167 Standard_Real ChFiDS_ElSpine::Resolution(const Standard_Real R3d) const
168 {
169   return curve.Resolution(R3d);
170 }
171
172
173 //=======================================================================
174 //function : Resolution
175 //purpose  : 
176 //=======================================================================
177
178 GeomAbs_CurveType ChFiDS_ElSpine::GetType() const
179 {
180   return curve.GetType();
181 }
182
183
184 //=======================================================================
185 //function : IsPeriodic
186 //purpose  : 
187 //=======================================================================
188
189 Standard_Boolean ChFiDS_ElSpine::IsPeriodic() const
190 {
191   return periodic;
192 }
193
194
195 //=======================================================================
196 //function : SetPeriodic
197 //purpose  : 
198 //=======================================================================
199
200 void ChFiDS_ElSpine::SetPeriodic(const Standard_Boolean I) 
201 {
202   periodic = I;
203   period = plast - pfirst;
204 }
205
206
207
208 //=======================================================================
209 //function : Period
210 //purpose  : 
211 //=======================================================================
212
213 Standard_Real ChFiDS_ElSpine::Period() const
214 {
215   if(!periodic) throw Standard_Failure("ElSpine non periodique");
216   return period;
217 }
218
219
220 //=======================================================================
221 //function : Value
222 //purpose  : 
223 //=======================================================================
224
225 gp_Pnt ChFiDS_ElSpine::Value(const Standard_Real AbsC) const
226 {
227   return curve.Value(AbsC);
228 }
229
230
231 //=======================================================================
232 //function : D0
233 //purpose  : 
234 //=======================================================================
235
236 void ChFiDS_ElSpine::D0(const Standard_Real AbsC, gp_Pnt& P) const
237 {
238   curve.D0(AbsC,P);
239 }
240
241
242 //=======================================================================
243 //function : D1
244 //purpose  : 
245 //=======================================================================
246
247 void ChFiDS_ElSpine::D1(const Standard_Real AbsC, gp_Pnt& P, gp_Vec& V1)
248 const
249 {
250   curve.D1(AbsC,P,V1);
251 }
252
253
254 //=======================================================================
255 //function : D2
256 //purpose  : 
257 //=======================================================================
258
259 void ChFiDS_ElSpine::D2(const Standard_Real AbsC, 
260                         gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const
261 {  
262   curve.D2(AbsC,P,V1,V2);
263 }
264
265 //=======================================================================
266 //function : D3
267 //purpose  : 
268 //=======================================================================
269
270 void ChFiDS_ElSpine::D3(const Standard_Real AbsC, 
271                         gp_Pnt& P, gp_Vec& V1, gp_Vec& V2,  gp_Vec& V3) const
272 {  
273   curve.D3(AbsC,P,V1,V2,V3);
274 }
275
276
277 //=======================================================================
278 //function : FirstParameter
279 //purpose  : 
280 //=======================================================================
281
282 void ChFiDS_ElSpine::FirstParameter(const Standard_Real P)
283 {
284   pfirst = P;
285 }
286
287
288 //=======================================================================
289 //function : LastParameter
290 //purpose  : 
291 //=======================================================================
292
293 void ChFiDS_ElSpine::LastParameter(const Standard_Real P)
294 {
295   plast = P;
296 }
297
298 //=======================================================================
299 //function : SaveFirstParameter
300 //purpose  : 
301 //=======================================================================
302
303 void ChFiDS_ElSpine::SaveFirstParameter()
304 {
305   pfirstsav = pfirst;
306 }
307
308 //=======================================================================
309 //function : SaveLastParameter
310 //purpose  : 
311 //=======================================================================
312
313 void ChFiDS_ElSpine::SaveLastParameter()
314 {
315   plastsav = plast;
316 }
317
318
319 //=======================================================================
320 //function : SetOrigin
321 //purpose  : 
322 //=======================================================================
323
324 void ChFiDS_ElSpine::SetOrigin(const Standard_Real O)
325 {
326   if(!periodic) throw Standard_Failure("Elspine non periodique");
327   Handle(Geom_BSplineCurve) bs = Handle(Geom_BSplineCurve)::DownCast(curve.Curve());
328   if(!bs.IsNull()) {
329     bs->SetOrigin(O,Precision::PConfusion());
330     curve.Load(bs);
331   }
332 }
333
334 //=======================================================================
335 //function : SetFirstPointAndTgt
336 //purpose  : 
337 //=======================================================================
338
339 void ChFiDS_ElSpine::SetFirstPointAndTgt(const gp_Pnt& P,
340                                          const gp_Vec& T)
341 {
342   ptfirst = P;
343   tgfirst = T;
344 }
345
346 //=======================================================================
347 //function : SetLastPointAndTgt
348 //purpose  : 
349 //=======================================================================
350
351 void ChFiDS_ElSpine::SetLastPointAndTgt(const gp_Pnt& P,
352                                         const gp_Vec& T)
353 {
354   ptlast = P;
355   tglast = T;
356 }
357
358 //=======================================================================
359 //function : AddVertexWithTangent
360 //purpose  : 
361 //=======================================================================
362
363 void ChFiDS_ElSpine::AddVertexWithTangent(const gp_Ax1& anAx1)
364 {
365   VerticesWithTangents.Append(anAx1);
366 }
367
368 //=======================================================================
369 //function : FirstPointAndTgt
370 //purpose  : 
371 //=======================================================================
372
373 void ChFiDS_ElSpine::FirstPointAndTgt(gp_Pnt& P,
374                                       gp_Vec& T) const
375 {
376   P = ptfirst;
377   T = tgfirst;
378 }
379
380 //=======================================================================
381 //function : LastPointAndTgt
382 //purpose  : 
383 //=======================================================================
384
385 void ChFiDS_ElSpine::LastPointAndTgt(gp_Pnt& P,
386                                      gp_Vec& T) const
387 {
388   P = ptlast;
389   T = tglast;
390 }
391
392 //=======================================================================
393 //function : NbVertices
394 //purpose  : 
395 //=======================================================================
396
397 Standard_Integer ChFiDS_ElSpine::NbVertices() const
398 {
399   return VerticesWithTangents.Length();
400 }
401
402 //=======================================================================
403 //function : VertexWithTangent
404 //purpose  : 
405 //=======================================================================
406
407 const gp_Ax1& ChFiDS_ElSpine::VertexWithTangent(const Standard_Integer Index) const
408 {
409   return VerticesWithTangents(Index);
410 }
411
412 //=======================================================================
413 //function : SetCurve
414 //purpose  : 
415 //=======================================================================
416
417 void ChFiDS_ElSpine::SetCurve(const Handle(Geom_Curve)& C)
418 {
419   curve.Load(C);
420 }
421
422 //=======================================================================
423 //function : Previous
424 //purpose  : 
425 //=======================================================================
426
427 const Handle(ChFiDS_SurfData)& ChFiDS_ElSpine::Previous() const 
428 {
429   return previous;
430 }
431
432
433 //=======================================================================
434 //function : ChangePrevious
435 //purpose  : 
436 //=======================================================================
437
438 Handle(ChFiDS_SurfData)& ChFiDS_ElSpine::ChangePrevious()
439 {
440   return previous;
441 }
442
443 //=======================================================================
444 //function : Next
445 //purpose  : 
446 //=======================================================================
447
448 const Handle(ChFiDS_SurfData)& ChFiDS_ElSpine::Next() const 
449 {
450   return next;
451 }
452
453
454 //=======================================================================
455 //function : ChangeNext
456 //purpose  : 
457 //=======================================================================
458
459 Handle(ChFiDS_SurfData)& ChFiDS_ElSpine::ChangeNext()
460 {
461   return next;
462 }
463
464 //    --
465 //    --     The following methods must  be called when GetType returned
466 //    --     the corresponding type.
467 //    --     
468
469 //=======================================================================
470 //function : Line
471 //purpose  : 
472 //=======================================================================
473
474 gp_Lin ChFiDS_ElSpine::Line() const 
475 {
476  return curve.Line();
477 }
478
479 //=======================================================================
480 //function : Circle
481 //purpose  : 
482 //=======================================================================
483
484 gp_Circ  ChFiDS_ElSpine::Circle() const 
485 {
486  return curve.Circle();
487 }
488
489 //=======================================================================
490 //function : Ellipse
491 //purpose  : 
492 //=======================================================================
493
494 gp_Elips ChFiDS_ElSpine::Ellipse() const 
495 {
496   return curve.Ellipse();
497 }
498
499 //=======================================================================
500 //function : Hyperbola
501 //purpose  : 
502 //=======================================================================
503
504 gp_Hypr ChFiDS_ElSpine::Hyperbola() const 
505 {
506   return curve.Hyperbola();
507 }
508
509 //=======================================================================
510 //function : Parabola
511 //purpose  : 
512 //=======================================================================
513
514 gp_Parab ChFiDS_ElSpine::Parabola() const 
515 {
516  return curve.Parabola();
517 }
518
519 //=======================================================================
520 //function : Bezier
521 //purpose  : 
522 //=======================================================================
523
524 Handle(Geom_BezierCurve) ChFiDS_ElSpine::Bezier() const 
525 {
526   return curve.Bezier();
527 }
528
529 //=======================================================================
530 //function : BSpline
531 //purpose  : 
532 //=======================================================================
533
534 Handle(Geom_BSplineCurve) ChFiDS_ElSpine::BSpline() const 
535 {
536   return curve.BSpline();
537 }