0024157: Parallelization of assembly part of BO
[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-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21
22
23 #include <ChFiDS_ElSpine.ixx>
24 #include <Geom_BSplineCurve.hxx>
25 #include <ElCLib.hxx>
26 #include <Precision.hxx>
27
28
29 //=======================================================================
30 //function : ChFiDS_ElSpine
31 //purpose  : 
32 //=======================================================================
33
34 ChFiDS_ElSpine::ChFiDS_ElSpine():periodic(0)
35 {
36 }
37
38
39 //=======================================================================
40 //function : FirstParameter
41 //purpose  : 
42 //=======================================================================
43
44 Standard_Real ChFiDS_ElSpine::FirstParameter() const
45 {
46   return pfirst;
47 }
48
49
50 //=======================================================================
51 //function : LastParameter
52 //purpose  : 
53 //=======================================================================
54
55 Standard_Real ChFiDS_ElSpine::LastParameter() const
56 {
57   return plast;
58 }
59
60 //=======================================================================
61 //function : Continuity
62 //purpose  : 
63 //=======================================================================
64
65 GeomAbs_Shape ChFiDS_ElSpine::Continuity() const
66 {
67   return curve.Continuity();
68 }
69
70 //=======================================================================
71 //function : NbIntervals
72 //purpose  : 
73 //=======================================================================
74
75 Standard_Integer ChFiDS_ElSpine::NbIntervals(const GeomAbs_Shape S) 
76 {
77   return curve.NbIntervals(S);
78 }
79
80 //=======================================================================
81 //function : Intervals
82 //purpose  : 
83 //=======================================================================
84
85 void ChFiDS_ElSpine::Intervals(TColStd_Array1OfReal& T,const GeomAbs_Shape S) 
86 {
87   curve.Intervals(T,S);
88 }
89
90 //=======================================================================
91 //function : Trim
92 //purpose  : 
93 //=======================================================================
94
95 Handle(Adaptor3d_HCurve) ChFiDS_ElSpine::Trim(const Standard_Real First,
96                                             const Standard_Real Last,
97                                             const Standard_Real Tol) const
98 {
99   return curve.Trim(First,Last,Tol);
100 }
101
102 //=======================================================================
103 //function : Resolution
104 //purpose  : 
105 //=======================================================================
106
107 Standard_Real ChFiDS_ElSpine::Resolution(const Standard_Real R3d) const
108 {
109   return curve.Resolution(R3d);
110 }
111
112
113 //=======================================================================
114 //function : Resolution
115 //purpose  : 
116 //=======================================================================
117
118 GeomAbs_CurveType ChFiDS_ElSpine::GetType() const
119 {
120   return curve.GetType();
121 }
122
123
124 //=======================================================================
125 //function : IsPeriodic
126 //purpose  : 
127 //=======================================================================
128
129 Standard_Boolean ChFiDS_ElSpine::IsPeriodic() const
130 {
131   return periodic;
132 }
133
134
135 //=======================================================================
136 //function : SetPeriodic
137 //purpose  : 
138 //=======================================================================
139
140 void ChFiDS_ElSpine::SetPeriodic(const Standard_Boolean I) 
141 {
142   periodic = I;
143   period = plast - pfirst;
144 }
145
146
147
148 //=======================================================================
149 //function : Period
150 //purpose  : 
151 //=======================================================================
152
153 Standard_Real ChFiDS_ElSpine::Period() const
154 {
155   if(!periodic) Standard_Failure::Raise("ElSpine non periodique");
156   return period;
157 }
158
159
160 //=======================================================================
161 //function : Value
162 //purpose  : 
163 //=======================================================================
164
165 gp_Pnt ChFiDS_ElSpine::Value(const Standard_Real AbsC) const
166 {
167   return curve.Value(AbsC);
168 }
169
170
171 //=======================================================================
172 //function : D0
173 //purpose  : 
174 //=======================================================================
175
176 void ChFiDS_ElSpine::D0(const Standard_Real AbsC, gp_Pnt& P) const
177 {
178   curve.D0(AbsC,P);
179 }
180
181
182 //=======================================================================
183 //function : D1
184 //purpose  : 
185 //=======================================================================
186
187 void ChFiDS_ElSpine::D1(const Standard_Real AbsC, gp_Pnt& P, gp_Vec& V1)
188 const
189 {
190   curve.D1(AbsC,P,V1);
191 }
192
193
194 //=======================================================================
195 //function : D2
196 //purpose  : 
197 //=======================================================================
198
199 void ChFiDS_ElSpine::D2(const Standard_Real AbsC, 
200                         gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const
201 {  
202   curve.D2(AbsC,P,V1,V2);
203 }
204
205 //=======================================================================
206 //function : D3
207 //purpose  : 
208 //=======================================================================
209
210 void ChFiDS_ElSpine::D3(const Standard_Real AbsC, 
211                         gp_Pnt& P, gp_Vec& V1, gp_Vec& V2,  gp_Vec& V3) const
212 {  
213   curve.D3(AbsC,P,V1,V2,V3);
214 }
215
216
217 //=======================================================================
218 //function : FirstParameter
219 //purpose  : 
220 //=======================================================================
221
222 void ChFiDS_ElSpine::FirstParameter(const Standard_Real P)
223 {
224   pfirst = P;
225 }
226
227
228 //=======================================================================
229 //function : LastParameter
230 //purpose  : 
231 //=======================================================================
232
233 void ChFiDS_ElSpine::LastParameter(const Standard_Real P)
234 {
235   plast = P;
236 }
237
238
239 //=======================================================================
240 //function : SetOrigin
241 //purpose  : 
242 //=======================================================================
243
244 void ChFiDS_ElSpine::SetOrigin(const Standard_Real O)
245 {
246   if(!periodic) Standard_Failure::Raise("Elspine non periodique");
247   Handle(Geom_BSplineCurve) bs = Handle(Geom_BSplineCurve)::DownCast(curve.Curve());
248   if(!bs.IsNull()) {
249     bs->SetOrigin(O,Precision::PConfusion());
250     curve.Load(bs);
251   }
252 }
253
254 //=======================================================================
255 //function : SetFirstPointAndTgt
256 //purpose  : 
257 //=======================================================================
258
259 void ChFiDS_ElSpine::SetFirstPointAndTgt(const gp_Pnt& P,
260                                          const gp_Vec& T)
261 {
262   ptfirst = P;
263   tgfirst = T;
264 }
265
266 //=======================================================================
267 //function : SetLastPointAndTgt
268 //purpose  : 
269 //=======================================================================
270
271 void ChFiDS_ElSpine::SetLastPointAndTgt(const gp_Pnt& P,
272                                         const gp_Vec& T)
273 {
274   ptlast = P;
275   tglast = T;
276 }
277
278 //=======================================================================
279 //function : FirstPointAndTgt
280 //purpose  : 
281 //=======================================================================
282
283 void ChFiDS_ElSpine::FirstPointAndTgt(gp_Pnt& P,
284                                       gp_Vec& T) const
285 {
286   P = ptfirst;
287   T = tgfirst;
288 }
289
290 //=======================================================================
291 //function : LastPointAndTgt
292 //purpose  : 
293 //=======================================================================
294
295 void ChFiDS_ElSpine::LastPointAndTgt(gp_Pnt& P,
296                                      gp_Vec& T) const
297 {
298   P = ptlast;
299   T = tglast;
300 }
301
302 //=======================================================================
303 //function : SetCurve
304 //purpose  : 
305 //=======================================================================
306
307 void ChFiDS_ElSpine::SetCurve(const Handle(Geom_Curve)& C)
308 {
309   curve.Load(C);
310 }
311
312 //=======================================================================
313 //function : Previous
314 //purpose  : 
315 //=======================================================================
316
317 const Handle(ChFiDS_SurfData)& ChFiDS_ElSpine::Previous() const 
318 {
319   return previous;
320 }
321
322
323 //=======================================================================
324 //function : ChangePrevious
325 //purpose  : 
326 //=======================================================================
327
328 Handle(ChFiDS_SurfData)& ChFiDS_ElSpine::ChangePrevious()
329 {
330   return previous;
331 }
332
333 //=======================================================================
334 //function : Next
335 //purpose  : 
336 //=======================================================================
337
338 const Handle(ChFiDS_SurfData)& ChFiDS_ElSpine::Next() const 
339 {
340   return next;
341 }
342
343
344 //=======================================================================
345 //function : ChangeNext
346 //purpose  : 
347 //=======================================================================
348
349 Handle(ChFiDS_SurfData)& ChFiDS_ElSpine::ChangeNext()
350 {
351   return next;
352 }
353
354 //    --
355 //    --     The following methods must  be called when GetType returned
356 //    --     the corresponding type.
357 //    --     
358
359 //=======================================================================
360 //function : Line
361 //purpose  : 
362 //=======================================================================
363
364 gp_Lin ChFiDS_ElSpine::Line() const 
365 {
366  return curve.Line();  
367 }
368
369 //=======================================================================
370 //function : Circle
371 //purpose  : 
372 //=======================================================================
373
374 gp_Circ  ChFiDS_ElSpine::Circle() const 
375 {
376  return curve.Circle();
377 }
378
379 //=======================================================================
380 //function : Ellipse
381 //purpose  : 
382 //=======================================================================
383
384 gp_Elips ChFiDS_ElSpine::Ellipse() const 
385 {
386   return curve.Ellipse();
387 }
388
389 //=======================================================================
390 //function : Hyperbola
391 //purpose  : 
392 //=======================================================================
393
394 gp_Hypr ChFiDS_ElSpine::Hyperbola() const 
395 {
396   return curve.Hyperbola();  
397 }
398
399 //=======================================================================
400 //function : Parabola
401 //purpose  : 
402 //=======================================================================
403
404 gp_Parab ChFiDS_ElSpine::Parabola() const 
405 {
406  return curve.Parabola();
407 }
408
409 //=======================================================================
410 //function : Bezier
411 //purpose  : 
412 //=======================================================================
413
414 Handle(Geom_BezierCurve) ChFiDS_ElSpine::Bezier() const 
415 {
416   return curve.Bezier();
417 }
418
419 //=======================================================================
420 //function : BSpline
421 //purpose  : 
422 //=======================================================================
423
424 Handle(Geom_BSplineCurve) ChFiDS_ElSpine::BSpline() const 
425 {
426   return curve.BSpline();
427 }