Salome HOME
0023505: Sigsegv with fuse on cylinder and cone
[modules/geom.git] / src / GEOMUtils / GEOMUtils_TrsfCurve2d.cxx
1 // Copyright (C) 2015-2016  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20
21 #include <GEOMUtils_TrsfCurve2d.hxx>
22 #include <GEOMUtils_HTrsfCurve2d.hxx>
23
24 //=======================================================================
25 //function : TrsfCurve2d
26 //purpose  :
27 //=======================================================================
28 GEOMUtils::TrsfCurve2d::TrsfCurve2d(const Handle(Geom2d_Curve) &theCurve,
29                                     const Trsf2d               &theTrsf)
30 : myCurve (theCurve),
31   myTrsf  (theTrsf)
32 {
33 }
34
35 //=======================================================================
36 //function : TrsfCurve2d
37 //purpose  :
38 //=======================================================================
39 GEOMUtils::TrsfCurve2d::TrsfCurve2d(const Handle(Geom2d_Curve) &theCurve,
40                                     const Standard_Real         theUFirst,
41                                     const Standard_Real         theULast,
42                                     const Trsf2d               &theTrsf)
43 : myCurve (theCurve, theUFirst, theULast),
44   myTrsf  (theTrsf)
45 {
46 }
47
48 //=======================================================================
49 //function : FirstParameter
50 //purpose  :
51 //=======================================================================
52 Standard_Real GEOMUtils::TrsfCurve2d::FirstParameter() const
53 {
54   return myCurve.FirstParameter();
55 }
56
57 //=======================================================================
58 //function : LastParameter
59 //purpose  :
60 //=======================================================================
61 Standard_Real GEOMUtils::TrsfCurve2d::LastParameter() const
62 {
63   return myCurve.LastParameter();
64 }
65
66 //=======================================================================
67 //function : Curve
68 //purpose  :
69 //=======================================================================
70 const Handle(Geom2d_Curve) &GEOMUtils::TrsfCurve2d::Curve() const
71 {
72   return myCurve.Curve();
73 }
74
75 //=======================================================================
76 //function : GetType
77 //purpose  :
78 //=======================================================================
79 GeomAbs_CurveType GEOMUtils::TrsfCurve2d::GetType() const
80 {
81   return GeomAbs_OtherCurve;
82 }
83
84 //=======================================================================
85 //function : Load
86 //purpose  :
87 //=======================================================================
88 void GEOMUtils::TrsfCurve2d::Load(const Handle(Geom2d_Curve) &C)
89 {
90   myCurve.Load(C);
91 }
92
93 //=======================================================================
94 //function : Load
95 //purpose  :
96 //=======================================================================
97 void GEOMUtils::TrsfCurve2d::Load(const Handle(Geom2d_Curve) &C,
98                                   const Standard_Real         UFirst,
99                                   const Standard_Real         ULast)
100 {
101   myCurve.Load(C, UFirst, ULast);
102 }
103
104 //=======================================================================
105 //function : Continuity
106 //purpose  :
107 //=======================================================================
108 GeomAbs_Shape GEOMUtils::TrsfCurve2d::Continuity() const
109 {
110   return myCurve.Continuity();
111 }
112
113 //=======================================================================
114 //function : NbIntervals
115 //purpose  :
116 //=======================================================================
117 Standard_Integer GEOMUtils::TrsfCurve2d::NbIntervals
118                       (const GeomAbs_Shape S) const
119 {
120   return myCurve.NbIntervals(S);
121 }
122
123 //=======================================================================
124 //function : Intervals
125 //purpose  :
126 //=======================================================================
127 void GEOMUtils::TrsfCurve2d::Intervals(TColStd_Array1OfReal &T,
128                                        const GeomAbs_Shape   S) const
129 {
130   myCurve.Intervals(T, S);
131 }
132
133 //=======================================================================
134 //function : Trim
135 //purpose  :
136 //=======================================================================
137 Handle(Adaptor2d_HCurve2d) GEOMUtils::TrsfCurve2d::Trim
138               (const Standard_Real First, const Standard_Real Last,
139                const Standard_Real /*Tol*/) const
140 {
141   Handle(Geom2d_Curve)            aCurve = myCurve.Curve();
142 #if OCC_VERSION_MAJOR < 7
143   GEOMUtils::Handle(HTrsfCurve2d) aAHCurve =
144 #else
145   Handle(GEOMUtils::HTrsfCurve2d) aAHCurve =
146 #endif
147     new GEOMUtils::HTrsfCurve2d(aCurve, First, Last, myTrsf);
148
149   return aAHCurve;
150 }
151
152 //=======================================================================
153 //function : IsClosed
154 //purpose  :
155 //=======================================================================
156 Standard_Boolean GEOMUtils::TrsfCurve2d::IsClosed() const
157 {
158   return myCurve.IsClosed();
159 }
160
161 //=======================================================================
162 //function : IsPeriodic
163 //purpose  :
164 //=======================================================================
165 Standard_Boolean GEOMUtils::TrsfCurve2d::IsPeriodic() const
166 {
167   return myCurve.IsPeriodic();
168 }
169
170 //=======================================================================
171 //function : Period
172 //purpose  :
173 //=======================================================================
174 Standard_Real GEOMUtils::TrsfCurve2d::Period() const
175 {
176   return myCurve.Period();
177 }
178
179 //=======================================================================
180 //function : Value
181 //purpose  :
182 //=======================================================================
183 gp_Pnt2d GEOMUtils::TrsfCurve2d::Value(const Standard_Real U) const
184 {
185   gp_Pnt2d aPnt = myCurve.Value(U);
186
187   myTrsf.TransformD0(aPnt);
188
189   return aPnt;
190 }
191
192 //=======================================================================
193 //function : D0
194 //purpose  :
195 //=======================================================================
196 void GEOMUtils::TrsfCurve2d::D0(const Standard_Real U, gp_Pnt2d &P) const
197 {
198   myCurve.D0(U, P);
199   myTrsf.TransformD0(P);
200 }
201
202 //=======================================================================
203 //function : D1
204 //purpose  :
205 //=======================================================================
206 void GEOMUtils::TrsfCurve2d::D1(const Standard_Real U,
207                                 gp_Pnt2d &P, gp_Vec2d &V) const
208 {
209   myCurve.D1(U, P, V);
210   myTrsf.TransformD1(P, V);
211 }
212
213 //=======================================================================
214 //function : D2
215 //purpose  :
216 //=======================================================================
217 void GEOMUtils::TrsfCurve2d::D2(const Standard_Real U, gp_Pnt2d &P,
218                                 gp_Vec2d &V1, gp_Vec2d &V2) const
219 {
220   myCurve.D2(U, P, V1, V2);
221   myTrsf.TransformD2(P, V1, V2);
222 }
223
224 //=======================================================================
225 //function : D3
226 //purpose  :
227 //=======================================================================
228 void GEOMUtils::TrsfCurve2d::D3(const Standard_Real U, gp_Pnt2d &P,
229                                 gp_Vec2d &V1, gp_Vec2d &V2, gp_Vec2d &V3) const
230 {
231   myCurve.D3(U, P, V1, V2, V3);
232   myTrsf.TransformD3(P, V1, V2, V3);
233 }
234
235 //=======================================================================
236 //function : DN
237 //purpose  :
238 //=======================================================================
239 gp_Vec2d GEOMUtils::TrsfCurve2d::DN(const Standard_Real    U,
240                                     const Standard_Integer N) const
241 {
242   gp_Pnt2d aPnt = myCurve.Value(U);
243   gp_Vec2d aVec = myCurve.DN(U, N);
244
245   myTrsf.TransformD1(aPnt, aVec);
246   return aVec;
247 }
248
249 //=======================================================================
250 //function : Resolution
251 //purpose  :
252 //=======================================================================
253 Standard_Real GEOMUtils::TrsfCurve2d::Resolution(const Standard_Real Ruv) const
254 {
255   return Precision::Parametric(Ruv);
256 }
257
258 //=======================================================================
259 //function : Line
260 //purpose  :
261 //=======================================================================
262 gp_Lin2d GEOMUtils::TrsfCurve2d::Line() const
263 {
264   Standard_NoSuchObject::Raise();
265
266   return gp_Lin2d();
267 }
268
269 //=======================================================================
270 //function : Circle
271 //purpose  :
272 //=======================================================================
273 gp_Circ2d  GEOMUtils::TrsfCurve2d::Circle() const
274 {
275   Standard_NoSuchObject::Raise();
276
277   return gp_Circ2d();
278 }
279
280 //=======================================================================
281 //function : Ellipse
282 //purpose  :
283 //=======================================================================
284 gp_Elips2d GEOMUtils::TrsfCurve2d::Ellipse() const
285 {
286   Standard_NoSuchObject::Raise();
287
288   return gp_Elips2d();
289 }
290
291 //=======================================================================
292 //function : Hyperbola
293 //purpose  :
294 //=======================================================================
295 gp_Hypr2d GEOMUtils::TrsfCurve2d::Hyperbola() const
296 {
297   Standard_NoSuchObject::Raise();
298
299   return gp_Hypr2d();
300 }
301
302 //=======================================================================
303 //function : Parabola
304 //purpose  :
305 //=======================================================================
306 gp_Parab2d GEOMUtils::TrsfCurve2d::Parabola() const
307 {
308   Standard_NoSuchObject::Raise();
309
310   return gp_Parab2d();
311 }
312
313 //=======================================================================
314 //function : Degree
315 //purpose  :
316 //=======================================================================
317 Standard_Integer GEOMUtils::TrsfCurve2d::Degree() const
318 {
319   Standard_NoSuchObject::Raise();
320
321   return 0;
322 }
323
324 //=======================================================================
325 //function : IsRational
326 //purpose  :
327 //=======================================================================
328 Standard_Boolean GEOMUtils::TrsfCurve2d::IsRational() const
329 {
330   return Standard_False;
331 }
332
333 //=======================================================================
334 //function : NbPoles
335 //purpose  :
336 //=======================================================================
337 Standard_Integer GEOMUtils::TrsfCurve2d::NbPoles() const
338 {
339   Standard_NoSuchObject::Raise();
340
341   return 0;
342 }
343
344 //=======================================================================
345 //function : NbKnots
346 //purpose  :
347 //=======================================================================
348 Standard_Integer GEOMUtils::TrsfCurve2d::NbKnots() const
349 {
350   Standard_NoSuchObject::Raise();
351
352   return 0;
353 }
354
355 //=======================================================================
356 //function : Bezier
357 //purpose  :
358 //=======================================================================
359 Handle(Geom2d_BezierCurve) GEOMUtils::TrsfCurve2d::Bezier() const
360 {
361   Standard_NoSuchObject::Raise();
362
363   return NULL;
364 }
365
366 //=======================================================================
367 //function : BSpline
368 //purpose  :
369 //=======================================================================
370 Handle(Geom2d_BSplineCurve) GEOMUtils::TrsfCurve2d::BSpline() const
371 {
372   Standard_NoSuchObject::Raise();
373
374   return NULL;
375 }
376
377 //=======================================================================
378 //function : NbSamples
379 //purpose  :
380 //=======================================================================
381 Standard_Integer GEOMUtils::TrsfCurve2d::NbSamples() const
382 {
383   return myCurve.NbSamples();
384 }