0023632: Add support for NPOT mipmap textures in TKOpenGl
[occt.git] / src / GeomToIGES / GeomToIGES_GeomSurface.cxx
CommitLineData
b311480e 1// Copyright (c) 1999-2012 OPEN CASCADE SAS
2//
3// The content of this file is subject to the Open CASCADE Technology Public
4// License Version 6.5 (the "License"). You may not use the content of this file
5// except in compliance with the License. Please obtain a copy of the License
6// at http://www.opencascade.org and read it completely before using this file.
7//
8// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
10//
11// The Original Code and all software distributed under the License is
12// distributed on an "AS IS" basis, without warranty of any kind, and the
13// Initial Developer hereby disclaims all such warranties, including without
14// limitation, any warranties of merchantability, fitness for a particular
15// purpose or non-infringement. Please see the License for the specific terms
16// and conditions governing the rights and limitations under the License.
17
7fd59977 18
19// modif du 22/10/96 mjm
20// ajout du champ TheLength
21//:l6 abv 15.01.99: CTS22022: writing full tori
22//szv#4:S4163:12Mar99
23//S4181 pdn 20.04.99 implementing of writing IGES elementary surfaces.
24//szv#10:PRO19566:05Oct99 workaround against weights array loss
25
26#include <GeomToIGES_GeomSurface.ixx>
27#include <GeomToIGES_GeomCurve.hxx>
28#include <GeomToIGES_GeomPoint.hxx>
29#include <GeomToIGES_GeomVector.hxx>
30
31#include <Geom_BSplineSurface.hxx>
32#include <Geom_BezierSurface.hxx>
33#include <Geom_BoundedSurface.hxx>
34#include <Geom_CartesianPoint.hxx>
35#include <Geom_ConicalSurface.hxx>
36#include <Geom_Circle.hxx>
37#include <Geom_Curve.hxx>
38#include <Geom_CylindricalSurface.hxx>
39#include <Geom_Curve.hxx>
40#include <Geom_Direction.hxx>
41#include <Geom_Geometry.hxx>
42#include <Geom_Line.hxx>
43#include <Geom_OffsetSurface.hxx>
44#include <Geom_Plane.hxx>
45#include <Geom_Point.hxx>
46#include <Geom_RectangularTrimmedSurface.hxx>
47#include <Geom_SphericalSurface.hxx>
48#include <Geom_Surface.hxx>
49#include <Geom_SurfaceOfLinearExtrusion.hxx>
50#include <Geom_SurfaceOfRevolution.hxx>
51#include <Geom_SweptSurface.hxx>
52#include <Geom_ToroidalSurface.hxx>
53
54#include <GeomConvert.hxx>
55
56#include <GeomLProp_SLProps.hxx>
57
58#include <IGESConvGeom_GeomBuilder.hxx>
59
60#include <IGESData_IGESEntity.hxx>
61
62#include <IGESGeom_BoundedSurface.hxx>
63#include <IGESGeom_BSplineSurface.hxx>
64#include <IGESGeom_CircularArc.hxx>
65#include <IGESGeom_CurveOnSurface.hxx>
66#include <IGESGeom_Direction.hxx>
67#include <IGESGeom_Line.hxx>
68#include <IGESGeom_OffsetSurface.hxx>
69#include <IGESGeom_Plane.hxx>
70#include <IGESGeom_Point.hxx>
71#include <IGESGeom_RuledSurface.hxx>
72#include <IGESGeom_SurfaceOfRevolution.hxx>
73#include <IGESGeom_TabulatedCylinder.hxx>
74#include <IGESGeom_TransformationMatrix.hxx>
75
76#include <IGESSolid_PlaneSurface.hxx>
77#include <Interface_Macros.hxx>
78
79#include <gce_MakeLin.hxx>
80
81#include <gp.hxx>
82#include <gp_Ax1.hxx>
83#include <gp_Ax3.hxx>
84#include <gp_Cone.hxx>
85#include <gp_Cylinder.hxx>
86#include <gp_Dir.hxx>
87#include <gp_Pln.hxx>
88#include <gp_Pnt.hxx>
89#include <gp_Sphere.hxx>
90#include <gp_Torus.hxx>
91#include <gp_Trsf.hxx>
92#include <gp_Vec.hxx>
93#include <gp_XYZ.hxx>
94
95#include <Precision.hxx>
96
97#include <TColgp_HArray2OfXYZ.hxx>
98#include <TColStd_HArray1OfReal.hxx>
99#include <TColStd_HArray2OfReal.hxx>
100#include <IGESSolid_CylindricalSurface.hxx>
101#include <IGESSolid_ConicalSurface.hxx>
102#include <IGESSolid_SphericalSurface.hxx>
103#include <IGESSolid_ToroidalSurface.hxx>
104#include <Geom_TrimmedCurve.hxx>
105
b311480e 106
7fd59977 107//=============================================================================
108// GeomToIGES_GeomSurface
109//=============================================================================
110
111GeomToIGES_GeomSurface::GeomToIGES_GeomSurface()
112:GeomToIGES_GeomEntity()
113{
114 myBRepMode = Standard_False;
115 myAnalytic = Standard_False;
116}
117
118
119//=============================================================================
120// GeomToIGES_GeomSurface
121//=============================================================================
122
123GeomToIGES_GeomSurface::GeomToIGES_GeomSurface(const GeomToIGES_GeomEntity& GE)
124 :GeomToIGES_GeomEntity(GE)
125{
126 myBRepMode = Standard_False;
127 myAnalytic = Standard_False;
128}
129
130
131//=============================================================================
132// Transfer des Entites Surface de Geom vers IGES
133// TransferSurface
134//=============================================================================
135
136Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface(const Handle(Geom_Surface)& start,
137 const Standard_Real Udeb,
138 const Standard_Real Ufin,
139 const Standard_Real Vdeb,
140 const Standard_Real Vfin)
141{
142 Handle(IGESData_IGESEntity) res;
143 if (start.IsNull()) {
144 return res;
145 }
146
147 if (start->IsKind(STANDARD_TYPE(Geom_BoundedSurface))) {
148 DeclareAndCast(Geom_BoundedSurface, Bounded, start);
149 res = TransferSurface(Bounded, Udeb, Ufin, Vdeb, Vfin);
150 }
151 else if (start->IsKind(STANDARD_TYPE(Geom_ElementarySurface))) {
152 DeclareAndCast(Geom_ElementarySurface, Elementary, start);
153 res = TransferSurface(Elementary, Udeb, Ufin, Vdeb, Vfin);
154 }
155 else if ( start->IsKind(STANDARD_TYPE(Geom_SweptSurface))) {
156 DeclareAndCast(Geom_SweptSurface, Swept, start);
157 res = TransferSurface(Swept, Udeb, Ufin, Vdeb, Vfin);
158 }
159 else if ( start->IsKind(STANDARD_TYPE(Geom_OffsetSurface))) {
160 DeclareAndCast(Geom_OffsetSurface, OffsetS, start);
161 res = TransferSurface(OffsetS, Udeb, Ufin, Vdeb, Vfin);
162 }
163
164 return res;
165}
166
167
168//=============================================================================
169// Transfer des Entites BoundedSurface de Geom vers IGES
170// TransferSurface
171//=============================================================================
172
173Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface(const Handle(Geom_BoundedSurface)& start,
174 const Standard_Real Udeb,
175 const Standard_Real Ufin,
176 const Standard_Real Vdeb,
177 const Standard_Real Vfin)
178{
179 Handle(IGESData_IGESEntity) res;
180 if (start.IsNull()) {
181 return res;
182 }
183
184 if (start->IsKind(STANDARD_TYPE(Geom_BSplineSurface))) {
185 DeclareAndCast(Geom_BSplineSurface, BSpline, start);
186 res = TransferSurface(BSpline, Udeb, Ufin, Vdeb, Vfin);
187 }
188 else if (start->IsKind(STANDARD_TYPE(Geom_BezierSurface))) {
189 DeclareAndCast(Geom_BezierSurface, Bezier, start);
190 res = TransferSurface(Bezier, Udeb, Ufin, Vdeb, Vfin);
191 }
192 else if ( start->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) {
193 DeclareAndCast(Geom_RectangularTrimmedSurface, Trimmed, start);
194 res = TransferSurface(Trimmed,Udeb, Ufin, Vdeb, Vfin);
195 }
196
197 return res;
198}
199
200
201//=============================================================================
202// Transfer des Entites BSplineSurface de Geom vers IGES
203// TransferSurface
204//=============================================================================
205
206Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface(const Handle(Geom_BSplineSurface)& start,
207 const Standard_Real Udeb,
208 const Standard_Real Ufin,
209 const Standard_Real Vdeb,
210 const Standard_Real Vfin)
211{
212 // a b-spline surface is defined by :
213 // The U and V Degree (up to 25)
214 // The Poles (and the weights if it is rational)
215 // The U and V Knots and Multiplicities
216 //
217 // The knot vector is an increasing sequence of reals without repetition.
218 // The multiplicities are the repetition of the knots.
219 //
220 // If the knots are regularly spaced (the difference of two consecutive knots
221 // is a constant),
222 // the knots repartition (in U or V) is :
223 // - Uniform if all multiplicities are 1.
224 // - Quasi-uniform if all multiplicities are 1
225 // but the first and the last which are Degree+1.
226 // - PiecewiseBezier if all multiplicites are
227 // Degree but the first and the last which are
228 // Degree+1.
229 //
230 // The surface may be periodic in U and in V.
231 // On a U periodic surface if there are k U knots
232 // and the poles table has p rows. the U period
233 // is uknot(k) - uknot(1)
234 //
235 // the poles and knots are infinite vectors with :
236 // uknot(i+k) = uknot(i) + period
237 // pole(i+p,j) = pole(i,j)
238
239
240 Handle(IGESData_IGESEntity) res;
241 TheLength = 1;
242 if (start.IsNull()) {
243 return res;
244 }
245
246 Handle(IGESGeom_BSplineSurface) BSpline = new IGESGeom_BSplineSurface;
247 Handle(Geom_BSplineSurface) mysurface;
248
249 Standard_Boolean PeriodU = start->IsUPeriodic();
250 Standard_Boolean PeriodV = start->IsVPeriodic();
251 if (PeriodU || PeriodV) {
252 mysurface = Handle(Geom_BSplineSurface)::DownCast(start->Copy());
253
254 //szv#10:PRO19566:05Oct99
255 Standard_Boolean workaround = !(mysurface->IsURational() || mysurface->IsVRational());
256 if (workaround) mysurface->SetWeight(1,1,0.3);
257
258 if ( PeriodU ) mysurface->SetUNotPeriodic();
259 if ( PeriodV ) mysurface->SetVNotPeriodic();
260
261 //szv#10:PRO19566:05Oct99
262 if (workaround) mysurface->SetWeight(1,1,1.);
263 }
264 else {
265 mysurface = start;
266 }
267
268 Standard_Integer DegU = mysurface->UDegree();
269 Standard_Integer DegV = mysurface->VDegree();
270 Standard_Boolean CloseU = mysurface->IsUClosed();
271 Standard_Boolean CloseV = mysurface->IsVClosed();
272 //Standard_Boolean PeriodU = start->IsUPeriodic();
273 //Standard_Boolean PeriodV = start->IsVPeriodic();
274 Standard_Boolean RationU = mysurface->IsURational();
275 Standard_Boolean RationV = mysurface->IsVRational();
276 Standard_Integer NbUPoles = mysurface->NbUPoles();
277 Standard_Integer NbVPoles = mysurface->NbVPoles();
278 Standard_Integer IndexU = NbUPoles -1;
279 Standard_Integer IndexV = NbVPoles -1;
280 Standard_Boolean Polynom = !(RationU || RationV); //szv#10:PRO19566:05Oct99 && was wrong
281
282 // filling knots array for U :
283 // Sequence des Knots de [-DegU, IndexU+1] dans IGESGeom.
284 Standard_Integer Knotindex;
285 Standard_Real rtampon;
286 Standard_Integer itampon;
287 TColStd_Array1OfReal KU(1, NbUPoles+ DegU+ 1);
288 mysurface->UKnotSequence(KU);
289 itampon = -DegU;
290 Handle(TColStd_HArray1OfReal) KnotsU =
291 new TColStd_HArray1OfReal(-DegU,IndexU+1 );
292 for ( Knotindex=KU.Lower(); Knotindex<=KU.Upper(); Knotindex++) {
293 rtampon = KU.Value(Knotindex);
294 KnotsU->SetValue(itampon, rtampon);
295 itampon++;
296 }
297
298 // filling knots array for V :
299 // Sequence des Knots de [-DegV, IndexV+1] dans IGESGeom.
300 TColStd_Array1OfReal KV(1, NbVPoles+ DegV+ 1);
301 mysurface->VKnotSequence(KV);
302 itampon = -DegV;
303 Handle(TColStd_HArray1OfReal) KnotsV =
304 new TColStd_HArray1OfReal(-DegV, IndexV+1);
305 for ( Knotindex=KV.Lower(); Knotindex<=KV.Upper(); Knotindex++) {
306 rtampon = KV.Value(Knotindex);
307 KnotsV->SetValue(itampon, rtampon);
308 itampon++;
309 }
310
311 // filling Weights array de [0, IndexU, 0, IndexV]
312 // ----------------------------------------------
313 Handle(TColStd_HArray2OfReal) Weights =
314 new TColStd_HArray2OfReal(0 , IndexU, 0, IndexV);
315 Standard_Integer WeightRow = Weights->LowerRow();
316 Standard_Integer WeightCol = Weights->LowerCol();
317 Standard_Integer iw, jw;
318
319 if(RationU || RationV) {
320 for ( iw = 1; iw<= IndexU+1; iw++) {
321 for ( jw = 1; jw<= IndexV+1; jw++)
322 Weights->SetValue(WeightRow, WeightCol++, mysurface->Weight(iw,jw));
323 WeightRow++;
324 WeightCol = Weights->LowerCol();
325 }
326 } else {
327 for ( iw = 1; iw<= IndexU+1; iw++) {
328 for ( jw = 1; jw<= IndexV+1; jw++)
329 Weights->SetValue(WeightRow, WeightCol++, 1.0);
330 WeightRow++;
331 WeightCol = Weights->LowerCol();
332 }
333
334 }
335
336 // filling Poles array de [0, IndexU, 0, IndexV]
337 // ---------------------------------------------
338 Handle(TColgp_HArray2OfXYZ) Poles =
339 new TColgp_HArray2OfXYZ(0, IndexU, 0, IndexV);
340 Standard_Integer UIndex = Poles->LowerRow();
341 Standard_Integer VIndex = Poles->LowerCol();
342 Standard_Integer ipole, jpole;
343 Standard_Real Xd, Yd, Zd;
344
345 for ( ipole = 1; ipole<= IndexU+1; ipole++) {
346 for ( jpole = 1; jpole<= IndexV+1; jpole++) {
347 gp_Pnt tempPnt = mysurface-> Pole(ipole, jpole);
348 tempPnt.Coord(Xd, Yd, Zd);
349 gp_XYZ PXYZ = gp_XYZ( Xd/GetUnit(), Yd/GetUnit(), Zd/GetUnit());
350 Poles->SetValue(UIndex, VIndex++, PXYZ);
351 }
352 UIndex++;
353 VIndex = Poles->LowerCol();
354 }
355
356 // mjm le 9/10/97 mise en place d`une protection
357 Standard_Real U1,U2,V1,V2;
358 Standard_Real Umin = Udeb;
359 Standard_Real Umax = Ufin;
360 Standard_Real Vmin = Vdeb;
361 Standard_Real Vmax = Vfin;
362 mysurface->Bounds(U1,U2,V1,V2);
363 if ( U1 > Umin ) Umin = U1;
364 if ( V1 > Vmin ) Vmin = V1;
365 if ( U2 < Umax ) Umax = U2;
366 if ( V2 < Vmax ) Vmax = V2;
367
368 BSpline-> Init (IndexU, IndexV, DegU, DegV, CloseU, CloseV, Polynom, PeriodU,
369 PeriodV, KnotsU, KnotsV, Weights, Poles, Umin, Umax, Vmin, Vmax);
370 res = BSpline;
371 return res;
372}
373
374
375//=============================================================================
376// Transfer des Entites BezierSurface de Geom vers IGES
377// TransferSurface
378//=============================================================================
379
380Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface(const Handle(Geom_BezierSurface)& start,
381 const Standard_Real /*Udeb*/,
382 const Standard_Real /*Ufin*/,
383 const Standard_Real /*Vdeb*/,
384 const Standard_Real /*Vfin*/)
385{
386 Handle(IGESData_IGESEntity) res;
387 if (start.IsNull()) {
388 return res;
389 }
390
391 Handle(Geom_BSplineSurface) Bspline =
392 GeomConvert::SurfaceToBSplineSurface(start);
393 Standard_Real U1,U2,V1,V2;
394 Bspline->Bounds(U1,U2,V1,V2);
395 res = TransferSurface(Bspline, U1, U2, V1, V2);
396 return res;
397}
398
399
400//=============================================================================
401// Transfer des Entites RectangularTrimmedSurface de Geom vers IGES
402// TransferSurface
403//=============================================================================
404
405Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface(const Handle(Geom_RectangularTrimmedSurface)& start,
406 const Standard_Real Udeb,
407 const Standard_Real Ufin,
408 const Standard_Real Vdeb,
409 const Standard_Real Vfin)
410{
411 Handle(IGESData_IGESEntity) res;
412 if (start.IsNull()) {
413 return res;
414 }
415
416 Handle(Geom_Surface) st = start->BasisSurface();
417 if (st->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) {
418 //message d'erreur pas de trimmed a partir d'une trimmed ,
419 //on peut eventuellement ecrire la surface de base : st.
420 return res;
421 }
422
423 res = TransferSurface(st, Udeb, Ufin, Vdeb, Vfin);
424 return res;
425
426}
427
428
429//=============================================================================
430// Transfer des Entites ElementarySurface de Geom vers IGES
431// TransferSurface
432//=============================================================================
433
434Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface(const Handle(Geom_ElementarySurface)& start,
435 const Standard_Real Udeb,
436 const Standard_Real Ufin,
437 const Standard_Real Vdeb,
438 const Standard_Real Vfin)
439{
440 Handle(IGESData_IGESEntity) res;
441 // All these entities are located in 3D space with an axis
442 // placement (Location point, XAxis, YAxis, ZAxis). It is
443 // their local coordinate system.
444
445 //S4181 pdn 16.04.99 Hereunder, the implementation of translation of CAS.CADE
446 // elementary surfaces into different types of IGES surfaces according to boolean flags
447 if (start.IsNull()) {
448 return res;
449 }
450 if (start->IsKind(STANDARD_TYPE(Geom_Plane))) {
451 DeclareAndCast(Geom_Plane, Plane, start);
452 if(myBRepMode)
453 res = TransferPlaneSurface(Plane, Udeb, Ufin, Vdeb, Vfin);
454 else
455 res = TransferSurface(Plane, Udeb, Ufin, Vdeb, Vfin);
456 }
457 else if (start->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) {
458 DeclareAndCast(Geom_CylindricalSurface, Cylindrical, start);
459 if(myBRepMode&&myAnalytic)
460 res = TransferCylindricalSurface(Cylindrical, Udeb, Ufin, Vdeb, Vfin);
461 else
462 res = TransferSurface(Cylindrical, Udeb, Ufin, Vdeb, Vfin);
463 }
464 else if ( start->IsKind(STANDARD_TYPE(Geom_ConicalSurface))) {
465 DeclareAndCast(Geom_ConicalSurface, Conical, start);
466 if(myBRepMode&&myAnalytic)
467 res = TransferConicalSurface(Conical, Udeb, Ufin, Vdeb, Vfin);
468 else
469 res = TransferSurface(Conical, Udeb, Ufin, Vdeb, Vfin);
470 }
471 else if (start->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) {
472 DeclareAndCast(Geom_SphericalSurface, Spherical, start);
473 if(myBRepMode&&myAnalytic)
474 res = TransferSphericalSurface(Spherical, Udeb, Ufin, Vdeb, Vfin);
475 else
476 res = TransferSurface(Spherical, Udeb, Ufin, Vdeb, Vfin);
477 }
478 else if ( start->IsKind(STANDARD_TYPE(Geom_ToroidalSurface))) {
479 DeclareAndCast(Geom_ToroidalSurface, Toroidal, start);
480 if(myBRepMode&&myAnalytic)
481 res = TransferToroidalSurface(Toroidal, Udeb, Ufin, Vdeb, Vfin);
482 else
483 res = TransferSurface(Toroidal, Udeb, Ufin, Vdeb, Vfin);
484 }
485
486 return res;
487
488}
489
490
491//=============================================================================
492// Transfer des Entites Plane de Geom vers IGES
493// TransferSurface
494//=============================================================================
495
496Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface(const Handle(Geom_Plane)& start,
497 const Standard_Real Udeb,
498 const Standard_Real Ufin,
499 const Standard_Real Vdeb,
500 const Standard_Real Vfin)
501{
502 // on va ecrire une BSplineSurface pour pouvoir etre coherent avec les courbes 2d
503 Handle(IGESData_IGESEntity) res;
504 TheLength = 1;
505 if (start.IsNull()) {
506 return res;
507 }
508
509 Handle(IGESGeom_BSplineSurface) BSpline = new IGESGeom_BSplineSurface;
510 gp_Pnt P1 ,P2, P3, P4;
511 start->D0(Udeb, Vdeb, P1);
512 start->D0(Udeb, Vfin, P2);
513 start->D0(Ufin, Vdeb, P3);
514 start->D0(Ufin, Vfin, P4);
515 Handle(TColgp_HArray2OfXYZ) Poles = new TColgp_HArray2OfXYZ(0, 1, 0, 1);
516 Standard_Real X,Y,Z;
517 P1.Coord(X,Y,Z);
518 Poles->SetValue (0, 0, gp_XYZ(X/GetUnit(),Y/GetUnit(),Z/GetUnit()));
519 P2.Coord(X,Y,Z);
520 Poles->SetValue (0, 1, gp_XYZ(X/GetUnit(),Y/GetUnit(),Z/GetUnit()));
521 P3.Coord(X,Y,Z);
522 Poles->SetValue (1, 0, gp_XYZ(X/GetUnit(),Y/GetUnit(),Z/GetUnit()));
523 P4.Coord(X,Y,Z);
524 Poles->SetValue (1, 1, gp_XYZ(X/GetUnit(),Y/GetUnit(),Z/GetUnit()));
525
526 Handle(TColStd_HArray1OfReal) KnotsU = new TColStd_HArray1OfReal(-1,2);
527 KnotsU->SetValue(-1, Udeb);
528 KnotsU->SetValue(0, Udeb);
529 KnotsU->SetValue(1, Ufin);
530 KnotsU->SetValue(2, Ufin);
531
532 Handle(TColStd_HArray1OfReal) KnotsV = new TColStd_HArray1OfReal(-1,2);
533 KnotsV->SetValue(-1, Vdeb);
534 KnotsV->SetValue(0, Vdeb);
535 KnotsV->SetValue(1, Vfin);
536 KnotsV->SetValue(2, Vfin);
537
538 Handle(TColStd_HArray2OfReal) Weights =
539 new TColStd_HArray2OfReal(0, 1, 0, 1, 1.);
540
541 //#32 rln 19.10.98
542 BSpline-> Init ( 1, 1, 1, 1, Standard_False , Standard_False, Standard_True,
543 Standard_False, Standard_False,
544 KnotsU, KnotsV, Weights, Poles, Udeb, Ufin, Vdeb, Vfin);
545 res = BSpline;
546 return res;
547
548}
549
550
551//=============================================================================
552// Transfer des Entites CylindricalSurface de Geom vers IGES
553// TransferSurface
554//=============================================================================
555
556Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface
557( const Handle(Geom_CylindricalSurface)& start, const Standard_Real Udeb,
558 const Standard_Real Ufin, const Standard_Real Vdeb, const Standard_Real Vfin)
559{
560 // The "ZAxis" is the symmetry axis of the CylindricalSurface,
561 // it gives the direction of increasing parametric value V.
562 // The parametrization range is :
563 // U [0, 2*PI], V ]- infinite, + infinite[
564 // The "XAxis" and the "YAxis" define the placement plane of the
565 // surface (Z = 0, and parametric value V = 0) perpendicular to
566 // the symmetry axis. The "XAxis" defines the origin of the
567 // parameter U = 0. The trigonometric sense gives the positive
568 // orientation for the parameter U.
569
570 Handle(IGESData_IGESEntity) res;
571 TheLength = 1;
572 if (start.IsNull()) {
573 return res;
574 }
575
576 Handle(IGESGeom_SurfaceOfRevolution) Surf = new IGESGeom_SurfaceOfRevolution;
577 Standard_Real U1 = Udeb;
578 Standard_Real U2 = Ufin;
579 Standard_Real V1 = Vdeb;
580 Standard_Real V2 = Vfin;
581 if (Precision::IsNegativeInfinite(Vdeb)) V1 = -Precision::Infinite();
582 if (Precision::IsPositiveInfinite(Vfin)) V2 = Precision::Infinite();
583
584 // creation de la generatrice : Generatrix
585 Handle(Geom_Line) Ligne =
586 new Geom_Line (gp_Pnt(start->Cylinder().Radius(), 0.0, 0.0),
587 gp_Dir(0.0, 0.0, 1.0));
588 GeomToIGES_GeomCurve GC(*this);
589 Handle(IGESData_IGESEntity) Generatrix = GC.TransferCurve( Ligne, V1, V2);
590 gp_Pnt gen1 = Ligne->Value(V1);
591 gp_Pnt gen2 = Ligne->Value(V2);
592 TheLength = gen1.Distance(gen2);
593
594
595 // creation de l`axe : Axis .
596 Handle(IGESGeom_Line) Axis = new IGESGeom_Line;
597 //#30 rln 19.10.98 IGES axis = reversed CAS.CADE axis
598 //Axis->Init(gp_XYZ(0.0, 0.0, 0.0), gp_XYZ(0.0, 0.0, 1.0/GetUnit()));
599 //Surf->Init (Axis, Generatrix, U1, U2);
600 Axis->Init(gp_XYZ (0, 0, 1. / GetUnit()), gp_XYZ (0, 0, 0));
c6541a0c 601 Surf->Init (Axis, Generatrix, 2 * M_PI - U2, 2 * M_PI - U1);
7fd59977 602
603
604 // creation de la Trsf (#124)
605 // il faut tenir compte de l`unite pour la matrice de transformation
606 // (partie translation).
607 IGESConvGeom_GeomBuilder Build;
608 Standard_Real xloc,yloc,zloc;
609 start->Cylinder().Location().Coord(xloc,yloc,zloc);
610 gp_Pnt Loc;
611 Loc.SetCoord(xloc, yloc, zloc);
612 gp_Ax3 Pos = start->Cylinder().Position();
613 Pos.SetLocation(Loc);
614 Build.SetPosition(Pos);
615 if (!Build.IsIdentity()){
616 Handle(IGESGeom_TransformationMatrix) TMat =
617 new IGESGeom_TransformationMatrix;
618 TMat = Build.MakeTransformation(GetUnit());
619 Surf->InitTransf(TMat);
620 }
621 res = Surf;
622 return res;
623
624}
625
626
627//=============================================================================
628// Transfer des Entites ConicalSurface de Geom vers IGES
629// TransferSurface
630//=============================================================================
631
632Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface
633( const Handle(Geom_ConicalSurface)& start, const Standard_Real Udeb,
634 const Standard_Real Ufin, const Standard_Real Vdeb, const Standard_Real Vfin)
635{
636 // The "ZAxis" is the symmetry axis of the ConicalSurface,
637 // it gives the direction of increasing parametric value V.
638 // The apex of the surface is on the negative side of this axis.
639 // The parametrization range is :
640 // U [0, 2*PI], V ]-infinite, + infinite[
641 // The "XAxis" and the "YAxis" define the placement plane of the
642 // surface (Z = 0, and parametric value V = 0) perpendicular to
643 // the symmetry axis. The "XAxis" defines the origin of the
644 // parameter U = 0. The trigonometric sense gives the positive
645 // orientation for the parameter U.
646
647
648 Handle(IGESData_IGESEntity) res;
649 TheLength = 1;
650 if (start.IsNull()) {
651 return res;
652 }
653 Handle(IGESGeom_SurfaceOfRevolution) Surf = new IGESGeom_SurfaceOfRevolution;
654 Standard_Real U1 = Udeb;
655 Standard_Real U2 = Ufin;
656 Standard_Real V1 = Vdeb;
657 Standard_Real V2 = Vfin;
658 if (Precision::IsNegativeInfinite(Vdeb)) V1 = -Precision::Infinite();
659 if (Precision::IsPositiveInfinite(Vfin)) V2 = Precision::Infinite();
660
661 // creation de la generatrice : Generatrix
662 Handle(Geom_Line) Ligne =
663 new Geom_Line( gp_Pnt(start->Cone().RefRadius(), 0.0, 0.0),
664 gp_Dir(sin(start->Cone().SemiAngle()), 0.,
665 cos(start->Cone().SemiAngle())));
666 GeomToIGES_GeomCurve GC(*this);
667 Handle(IGESData_IGESEntity) Generatrix = GC.TransferCurve( Ligne, V1, V2);
668 gp_Pnt gen1 = Ligne->Value(V1);
669 gp_Pnt gen2 = Ligne->Value(V2);
670// TheLength = gen1.Distance(gen2)*Cos(start->Cone().SemiAngle());
671 TheLength = gen1.Distance(gen2);
672
673 // creation de l`axe : Axis .
674 Handle(IGESGeom_Line) Axis = new IGESGeom_Line;
675 //#30 rln 19.10.98 IGES axis = reversed CAS.CADE axis
676 //Axis->Init(gp_XYZ(0.0, 0.0, 0.0), gp_XYZ(0.0, 0.0, 1.0/GetUnit()));
677 //Surf->Init (Axis, Generatrix, U1, U2);
678 Axis->Init(gp_XYZ (0, 0, 1. / GetUnit()), gp_XYZ (0, 0, 0));
c6541a0c 679 Surf->Init (Axis, Generatrix, 2 * M_PI - U2, 2 * M_PI - U1);
7fd59977 680
681
682 // creation de la Trsf (#124)
683 // il faut tenir compte de l`unite pour la matrice de transformation
684 // (partie translation).
685 IGESConvGeom_GeomBuilder Build;
686 Standard_Real xloc,yloc,zloc;
687 start->Cone().Location().Coord(xloc,yloc,zloc);
688 gp_Pnt Loc;
689 Loc.SetCoord(xloc, yloc, zloc);
690 gp_Ax3 Pos = start->Cone().Position();
691 Pos.SetLocation(Loc);
692 Build.SetPosition(Pos);
693 if (!Build.IsIdentity()){
694 Handle(IGESGeom_TransformationMatrix) TMat =
695 new IGESGeom_TransformationMatrix;
696 TMat = Build.MakeTransformation(GetUnit());
697 Surf->InitTransf(TMat);
698 }
699 res = Surf;
700 return res;
701
702}
703
704
705//=============================================================================
706// Transfer des Entites SphericalSurface de Geom vers IGES
707// TransferSurface
708//=============================================================================
709
710Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface
711( const Handle(Geom_SphericalSurface)& start, const Standard_Real Udeb,
712 const Standard_Real Ufin, const Standard_Real Vdeb, const Standard_Real Vfin)
713{
714 // The center of the sphere is the "Location" point of the local
715 // coordinate system.
716 // The V isoparametric curves of the surface are defined by
717 // the section of the spherical surface with plane parallel to the
718 // plane (Location, XAxis, YAxis). This plane defines the origin of
719 // parametrization V.
720 // The U isoparametric curves of the surface are defined by the
721 // section of the spherical surface with plane obtained by rotation
722 // of the plane (Location, XAxis, ZAxis) around ZAxis. This plane
723 // defines the origin of parametrization u.
724 // The parametrization range is U [0, 2*PI], V [- PI/2, + PI/2]
725
726 Handle(IGESData_IGESEntity) res;
727 TheLength = 1;
728 if (start.IsNull()) {
729 return res;
730 }
731
732 Handle(IGESGeom_SurfaceOfRevolution) Surf = new IGESGeom_SurfaceOfRevolution;
733
734 Standard_Real U1 = Udeb;
735 Standard_Real U2 = Ufin;
736 Standard_Real V1 = Vdeb;
737 Standard_Real V2 = Vfin;
738
739 // creation de la generatrice : Generatrix (1/2 cercle)
740 gp_Ax2 Axe(gp::Origin(), -gp::DY(), gp::DX());
741 Handle(Geom_Circle) Cercle =
742 new Geom_Circle(Axe, start->Sphere().Radius());
743 GeomToIGES_GeomCurve GC(*this);
744 Handle(IGESData_IGESEntity) Gen = GC.TransferCurve( Cercle, V1, V2);
745
746 // creation de l`axe : Axis .
747 Handle(IGESGeom_Line) Axis = new IGESGeom_Line;
748 //#30 rln 19.10.98 IGES axis = reversed CAS.CADE axis
749 //Axis->Init(gp_XYZ(0.0, 0.0, 0.0), gp_XYZ(0.0, 0.0, 1.0/GetUnit()));
750 Axis->Init(gp_XYZ (0, 0, 1. / GetUnit()), gp_XYZ (0, 0, 0));
751
752 if ( Gen->IsKind(STANDARD_TYPE(IGESGeom_CircularArc))) {
753 //#30 rln 19.10.98 Surf->Init (Axis, Gen, U1, U2);
c6541a0c 754 Surf->Init (Axis, Gen, 2 * M_PI - U2, 2 * M_PI - U1);
7fd59977 755 IGESConvGeom_GeomBuilder Build;
756 Standard_Real xloc,yloc,zloc;
757 start->Sphere().Location().Coord(xloc,yloc,zloc);
758 gp_Pnt Loc;
759 Loc.SetCoord(xloc, yloc, zloc);
760 gp_Ax3 Pos = start->Sphere().Position();
761 Pos.SetLocation(Loc);
762 Build.SetPosition(Pos);
763 if (!Build.IsIdentity()){
764 Handle(IGESGeom_TransformationMatrix) TMat =
765 new IGESGeom_TransformationMatrix;
766 TMat = Build.MakeTransformation(GetUnit());
767 Surf->InitTransf(TMat);
768 }
769 }
770 res = Surf;
771 return res;
772}
773
774
775//=============================================================================
776// Transfer des Entites ToroidalSurface de Geom vers IGES
777// TransferSurface
778//=============================================================================
779
780Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface
781( const Handle(Geom_ToroidalSurface)& start, const Standard_Real Udeb,
782 const Standard_Real Ufin, const Standard_Real Vdeb, const Standard_Real Vfin)
783{
784 // The "Location point" of the axis placement is the center
785 // of the surface.
786 // The plane (Location, XAxis, ZAxis) defines the origin of the
787 // parametrization U. The plane (Location, XAxis, YAxis)
788 // defines the origin of the parametrization V.
789 // The parametrization range is U [0, 2*PI], V [0, 2*PI]
790
791
792 Handle(IGESData_IGESEntity) res;
793 TheLength = 1;
794 if (start.IsNull()) {
795 return res;
796 }
797
798 Handle(IGESGeom_SurfaceOfRevolution) Surf = new IGESGeom_SurfaceOfRevolution;
799 Standard_Real U1 = Udeb;
800 Standard_Real U2 = Ufin;
801 Standard_Real V1 = Vdeb;
802 Standard_Real V2 = Vfin;
803
7fd59977 804 // creation de la generatrice : Generatrix (cercle)
805 gp_Ax2 Axe = gp_Ax2(gp_Pnt((start->Torus().MajorRadius()), 0., 0.),
806 -gp::DY(), gp::DX());
807 Handle(Geom_Circle) Cercle =
808 new Geom_Circle(Axe, start->Torus().MinorRadius());
809 GeomToIGES_GeomCurve GC(*this);
810 Handle(IGESData_IGESEntity) Gen = GC.TransferCurve( Cercle, V1, V2);
811
812 // creation de l`axe : Axis .
813 Handle(IGESGeom_Line) Axis = new IGESGeom_Line;
814 //#30 rln 19.10.98 IGES axis = reversed CAS.CADE axis
815 //Axis->Init(gp_XYZ(0.0, 0.0, 0.0), gp_XYZ(0.0, 0.0, 1.0/GetUnit()));
816 Axis->Init(gp_XYZ (0, 0, 1. / GetUnit()), gp_XYZ (0, 0, 0));
817
818//:l6 abv: CTS22022: writing full tori: if ( Gen->IsKind(STANDARD_TYPE(IGESGeom_CircularArc))) {
819 //#30 rln 19.10.98 Surf->Init (Axis, Gen, U1, U2);
c6541a0c 820 Surf->Init (Axis, Gen, 2 * M_PI - U2, 2 * M_PI - U1);
7fd59977 821 IGESConvGeom_GeomBuilder Build;
822/* //:l6: useless
823 Standard_Real xloc,yloc,zloc;
824 start->Torus().Location().Coord(xloc,yloc,zloc);
825 gp_Pnt Loc;
826 Loc.SetCoord(xloc, yloc, zloc);
827*/
828 gp_Ax3 Pos = start->Torus().Position();
829//:l6 Pos.SetLocation(Loc);
830 Build.SetPosition(Pos);
831 if (!Build.IsIdentity()){
832 Handle(IGESGeom_TransformationMatrix) TMat =
833 new IGESGeom_TransformationMatrix;
834 TMat = Build.MakeTransformation(GetUnit());
835 Surf->InitTransf(TMat);
836 }
837//:l6 }
838 res = Surf;
839 return res;
840
841}
842
843//=============================================================================
844// Transfer des Entites SweptSurface de Geom vers IGES
845// TransferSurface
846//=============================================================================
847
848Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface
849( const Handle(Geom_SweptSurface)& start, const Standard_Real Udeb,
850 const Standard_Real Ufin, const Standard_Real Vdeb, const Standard_Real Vfin)
851{
852 Handle(IGESData_IGESEntity) res;
853 if (start.IsNull()) {
854 return res;
855 }
856
857 if (start->IsKind(STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion))) {
858 DeclareAndCast(Geom_SurfaceOfLinearExtrusion, Extrusion, start);
859 res = TransferSurface(Extrusion, Udeb, Ufin, Vdeb, Vfin);
860 }
861 else if (start->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) {
862 DeclareAndCast(Geom_SurfaceOfRevolution, Revolution, start);
863 res = TransferSurface(Revolution, Udeb, Ufin, Vdeb, Vfin);
864 }
865
866 return res;
867
868}
869
870//=============================================================================
871// Transfer des Entites SurfaceOfLinearExtrusion de Geom vers IGES
872// TransferSurface
873//=============================================================================
874
875Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface
876( const Handle(Geom_SurfaceOfLinearExtrusion)& start, const Standard_Real Udeb,
877 const Standard_Real Ufin, const Standard_Real Vdeb, const Standard_Real Vfin)
878{
879 // This surface is obtained by sweeping a curve in a given direction.
880 // The parametrization range for the parameter U is defined with the
881 // referenced curve.
882 // The parametrization range for the parameter V is
883 // ]-infinite, + infinite[
884 // The position of the curve gives the origin for the parameter V.
885
886
887 Handle(IGESData_IGESEntity) res;
888 TheLength = 1;
889 if (start.IsNull()) {
890 return res;
891 }
892
893 Handle(IGESGeom_TabulatedCylinder) Surf = new IGESGeom_TabulatedCylinder;
894 Standard_Real U1 = Udeb;
895 Standard_Real U2 = Ufin;
896 Standard_Real V1 = Vdeb;
897 Standard_Real V2 = Vfin;
898 if (Precision::IsNegativeInfinite(Vdeb)) V1 = -Precision::Infinite();
899 if (Precision::IsPositiveInfinite(Vfin)) V2 = Precision::Infinite();
900
901 // added by skl 18.07.2005 for OCC9490
902 Standard_Real UF,UL,VF,VL;
903 start->Bounds(UF,UL,VF,VL);
904 U1=UF;
905 U2=UL;
906
907 Handle(Geom_Curve) TheCurve = start->BasisCurve();
908
909 //dans IGES l'origine de la generatrice est identique a l'origine
910 //de la directrice , il faut translater la courbe si les deux
911 //points ne sont pas confondus dans Geom et donc la copier !!!!!!!
912 gp_Pnt TheEnd = start->Value(U1,V2);
913 Standard_Real Xe, Ye, Ze;
914 TheEnd.Coord(Xe, Ye, Ze);
915 gp_XYZ End = gp_XYZ (Xe/GetUnit(), Ye/GetUnit(), Ze/GetUnit());
916
917 GeomToIGES_GeomCurve GC(*this);
918// commented by skl 18.07.2005 for OCC9490
919 Handle(Geom_Curve) CopyCurve;
920 if ( Abs(V1) > Precision::Confusion()) {
921 CopyCurve = Handle(Geom_Curve)::DownCast
922 (TheCurve->Translated (start->Value(U1,0.), start->Value(U1,V1)));
923 }
924 else {
925 CopyCurve = TheCurve;
926 }
927 //Handle(IGESData_IGESEntity) Directrix = GC.TransferCurve( CopyCurve, V1, V2);
928 Handle(IGESData_IGESEntity) Directrix = GC.TransferCurve( CopyCurve, U1, U2);
929 //Handle(IGESData_IGESEntity) Directrix = GC.TransferCurve( TheCurve, U1, U2);
930 //gp_Pnt gen1 = start->Value(U1,V1);
931 //TheLength = gen1.Distance(TheEnd);
932
933 Surf->Init (Directrix, End);
934 res = Surf;
935 return res;
936
937}
938
939//=============================================================================
940// Transfer des Entites SurfaceOfRevolution de Geom vers IGES
941// TransferSurface
942//=============================================================================
943
944Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface
945( const Handle(Geom_SurfaceOfRevolution)& start, const Standard_Real Udeb,
946 const Standard_Real Ufin, const Standard_Real Vdeb, const Standard_Real Vfin)
947{
948 // The surface is obtained by rotating a curve a complete revolution
949 // about an axis. The curve and the axis must be in the same plane.
950 // For a complete surface of revolution the parametric range is
951 // 0 <= U <= 2*PI.
952 // The parametric range for V is defined with the revolved curve.
953 // The origin of the U parametrization is given by the position
954 // of the revolved curve (reference). The direction of the revolution
955 // axis defines the positive sense of rotation (trigonometric sense)
956 // corresponding to the increasing of the parametric value U.
957 // The derivatives are always defined for the u direction.
958 // For the v direction the definition of the derivatives depends on
959 // the degree of continuity of the referenced curve.
960
961 Handle(IGESData_IGESEntity) res;
962 TheLength = 1;
963 if (start.IsNull()) {
964 return res;
965 }
966
967 Handle(IGESGeom_SurfaceOfRevolution) Surf = new IGESGeom_SurfaceOfRevolution;
968 Standard_Real U1 = Udeb;
969 Standard_Real U2 = Ufin;
970 Standard_Real V1 = Vdeb;
971 Standard_Real V2 = Vfin;
972 if (Precision::IsNegativeInfinite(Vdeb)) V1 = -Precision::Infinite();
973 if (Precision::IsPositiveInfinite(Vfin)) V2 = Precision::Infinite();
974
975 // creation de la generatrice : Generatrix
976 Handle(Geom_Curve) Curve = start->BasisCurve();
977 GeomToIGES_GeomCurve GC(*this);
978 Handle(IGESData_IGESEntity) Generatrix = GC.TransferCurve( Curve, V1, V2);
979 //pdn BUC184: decoding a trimmed curve
980 while( Curve->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
981 Handle(Geom_TrimmedCurve) aTrCurve = Handle(Geom_TrimmedCurve)::
982 DownCast(Curve);
983 Curve = aTrCurve->BasisCurve();
984 }
985
986 if ( Curve->IsKind(STANDARD_TYPE(Geom_Line))) {
987 DeclareAndCast(Geom_Line, Line, Curve);
988 gp_Pnt gen1 = Line->Value(V1);
989 gp_Pnt gen2 = Line->Value(V2);
990 TheLength = gen1.Distance(gen2);
991 }
992
993 // creation de l`axe : Axis .
994 Handle(IGESGeom_Line) Axis = new IGESGeom_Line;
995 gp_Ax1 Axe = start->Axis();
996 Standard_Real X1,Y1,Z1,X2,Y2,Z2;
997 Axe.Location().Coord(X1,Y1,Z1);
998 Axe.Direction().Coord(X2,Y2,Z2);
999
1000 //#30 rln 19.10.98 IGES axis = reversed CAS.CADE axis
1001 //Axis->Init(gp_XYZ(X1/GetUnit(),Y1/GetUnit(),Z1/GetUnit()),
1002 // gp_XYZ(X2/GetUnit(),Y2/GetUnit(),Z2/GetUnit()));
1003 //#36 rln 27.10.98 BUC60328 face 7
1004 Axis->Init(gp_XYZ(X1/GetUnit(),Y1/GetUnit(),Z1/GetUnit()),
1005 gp_XYZ( (X1 - X2) / GetUnit(), (Y1 - Y2) / GetUnit(), (Z1 - Z2) / GetUnit()));
1006
c6541a0c 1007 Surf->Init (Axis, Generatrix, 2 * M_PI - U2, 2 * M_PI - U1);
7fd59977 1008 res = Surf;
1009 return res;
1010
1011}
1012
1013
1014//=============================================================================
1015// Transfer des Entites OffsetSurface de Geom vers IGES
1016// TransferSurface
1017//=============================================================================
1018
1019Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSurface
1020( const Handle(Geom_OffsetSurface)& start, const Standard_Real Udeb, const Standard_Real
1021 Ufin, const Standard_Real Vdeb, const Standard_Real Vfin)
1022{
1023 // An offset surface is a surface at constant distance
1024 // (Offset) from a basis surface. The distance may be positive
1025 // or negative to the preferred side of the surface.
1026 // The positive side is defined by the cross product D1u ^ D1v
1027 // where D1u and D1v are the tangent vectors of the basis
1028 // surface in the U and V parametric directions. The previous
1029 // cross product defines the normal direction to the basis
1030 // surface.
1031
1032 Handle(IGESData_IGESEntity) res;
1033 if (start.IsNull()) {
1034 return res;
1035 }
1036
1037 Handle(IGESGeom_OffsetSurface) Surf = new IGESGeom_OffsetSurface;
1038 Handle(Geom_Surface) TheSurf = start->BasisSurface();
1039 Standard_Real U1, U2, V1, V2 , Um, Vm;
1040 start->Bounds (U1, U2, V1, V2);
1041 Um = (U1 + U2 ) /2.;
1042 Vm = (V1 + V2 ) /2.;
1043 Handle(IGESData_IGESEntity) Surface = TransferSurface
1044 (TheSurf, Udeb, Ufin, Vdeb, Vfin);
1045 Standard_Real Distance = start->Offset()/GetUnit();
1046 GeomLProp_SLProps Prop = GeomLProp_SLProps
1047 (TheSurf, Um, Vm, 1, Precision::Confusion());
1048 gp_Dir Dir = Prop.Normal();
1049 Standard_Real Xd, Yd, Zd;
1050 Dir.Coord(Xd, Yd, Zd);
1051 gp_XYZ Indicator = gp_XYZ(Xd/GetUnit(), Yd/GetUnit(), Zd/GetUnit());
1052
1053 Surf-> Init (Indicator, Distance, Surface);
1054 res = Surf;
1055 return res;
1056
1057}
1058
1059
1060//=============================================================================
1061// Transfer des Entites Plane de Geom vers IGESSolid
1062// TransferPlaneSurface
1063//=============================================================================
1064
1065Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferPlaneSurface(const Handle(Geom_Plane)& start,
1066 const Standard_Real /*Udeb*/,
1067 const Standard_Real /*Ufin*/,
1068 const Standard_Real /*Vdeb*/,
1069 const Standard_Real /*Vfin*/)
1070{
1071 // The parametrization range is U, V ]- infinite, + infinite[
1072 // The local coordinate system of the plane is defined with
1073 // an axis placement two axis.
1074
1075 Handle(IGESData_IGESEntity) res;
1076 TheLength = 1;
1077 if (start.IsNull()) {
1078 return res;
1079 }
1080
1081 Handle(IGESSolid_PlaneSurface) Plsurf = new IGESSolid_PlaneSurface;
1082 GeomToIGES_GeomPoint GP(*this);
1083 GeomToIGES_GeomVector GV(*this);
1084
1085 gp_Pln Pln = start->Pln();
1086
1087 Handle(Geom_CartesianPoint) mypoint = new Geom_CartesianPoint(Pln.Location());
1088 Handle(IGESGeom_Point) aLocation = GP.TransferPoint(mypoint);
1089
1090 gp_Ax1 Axe = Pln.Axis();
1091 Handle(Geom_Direction) mydir = new Geom_Direction(Axe.Direction());
1092 Handle(IGESGeom_Direction) aNormal = GV.TransferVector(mydir);
1093
1094 gp_Ax1 XAxe = Pln.XAxis();
1095 Handle(Geom_Direction) rdir = new Geom_Direction(XAxe.Direction());
1096 Handle(IGESGeom_Direction) refdir = GV.TransferVector(rdir);
1097
1098 Plsurf->Init (aLocation, aNormal, refdir);
1099 res = Plsurf;
1100 return res;
1101
1102}
1103
1104//=======================================================================
1105//function : TransferCylindricaSurface
1106//purpose :
1107//=======================================================================
1108
1109Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferCylindricalSurface(const Handle(Geom_CylindricalSurface)& start,
1110 const Standard_Real /*Udeb*/,
1111 const Standard_Real /*Ufin*/,
1112 const Standard_Real /*Vdeb*/,
1113 const Standard_Real /*Vfin*/)
1114{
1115
1116 Handle(IGESData_IGESEntity) res;
1117 TheLength = 1;
1118 if (start.IsNull()) {
1119 return res;
1120 }
1121
1122 Handle(IGESSolid_CylindricalSurface) CylSurf = new IGESSolid_CylindricalSurface;
1123 GeomToIGES_GeomPoint GP(*this);
1124 GeomToIGES_GeomVector GV(*this);
1125
1126 gp_Cylinder Cyl = start->Cylinder();
1127
1128 Handle(Geom_CartesianPoint) mypoint = new Geom_CartesianPoint(Cyl.Location());
1129 Handle(IGESGeom_Point) aLocation = GP.TransferPoint(mypoint);
1130
1131 gp_Ax1 Axe = Cyl.Axis();
1132 Handle(Geom_Direction) mydir = new Geom_Direction(Axe.Direction());
1133 Handle(IGESGeom_Direction) Axis = GV.TransferVector(mydir);
1134
1135 gp_Ax1 XAxe = Cyl.XAxis();
1136 Handle(Geom_Direction) rdir = new Geom_Direction(XAxe.Direction());
1137 Handle(IGESGeom_Direction) refdir = GV.TransferVector(rdir);
1138
1139 Standard_Real radius = Cyl.Radius();
1140
1141 CylSurf->Init (aLocation, Axis, radius, refdir);
1142 res = CylSurf;
1143 return res;
1144}
1145
1146
1147//=======================================================================
1148//function : TransferConicalSurface
1149//purpose :
1150//=======================================================================
1151
1152Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferConicalSurface(const Handle(Geom_ConicalSurface)& start,
1153 const Standard_Real /*Udeb*/,
1154 const Standard_Real /*Ufin*/,
1155 const Standard_Real /*Vdeb*/,
1156 const Standard_Real /*Vfin*/)
1157{
1158
1159 Handle(IGESData_IGESEntity) res;
1160 TheLength = 1;
1161 if (start.IsNull()) {
1162 return res;
1163 }
1164
1165 Handle(IGESSolid_ConicalSurface) ConSurf = new IGESSolid_ConicalSurface;
1166 GeomToIGES_GeomPoint GP(*this);
1167 GeomToIGES_GeomVector GV(*this);
1168
1169 gp_Cone Con = start->Cone();
1170 Standard_Real radius = Con.RefRadius();
1171 Standard_Real angle = Con.SemiAngle();
1172 gp_Ax1 Axe = Con.Axis();
1173 gp_Ax1 XAxe = Con.XAxis();
1174 gp_Dir XDir = XAxe.Direction();
1175
1176 Handle(Geom_CartesianPoint) mypoint = new Geom_CartesianPoint(Con.Location());
1177 if(angle < 0.) {
1178 gp_Pnt pnt = mypoint->Pnt();
1179 mypoint->SetPnt(Con.Apex().XYZ()*2-pnt.XYZ());
1180 angle = -angle;
1181 XDir.Reverse();
1182 }
1183 Handle(IGESGeom_Point) aLocation = GP.TransferPoint(mypoint);
1184
1185 Handle(Geom_Direction) mydir = new Geom_Direction(Axe.Direction());
1186 Handle(IGESGeom_Direction) Axis = GV.TransferVector(mydir);
1187
1188 Handle(Geom_Direction) rdir = new Geom_Direction(XDir);//XAxe.Direction());
1189 Handle(IGESGeom_Direction) refdir = GV.TransferVector(rdir);
1190
c6541a0c 1191 ConSurf->Init (aLocation, Axis, radius, angle*180./M_PI, refdir);
7fd59977 1192 res = ConSurf;
1193 return res;
1194}
1195
1196
1197//=======================================================================
1198//function : TransferSphericalSurface
1199//purpose :
1200//=======================================================================
1201
1202Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferSphericalSurface(const Handle(Geom_SphericalSurface)& start,
1203 const Standard_Real /*Udeb*/,
1204 const Standard_Real /*Ufin*/,
1205 const Standard_Real /*Vdeb*/,
1206 const Standard_Real /*Vfin*/)
1207{
1208
1209 Handle(IGESData_IGESEntity) res;
1210 TheLength = 1;
1211 if (start.IsNull()) {
1212 return res;
1213 }
1214
1215 Handle(IGESSolid_SphericalSurface) SphSurf = new IGESSolid_SphericalSurface;
1216 GeomToIGES_GeomPoint GP(*this);
1217 GeomToIGES_GeomVector GV(*this);
1218
1219 gp_Sphere Sph = start->Sphere();
1220
1221 Handle(Geom_CartesianPoint) mypoint = new Geom_CartesianPoint(Sph.Location());
1222 Handle(IGESGeom_Point) aLocation = GP.TransferPoint(mypoint);
1223
1224 gp_Ax1 Axe = Sph.Position().Axis();
1225 Handle(Geom_Direction) mydir = new Geom_Direction(Axe.Direction());
1226 Handle(IGESGeom_Direction) Axis = GV.TransferVector(mydir);
1227
1228 gp_Ax1 XAxe = Sph.XAxis();
1229 Handle(Geom_Direction) rdir = new Geom_Direction(XAxe.Direction());
1230 Handle(IGESGeom_Direction) refdir = GV.TransferVector(rdir);
1231
1232 Standard_Real radius = Sph.Radius();
1233
1234 SphSurf->Init (aLocation, radius, Axis, refdir);
1235 res = SphSurf;
1236 return res;
1237}
1238
1239Handle(IGESData_IGESEntity) GeomToIGES_GeomSurface::TransferToroidalSurface(const Handle(Geom_ToroidalSurface)& start,
1240 const Standard_Real /*Udeb*/,
1241 const Standard_Real /*Ufin*/,
1242 const Standard_Real /*Vdeb*/,
1243 const Standard_Real /*Vfin*/)
1244{
1245
1246 Handle(IGESData_IGESEntity) res;
1247 TheLength = 1;
1248 if (start.IsNull()) {
1249 return res;
1250 }
1251
1252 Handle(IGESSolid_ToroidalSurface) TorSurf = new IGESSolid_ToroidalSurface;
1253 GeomToIGES_GeomPoint GP(*this);
1254 GeomToIGES_GeomVector GV(*this);
1255
1256 gp_Torus Tor = start->Torus();
1257
1258 Handle(Geom_CartesianPoint) mypoint = new Geom_CartesianPoint(Tor.Location());
1259 Handle(IGESGeom_Point) aLocation = GP.TransferPoint(mypoint);
1260
1261 gp_Ax1 Axe = Tor.Axis();
1262 Handle(Geom_Direction) mydir = new Geom_Direction(Axe.Direction());
1263 Handle(IGESGeom_Direction) Axis = GV.TransferVector(mydir);
1264
1265 gp_Ax1 XAxe = Tor.XAxis();
1266 Handle(Geom_Direction) rdir = new Geom_Direction(XAxe.Direction());
1267 Handle(IGESGeom_Direction) refdir = GV.TransferVector(rdir);
1268
1269 Standard_Real major = Tor.MajorRadius();
1270 Standard_Real minor = Tor.MinorRadius();
1271
1272 TorSurf->Init (aLocation, Axis, major, minor, refdir);
1273 res = TorSurf;
1274 return res;
1275}
1276
1277
1278//=======================================================================
1279//function : Length
1280//purpose :
1281//=======================================================================
1282Standard_Real GeomToIGES_GeomSurface::Length() const
1283{ return TheLength; }
1284
1285//=======================================================================
1286//function : GetBRepMode
1287//purpose :
1288//=======================================================================
1289
1290Standard_Boolean GeomToIGES_GeomSurface::GetBRepMode() const
1291{
1292 return myBRepMode;
1293}
1294
1295//=======================================================================
1296//function : SetBRepMode
1297//purpose :
1298//=======================================================================
1299
1300void GeomToIGES_GeomSurface::SetBRepMode(const Standard_Boolean flag)
1301{
1302 myBRepMode = flag;
1303}
1304
1305//=======================================================================
1306//function : GetAnalyticMode
1307//purpose :
1308//=======================================================================
1309
1310Standard_Boolean GeomToIGES_GeomSurface::GetAnalyticMode() const
1311{
1312 return myAnalytic;
1313}
1314
1315void GeomToIGES_GeomSurface::SetAnalyticMode(const Standard_Boolean flag)
1316{
1317 myAnalytic = flag;
1318}
1319