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