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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
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>
25 #include <gp_Circ.hxx>
26 #include <gp_Elips.hxx>
27 #include <gp_Hypr.hxx>
29 #include <gp_Parab.hxx>
32 #include <Precision.hxx>
34 IMPLEMENT_STANDARD_RTTIEXT(ChFiDS_ElSpine, Adaptor3d_Curve)
36 //=======================================================================
37 //function : ChFiDS_ElSpine
39 //=======================================================================
40 ChFiDS_ElSpine::ChFiDS_ElSpine()
44 periodic (Standard_False),
45 pfirstsav (Precision::Infinite()),
46 plastsav (Precision::Infinite())
50 //=======================================================================
51 //function : ShallowCopy
53 //=======================================================================
54 Handle(Adaptor3d_Curve) ChFiDS_ElSpine::ShallowCopy() const
56 Handle(ChFiDS_ElSpine) aCopy = new ChFiDS_ElSpine();
58 const Handle(Adaptor3d_Curve) aCurve = curve.ShallowCopy();
59 const GeomAdaptor_Curve& aGeomCurve = *(Handle(GeomAdaptor_Curve)::DownCast(aCurve));
60 aCopy->curve = aGeomCurve;
62 aCopy->ptfirst = ptfirst;
63 aCopy->ptlast = ptlast;
64 aCopy->tgfirst = tgfirst;
65 aCopy->tglast = tglast;
66 aCopy->VerticesWithTangents = VerticesWithTangents;
67 aCopy->previous = previous;
69 aCopy->pfirst = pfirst;
71 aCopy->period = period;
72 aCopy->periodic = periodic;
73 aCopy->pfirstsav = pfirstsav;
74 aCopy->plastsav = plastsav;
79 //=======================================================================
80 //function : FirstParameter
82 //=======================================================================
84 Standard_Real ChFiDS_ElSpine::FirstParameter() const
90 //=======================================================================
91 //function : LastParameter
93 //=======================================================================
95 Standard_Real ChFiDS_ElSpine::LastParameter() const
100 //=======================================================================
101 //function : GetSavedFirstParameter
103 //=======================================================================
105 Standard_Real ChFiDS_ElSpine::GetSavedFirstParameter() const
110 //=======================================================================
111 //function : GetSavedLastParameter
113 //=======================================================================
115 Standard_Real ChFiDS_ElSpine::GetSavedLastParameter() const
120 //=======================================================================
121 //function : Continuity
123 //=======================================================================
125 GeomAbs_Shape ChFiDS_ElSpine::Continuity() const
127 return curve.Continuity();
130 //=======================================================================
131 //function : NbIntervals
133 //=======================================================================
135 Standard_Integer ChFiDS_ElSpine::NbIntervals(const GeomAbs_Shape S) const
137 return curve.NbIntervals(S);
140 //=======================================================================
141 //function : Intervals
143 //=======================================================================
145 void ChFiDS_ElSpine::Intervals(TColStd_Array1OfReal& T,const GeomAbs_Shape S) const
147 curve.Intervals(T,S);
150 //=======================================================================
153 //=======================================================================
155 Handle(Adaptor3d_Curve) ChFiDS_ElSpine::Trim(const Standard_Real First,
156 const Standard_Real Last,
157 const Standard_Real Tol) const
159 return curve.Trim(First,Last,Tol);
162 //=======================================================================
163 //function : Resolution
165 //=======================================================================
167 Standard_Real ChFiDS_ElSpine::Resolution(const Standard_Real R3d) const
169 return curve.Resolution(R3d);
173 //=======================================================================
174 //function : Resolution
176 //=======================================================================
178 GeomAbs_CurveType ChFiDS_ElSpine::GetType() const
180 return curve.GetType();
184 //=======================================================================
185 //function : IsPeriodic
187 //=======================================================================
189 Standard_Boolean ChFiDS_ElSpine::IsPeriodic() const
195 //=======================================================================
196 //function : SetPeriodic
198 //=======================================================================
200 void ChFiDS_ElSpine::SetPeriodic(const Standard_Boolean I)
203 period = plast - pfirst;
208 //=======================================================================
211 //=======================================================================
213 Standard_Real ChFiDS_ElSpine::Period() const
215 if(!periodic) throw Standard_Failure("ElSpine non periodique");
220 //=======================================================================
223 //=======================================================================
225 gp_Pnt ChFiDS_ElSpine::Value(const Standard_Real AbsC) const
227 return curve.Value(AbsC);
231 //=======================================================================
234 //=======================================================================
236 void ChFiDS_ElSpine::D0(const Standard_Real AbsC, gp_Pnt& P) const
242 //=======================================================================
245 //=======================================================================
247 void ChFiDS_ElSpine::D1(const Standard_Real AbsC, gp_Pnt& P, gp_Vec& V1)
254 //=======================================================================
257 //=======================================================================
259 void ChFiDS_ElSpine::D2(const Standard_Real AbsC,
260 gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const
262 curve.D2(AbsC,P,V1,V2);
265 //=======================================================================
268 //=======================================================================
270 void ChFiDS_ElSpine::D3(const Standard_Real AbsC,
271 gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const
273 curve.D3(AbsC,P,V1,V2,V3);
277 //=======================================================================
278 //function : FirstParameter
280 //=======================================================================
282 void ChFiDS_ElSpine::FirstParameter(const Standard_Real P)
288 //=======================================================================
289 //function : LastParameter
291 //=======================================================================
293 void ChFiDS_ElSpine::LastParameter(const Standard_Real P)
298 //=======================================================================
299 //function : SaveFirstParameter
301 //=======================================================================
303 void ChFiDS_ElSpine::SaveFirstParameter()
308 //=======================================================================
309 //function : SaveLastParameter
311 //=======================================================================
313 void ChFiDS_ElSpine::SaveLastParameter()
319 //=======================================================================
320 //function : SetOrigin
322 //=======================================================================
324 void ChFiDS_ElSpine::SetOrigin(const Standard_Real O)
326 if(!periodic) throw Standard_Failure("Elspine non periodique");
327 Handle(Geom_BSplineCurve) bs = Handle(Geom_BSplineCurve)::DownCast(curve.Curve());
329 bs->SetOrigin(O,Precision::PConfusion());
334 //=======================================================================
335 //function : SetFirstPointAndTgt
337 //=======================================================================
339 void ChFiDS_ElSpine::SetFirstPointAndTgt(const gp_Pnt& P,
346 //=======================================================================
347 //function : SetLastPointAndTgt
349 //=======================================================================
351 void ChFiDS_ElSpine::SetLastPointAndTgt(const gp_Pnt& P,
358 //=======================================================================
359 //function : AddVertexWithTangent
361 //=======================================================================
363 void ChFiDS_ElSpine::AddVertexWithTangent(const gp_Ax1& anAx1)
365 VerticesWithTangents.Append(anAx1);
368 //=======================================================================
369 //function : FirstPointAndTgt
371 //=======================================================================
373 void ChFiDS_ElSpine::FirstPointAndTgt(gp_Pnt& P,
380 //=======================================================================
381 //function : LastPointAndTgt
383 //=======================================================================
385 void ChFiDS_ElSpine::LastPointAndTgt(gp_Pnt& P,
392 //=======================================================================
393 //function : NbVertices
395 //=======================================================================
397 Standard_Integer ChFiDS_ElSpine::NbVertices() const
399 return VerticesWithTangents.Length();
402 //=======================================================================
403 //function : VertexWithTangent
405 //=======================================================================
407 const gp_Ax1& ChFiDS_ElSpine::VertexWithTangent(const Standard_Integer Index) const
409 return VerticesWithTangents(Index);
412 //=======================================================================
413 //function : SetCurve
415 //=======================================================================
417 void ChFiDS_ElSpine::SetCurve(const Handle(Geom_Curve)& C)
422 //=======================================================================
423 //function : Previous
425 //=======================================================================
427 const Handle(ChFiDS_SurfData)& ChFiDS_ElSpine::Previous() const
433 //=======================================================================
434 //function : ChangePrevious
436 //=======================================================================
438 Handle(ChFiDS_SurfData)& ChFiDS_ElSpine::ChangePrevious()
443 //=======================================================================
446 //=======================================================================
448 const Handle(ChFiDS_SurfData)& ChFiDS_ElSpine::Next() const
454 //=======================================================================
455 //function : ChangeNext
457 //=======================================================================
459 Handle(ChFiDS_SurfData)& ChFiDS_ElSpine::ChangeNext()
465 // -- The following methods must be called when GetType returned
466 // -- the corresponding type.
469 //=======================================================================
472 //=======================================================================
474 gp_Lin ChFiDS_ElSpine::Line() const
479 //=======================================================================
482 //=======================================================================
484 gp_Circ ChFiDS_ElSpine::Circle() const
486 return curve.Circle();
489 //=======================================================================
492 //=======================================================================
494 gp_Elips ChFiDS_ElSpine::Ellipse() const
496 return curve.Ellipse();
499 //=======================================================================
500 //function : Hyperbola
502 //=======================================================================
504 gp_Hypr ChFiDS_ElSpine::Hyperbola() const
506 return curve.Hyperbola();
509 //=======================================================================
510 //function : Parabola
512 //=======================================================================
514 gp_Parab ChFiDS_ElSpine::Parabola() const
516 return curve.Parabola();
519 //=======================================================================
522 //=======================================================================
524 Handle(Geom_BezierCurve) ChFiDS_ElSpine::Bezier() const
526 return curve.Bezier();
529 //=======================================================================
532 //=======================================================================
534 Handle(Geom_BSplineCurve) ChFiDS_ElSpine::BSpline() const
536 return curve.BSpline();