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