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