b311480e |
1 | // Created on: 1993-02-19 |
2 | // Created by: Remi LEQUETTE |
3 | // Copyright (c) 1993-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | #include <BRepAdaptor_Surface.ixx> |
23 | #include <BRep_Tool.hxx> |
24 | #include <BRepTools.hxx> |
25 | #include <GeomAdaptor_HSurface.hxx> |
26 | #include <GeomAdaptor_HCurve.hxx> |
27 | |
28 | //======================================================================= |
29 | //function : BRepAdaptor_Surface |
30 | //purpose : |
31 | //======================================================================= |
32 | |
33 | BRepAdaptor_Surface::BRepAdaptor_Surface() |
34 | { |
35 | } |
36 | |
37 | |
38 | //======================================================================= |
39 | //function : BRepAdaptor_Surface |
40 | //purpose : |
41 | //======================================================================= |
42 | |
43 | BRepAdaptor_Surface::BRepAdaptor_Surface(const TopoDS_Face& F, |
44 | const Standard_Boolean R) |
45 | { |
46 | Initialize(F,R); |
47 | } |
48 | |
49 | |
50 | //======================================================================= |
51 | //function : Initialize |
52 | //purpose : |
53 | //======================================================================= |
54 | |
55 | void BRepAdaptor_Surface::Initialize(const TopoDS_Face& F, |
56 | const Standard_Boolean Restriction) |
57 | { |
58 | myFace = F; |
59 | TopLoc_Location L; |
60 | if (Restriction) { |
61 | Standard_Real umin,umax,vmin,vmax; |
62 | BRepTools::UVBounds(F,umin,umax,vmin,vmax); |
63 | mySurf.Load(BRep_Tool::Surface(F,L),umin,umax,vmin,vmax); |
64 | } |
65 | else |
66 | mySurf.Load(BRep_Tool::Surface(F,L)); |
67 | myTrsf = L.Transformation(); |
68 | } |
69 | |
70 | |
71 | //======================================================================= |
72 | //function : Surface |
73 | //purpose : |
74 | //======================================================================= |
75 | |
76 | const GeomAdaptor_Surface& BRepAdaptor_Surface::Surface() const |
77 | { |
78 | return mySurf; |
79 | } |
80 | |
81 | |
82 | //======================================================================= |
83 | //function : ChangeSurface |
84 | //purpose : |
85 | //======================================================================= |
86 | |
87 | GeomAdaptor_Surface& BRepAdaptor_Surface::ChangeSurface() |
88 | { |
89 | return mySurf; |
90 | } |
91 | |
92 | |
93 | //======================================================================= |
94 | //function : Trsf |
95 | //purpose : |
96 | //======================================================================= |
97 | |
98 | const gp_Trsf& BRepAdaptor_Surface::Trsf() const |
99 | { |
100 | return myTrsf; |
101 | } |
102 | |
103 | |
104 | //======================================================================= |
105 | //function : Face |
106 | //purpose : |
107 | //======================================================================= |
108 | |
109 | const TopoDS_Face& BRepAdaptor_Surface::Face() const |
110 | { |
111 | return myFace; |
112 | } |
113 | |
114 | //======================================================================= |
115 | //function : Tolerance |
116 | //purpose : |
117 | //======================================================================= |
118 | |
119 | Standard_Real BRepAdaptor_Surface::Tolerance() const |
120 | { |
121 | return BRep_Tool::Tolerance(myFace); |
122 | } |
123 | |
124 | |
125 | //======================================================================= |
126 | //function : UIntervals |
127 | //purpose : |
128 | //======================================================================= |
129 | |
130 | void BRepAdaptor_Surface::UIntervals(TColStd_Array1OfReal& T, |
131 | const GeomAbs_Shape S) const |
132 | { |
133 | mySurf.UIntervals(T,S); |
134 | } |
135 | |
136 | |
137 | //======================================================================= |
138 | //function : VIntervals |
139 | //purpose : |
140 | //======================================================================= |
141 | |
142 | void BRepAdaptor_Surface::VIntervals(TColStd_Array1OfReal& T, |
143 | const GeomAbs_Shape S) const |
144 | { |
145 | mySurf.VIntervals(T,S); |
146 | } |
147 | |
148 | |
149 | //======================================================================= |
150 | //function : UTrim |
151 | //purpose : |
152 | //======================================================================= |
153 | |
154 | Handle(Adaptor3d_HSurface) BRepAdaptor_Surface::UTrim |
155 | (const Standard_Real First, |
156 | const Standard_Real Last , |
157 | const Standard_Real Tol ) const |
158 | { |
159 | Handle(GeomAdaptor_HSurface) HS = new GeomAdaptor_HSurface(); |
160 | HS->ChangeSurface().Load |
161 | (Handle(Geom_Surface)::DownCast(mySurf.Surface()->Transformed(myTrsf))); |
162 | return HS->UTrim(First,Last,Tol); |
163 | } |
164 | |
165 | |
166 | //======================================================================= |
167 | //function : VTrim |
168 | //purpose : |
169 | //======================================================================= |
170 | |
171 | Handle(Adaptor3d_HSurface) BRepAdaptor_Surface::VTrim |
172 | (const Standard_Real First, |
173 | const Standard_Real Last, |
174 | const Standard_Real Tol) const |
175 | { |
176 | Handle(GeomAdaptor_HSurface) HS = new GeomAdaptor_HSurface(); |
177 | HS->ChangeSurface().Load |
178 | (Handle(Geom_Surface)::DownCast(mySurf.Surface()->Transformed(myTrsf))); |
179 | return HS->VTrim(First,Last,Tol); |
180 | } |
181 | |
182 | |
183 | //======================================================================= |
184 | //function : Value |
185 | //purpose : |
186 | //======================================================================= |
187 | |
188 | gp_Pnt BRepAdaptor_Surface::Value(const Standard_Real U, |
189 | const Standard_Real V) const |
190 | { |
191 | return mySurf.Value(U,V).Transformed(myTrsf); |
192 | } |
193 | |
194 | //======================================================================= |
195 | //function : D0 |
196 | //purpose : |
197 | //======================================================================= |
198 | |
199 | void BRepAdaptor_Surface::D0(const Standard_Real U, |
200 | const Standard_Real V, |
201 | gp_Pnt& P) const |
202 | { |
203 | mySurf.D0(U,V,P); |
204 | P.Transform(myTrsf); |
205 | } |
206 | |
207 | //======================================================================= |
208 | //function : D1 |
209 | //purpose : |
210 | //======================================================================= |
211 | |
212 | void BRepAdaptor_Surface::D1(const Standard_Real U, |
213 | const Standard_Real V, |
214 | gp_Pnt& P, |
215 | gp_Vec& D1U, |
216 | gp_Vec& D1V)const |
217 | { |
218 | mySurf.D1(U,V,P,D1U,D1V); |
219 | P.Transform(myTrsf); |
220 | D1U.Transform(myTrsf); |
221 | D1V.Transform(myTrsf); |
222 | } |
223 | |
224 | |
225 | //======================================================================= |
226 | //function : D2 |
227 | //purpose : |
228 | //======================================================================= |
229 | |
230 | void BRepAdaptor_Surface::D2(const Standard_Real U, |
231 | const Standard_Real V, |
232 | gp_Pnt& P, gp_Vec& D1U, |
233 | gp_Vec& D1V, |
234 | gp_Vec& D2U, |
235 | gp_Vec& D2V, |
236 | gp_Vec& D2UV)const |
237 | { |
238 | mySurf.D2(U,V,P,D1U,D1V,D2U,D2V,D2UV); |
239 | P.Transform(myTrsf); |
240 | D1U.Transform(myTrsf); |
241 | D1V.Transform(myTrsf); |
242 | D2U.Transform(myTrsf); |
243 | D2V.Transform(myTrsf); |
244 | D2UV.Transform(myTrsf); |
245 | } |
246 | |
247 | //======================================================================= |
248 | //function : D3 |
249 | //purpose : |
250 | //======================================================================= |
251 | |
252 | void BRepAdaptor_Surface::D3(const Standard_Real U, |
253 | const Standard_Real V, |
254 | gp_Pnt& P, |
255 | gp_Vec& D1U, gp_Vec& D1V, |
256 | gp_Vec& D2U, gp_Vec& D2V, |
257 | gp_Vec& D2UV, |
258 | gp_Vec& D3U, gp_Vec& D3V, |
259 | gp_Vec& D3UUV, gp_Vec& D3UVV)const |
260 | { |
261 | mySurf.D3(U,V,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); |
262 | P.Transform(myTrsf); |
263 | D1U.Transform(myTrsf); |
264 | D1V.Transform(myTrsf); |
265 | D2U.Transform(myTrsf); |
266 | D2V.Transform(myTrsf); |
267 | D2UV.Transform(myTrsf); |
268 | D3U.Transform(myTrsf); |
269 | D3V.Transform(myTrsf); |
270 | D3UUV.Transform(myTrsf); |
271 | D3UVV.Transform(myTrsf); |
272 | } |
273 | |
274 | |
275 | //======================================================================= |
276 | //function : DN |
277 | //purpose : |
278 | //======================================================================= |
279 | |
280 | gp_Vec BRepAdaptor_Surface::DN(const Standard_Real U, |
281 | const Standard_Real V, |
282 | const Standard_Integer Nu, |
283 | const Standard_Integer Nv) const |
284 | { |
285 | return mySurf.DN(U,V,Nu,Nv).Transformed(myTrsf); |
286 | } |
287 | |
288 | //======================================================================= |
289 | //function : Plane |
290 | //purpose : |
291 | //======================================================================= |
292 | |
293 | gp_Pln BRepAdaptor_Surface::Plane()const |
294 | { |
295 | return mySurf.Plane().Transformed(myTrsf); |
296 | } |
297 | |
298 | |
299 | //======================================================================= |
300 | //function : Cylinder |
301 | //purpose : |
302 | //======================================================================= |
303 | |
304 | gp_Cylinder BRepAdaptor_Surface::Cylinder()const |
305 | { |
306 | return mySurf.Cylinder().Transformed(myTrsf); |
307 | } |
308 | |
309 | |
310 | //======================================================================= |
311 | //function : Sphere |
312 | //purpose : |
313 | //======================================================================= |
314 | |
315 | gp_Sphere BRepAdaptor_Surface::Sphere()const |
316 | { |
317 | return mySurf.Sphere().Transformed(myTrsf); |
318 | } |
319 | |
320 | |
321 | //======================================================================= |
322 | //function : Cone |
323 | //purpose : |
324 | //======================================================================= |
325 | |
326 | gp_Cone BRepAdaptor_Surface::Cone()const |
327 | { |
328 | return mySurf.Cone().Transformed(myTrsf); |
329 | } |
330 | |
331 | //======================================================================= |
332 | //function : Torus |
333 | //purpose : |
334 | //======================================================================= |
335 | |
336 | gp_Torus BRepAdaptor_Surface::Torus()const |
337 | { |
338 | return mySurf.Torus().Transformed(myTrsf); |
339 | } |
340 | |
341 | //======================================================================= |
342 | //function : Bezier |
343 | //purpose : |
344 | //======================================================================= |
345 | |
346 | Handle(Geom_BezierSurface) BRepAdaptor_Surface::Bezier() const |
347 | { |
348 | return Handle(Geom_BezierSurface)::DownCast |
349 | (mySurf.Bezier()->Transformed(myTrsf)); |
350 | } |
351 | |
352 | |
353 | //======================================================================= |
354 | //function : BSpline |
355 | //purpose : |
356 | //======================================================================= |
357 | |
358 | Handle(Geom_BSplineSurface) BRepAdaptor_Surface::BSpline() const |
359 | { |
360 | return Handle(Geom_BSplineSurface)::DownCast |
361 | (mySurf.BSpline()->Transformed(myTrsf)); |
362 | } |
363 | |
364 | |
365 | //======================================================================= |
366 | //function : AxeOfRevolution |
367 | //purpose : |
368 | //======================================================================= |
369 | |
370 | gp_Ax1 BRepAdaptor_Surface::AxeOfRevolution() const |
371 | { |
372 | return mySurf.AxeOfRevolution().Transformed(myTrsf); |
373 | } |
374 | |
375 | |
376 | //======================================================================= |
377 | //function : Direction |
378 | //purpose : |
379 | //======================================================================= |
380 | |
381 | gp_Dir BRepAdaptor_Surface::Direction() const |
382 | { |
383 | return mySurf.Direction().Transformed(myTrsf); |
384 | } |
385 | |
386 | |
387 | //======================================================================= |
388 | //function : BasisCurve |
389 | //purpose : |
390 | //======================================================================= |
391 | |
392 | Handle(Adaptor3d_HCurve) BRepAdaptor_Surface::BasisCurve() const |
393 | { |
394 | Handle(GeomAdaptor_HSurface) HS = new GeomAdaptor_HSurface(); |
395 | HS->ChangeSurface().Load |
396 | (Handle(Geom_Surface)::DownCast(mySurf.Surface()->Transformed(myTrsf))); |
397 | |
398 | return HS->BasisCurve(); |
399 | } |
400 | |
401 | |
402 | //======================================================================= |
403 | //function : BasisSurface |
404 | //purpose : |
405 | //======================================================================= |
406 | |
407 | Handle(Adaptor3d_HSurface) BRepAdaptor_Surface::BasisSurface() const |
408 | { |
409 | Handle(GeomAdaptor_HSurface) HS = new GeomAdaptor_HSurface(); |
410 | HS->ChangeSurface().Load |
411 | (Handle(Geom_Surface)::DownCast(mySurf.Surface()->Transformed(myTrsf))); |
412 | return HS->BasisSurface(); |
413 | } |
414 | |
415 | |
416 | //======================================================================= |
417 | //function : OffsetValue |
418 | //purpose : |
419 | //======================================================================= |
420 | |
421 | Standard_Real BRepAdaptor_Surface::OffsetValue() const |
422 | { |
423 | return mySurf.OffsetValue(); |
424 | } |
425 | |