0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / BiTgte / BiTgte_CurveOnEdge.cxx
1 // Created on: 1997-01-10
2 // Created by: Bruno DUMORTIER
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <Adaptor3d_HCurve.hxx>
19 #include <BiTgte_CurveOnEdge.hxx>
20 #include <BiTgte_HCurveOnEdge.hxx>
21 #include <BRep_Tool.hxx>
22 #include <Geom_BezierCurve.hxx>
23 #include <Geom_BSplineCurve.hxx>
24 #include <Geom_Curve.hxx>
25 #include <Geom_TrimmedCurve.hxx>
26 #include <GeomAdaptor_Curve.hxx>
27 #include <GeomAPI_ProjectPointOnCurve.hxx>
28 #include <gp_Circ.hxx>
29 #include <gp_Elips.hxx>
30 #include <gp_Hypr.hxx>
31 #include <gp_Lin.hxx>
32 #include <gp_Parab.hxx>
33 #include <gp_Pnt.hxx>
34 #include <gp_Vec.hxx>
35 #include <Precision.hxx>
36 #include <Standard_DomainError.hxx>
37 #include <Standard_NoSuchObject.hxx>
38 #include <Standard_NotImplemented.hxx>
39 #include <Standard_OutOfRange.hxx>
40 #include <TopoDS_Edge.hxx>
41
42 //=======================================================================
43 //function : BiTgte_CurveOnEdge
44 //purpose  : 
45 //======================================================================
46 BiTgte_CurveOnEdge::BiTgte_CurveOnEdge()
47 : myType(GeomAbs_OtherCurve)
48 {
49 }
50
51
52 //=======================================================================
53 //function : BiTgte_CurveOnEdge
54 //purpose  : 
55 //=======================================================================
56
57 BiTgte_CurveOnEdge::BiTgte_CurveOnEdge(const TopoDS_Edge& theEonF,
58                                        const TopoDS_Edge& theEdge)
59 : myEdge(theEdge),
60   myEonF(theEonF),
61   myType(GeomAbs_OtherCurve)
62 {
63   Init(theEonF, theEdge);
64 }
65
66
67 //=======================================================================
68 //function : Init
69 //purpose  : 
70 //=======================================================================
71
72 void BiTgte_CurveOnEdge::Init(const TopoDS_Edge& EonF,
73                               const TopoDS_Edge& Edge)
74 {
75   Standard_Real f,l;
76
77   myEdge = Edge;
78   myCurv = BRep_Tool::Curve(myEdge,f,l);
79   myCurv = new Geom_TrimmedCurve(myCurv,f,l);
80
81   myEonF = EonF;
82   myConF = BRep_Tool::Curve(myEonF,f,l);
83   myConF = new Geom_TrimmedCurve(myConF,f,l);
84
85   // peut on generer un cercle de rayon nul
86   GeomAdaptor_Curve Curv(myCurv);
87   GeomAdaptor_Curve ConF(myConF);
88   
89   myType = GeomAbs_OtherCurve;
90   if (Curv.GetType() == GeomAbs_Line && 
91       ConF.GetType() == GeomAbs_Circle ) {
92     gp_Ax1 a1 = Curv.Line().Position();
93     gp_Ax1 a2 = ConF.Circle().Axis();
94     if ( a1.IsCoaxial(a2,Precision::Angular(),Precision::Confusion())) {
95       myType = GeomAbs_Circle;
96       myCirc = gp_Circ(ConF.Circle().Position(),0.);
97     }
98   }
99 }
100
101
102 //=======================================================================
103 //function : FirstParameter
104 //purpose  : 
105 //=======================================================================
106
107 Standard_Real BiTgte_CurveOnEdge::FirstParameter() const
108 {
109   return myConF->FirstParameter();
110 }
111
112
113 //=======================================================================
114 //function : LastParameter
115 //purpose  : 
116 //=======================================================================
117
118 Standard_Real BiTgte_CurveOnEdge::LastParameter() const
119 {
120   return myConF->LastParameter();
121 }
122
123
124 //=======================================================================
125 //function : 
126 //purpose  : 
127 //=======================================================================
128
129 GeomAbs_Shape BiTgte_CurveOnEdge::Continuity() const
130 {
131   Standard_NotImplemented::Raise("BiTgte_CurveOnEdge");
132   return GeomAbs_C0;
133 }
134
135
136 //=======================================================================
137 //function : 
138 //purpose  : 
139 //=======================================================================
140
141 Standard_Integer BiTgte_CurveOnEdge::NbIntervals(const GeomAbs_Shape) const
142 {
143   Standard_NotImplemented::Raise("BiTgte_CurveOnEdge");
144   return 0;
145 }
146
147
148 //=======================================================================
149 //function : 
150 //purpose  : 
151 //=======================================================================
152
153 void BiTgte_CurveOnEdge::Intervals(TColStd_Array1OfReal&,
154                                    const GeomAbs_Shape) const
155 {
156   Standard_NotImplemented::Raise("BiTgte_CurveOnEdge");
157 }
158
159
160 //=======================================================================
161 //function : 
162 //purpose  : 
163 //=======================================================================
164
165 Handle(Adaptor3d_HCurve) BiTgte_CurveOnEdge::Trim(const Standard_Real,
166                                                   const Standard_Real,
167                                                   const Standard_Real) const
168 {
169   Standard_NotImplemented::Raise("BiTgte_CurveOnEdge");
170   Handle(BiTgte_HCurveOnEdge) HC;
171   return HC;
172 }
173
174
175 //=======================================================================
176 //function : 
177 //purpose  : 
178 //=======================================================================
179
180 Standard_Boolean BiTgte_CurveOnEdge::IsClosed() const
181 {
182   Standard_NotImplemented::Raise("BiTgte_CurveOnEdge");
183   return Standard_False;
184 }
185
186
187 //=======================================================================
188 //function : 
189 //purpose  : 
190 //=======================================================================
191
192 Standard_Boolean BiTgte_CurveOnEdge::IsPeriodic() const
193 {
194   Standard_NotImplemented::Raise("BiTgte_CurveOnEdge");
195   return Standard_False;
196 }
197
198
199 //=======================================================================
200 //function : 
201 //purpose  : 
202 //=======================================================================
203
204 Standard_Real BiTgte_CurveOnEdge::Period() const
205 {
206   Standard_NotImplemented::Raise("BiTgte_CurveOnEdge");
207   return 0.;
208 }
209
210
211 //=======================================================================
212 //function : 
213 //purpose  : 
214 //=======================================================================
215
216 gp_Pnt BiTgte_CurveOnEdge::Value(const Standard_Real U) const
217 {
218   gp_Pnt P;
219   D0(U,P);
220   return P;
221 }
222
223
224 //=======================================================================
225 //function : 
226 //purpose  : 
227 //=======================================================================
228
229 void BiTgte_CurveOnEdge::D0(const Standard_Real U,gp_Pnt& P) const
230 {
231   GeomAPI_ProjectPointOnCurve Projector;
232   P = myConF->Value(U);
233   Projector.Init(P, myCurv);
234   P = Projector.NearestPoint();
235 }
236
237
238 //=======================================================================
239 //function : 
240 //purpose  : 
241 //=======================================================================
242
243 void BiTgte_CurveOnEdge::D1(const Standard_Real,gp_Pnt& ,gp_Vec& ) const
244 {
245   Standard_NotImplemented::Raise("BiTgte_CurveOnEdge");
246 }
247
248
249 //=======================================================================
250 //function : 
251 //purpose  : 
252 //=======================================================================
253
254 void BiTgte_CurveOnEdge::D2(const Standard_Real ,gp_Pnt&,
255                             gp_Vec& ,gp_Vec&) const
256 {
257   Standard_NotImplemented::Raise("BiTgte_CurveOnEdge");
258 }
259
260
261 //=======================================================================
262 //function : 
263 //purpose  : 
264 //=======================================================================
265
266 void BiTgte_CurveOnEdge::D3(const Standard_Real ,gp_Pnt&,
267                             gp_Vec& ,gp_Vec& ,gp_Vec& ) const
268 {
269   Standard_NotImplemented::Raise("BiTgte_CurveOnEdge");
270 }
271
272
273 //=======================================================================
274 //function : 
275 //purpose  : 
276 //=======================================================================
277
278 gp_Vec BiTgte_CurveOnEdge::DN(const Standard_Real,
279                               const Standard_Integer) const
280 {
281   Standard_NotImplemented::Raise("BiTgte_CurveOnEdge");
282   return gp_Vec();
283 }
284
285
286 //=======================================================================
287 //function : 
288 //purpose  : 
289 //=======================================================================
290
291 Standard_Real BiTgte_CurveOnEdge::Resolution(const Standard_Real) const
292 {
293   Standard_NotImplemented::Raise("BiTgte_CurveOnEdge");
294   return 0.;
295 }
296
297
298 //=======================================================================
299 //function : 
300 //purpose  : 
301 //=======================================================================
302
303 GeomAbs_CurveType BiTgte_CurveOnEdge::GetType() const
304 {
305   return myType;
306 }
307
308
309 //=======================================================================
310 //function : 
311 //purpose  : 
312 //=======================================================================
313
314 gp_Lin BiTgte_CurveOnEdge::Line() const
315 {
316   Standard_NotImplemented::Raise("BiTgte_CurveOnEdge");
317   return gp_Lin();
318 }
319
320
321 //=======================================================================
322 //function : 
323 //purpose  : 
324 //=======================================================================
325
326 gp_Circ BiTgte_CurveOnEdge::Circle() const
327 {
328   if ( myType != GeomAbs_Circle) {
329     Standard_NoSuchObject::Raise("BiTgte_CurveOnEdge::Circle");
330     return gp_Circ();
331   }
332
333   return myCirc;
334 }
335
336
337 //=======================================================================
338 //function : 
339 //purpose  : 
340 //=======================================================================
341
342 gp_Elips BiTgte_CurveOnEdge::Ellipse() const
343 {
344   Standard_NotImplemented::Raise("BiTgte_CurveOnEdge");
345   return gp_Elips();
346 }
347
348
349 //=======================================================================
350 //function : 
351 //purpose  : 
352 //=======================================================================
353
354 gp_Hypr BiTgte_CurveOnEdge::Hyperbola() const
355 {
356   Standard_NotImplemented::Raise("BiTgte_CurveOnEdge");
357   return gp_Hypr();
358 }
359
360
361 //=======================================================================
362 //function : 
363 //purpose  : 
364 //=======================================================================
365
366 gp_Parab BiTgte_CurveOnEdge::Parabola() const
367 {
368   Standard_NotImplemented::Raise("BiTgte_CurveOnEdge");
369   return gp_Parab();
370 }
371
372
373 //=======================================================================
374 //function : 
375 //purpose  : 
376 //=======================================================================
377
378 Standard_Integer BiTgte_CurveOnEdge::Degree() const
379 {
380   Standard_NotImplemented::Raise("BiTgte_CurveOnEdge");
381   return 0;
382 }
383
384
385 //=======================================================================
386 //function : 
387 //purpose  : 
388 //=======================================================================
389
390 Standard_Boolean BiTgte_CurveOnEdge::IsRational() const
391 {
392   Standard_NotImplemented::Raise("BiTgte_CurveOnEdge");
393   return Standard_False;
394 }
395
396
397 //=======================================================================
398 //function : 
399 //purpose  : 
400 //=======================================================================
401
402 Standard_Integer BiTgte_CurveOnEdge::NbPoles() const
403 {
404   Standard_NotImplemented::Raise("BiTgte_CurveOnEdge");
405   return 0;
406 }
407
408
409 //=======================================================================
410 //function : 
411 //purpose  : 
412 //=======================================================================
413
414 Standard_Integer BiTgte_CurveOnEdge::NbKnots() const
415 {
416   Standard_NotImplemented::Raise("BiTgte_CurveOnEdge");
417   return 0;
418 }
419
420
421 //=======================================================================
422 //function : 
423 //purpose  : 
424 //=======================================================================
425
426 Handle(Geom_BezierCurve) BiTgte_CurveOnEdge::Bezier() const
427 {
428   Standard_NotImplemented::Raise("BiTgte_CurveOnEdge");
429   Handle(Geom_BezierCurve) B;
430   return B;
431 }
432
433
434 //=======================================================================
435 //function : 
436 //purpose  : 
437 //=======================================================================
438
439 Handle(Geom_BSplineCurve) BiTgte_CurveOnEdge::BSpline() const
440 {
441   Standard_NotImplemented::Raise("BiTgte_CurveOnEdge");
442   Handle(Geom_BSplineCurve) B;
443   return B;
444 }
445
446