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