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