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