Salome HOME
Copyright update 2022
[modules/geom.git] / src / GEOMUtils / GEOMUtils_TrsfCurve2d.cxx
1 // Copyright (C) 2015-2022  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   Handle(GEOMUtils::HTrsfCurve2d) aAHCurve =
143     new GEOMUtils::HTrsfCurve2d(aCurve, First, Last, myTrsf);
144
145   return aAHCurve;
146 }
147
148 //=======================================================================
149 //function : IsClosed
150 //purpose  :
151 //=======================================================================
152 Standard_Boolean GEOMUtils::TrsfCurve2d::IsClosed() const
153 {
154   return myCurve.IsClosed();
155 }
156
157 //=======================================================================
158 //function : IsPeriodic
159 //purpose  :
160 //=======================================================================
161 Standard_Boolean GEOMUtils::TrsfCurve2d::IsPeriodic() const
162 {
163   return myCurve.IsPeriodic();
164 }
165
166 //=======================================================================
167 //function : Period
168 //purpose  :
169 //=======================================================================
170 Standard_Real GEOMUtils::TrsfCurve2d::Period() const
171 {
172   return myCurve.Period();
173 }
174
175 //=======================================================================
176 //function : Value
177 //purpose  :
178 //=======================================================================
179 gp_Pnt2d GEOMUtils::TrsfCurve2d::Value(const Standard_Real U) const
180 {
181   gp_Pnt2d aPnt = myCurve.Value(U);
182
183   myTrsf.TransformD0(aPnt);
184
185   return aPnt;
186 }
187
188 //=======================================================================
189 //function : D0
190 //purpose  :
191 //=======================================================================
192 void GEOMUtils::TrsfCurve2d::D0(const Standard_Real U, gp_Pnt2d &P) const
193 {
194   myCurve.D0(U, P);
195   myTrsf.TransformD0(P);
196 }
197
198 //=======================================================================
199 //function : D1
200 //purpose  :
201 //=======================================================================
202 void GEOMUtils::TrsfCurve2d::D1(const Standard_Real U,
203                                 gp_Pnt2d &P, gp_Vec2d &V) const
204 {
205   myCurve.D1(U, P, V);
206   myTrsf.TransformD1(P, V);
207 }
208
209 //=======================================================================
210 //function : D2
211 //purpose  :
212 //=======================================================================
213 void GEOMUtils::TrsfCurve2d::D2(const Standard_Real U, gp_Pnt2d &P,
214                                 gp_Vec2d &V1, gp_Vec2d &V2) const
215 {
216   myCurve.D2(U, P, V1, V2);
217   myTrsf.TransformD2(P, V1, V2);
218 }
219
220 //=======================================================================
221 //function : D3
222 //purpose  :
223 //=======================================================================
224 void GEOMUtils::TrsfCurve2d::D3(const Standard_Real U, gp_Pnt2d &P,
225                                 gp_Vec2d &V1, gp_Vec2d &V2, gp_Vec2d &V3) const
226 {
227   myCurve.D3(U, P, V1, V2, V3);
228   myTrsf.TransformD3(P, V1, V2, V3);
229 }
230
231 //=======================================================================
232 //function : DN
233 //purpose  :
234 //=======================================================================
235 gp_Vec2d GEOMUtils::TrsfCurve2d::DN(const Standard_Real    U,
236                                     const Standard_Integer N) const
237 {
238   gp_Pnt2d aPnt = myCurve.Value(U);
239   gp_Vec2d aVec = myCurve.DN(U, N);
240
241   myTrsf.TransformD1(aPnt, aVec);
242   return aVec;
243 }
244
245 //=======================================================================
246 //function : Resolution
247 //purpose  :
248 //=======================================================================
249 Standard_Real GEOMUtils::TrsfCurve2d::Resolution(const Standard_Real Ruv) const
250 {
251   return Precision::Parametric(Ruv);
252 }
253
254 //=======================================================================
255 //function : Line
256 //purpose  :
257 //=======================================================================
258 gp_Lin2d GEOMUtils::TrsfCurve2d::Line() const
259 {
260   Standard_NoSuchObject::Raise();
261
262   return gp_Lin2d();
263 }
264
265 //=======================================================================
266 //function : Circle
267 //purpose  :
268 //=======================================================================
269 gp_Circ2d  GEOMUtils::TrsfCurve2d::Circle() const
270 {
271   Standard_NoSuchObject::Raise();
272
273   return gp_Circ2d();
274 }
275
276 //=======================================================================
277 //function : Ellipse
278 //purpose  :
279 //=======================================================================
280 gp_Elips2d GEOMUtils::TrsfCurve2d::Ellipse() const
281 {
282   Standard_NoSuchObject::Raise();
283
284   return gp_Elips2d();
285 }
286
287 //=======================================================================
288 //function : Hyperbola
289 //purpose  :
290 //=======================================================================
291 gp_Hypr2d GEOMUtils::TrsfCurve2d::Hyperbola() const
292 {
293   Standard_NoSuchObject::Raise();
294
295   return gp_Hypr2d();
296 }
297
298 //=======================================================================
299 //function : Parabola
300 //purpose  :
301 //=======================================================================
302 gp_Parab2d GEOMUtils::TrsfCurve2d::Parabola() const
303 {
304   Standard_NoSuchObject::Raise();
305
306   return gp_Parab2d();
307 }
308
309 //=======================================================================
310 //function : Degree
311 //purpose  :
312 //=======================================================================
313 Standard_Integer GEOMUtils::TrsfCurve2d::Degree() const
314 {
315   Standard_NoSuchObject::Raise();
316
317   return 0;
318 }
319
320 //=======================================================================
321 //function : IsRational
322 //purpose  :
323 //=======================================================================
324 Standard_Boolean GEOMUtils::TrsfCurve2d::IsRational() const
325 {
326   return Standard_False;
327 }
328
329 //=======================================================================
330 //function : NbPoles
331 //purpose  :
332 //=======================================================================
333 Standard_Integer GEOMUtils::TrsfCurve2d::NbPoles() const
334 {
335   Standard_NoSuchObject::Raise();
336
337   return 0;
338 }
339
340 //=======================================================================
341 //function : NbKnots
342 //purpose  :
343 //=======================================================================
344 Standard_Integer GEOMUtils::TrsfCurve2d::NbKnots() const
345 {
346   Standard_NoSuchObject::Raise();
347
348   return 0;
349 }
350
351 //=======================================================================
352 //function : Bezier
353 //purpose  :
354 //=======================================================================
355 Handle(Geom2d_BezierCurve) GEOMUtils::TrsfCurve2d::Bezier() const
356 {
357   Standard_NoSuchObject::Raise();
358
359   return NULL;
360 }
361
362 //=======================================================================
363 //function : BSpline
364 //purpose  :
365 //=======================================================================
366 Handle(Geom2d_BSplineCurve) GEOMUtils::TrsfCurve2d::BSpline() const
367 {
368   Standard_NoSuchObject::Raise();
369
370   return NULL;
371 }
372
373 //=======================================================================
374 //function : NbSamples
375 //purpose  :
376 //=======================================================================
377 Standard_Integer GEOMUtils::TrsfCurve2d::NbSamples() const
378 {
379   return myCurve.NbSamples();
380 }