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():periodic(0)
44 pfirstsav = Precision::Infinite();
45 plastsav = Precision::Infinite();
49 //=======================================================================
50 //function : FirstParameter
52 //=======================================================================
54 Standard_Real ChFiDS_ElSpine::FirstParameter() const
60 //=======================================================================
61 //function : LastParameter
63 //=======================================================================
65 Standard_Real ChFiDS_ElSpine::LastParameter() const
70 //=======================================================================
71 //function : GetSavedFirstParameter
73 //=======================================================================
75 Standard_Real ChFiDS_ElSpine::GetSavedFirstParameter() const
80 //=======================================================================
81 //function : GetSavedLastParameter
83 //=======================================================================
85 Standard_Real ChFiDS_ElSpine::GetSavedLastParameter() const
90 //=======================================================================
91 //function : Continuity
93 //=======================================================================
95 GeomAbs_Shape ChFiDS_ElSpine::Continuity() const
97 return curve.Continuity();
100 //=======================================================================
101 //function : NbIntervals
103 //=======================================================================
105 Standard_Integer ChFiDS_ElSpine::NbIntervals(const GeomAbs_Shape S) const
107 return curve.NbIntervals(S);
110 //=======================================================================
111 //function : Intervals
113 //=======================================================================
115 void ChFiDS_ElSpine::Intervals(TColStd_Array1OfReal& T,const GeomAbs_Shape S) const
117 curve.Intervals(T,S);
120 //=======================================================================
123 //=======================================================================
125 Handle(Adaptor3d_HCurve) ChFiDS_ElSpine::Trim(const Standard_Real First,
126 const Standard_Real Last,
127 const Standard_Real Tol) const
129 return curve.Trim(First,Last,Tol);
132 //=======================================================================
133 //function : Resolution
135 //=======================================================================
137 Standard_Real ChFiDS_ElSpine::Resolution(const Standard_Real R3d) const
139 return curve.Resolution(R3d);
143 //=======================================================================
144 //function : Resolution
146 //=======================================================================
148 GeomAbs_CurveType ChFiDS_ElSpine::GetType() const
150 return curve.GetType();
154 //=======================================================================
155 //function : IsPeriodic
157 //=======================================================================
159 Standard_Boolean ChFiDS_ElSpine::IsPeriodic() const
165 //=======================================================================
166 //function : SetPeriodic
168 //=======================================================================
170 void ChFiDS_ElSpine::SetPeriodic(const Standard_Boolean I)
173 period = plast - pfirst;
178 //=======================================================================
181 //=======================================================================
183 Standard_Real ChFiDS_ElSpine::Period() const
185 if(!periodic) throw Standard_Failure("ElSpine non periodique");
190 //=======================================================================
193 //=======================================================================
195 gp_Pnt ChFiDS_ElSpine::Value(const Standard_Real AbsC) const
197 return curve.Value(AbsC);
201 //=======================================================================
204 //=======================================================================
206 void ChFiDS_ElSpine::D0(const Standard_Real AbsC, gp_Pnt& P) const
212 //=======================================================================
215 //=======================================================================
217 void ChFiDS_ElSpine::D1(const Standard_Real AbsC, gp_Pnt& P, gp_Vec& V1)
224 //=======================================================================
227 //=======================================================================
229 void ChFiDS_ElSpine::D2(const Standard_Real AbsC,
230 gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const
232 curve.D2(AbsC,P,V1,V2);
235 //=======================================================================
238 //=======================================================================
240 void ChFiDS_ElSpine::D3(const Standard_Real AbsC,
241 gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const
243 curve.D3(AbsC,P,V1,V2,V3);
247 //=======================================================================
248 //function : FirstParameter
250 //=======================================================================
252 void ChFiDS_ElSpine::FirstParameter(const Standard_Real P)
258 //=======================================================================
259 //function : LastParameter
261 //=======================================================================
263 void ChFiDS_ElSpine::LastParameter(const Standard_Real P)
268 //=======================================================================
269 //function : SaveFirstParameter
271 //=======================================================================
273 void ChFiDS_ElSpine::SaveFirstParameter()
278 //=======================================================================
279 //function : SaveLastParameter
281 //=======================================================================
283 void ChFiDS_ElSpine::SaveLastParameter()
289 //=======================================================================
290 //function : SetOrigin
292 //=======================================================================
294 void ChFiDS_ElSpine::SetOrigin(const Standard_Real O)
296 if(!periodic) throw Standard_Failure("Elspine non periodique");
297 Handle(Geom_BSplineCurve) bs = Handle(Geom_BSplineCurve)::DownCast(curve.Curve());
299 bs->SetOrigin(O,Precision::PConfusion());
304 //=======================================================================
305 //function : SetFirstPointAndTgt
307 //=======================================================================
309 void ChFiDS_ElSpine::SetFirstPointAndTgt(const gp_Pnt& P,
316 //=======================================================================
317 //function : SetLastPointAndTgt
319 //=======================================================================
321 void ChFiDS_ElSpine::SetLastPointAndTgt(const gp_Pnt& P,
328 //=======================================================================
329 //function : AddVertexWithTangent
331 //=======================================================================
333 void ChFiDS_ElSpine::AddVertexWithTangent(const gp_Ax1& anAx1)
335 VerticesWithTangents.Append(anAx1);
338 //=======================================================================
339 //function : FirstPointAndTgt
341 //=======================================================================
343 void ChFiDS_ElSpine::FirstPointAndTgt(gp_Pnt& P,
350 //=======================================================================
351 //function : LastPointAndTgt
353 //=======================================================================
355 void ChFiDS_ElSpine::LastPointAndTgt(gp_Pnt& P,
362 //=======================================================================
363 //function : NbVertices
365 //=======================================================================
367 Standard_Integer ChFiDS_ElSpine::NbVertices() const
369 return VerticesWithTangents.Length();
372 //=======================================================================
373 //function : VertexWithTangent
375 //=======================================================================
377 const gp_Ax1& ChFiDS_ElSpine::VertexWithTangent(const Standard_Integer Index) const
379 return VerticesWithTangents(Index);
382 //=======================================================================
383 //function : SetCurve
385 //=======================================================================
387 void ChFiDS_ElSpine::SetCurve(const Handle(Geom_Curve)& C)
392 //=======================================================================
393 //function : Previous
395 //=======================================================================
397 const Handle(ChFiDS_SurfData)& ChFiDS_ElSpine::Previous() const
403 //=======================================================================
404 //function : ChangePrevious
406 //=======================================================================
408 Handle(ChFiDS_SurfData)& ChFiDS_ElSpine::ChangePrevious()
413 //=======================================================================
416 //=======================================================================
418 const Handle(ChFiDS_SurfData)& ChFiDS_ElSpine::Next() const
424 //=======================================================================
425 //function : ChangeNext
427 //=======================================================================
429 Handle(ChFiDS_SurfData)& ChFiDS_ElSpine::ChangeNext()
435 // -- The following methods must be called when GetType returned
436 // -- the corresponding type.
439 //=======================================================================
442 //=======================================================================
444 gp_Lin ChFiDS_ElSpine::Line() const
449 //=======================================================================
452 //=======================================================================
454 gp_Circ ChFiDS_ElSpine::Circle() const
456 return curve.Circle();
459 //=======================================================================
462 //=======================================================================
464 gp_Elips ChFiDS_ElSpine::Ellipse() const
466 return curve.Ellipse();
469 //=======================================================================
470 //function : Hyperbola
472 //=======================================================================
474 gp_Hypr ChFiDS_ElSpine::Hyperbola() const
476 return curve.Hyperbola();
479 //=======================================================================
480 //function : Parabola
482 //=======================================================================
484 gp_Parab ChFiDS_ElSpine::Parabola() const
486 return curve.Parabola();
489 //=======================================================================
492 //=======================================================================
494 Handle(Geom_BezierCurve) ChFiDS_ElSpine::Bezier() const
496 return curve.Bezier();
499 //=======================================================================
502 //=======================================================================
504 Handle(Geom_BSplineCurve) ChFiDS_ElSpine::BSpline() const
506 return curve.BSpline();