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_HCurve.hxx>
19 #include <ChFiDS_ElSpine.hxx>
20 #include <ChFiDS_SurfData.hxx>
22 #include <Geom_BezierCurve.hxx>
23 #include <Geom_BSplineCurve.hxx>
24 #include <Geom_Curve.hxx>
26 #include <gp_Circ.hxx>
27 #include <gp_Elips.hxx>
28 #include <gp_Hypr.hxx>
30 #include <gp_Parab.hxx>
33 #include <Precision.hxx>
34 #include <Standard_DomainError.hxx>
35 #include <Standard_NoSuchObject.hxx>
36 #include <Standard_OutOfRange.hxx>
38 //=======================================================================
39 //function : ChFiDS_ElSpine
41 //=======================================================================
42 ChFiDS_ElSpine::ChFiDS_ElSpine()
46 periodic (Standard_False),
47 pfirstsav (Precision::Infinite()),
48 plastsav (Precision::Infinite())
53 //=======================================================================
54 //function : FirstParameter
56 //=======================================================================
58 Standard_Real ChFiDS_ElSpine::FirstParameter() const
64 //=======================================================================
65 //function : LastParameter
67 //=======================================================================
69 Standard_Real ChFiDS_ElSpine::LastParameter() const
74 //=======================================================================
75 //function : GetSavedFirstParameter
77 //=======================================================================
79 Standard_Real ChFiDS_ElSpine::GetSavedFirstParameter() const
84 //=======================================================================
85 //function : GetSavedLastParameter
87 //=======================================================================
89 Standard_Real ChFiDS_ElSpine::GetSavedLastParameter() const
94 //=======================================================================
95 //function : Continuity
97 //=======================================================================
99 GeomAbs_Shape ChFiDS_ElSpine::Continuity() const
101 return curve.Continuity();
104 //=======================================================================
105 //function : NbIntervals
107 //=======================================================================
109 Standard_Integer ChFiDS_ElSpine::NbIntervals(const GeomAbs_Shape S) const
111 return curve.NbIntervals(S);
114 //=======================================================================
115 //function : Intervals
117 //=======================================================================
119 void ChFiDS_ElSpine::Intervals(TColStd_Array1OfReal& T,const GeomAbs_Shape S) const
121 curve.Intervals(T,S);
124 //=======================================================================
127 //=======================================================================
129 Handle(Adaptor3d_HCurve) ChFiDS_ElSpine::Trim(const Standard_Real First,
130 const Standard_Real Last,
131 const Standard_Real Tol) const
133 return curve.Trim(First,Last,Tol);
136 //=======================================================================
137 //function : Resolution
139 //=======================================================================
141 Standard_Real ChFiDS_ElSpine::Resolution(const Standard_Real R3d) const
143 return curve.Resolution(R3d);
147 //=======================================================================
148 //function : Resolution
150 //=======================================================================
152 GeomAbs_CurveType ChFiDS_ElSpine::GetType() const
154 return curve.GetType();
158 //=======================================================================
159 //function : IsPeriodic
161 //=======================================================================
163 Standard_Boolean ChFiDS_ElSpine::IsPeriodic() const
169 //=======================================================================
170 //function : SetPeriodic
172 //=======================================================================
174 void ChFiDS_ElSpine::SetPeriodic(const Standard_Boolean I)
177 period = plast - pfirst;
182 //=======================================================================
185 //=======================================================================
187 Standard_Real ChFiDS_ElSpine::Period() const
189 if(!periodic) throw Standard_Failure("ElSpine non periodique");
194 //=======================================================================
197 //=======================================================================
199 gp_Pnt ChFiDS_ElSpine::Value(const Standard_Real AbsC) const
201 return curve.Value(AbsC);
205 //=======================================================================
208 //=======================================================================
210 void ChFiDS_ElSpine::D0(const Standard_Real AbsC, gp_Pnt& P) const
216 //=======================================================================
219 //=======================================================================
221 void ChFiDS_ElSpine::D1(const Standard_Real AbsC, gp_Pnt& P, gp_Vec& V1)
228 //=======================================================================
231 //=======================================================================
233 void ChFiDS_ElSpine::D2(const Standard_Real AbsC,
234 gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const
236 curve.D2(AbsC,P,V1,V2);
239 //=======================================================================
242 //=======================================================================
244 void ChFiDS_ElSpine::D3(const Standard_Real AbsC,
245 gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const
247 curve.D3(AbsC,P,V1,V2,V3);
251 //=======================================================================
252 //function : FirstParameter
254 //=======================================================================
256 void ChFiDS_ElSpine::FirstParameter(const Standard_Real P)
262 //=======================================================================
263 //function : LastParameter
265 //=======================================================================
267 void ChFiDS_ElSpine::LastParameter(const Standard_Real P)
272 //=======================================================================
273 //function : SaveFirstParameter
275 //=======================================================================
277 void ChFiDS_ElSpine::SaveFirstParameter()
282 //=======================================================================
283 //function : SaveLastParameter
285 //=======================================================================
287 void ChFiDS_ElSpine::SaveLastParameter()
293 //=======================================================================
294 //function : SetOrigin
296 //=======================================================================
298 void ChFiDS_ElSpine::SetOrigin(const Standard_Real O)
300 if(!periodic) throw Standard_Failure("Elspine non periodique");
301 Handle(Geom_BSplineCurve) bs = Handle(Geom_BSplineCurve)::DownCast(curve.Curve());
303 bs->SetOrigin(O,Precision::PConfusion());
308 //=======================================================================
309 //function : SetFirstPointAndTgt
311 //=======================================================================
313 void ChFiDS_ElSpine::SetFirstPointAndTgt(const gp_Pnt& P,
320 //=======================================================================
321 //function : SetLastPointAndTgt
323 //=======================================================================
325 void ChFiDS_ElSpine::SetLastPointAndTgt(const gp_Pnt& P,
332 //=======================================================================
333 //function : AddVertexWithTangent
335 //=======================================================================
337 void ChFiDS_ElSpine::AddVertexWithTangent(const gp_Ax1& anAx1)
339 VerticesWithTangents.Append(anAx1);
342 //=======================================================================
343 //function : FirstPointAndTgt
345 //=======================================================================
347 void ChFiDS_ElSpine::FirstPointAndTgt(gp_Pnt& P,
354 //=======================================================================
355 //function : LastPointAndTgt
357 //=======================================================================
359 void ChFiDS_ElSpine::LastPointAndTgt(gp_Pnt& P,
366 //=======================================================================
367 //function : NbVertices
369 //=======================================================================
371 Standard_Integer ChFiDS_ElSpine::NbVertices() const
373 return VerticesWithTangents.Length();
376 //=======================================================================
377 //function : VertexWithTangent
379 //=======================================================================
381 const gp_Ax1& ChFiDS_ElSpine::VertexWithTangent(const Standard_Integer Index) const
383 return VerticesWithTangents(Index);
386 //=======================================================================
387 //function : SetCurve
389 //=======================================================================
391 void ChFiDS_ElSpine::SetCurve(const Handle(Geom_Curve)& C)
396 //=======================================================================
397 //function : Previous
399 //=======================================================================
401 const Handle(ChFiDS_SurfData)& ChFiDS_ElSpine::Previous() const
407 //=======================================================================
408 //function : ChangePrevious
410 //=======================================================================
412 Handle(ChFiDS_SurfData)& ChFiDS_ElSpine::ChangePrevious()
417 //=======================================================================
420 //=======================================================================
422 const Handle(ChFiDS_SurfData)& ChFiDS_ElSpine::Next() const
428 //=======================================================================
429 //function : ChangeNext
431 //=======================================================================
433 Handle(ChFiDS_SurfData)& ChFiDS_ElSpine::ChangeNext()
439 // -- The following methods must be called when GetType returned
440 // -- the corresponding type.
443 //=======================================================================
446 //=======================================================================
448 gp_Lin ChFiDS_ElSpine::Line() const
453 //=======================================================================
456 //=======================================================================
458 gp_Circ ChFiDS_ElSpine::Circle() const
460 return curve.Circle();
463 //=======================================================================
466 //=======================================================================
468 gp_Elips ChFiDS_ElSpine::Ellipse() const
470 return curve.Ellipse();
473 //=======================================================================
474 //function : Hyperbola
476 //=======================================================================
478 gp_Hypr ChFiDS_ElSpine::Hyperbola() const
480 return curve.Hyperbola();
483 //=======================================================================
484 //function : Parabola
486 //=======================================================================
488 gp_Parab ChFiDS_ElSpine::Parabola() const
490 return curve.Parabola();
493 //=======================================================================
496 //=======================================================================
498 Handle(Geom_BezierCurve) ChFiDS_ElSpine::Bezier() const
500 return curve.Bezier();
503 //=======================================================================
506 //=======================================================================
508 Handle(Geom_BSplineCurve) ChFiDS_ElSpine::BSpline() const
510 return curve.BSpline();