Salome HOME
c80e1f34fe0bb6745df913786112ce41972f2ac3
[modules/geom.git] / src / GEOMUtils / GEOMUtils_TrsfCurve2d.cxx
1 // Copyright (C) 2015-2023  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
23 #include <Geom2d_BezierCurve.hxx>
24 #include <Geom2d_BSplineCurve.hxx>
25
26 #if OCC_VERSION_LARGE < 0x07070000
27 #include <GEOMUtils_HTrsfCurve2d.hxx>
28 #else
29 IMPLEMENT_STANDARD_RTTIEXT(GEOMUtils::TrsfCurve2d, Adaptor2d_Curve2d)
30 #endif
31
32 //=======================================================================
33 //function : TrsfCurve2d
34 //purpose  :
35 //=======================================================================
36 GEOMUtils::TrsfCurve2d::TrsfCurve2d(const Handle(Geom2d_Curve) &theCurve,
37                                     const Trsf2d               &theTrsf)
38 : myCurve (theCurve),
39   myTrsf  (theTrsf)
40 {
41 }
42
43 //=======================================================================
44 //function : TrsfCurve2d
45 //purpose  :
46 //=======================================================================
47 GEOMUtils::TrsfCurve2d::TrsfCurve2d(const Handle(Geom2d_Curve) &theCurve,
48                                     const Standard_Real         theUFirst,
49                                     const Standard_Real         theULast,
50                                     const Trsf2d               &theTrsf)
51 : myCurve (theCurve, theUFirst, theULast),
52   myTrsf  (theTrsf)
53 {
54 }
55
56 //=======================================================================
57 //function : FirstParameter
58 //purpose  :
59 //=======================================================================
60 Standard_Real GEOMUtils::TrsfCurve2d::FirstParameter() const
61 {
62   return myCurve.FirstParameter();
63 }
64
65 //=======================================================================
66 //function : LastParameter
67 //purpose  :
68 //=======================================================================
69 Standard_Real GEOMUtils::TrsfCurve2d::LastParameter() const
70 {
71   return myCurve.LastParameter();
72 }
73
74 //=======================================================================
75 //function : Curve
76 //purpose  :
77 //=======================================================================
78 const Handle(Geom2d_Curve) &GEOMUtils::TrsfCurve2d::Curve() const
79 {
80   return myCurve.Curve();
81 }
82
83 //=======================================================================
84 //function : GetType
85 //purpose  :
86 //=======================================================================
87 GeomAbs_CurveType GEOMUtils::TrsfCurve2d::GetType() const
88 {
89   return GeomAbs_OtherCurve;
90 }
91
92 //=======================================================================
93 //function : Load
94 //purpose  :
95 //=======================================================================
96 void GEOMUtils::TrsfCurve2d::Load(const Handle(Geom2d_Curve) &C)
97 {
98   myCurve.Load(C);
99 }
100
101 //=======================================================================
102 //function : Load
103 //purpose  :
104 //=======================================================================
105 void GEOMUtils::TrsfCurve2d::Load(const Handle(Geom2d_Curve) &C,
106                                   const Standard_Real         UFirst,
107                                   const Standard_Real         ULast)
108 {
109   myCurve.Load(C, UFirst, ULast);
110 }
111
112 //=======================================================================
113 //function : Continuity
114 //purpose  :
115 //=======================================================================
116 GeomAbs_Shape GEOMUtils::TrsfCurve2d::Continuity() const
117 {
118   return myCurve.Continuity();
119 }
120
121 //=======================================================================
122 //function : NbIntervals
123 //purpose  :
124 //=======================================================================
125 Standard_Integer GEOMUtils::TrsfCurve2d::NbIntervals
126                       (const GeomAbs_Shape S) const
127 {
128   return myCurve.NbIntervals(S);
129 }
130
131 //=======================================================================
132 //function : Intervals
133 //purpose  :
134 //=======================================================================
135 void GEOMUtils::TrsfCurve2d::Intervals(TColStd_Array1OfReal &T,
136                                        const GeomAbs_Shape   S) const
137 {
138   myCurve.Intervals(T, S);
139 }
140
141 //=======================================================================
142 //function : Trim
143 //purpose  :
144 //=======================================================================
145 #if OCC_VERSION_LARGE < 0x07070000
146 Handle(Adaptor2d_HCurve2d) GEOMUtils::TrsfCurve2d::Trim
147               (const Standard_Real First, const Standard_Real Last,
148                const Standard_Real /*Tol*/) const
149 {
150   Handle(Geom2d_Curve)            aCurve = myCurve.Curve();
151   Handle(GEOMUtils::HTrsfCurve2d) aAHCurve =
152     new GEOMUtils::HTrsfCurve2d(aCurve, First, Last, myTrsf);
153
154   return aAHCurve;
155 }
156 #else
157 Handle(Adaptor2d_Curve2d) GEOMUtils::TrsfCurve2d::Trim
158               (const Standard_Real First, const Standard_Real Last,
159                const Standard_Real /*Tol*/) const
160 {
161   Handle(Geom2d_Curve)            aCurve = myCurve.Curve();
162   Handle(GEOMUtils::TrsfCurve2d) aAHCurve =
163     new GEOMUtils::TrsfCurve2d(aCurve, First, Last, myTrsf);
164
165   return aAHCurve;
166 }
167 #endif
168
169 //=======================================================================
170 //function : IsClosed
171 //purpose  :
172 //=======================================================================
173 Standard_Boolean GEOMUtils::TrsfCurve2d::IsClosed() const
174 {
175   return myCurve.IsClosed();
176 }
177
178 //=======================================================================
179 //function : IsPeriodic
180 //purpose  :
181 //=======================================================================
182 Standard_Boolean GEOMUtils::TrsfCurve2d::IsPeriodic() const
183 {
184   return myCurve.IsPeriodic();
185 }
186
187 //=======================================================================
188 //function : Period
189 //purpose  :
190 //=======================================================================
191 Standard_Real GEOMUtils::TrsfCurve2d::Period() const
192 {
193   return myCurve.Period();
194 }
195
196 //=======================================================================
197 //function : Value
198 //purpose  :
199 //=======================================================================
200 gp_Pnt2d GEOMUtils::TrsfCurve2d::Value(const Standard_Real U) const
201 {
202   gp_Pnt2d aPnt = myCurve.Value(U);
203
204   myTrsf.TransformD0(aPnt);
205
206   return aPnt;
207 }
208
209 //=======================================================================
210 //function : D0
211 //purpose  :
212 //=======================================================================
213 void GEOMUtils::TrsfCurve2d::D0(const Standard_Real U, gp_Pnt2d &P) const
214 {
215   myCurve.D0(U, P);
216   myTrsf.TransformD0(P);
217 }
218
219 //=======================================================================
220 //function : D1
221 //purpose  :
222 //=======================================================================
223 void GEOMUtils::TrsfCurve2d::D1(const Standard_Real U,
224                                 gp_Pnt2d &P, gp_Vec2d &V) const
225 {
226   myCurve.D1(U, P, V);
227   myTrsf.TransformD1(P, V);
228 }
229
230 //=======================================================================
231 //function : D2
232 //purpose  :
233 //=======================================================================
234 void GEOMUtils::TrsfCurve2d::D2(const Standard_Real U, gp_Pnt2d &P,
235                                 gp_Vec2d &V1, gp_Vec2d &V2) const
236 {
237   myCurve.D2(U, P, V1, V2);
238   myTrsf.TransformD2(P, V1, V2);
239 }
240
241 //=======================================================================
242 //function : D3
243 //purpose  :
244 //=======================================================================
245 void GEOMUtils::TrsfCurve2d::D3(const Standard_Real U, gp_Pnt2d &P,
246                                 gp_Vec2d &V1, gp_Vec2d &V2, gp_Vec2d &V3) const
247 {
248   myCurve.D3(U, P, V1, V2, V3);
249   myTrsf.TransformD3(P, V1, V2, V3);
250 }
251
252 //=======================================================================
253 //function : DN
254 //purpose  :
255 //=======================================================================
256 gp_Vec2d GEOMUtils::TrsfCurve2d::DN(const Standard_Real    U,
257                                     const Standard_Integer N) const
258 {
259   gp_Pnt2d aPnt = myCurve.Value(U);
260   gp_Vec2d aVec = myCurve.DN(U, N);
261
262   myTrsf.TransformD1(aPnt, aVec);
263   return aVec;
264 }
265
266 //=======================================================================
267 //function : Resolution
268 //purpose  :
269 //=======================================================================
270 Standard_Real GEOMUtils::TrsfCurve2d::Resolution(const Standard_Real Ruv) const
271 {
272   return Precision::Parametric(Ruv);
273 }
274
275 //=======================================================================
276 //function : Line
277 //purpose  :
278 //=======================================================================
279 gp_Lin2d GEOMUtils::TrsfCurve2d::Line() const
280 {
281   Standard_NoSuchObject::Raise();
282
283   return gp_Lin2d();
284 }
285
286 //=======================================================================
287 //function : Circle
288 //purpose  :
289 //=======================================================================
290 gp_Circ2d  GEOMUtils::TrsfCurve2d::Circle() const
291 {
292   Standard_NoSuchObject::Raise();
293
294   return gp_Circ2d();
295 }
296
297 //=======================================================================
298 //function : Ellipse
299 //purpose  :
300 //=======================================================================
301 gp_Elips2d GEOMUtils::TrsfCurve2d::Ellipse() const
302 {
303   Standard_NoSuchObject::Raise();
304
305   return gp_Elips2d();
306 }
307
308 //=======================================================================
309 //function : Hyperbola
310 //purpose  :
311 //=======================================================================
312 gp_Hypr2d GEOMUtils::TrsfCurve2d::Hyperbola() const
313 {
314   Standard_NoSuchObject::Raise();
315
316   return gp_Hypr2d();
317 }
318
319 //=======================================================================
320 //function : Parabola
321 //purpose  :
322 //=======================================================================
323 gp_Parab2d GEOMUtils::TrsfCurve2d::Parabola() const
324 {
325   Standard_NoSuchObject::Raise();
326
327   return gp_Parab2d();
328 }
329
330 //=======================================================================
331 //function : Degree
332 //purpose  :
333 //=======================================================================
334 Standard_Integer GEOMUtils::TrsfCurve2d::Degree() const
335 {
336   Standard_NoSuchObject::Raise();
337
338   return 0;
339 }
340
341 //=======================================================================
342 //function : IsRational
343 //purpose  :
344 //=======================================================================
345 Standard_Boolean GEOMUtils::TrsfCurve2d::IsRational() const
346 {
347   return Standard_False;
348 }
349
350 //=======================================================================
351 //function : NbPoles
352 //purpose  :
353 //=======================================================================
354 Standard_Integer GEOMUtils::TrsfCurve2d::NbPoles() const
355 {
356   Standard_NoSuchObject::Raise();
357
358   return 0;
359 }
360
361 //=======================================================================
362 //function : NbKnots
363 //purpose  :
364 //=======================================================================
365 Standard_Integer GEOMUtils::TrsfCurve2d::NbKnots() const
366 {
367   Standard_NoSuchObject::Raise();
368
369   return 0;
370 }
371
372 //=======================================================================
373 //function : Bezier
374 //purpose  :
375 //=======================================================================
376 Handle(Geom2d_BezierCurve) GEOMUtils::TrsfCurve2d::Bezier() const
377 {
378   Standard_NoSuchObject::Raise();
379
380   return NULL;
381 }
382
383 //=======================================================================
384 //function : BSpline
385 //purpose  :
386 //=======================================================================
387 Handle(Geom2d_BSplineCurve) GEOMUtils::TrsfCurve2d::BSpline() const
388 {
389   Standard_NoSuchObject::Raise();
390
391   return NULL;
392 }
393
394 //=======================================================================
395 //function : NbSamples
396 //purpose  :
397 //=======================================================================
398 Standard_Integer GEOMUtils::TrsfCurve2d::NbSamples() const
399 {
400   return myCurve.NbSamples();
401 }