1 //=======================================================================
2 //file : IGESToBRep_BasicCurve
5 // 21.12.98 rln, gka S4054
6 //:k5 abv 25 Dec 98: PRO8803 1901: extending method of fixing Multi > Degree
7 // 28.12.98 dce S3767 New messaging system
9 //#60 rln 29.12.98 PRO17015
10 //:l3 abv 11.01.99: CATIA01.igs: using less values for checking short lines
11 //%11 pdn 12.01.98 CTS22023 correcting used tolerances
12 //sln 29.12.2001 OCC90 : Method checkBSplineCurve and varification before creation of bspline curves were added
13 //=======================================================================
16 #include <IGESToBRep_BasicCurve.ixx>
18 #include <IGESToBRep.hxx>
19 #include <IGESToBRep_CurveAndSurface.hxx>
23 #include <Geom_BSplineCurve.hxx>
24 #include <Geom_Circle.hxx>
25 #include <Geom_Ellipse.hxx>
26 #include <Geom_Line.hxx>
27 #include <Geom_Hyperbola.hxx>
28 #include <Geom_Parabola.hxx>
29 #include <Geom_Transformation.hxx>
30 #include <Geom_TrimmedCurve.hxx>
32 #include <Geom2d_BSplineCurve.hxx>
33 #include <Geom2d_Circle.hxx>
34 #include <Geom2d_Ellipse.hxx>
35 #include <Geom2d_Hyperbola.hxx>
36 #include <Geom2d_Line.hxx>
37 #include <Geom2d_Parabola.hxx>
38 #include <Geom2d_TrimmedCurve.hxx>
41 #include <gp_Ax2d.hxx>
43 #include <gp_Dir2d.hxx>
44 #include <gp_GTrsf.hxx>
46 #include <gp_Pnt2d.hxx>
47 #include <gp_Trsf.hxx>
52 #include <IGESData_IGESEntity.hxx>
53 #include <IGESData_ToolLocation.hxx>
55 #include <IGESGeom_BSplineCurve.hxx>
56 #include <IGESGeom_CircularArc.hxx>
57 #include <IGESGeom_ConicArc.hxx>
58 #include <IGESGeom_Point.hxx>
59 #include <IGESGeom_SplineCurve.hxx>
60 #include <IGESGeom_TransformationMatrix.hxx>
62 #include <IGESConvGeom.hxx>
64 #include <Interface_Macros.hxx>
66 #include <Precision.hxx>
68 #include <TColgp_Array1OfPnt2d.hxx>
69 #include <TColgp_HArray1OfPnt.hxx>
70 #include <TColgp_HArray2OfPnt.hxx>
71 #include <TColgp_HArray1OfPnt2d.hxx>
73 #include <TColGeom_SequenceOfCurve.hxx>
75 #include <TColStd_Array1OfInteger.hxx>
76 #include <TColStd_Array1OfReal.hxx>
77 #include <TColStd_HArray1OfInteger.hxx>
78 #include <TColStd_HArray1OfReal.hxx>
79 #include <TColStd_SequenceOfInteger.hxx>
82 #include <Standard_ErrorHandler.hxx>
83 #include <Standard_Failure.hxx>
85 #include <Message_Msg.hxx>
86 #include <ShapeConstruct_Curve.hxx>
87 #include <gp_Hypr.hxx>
89 //=======================================================================
90 //function : CheckBSplineCurve
91 //purpose : Check coincidede knots Check whether knots are in ascending
92 // order and difference between vaues of weights more than 1000.
93 // Send corresponding messages. The function returns Standard_False
94 // if curve can not be created, Standard_True otherwise.
95 //=======================================================================
96 static Standard_Boolean checkBSplineCurve(IGESToBRep_BasicCurve* theCurve,
97 const Handle(IGESGeom_BSplineCurve)& theBSplineCurve,
98 TColStd_Array1OfReal& CKnots,
99 const TColStd_Array1OfReal& CWeights)
101 // check whether difference between vaues of weights more than 1000.
102 if(!theBSplineCurve->IsPolynomial()) {
103 Standard_Real aMinValue = CWeights.Value(CWeights.Lower());
104 Standard_Real aMaxValue = CWeights.Value(CWeights.Lower());
105 for(Standard_Integer i = CWeights.Lower()+1; i<= CWeights.Upper(); i++) {
106 if(CWeights.Value(i) < aMinValue) aMinValue = CWeights.Value(i);
107 if(CWeights.Value(i) > aMaxValue) aMaxValue = CWeights.Value(i);
109 if(aMaxValue - aMinValue > 1000) {
110 Message_Msg msg1374("IGES_1374"); // WARNING - Difference between weights is too big.
111 theCurve->SendWarning(theBSplineCurve, msg1374);
115 Standard_Boolean aResult = Standard_True;
117 //check whether knots are in ascending order.
118 for (Standard_Integer i = CKnots.Lower(); i < CKnots.Upper(); i++)
119 if(CKnots.Value (i+1) < CKnots.Value (i)) {
120 Message_Msg msg1373("IGES_1373"); // FAIL - Knots are not in ascending order
121 theCurve->SendFail(theBSplineCurve, msg1373);
122 aResult = Standard_False;
124 //Fix coincided knots
125 if(aResult) ShapeConstruct_Curve::FixKnots(CKnots);
133 //=======================================================================
134 //function : IGESToBRep_BasicCurve
136 //=======================================================================
137 IGESToBRep_BasicCurve::IGESToBRep_BasicCurve()
138 :IGESToBRep_CurveAndSurface()
140 SetModeTransfer(Standard_False);
144 //=======================================================================
145 //function : IGESToBRep_BasicCurve
147 //=======================================================================
148 IGESToBRep_BasicCurve::IGESToBRep_BasicCurve
149 (const IGESToBRep_CurveAndSurface& CS)
150 :IGESToBRep_CurveAndSurface(CS)
155 //=======================================================================
156 //function : IGESToBRep_BasicCurve
158 //=======================================================================
159 IGESToBRep_BasicCurve::IGESToBRep_BasicCurve
160 (const Standard_Real eps,
161 const Standard_Real epsCoeff,
162 const Standard_Real epsGeom,
163 const Standard_Boolean mode,
164 const Standard_Boolean modeapprox,
165 const Standard_Boolean optimized)
166 :IGESToBRep_CurveAndSurface(eps, epsCoeff, epsGeom, mode,
167 modeapprox,optimized)
172 //=======================================================================
173 //function : TransferBasicCurve
175 //=======================================================================
177 Handle(Geom_Curve) IGESToBRep_BasicCurve::TransferBasicCurve
178 (const Handle(IGESData_IGESEntity)& start)
180 Handle(Geom_Curve) res;
181 if (start.IsNull()) {
182 Message_Msg msg1005("IGES_1005");
183 SendFail(start, msg1005);
186 try { //:36 by abv 11.12.97: Geom_BSplineCurve fails if somw weights are <=0
189 if (start->IsKind(STANDARD_TYPE(IGESGeom_BSplineCurve))) {
190 DeclareAndCast(IGESGeom_BSplineCurve, st126, start);
191 res = TransferBSplineCurve(st126);
193 else if (start->IsKind(STANDARD_TYPE(IGESGeom_Line))) {
194 DeclareAndCast(IGESGeom_Line, st110, start);
195 res = TransferLine(st110);
197 else if (start->IsKind(STANDARD_TYPE(IGESGeom_CircularArc))) {
198 DeclareAndCast(IGESGeom_CircularArc, st100, start);
199 res = TransferCircularArc(st100);
201 else if (start->IsKind(STANDARD_TYPE(IGESGeom_ConicArc))) {
202 DeclareAndCast(IGESGeom_ConicArc, st104, start);
203 res = TransferConicArc(st104);
205 else if (start->IsKind(STANDARD_TYPE(IGESGeom_CopiousData))) {
206 DeclareAndCast(IGESGeom_CopiousData, st106, start);
207 res = TransferCopiousData(st106);
209 else if (start->IsKind(STANDARD_TYPE(IGESGeom_SplineCurve))) {
210 DeclareAndCast(IGESGeom_SplineCurve, st112, start);
211 res = TransferSplineCurve(st112);
214 // AddFail(start, "The IGESEntity is not a basic curve.");
215 // This case can not occur
220 catch(Standard_Failure) {
222 cout << "\n** Exception in IGESToBRep_BasicCurve::TransferBasicCurve : ";
223 Standard_Failure::Caught()->Print(cout);
227 // AddFail(start, "The IGESEntity cannot be transfered.");
228 // The more specific function have ever add a fail message for this entity
231 res->Scale(gp_Pnt(0,0,0),GetUnitFactor());
235 //=======================================================================
236 //function : Transfer2dBasicCurve
238 //=======================================================================
240 Handle(Geom2d_Curve) IGESToBRep_BasicCurve::Transfer2dBasicCurve
241 (const Handle(IGESData_IGESEntity)& start)
243 Handle(Geom2d_Curve) res;
244 if (start.IsNull()) {
245 Message_Msg msg1005("IGES_1005");
246 SendFail(start, msg1005);
249 try { //:h8 abv 15 Jul 98: BUC60291 43693: Bspline Multiplicity > Degree+1 -> exception
253 if (start->IsKind(STANDARD_TYPE(IGESGeom_BSplineCurve))) {
254 DeclareAndCast(IGESGeom_BSplineCurve, st126, start);
255 res = Transfer2dBSplineCurve(st126);
257 else if (start->IsKind(STANDARD_TYPE(IGESGeom_Line))) {
258 DeclareAndCast(IGESGeom_Line, st110, start);
259 res = Transfer2dLine(st110);
261 else if (start->IsKind(STANDARD_TYPE(IGESGeom_CircularArc))) {
262 DeclareAndCast(IGESGeom_CircularArc, st100, start);
263 res = Transfer2dCircularArc(st100);
265 else if (start->IsKind(STANDARD_TYPE(IGESGeom_ConicArc))) {
266 DeclareAndCast(IGESGeom_ConicArc, st104, start);
267 res = Transfer2dConicArc(st104);
269 else if (start->IsKind(STANDARD_TYPE(IGESGeom_CopiousData))) {
270 DeclareAndCast(IGESGeom_CopiousData, st106, start);
271 res = Transfer2dCopiousData(st106);
273 else if (start->IsKind(STANDARD_TYPE(IGESGeom_SplineCurve))) {
274 DeclareAndCast(IGESGeom_SplineCurve, st112, start);
275 res = Transfer2dSplineCurve(st112);
278 // AddFail(start, "The IGESEntity is not a basic curve.");
279 // This case can not occur
283 catch(Standard_Failure) {
285 cout << "\n** Exception in IGESToBRep_BasicCurve::Transfer2dBasicCurve : ";
286 Standard_Failure::Caught()->Print(cout);
294 //=======================================================================
295 //function : TransferConicArc
297 //=======================================================================
299 // A,B,C,D,E,F are the coefficients recorded in IGES. a,b,c,d,e,f are used to
300 // simplify the equations of convertion. They are already used in Euclid.
302 Handle(Geom_Curve) IGESToBRep_BasicCurve::TransferConicArc
303 (const Handle(IGESGeom_ConicArc)& st)
305 Handle(Geom_Curve) res;
307 Message_Msg msg1005("IGES_1005");
308 SendFail(st, msg1005);
311 // If the Conic is closed, the start and end points will be ignored.
312 if (!st->ComputedFormNumber()) {
313 Message_Msg msg1155("IGES_1155");
314 SendFail(st, msg1155);
315 // AddFail(st, "Coefficients do not define correctly a conic.");
319 // Conic = ax2+bxy+cy2+dx+ey+f=0 in the plane z=ZT.
320 Standard_Real a,b,c,d,e,f,ZT;
321 st->Equation(a, b, c, d, e, f);
325 gp_Pnt center, startPoint, endPoint;
326 gp_Dir mainAxis ,normAxis;
327 Standard_Real minorRadius, majorRadius;
329 if (!GetModeTransfer() && st->HasTransf()) {
331 st->TransformedDefinition(center ,mainAxis, minorRadius, majorRadius);
332 normAxis = st->TransformedAxis();
334 startPoint = st->TransformedStartPoint();
335 endPoint = st->TransformedEndPoint();
338 st->Definition(center ,mainAxis, minorRadius, majorRadius);
339 normAxis = st->Axis();
341 startPoint.SetCoord(st->StartPoint().X(), st->StartPoint().Y(), ZT);
342 endPoint.SetCoord (st->EndPoint().X() , st->EndPoint().Y() , ZT);
344 gp_Ax2 frame(center, normAxis, mainAxis);
345 Standard_Real t1 =0.0, t2 =0.0;
346 if (st->IsFromEllipse()) {
348 //#60 rln 29.12.98 PRO17015 reading back face#67: ellipse with big radii produces
350 //The dimensions should be also obliged:
352 //if ( (Abs(a-c) <= GetEpsGeom()) && (Abs(b) < GetEpsCoeff()))
353 Standard_Real eps2 = Precision::PConfusion() * Precision::PConfusion();
354 if ( (Abs(a-c) <= eps2) && (Abs(b) < eps2)) {
360 res = new Geom_Circle(frame, minorRadius);
362 if (!st->IsClosed()) {
364 gp_Circ circ(frame, minorRadius);
366 t1 = ElCLib::Parameter(circ, startPoint);
367 t2 = ElCLib::Parameter(circ, endPoint);
368 if (t1 > t2 && (t1 - t2) > Precision::Confusion()) t2 += 2.*M_PI;
369 if (Abs(t1 - t2) <= Precision::Confusion()) { // t1 = t2
370 Message_Msg msg1160("IGES_1160");
371 SendWarning(st, msg1160);
374 res = new Geom_TrimmedCurve(res, t1, t2);
379 // This is a no circular ellipse which will be computed with
380 // the hyperbola at the end of this member.
383 else if (st->IsFromParabola()) {
385 // ===================
387 // ===================
389 Standard_Real focal = minorRadius;
392 gp_Parab parab(frame, focal);
394 res = new Geom_Parabola(frame, focal);
396 t1 = ElCLib::Parameter(parab, startPoint);
397 t2 = ElCLib::Parameter(parab, endPoint);
398 if (Abs(t1 - t2) <= Precision::Confusion()) { // t1 = t2
399 Message_Msg msg1160("IGES_1160");
400 SendWarning(st, msg1160);
401 //AddWarning(st, "The trim of the parabola is not correct.");
404 // if t1 > t2, the course of the curve is going to be reversed.
405 res = new Geom_TrimmedCurve(res, t1, t2);
410 // Same computing for the ellipse and the hyperbola.
412 // =============================================
413 // == Hyperbola or a no circular Ellipse 3D. ==
414 // =============================================
417 if (st->IsFromEllipse()) {
418 res = new Geom_Ellipse(frame, majorRadius, minorRadius);
420 if (!st->IsClosed()) {
421 gp_Elips elips(frame, majorRadius, minorRadius);
423 t1 = ElCLib::Parameter(elips, startPoint);
424 t2 = ElCLib::Parameter(elips, endPoint);
425 if (t2 < t1 && (t1 -t2) > Precision::Confusion()) t2 += 2.*M_PI;
426 if (Abs(t1 - t2) <= Precision::Confusion()) { // t1 = t2
427 Message_Msg msg1160("IGES_1160");
428 SendWarning(st, msg1160);
429 //AddWarning(st, "The trim of the ellipse is not correct, the result will be a ellipse.");
432 res = new Geom_TrimmedCurve(res, t1, t2);
437 gp_Hypr hpr(frame, majorRadius, minorRadius);
439 t1 = ElCLib::Parameter(hpr, startPoint);
440 t2 = ElCLib::Parameter(hpr, endPoint);
442 res = new Geom_Hyperbola(frame, majorRadius, minorRadius);
444 //pdn taking PConfusion for parameters.
445 if (Abs(t1 - t2) <= Precision::PConfusion()) { // t1 = t2
446 Message_Msg msg1160("IGES_1160");
447 SendWarning(st, msg1160);
450 res = new Geom_TrimmedCurve(res, t2, t1); // inversion des parametres.
452 res = new Geom_TrimmedCurve(res, t1, t2);
459 //=======================================================================
460 //function : Transfer2dConicArc
461 //purpose : Transfer 2d of a ConicArc to be used as a boundary of a Face
462 //=======================================================================
464 Handle(Geom2d_Curve) IGESToBRep_BasicCurve::Transfer2dConicArc
465 (const Handle(IGESGeom_ConicArc)& st)
467 Handle(Geom2d_Curve) res;
469 Message_Msg msg1005("IGES_1005");
470 SendFail(st, msg1005);
474 if (!st->ComputedFormNumber()) {
475 Message_Msg msg1155("IGES_1155");
476 SendFail(st, msg1155);
480 Standard_Real a,b,c,d,e,f;
481 // Conic = ax2+bxy+cy2+dx+ey+f=0.
482 st->Equation(a, b, c, d, e, f);
486 gp_Pnt2d startPoint, endPoint;
487 Standard_Real minorRadius, majorRadius;
490 if (!st->TransformedAxis().IsParallel /*#45 rln 23.11.98 IsEqual*/(st->Axis(), GetEpsilon())) {
491 SetModeTransfer(Standard_True);
492 // Only not to use Trsf.
493 // the normal axis is not parallel with Z axis.
494 SendWarning(st, "The Trsf is not compatible with a transfer2d, it will not applied.");
497 if (!GetModeTransfer() && st->HasTransf()) {
499 st->TransformedDefinition(center3d,
503 startPoint.SetCoord(st->TransformedStartPoint().X(),
504 st->TransformedStartPoint().Y());
505 endPoint.SetCoord(st->TransformedEndPoint().X(),
506 st->TransformedEndPoint().Y());
509 st->Definition(center3d, mainAxis3d, minorRadius, majorRadius);
510 startPoint = st->StartPoint();
511 endPoint = st->EndPoint();
514 gp_Pnt2d center(center3d.X(), center3d.Y());
515 gp_Dir2d mainAxis(mainAxis3d.X(), mainAxis3d.Y());
516 gp_Ax2d frame(center, mainAxis);
517 Standard_Real t1 =0.0, t2=0.0;
518 if (st->IsFromEllipse()) {
520 //#60 rln 29.12.98 PRO17015
521 //if ( (Abs(a-c) <= GetEpsGeom()) && (Abs(b) < GetEpsCoeff()))
522 Standard_Real eps2 = Precision::PConfusion() * Precision::PConfusion();
523 if ( (Abs(a-c) <= eps2) && (Abs(b) < eps2)) {
529 res = new Geom2d_Circle(frame, minorRadius);
531 if (st->TransformedAxis().IsOpposite (st->Axis(), GetEpsilon()))
534 if (!st->IsClosed()) {
536 gp_Circ2d circ = Handle(Geom2d_Circle)::DownCast(res)->Circ2d();//#45 rln (frame, minorRadius);
538 t1 = ElCLib::Parameter(circ, startPoint);
539 t2 = ElCLib::Parameter(circ, endPoint);
541 if (t2 < t1 && (t1 -t2) > Precision::PConfusion()) t2 += 2.*M_PI;
542 if (Abs(t1 - t2) <= Precision::PConfusion()) { // t1 = t2
543 Message_Msg msg1160("IGES_1160");
544 SendWarning(st, msg1160);
547 res = new Geom2d_TrimmedCurve(res, t1, t2);
552 // This is a no circular ellipse, it will be computed with the hyperbola.
555 else if (st->IsFromParabola()) {
557 // ===================
559 // ===================
561 Standard_Real focal = minorRadius;
564 res = new Geom2d_Parabola(frame, focal);
566 if (st->TransformedAxis().IsOpposite (st->Axis(), GetEpsilon()))
569 gp_Parab2d parab = Handle(Geom2d_Parabola)::DownCast(res)->Parab2d();//#45 rln (frame, focal);
571 t1 = ElCLib::Parameter(parab, startPoint);
572 t2 = ElCLib::Parameter(parab, endPoint);
573 if (Abs(t1 - t2) <= Precision::PConfusion()) { // t1 = t2
574 Message_Msg msg1160("IGES_1160");
575 SendWarning(st, msg1160);
578 res = new Geom2d_TrimmedCurve(res, t2, t1); // inversion des parametres.
580 res = new Geom2d_TrimmedCurve(res, t1, t2);
584 /* Same computing for the ellipse2d and the hyperbola2d. */
586 // ============================================
587 // == Hyperbola or a no circular Ellipse 2D ==
588 // ============================================
590 if (st->IsFromEllipse()) {
592 res = new Geom2d_Ellipse(frame, majorRadius, minorRadius);
594 if (st->TransformedAxis().IsOpposite (st->Axis(), GetEpsilon()))
597 if (!st->IsClosed()) {
599 gp_Elips2d elips = Handle(Geom2d_Ellipse)::DownCast(res)->Elips2d();//#45 rln (frame, majorRadius, minorRadius);
601 t1 = ElCLib::Parameter(elips, startPoint);
602 t2 = ElCLib::Parameter(elips, endPoint);
603 if (t2 < t1 && (t1 - t2) > Precision::PConfusion()) t2 += 2.*M_PI;
604 if (Abs(t1 - t2) <= Precision::PConfusion()) { // t1 = t2
605 Message_Msg msg1160("IGES_1160");
606 SendWarning(st, msg1160);
609 res = new Geom2d_TrimmedCurve(res, t1, t2);
614 res = new Geom2d_Hyperbola(frame, majorRadius, minorRadius);
616 if (st->TransformedAxis().IsOpposite (st->Axis(), GetEpsilon()))
619 gp_Hypr2d hpr = Handle(Geom2d_Hyperbola)::DownCast(res)->Hypr2d();//#45 rln (frame, majorRadius, minorRadius);
621 t1 = ElCLib::Parameter(hpr, startPoint);
622 t2 = ElCLib::Parameter(hpr, endPoint);
624 if (Abs(t1 - t2) <= Precision::PConfusion()) { // t1 = t2
625 Message_Msg msg1160("IGES_1160");
626 SendWarning(st, msg1160);
629 res = new Geom2d_TrimmedCurve(res, t2, t1); // inversion des parametres.
631 res = new Geom2d_TrimmedCurve(res, t1, t2);
638 //=======================================================================
639 //function : TransferCircularArc
641 //=======================================================================
643 Handle(Geom_Curve) IGESToBRep_BasicCurve::TransferCircularArc
644 (const Handle(IGESGeom_CircularArc)& st)
646 Handle(Geom_Curve) res;
648 Message_Msg msg1005("IGES_1005");
649 SendFail(st,msg1005);
653 gp_Dir tNormAxis, tMainAxis;
655 gp_Pnt startPoint, endPoint;
657 if (!GetModeTransfer() && st->HasTransf()) {
659 tNormAxis = st->TransformedAxis();
661 gp_GTrsf loc = st->Location();
662 loc.SetTranslationPart (gp_XYZ(0.,0.,0.));
663 gp_XYZ mainAxis(1., 0., 0.);
664 loc.Transforms(mainAxis);
665 tMainAxis = gp_Dir(mainAxis);
667 startPoint = st->TransformedStartPoint();
668 endPoint = st->TransformedEndPoint();
670 frame = gp_Ax2(st->TransformedCenter(), tNormAxis, tMainAxis);
673 tNormAxis = st->Axis();
674 tMainAxis.SetCoord(1., 0., 0.);
676 Standard_Real ZT = st->ZPlane();
677 startPoint.SetCoord(st->StartPoint().X(), st->StartPoint().Y(), ZT);
678 endPoint.SetCoord (st->EndPoint().X() , st->EndPoint().Y() , ZT);
679 gp_Pnt centerPoint (st->Center().X() , st->Center().Y() , ZT);
681 frame = gp_Ax2(centerPoint, tNormAxis, tMainAxis);
684 res = new Geom_Circle(frame, st->Radius());
686 gp_Circ circ(frame, st->Radius());
688 Standard_Real t1 =0.0, t2 =0.0;
690 t1 = ElCLib::Parameter(circ, startPoint);
691 t2 = ElCLib::Parameter(circ, endPoint);
693 if ( st->IsClosed() && t1>=GetEpsGeom()) t2 = t1 + 2.*M_PI;
694 if (!st->IsClosed() && fabs(t1 - t2) <=Precision::PConfusion()) {
696 // cky 27 Aout 1996 : t2-t1 vaut distance(start,end)/rayon
697 t2 = t1 + startPoint.Distance(endPoint)/st->Radius();
699 if (!st->IsClosed() || t1>=GetEpsGeom()) {
700 if (t2 < t1) t2 += 2.*M_PI;
701 res = new Geom_TrimmedCurve(res, t1, t2);
707 //=======================================================================
708 //function : Transfer2dCircularArc
710 //=======================================================================
712 Handle(Geom2d_Curve) IGESToBRep_BasicCurve::Transfer2dCircularArc
713 (const Handle(IGESGeom_CircularArc)& st)
715 Handle(Geom2d_Curve) res;
717 Message_Msg msg1005("IGES_1005");
718 SendFail(st,msg1005);
722 gp_XYZ center(st->Center().X(), st->Center().Y(), 0.);
723 gp_XYZ mainAxis(1., 0., 0.);
726 if (!st->TransformedAxis().IsParallel /*#45 rln 23.11.98 IsEqual*/(st->Axis(), GetEpsilon())) {
727 SetModeTransfer(Standard_True); // Only not to use Trsf
728 Message_Msg msg1165("IGES_1165");
729 SendWarning(st, msg1165); //"The Trsf is not compatible with a transfer2d, it will not applied."
732 if (!GetModeTransfer() && st->HasTransf()) {
733 gp_GTrsf loc = st->Location();
734 loc.Transforms(center);
735 loc.SetTranslationPart (gp_XYZ(0.,0.,0.));
736 loc.Transforms(mainAxis);
738 gp_Pnt2d tCenter(center.X(), center.Y());
739 gp_Dir2d tMainAxis(mainAxis.X(), mainAxis.Y());
740 gp_Ax2d frame(tCenter, tMainAxis);
742 res = new Geom2d_Circle(frame, st->Radius());
744 gp_Pnt2d startPoint, endPoint;
745 if (!GetModeTransfer() && st->HasTransf()) {
746 startPoint.SetCoord(st->TransformedStartPoint().X(),
747 st->TransformedStartPoint().Y());
748 endPoint.SetCoord(st->TransformedEndPoint().X(),
749 st->TransformedEndPoint().Y());
751 if (st->TransformedAxis().IsOpposite (st->Axis(), GetEpsilon()))
755 startPoint = st->StartPoint();
756 endPoint = st->EndPoint();
759 gp_Circ2d circ = Handle(Geom2d_Circle)::DownCast(res)->Circ2d();//#45 rln (frame, st->Radius());
761 Standard_Real t1 =0.0, t2 =0.0;
763 t1 = ElCLib::Parameter(circ, startPoint);
764 t2 = ElCLib::Parameter(circ, endPoint);
766 if ( st->IsClosed() && t1>=GetEpsGeom()) t2 = t1 + 2.*M_PI;
767 if (!st->IsClosed() && fabs(t1 -t2) <= Precision::PConfusion()) {
769 // cky 27 Aout 1996 : t2-t1 vaut distance(start,end)/rayon
770 t2 = t1 + startPoint.Distance(endPoint)/st->Radius();
772 if (!st->IsClosed() || t1>= GetEpsGeom()) {
773 if (t2 < t1) t2 += 2.*M_PI;
774 res = new Geom2d_TrimmedCurve(res, t1, t2);
781 //=======================================================================
782 //function : TransferSplineCurve
784 //=======================================================================
786 Handle(Geom_BSplineCurve) IGESToBRep_BasicCurve::TransferSplineCurve
787 (const Handle(IGESGeom_SplineCurve)& st)
789 Handle(Geom_BSplineCurve) resconv;
791 Message_Msg msg1005("IGES_1005");
792 SendFail(st,msg1005);
796 Standard_Real epscoef = GetEpsCoeff();
797 Standard_Real epsgeom = GetEpsGeom();
799 Standard_Integer result = IGESConvGeom::SplineCurveFromIGES(st, epscoef, epsgeom, resconv);
803 Message_Msg msg246("XSTEP_246");
804 SendFail(st, msg246);
805 // less than on segment (no result produced)
809 Message_Msg msg1170("IGES_1170");
810 SendFail(st, msg1170);
811 // Polynomial equation is not correct ( no result produced
814 Message_Msg msg1175("IGES_1175");
815 SendFail(st, msg1175);
816 // Error during creation of control points ( no result produced)
819 Message_Msg msg1180("IGES_1180");
820 SendFail(st, msg1180);
821 //SplineType not processed (allowed : max 3) (no result produced)
827 // Checking C2 and C1 continuity :
828 // ===============================
829 IGESConvGeom::IncreaseCurveContinuity (resconv, Min(Precision::Confusion(),epsgeom), GetContinuity());
835 //=======================================================================
836 //function : Transfer2dSplineCurve
838 //=======================================================================
840 Handle(Geom2d_BSplineCurve) IGESToBRep_BasicCurve::Transfer2dSplineCurve
841 (const Handle(IGESGeom_SplineCurve)& st)
843 Handle(Geom2d_BSplineCurve) res;
845 Message_Msg msg1005("IGES_1005");
846 SendFail(st, msg1005);
852 // The same Presision as in BSpline 2d is used
853 Standard_Real epsGeom = GetEpsGeom();
854 SetEpsGeom(Precision::PConfusion());
855 Handle(Geom_BSplineCurve) res3d = TransferSplineCurve(st);
858 return res; // The transfer was not over the top.
863 Standard_Integer nbPoles = res3d->NbPoles();
864 Standard_Integer nbKnots = res3d->NbKnots();
866 TColgp_Array1OfPnt2d bspoles2d(1, nbPoles);
867 TColStd_Array1OfReal knots(1, nbKnots);
868 TColStd_Array1OfInteger multi(1, nbKnots);
871 res3d->Multiplicities(multi);
873 for (Standard_Integer i = bspoles2d.Lower(); i <= bspoles2d.Upper(); i++)
874 bspoles2d.SetValue(i, gp_Pnt2d(res3d->Pole(i).X(), res3d->Pole(i).Y()));
876 res = new Geom2d_BSplineCurve (bspoles2d, knots, multi, res3d->Degree());
880 //=======================================================================
881 //function : TransferBSplineCurve
883 //=======================================================================
885 Handle(Geom_Curve) IGESToBRep_BasicCurve::TransferBSplineCurve
886 (const Handle(IGESGeom_BSplineCurve)& start)
889 Handle(Geom_BSplineCurve) BSplineRes;
890 Handle(Geom_Curve) res;
892 if (start.IsNull()) {
893 Message_Msg msg1005("IGES_1005");
894 SendFail(start,msg1005);
898 Standard_Integer Degree = start->Degree();
900 if (Degree<=0 || Degree>Geom_BSplineCurve::MaxDegree()) {
901 Message_Msg msg1190("IGES_1190");
902 SendFail(start, msg1190);
903 // Improper degree either lower or equal to 0 or upper to MaxDegree
908 // Filling poles array :
909 // =====================
911 Standard_Integer NbPoles = start->NbPoles();
912 Standard_Integer newNbPoles = NbPoles;
915 Message_Msg msg1195("IGES_1195");
916 SendFail(start, msg1195);
917 // Transfer aborted for a BSpline Curve : Number of poles lower than 2
921 TColgp_Array1OfPnt Pole(1,NbPoles);
922 Standard_Integer PoleIndex = Pole.Lower();
923 Standard_Integer i; //szv#4:S4163:12Mar99 j unused
925 if (!GetModeTransfer() && start->HasTransf())
926 for (i=0; i<=start->UpperIndex(); i++)
927 Pole.SetValue(PoleIndex++, start->TransformedPole(i));
929 for (i=0; i<=start->UpperIndex(); i++)
930 Pole.SetValue(PoleIndex++, start->Pole(i));
933 // Filling knots & multiplicities arraies :
934 // ========================================
936 Standard_Integer NbKnots = start->NbKnots();
937 TColStd_Array1OfReal TempKnot(1,NbKnots);
938 TColStd_Array1OfInteger TempMult(1,NbKnots);
940 Standard_Integer KnotIndex = TempKnot.Lower();
942 TempKnot.SetValue(KnotIndex, start->Knot(-Degree));
944 // If several identical IGES knots are encountered, corresponding
945 // multiplicity is increased
946 // ==============================================================
948 for (i=1-Degree; i<NbKnots-Degree; i++) {
950 Standard_Real Knot1 = start->Knot(i);
951 Standard_Real Knot2 = start->Knot(i-1);
952 // Standard_Real ek = Epsilon(Knot1);
954 if (Abs(Knot1 - Knot2) <= Epsilon(Knot1))
955 TempMult.SetValue(KnotIndex, TempMult.Value(KnotIndex)+1);
957 TempKnot.SetValue(++KnotIndex, Knot1);
961 // Final knots & multiplicities arraies are dimensionned so as to be fully
963 // =======================================================================
965 TColStd_Array1OfReal Knot(1,KnotIndex);
966 TColStd_Array1OfInteger Mult(1,KnotIndex);
968 Standard_Integer SumOfMult=0;
970 TColStd_SequenceOfInteger SeqIndex;
971 Standard_Integer DelIndex;
972 Standard_Integer OldSumOfMult = 0;
973 for (i=1; i <= KnotIndex; i++) { //:k5 abv 25 Dec 98: cycle modified
974 Standard_Integer aMult = TempMult.Value(i);
975 Standard_Integer maxMult = ( i==1 || i == KnotIndex ? Degree + 1 : Degree );
976 if (aMult > maxMult) {
977 Message_Msg msg1200("IGES_1200");//#61 rln 05.01.99
978 const Standard_CString vide ("");
982 SendWarning(start, msg1200);//Multiplicity > Degree (or Degree+1 at end); corrected
983 for ( DelIndex = OldSumOfMult + 1; aMult > maxMult; DelIndex++, aMult-- ) {
985 SeqIndex.Append(DelIndex);
988 OldSumOfMult += TempMult.Value(i);
989 Knot.SetValue(i, TempKnot.Value(i));
990 Mult.SetValue(i, aMult);
994 // Mise a jour du tableau des poles lors de la correction de la multiplicite
995 TColgp_Array1OfPnt Poles(1,newNbPoles);
996 TColStd_SequenceOfInteger PoleInd;
998 if ( newNbPoles < NbPoles) {
999 for (i=1; i<=NbPoles; i++) PoleInd.Append(i);
1000 Standard_Integer Offset = 0;
1001 for (Standard_Integer itab = 1; itab <= SeqIndex.Length(); itab++) {
1002 DelIndex = SeqIndex.Value(itab) - Offset;
1003 PoleInd.Remove(DelIndex);
1006 Standard_Integer nbseq = PoleInd.Length();
1007 if ( nbseq == newNbPoles) {
1008 Standard_Integer indj = 1;
1009 for ( i=1; i<= newNbPoles; i++) {
1010 Poles.SetValue(i, Pole.Value(PoleInd.Value(indj++)));
1016 for ( i=1; i<= newNbPoles; i++) {
1017 Poles.SetValue (i, Pole.Value(i));
1022 if (! (SumOfMult == newNbPoles + Degree + 1)) {
1023 Message_Msg msg1210("IGES_1210");
1024 const Standard_CString vide ("");
1027 SendWarning(start, msg1210);
1028 //Sum of multiplicities not equal to the sum : Count of poles + Degree + 1
1031 // Output BSpline curve with the array of pole weights if any :
1032 // ============================================================
1034 TColStd_Array1OfReal Weight(1,newNbPoles);
1036 if (start->IsPolynomial()) {
1037 //:5 BSplineC = new Geom_BSplineCurve(Poles, Knot, Mult, Degree);
1040 TColStd_Array1OfReal PoleWeight(1,NbPoles);
1041 Standard_Boolean polynomial = Standard_True;
1042 Standard_Real WeightReference = start->Weight(0);
1043 Standard_Integer WeightIndex = PoleWeight.Lower();
1045 for (i=0; i <= start->UpperIndex(); i++) {
1046 polynomial = Abs(start->Weight(i) - WeightReference) <=
1047 Epsilon(WeightReference) && polynomial;
1048 //:39 by abv 15.12.97
1049 Standard_Real weight = start->Weight(i);
1050 if ( weight < Precision::PConfusion() ) {
1051 Message_Msg msg1215("IGES_1215");
1052 SendFail(start, msg1215);
1053 // Some weights are not positive
1056 PoleWeight.SetValue(WeightIndex++, weight);
1057 //:39 PoleWeight.SetValue(WeightIndex++, start->Weight(i));
1060 Message_Msg msg1220("IGES_1220");
1061 msg1220.Arg("curve");
1062 SendWarning(start, msg1220);
1063 // Rational curve is polynomial
1065 // Mise a jour du tableau des Weight lors de la correction de la multiplicite
1066 if ( newNbPoles < NbPoles) {
1067 Standard_Integer indj = 1;
1068 for ( i=1; i<= newNbPoles; i++) {
1069 Weight.SetValue(i, PoleWeight.Value(PoleInd.Value(indj++)));
1073 for ( i=1; i<= newNbPoles; i++) {
1074 Weight.SetValue (i, PoleWeight.Value(i));
1077 //:5 BSplineC = new Geom_BSplineCurve(Poles, Weight, Knot, Mult, Degree);
1080 //sln 29.12.2001 OCC90 : If curve can not be created do nothing
1081 if(!checkBSplineCurve(this, start, Knot, Weight)) return BSplineRes;
1086 if (start->IsPolynomial())
1087 BSplineRes = new Geom_BSplineCurve(Poles, Knot, Mult, Degree);
1089 BSplineRes = new Geom_BSplineCurve(Poles, Weight, Knot, Mult, Degree);
1091 catch(Standard_Failure) {
1093 cout << "\n** Exception in IGESToBRep_BasicCurve::TransferBSplineCurve during creation of Geom_BSplineCurve : ";
1094 Standard_Failure::Caught()->Print(cout);
1099 Standard_Real First = BSplineRes->FirstParameter();
1100 Standard_Real Last = BSplineRes->LastParameter();
1101 Standard_Real Udeb = start->UMin();
1102 Standard_Real Ufin = start->UMax();
1103 //%11 pdn 12.01.98 CTS22023
1104 //if ( (Udeb-First) > Precision::PConfusion() || (Last-Ufin) > Precision::PConfusion() )
1105 // BSplineRes->Segment(Udeb, Ufin);
1108 // IGESConvGeom::IncreaseCurveContinuity (BSplineRes,Min(Precision::Confusion(),GetEpsGeom()), GetContinuity());
1110 // skl 21.02.2002 (exception in OCC133 and for file
1111 // "/dn04/OS/USINOR/UIdev/src/IsoLim/dat/igs/ps1002-v5.igs")
1112 Handle(Geom_BSplineCurve) BSplineRes2 = BSplineRes;
1113 if (((Udeb-First)>-Precision::PConfusion() &&
1114 (Last-Ufin)>-Precision::PConfusion()) && Udeb<=Ufin ) {
1117 BSplineRes->Segment(Udeb, Ufin);
1120 catch (Standard_Failure) {
1121 Handle(Geom_TrimmedCurve) gtc = new Geom_TrimmedCurve(BSplineRes2,Udeb,Ufin);
1133 //=======================================================================
1134 //function : Transfer2dBSplineCurve
1136 //=======================================================================
1138 Handle(Geom2d_Curve) IGESToBRep_BasicCurve::Transfer2dBSplineCurve
1139 (const Handle(IGESGeom_BSplineCurve)& start)
1141 Handle(Geom2d_Curve) res;
1142 if (start.IsNull()) {
1143 Message_Msg msg1005("IGES_1005");
1144 SendFail(start, msg1005);
1148 Handle(Geom2d_BSplineCurve) BSplineC;
1149 Handle(Geom_BSplineCurve) Bspline;
1150 Standard_Boolean IsTrimmed = Standard_False;
1151 Standard_Real Deb=0., Fin=0.;
1153 // 3d transfer first :
1154 // ===================
1155 // Standard_Real epsGeom = GetEpsGeom();
1156 // SetEpsGeom(Precision::PConfusion());
1157 Handle(Geom_Curve) res3d = TransferBSplineCurve(start);
1158 // SetEpsGeom(epsGeom);
1159 if (res3d.IsNull()) {
1164 if (res3d->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
1165 DeclareAndCast(Geom_TrimmedCurve, TrimC, res3d);
1166 Handle(Geom_Curve) BasicCurve = TrimC->BasisCurve();
1167 Deb = TrimC->FirstParameter();
1168 Fin = TrimC->LastParameter();
1169 IsTrimmed = Standard_True;
1170 if (BasicCurve->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) {
1171 DeclareAndCast(Geom_BSplineCurve, BSpline, BasicCurve);
1178 else if (res3d->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) {
1179 DeclareAndCast(Geom_BSplineCurve, BSpline, res3d);
1184 // Creating 2d poles :
1185 // ===================
1187 Standard_Integer NbPoles = Bspline->NbPoles();
1188 TColgp_Array1OfPnt2d Pole(1,NbPoles);
1190 for (Standard_Integer i=1; i<=NbPoles; i++){
1191 gp_Pnt2d aPole2d(Bspline->Pole(i).X(),Bspline->Pole(i).Y());
1192 Pole.SetValue(i,aPole2d);
1195 // Knots and multiplicities are the same :
1196 // =======================================
1198 Standard_Integer NbKnots = Bspline->NbKnots();
1200 TColStd_Array1OfReal Knot(1,NbKnots);
1201 Bspline->Knots(Knot);
1203 TColStd_Array1OfInteger Mult(1,NbKnots);
1204 Bspline->Multiplicities(Mult);
1206 Standard_Integer Degree = Bspline->Degree();
1208 if (Bspline->IsRational()) {
1209 TColStd_Array1OfReal Weight(1,NbPoles);
1210 Bspline->Weights(Weight);
1211 BSplineC = new Geom2d_BSplineCurve(Pole, Weight, Knot, Mult, Degree);
1213 else BSplineC = new Geom2d_BSplineCurve(Pole, Knot, Mult, Degree);
1217 // cas ou la Bspline est trimmee.
1219 Handle(Geom2d_TrimmedCurve) TC = new Geom2d_TrimmedCurve
1220 (BSplineC, Deb, Fin, Standard_True);
1229 //=======================================================================
1230 //function : TransferLine
1232 //=======================================================================
1234 Handle(Geom_Curve) IGESToBRep_BasicCurve::TransferLine
1235 (const Handle(IGESGeom_Line)& start)
1237 Handle(Geom_Curve) res;
1238 if (start.IsNull()) {
1239 Message_Msg msg1005("IGES_1005");
1240 SendFail(start, msg1005);
1246 if (!GetModeTransfer() && start->HasTransf()) {
1247 Ps = start->TransformedStartPoint();
1248 Pe = start->TransformedEndPoint();
1251 Ps = start->StartPoint();
1252 Pe = start->EndPoint();
1255 // modif du 15/10/97 : test moins severe
1256 // beaucoup de points confondus a GetEpsGeom()*GetUnitFactor()
1257 if (!Ps.IsEqual(Pe,Precision::Confusion())) { //:l3 abv 11 Jan 99: GetEpsGeom()*GetUnitFactor()/10.)) {
1258 gp_Lin line(Ps, gp_Dir(gp_Vec(Ps,Pe)));
1259 Standard_Real t1 = ElCLib::Parameter(line, Ps);
1260 Standard_Real t2 = ElCLib::Parameter(line, Pe);
1261 Handle(Geom_Line) Gline = new Geom_Line(line);
1262 if (Precision::IsNegativeInfinite(t1)) t1 = -Precision::Infinite();
1263 if (Precision::IsPositiveInfinite(t2)) t2 = Precision::Infinite();
1264 res = new Geom_TrimmedCurve(Gline, t1, t2);
1267 Message_Msg msg1225("IGES_1225");
1268 SendFail(start, msg1225);
1269 // StartPoint and EndPoint of the line are the same Point
1277 //=======================================================================
1278 //function : Transfer2dLine
1280 //=======================================================================
1282 Handle(Geom2d_Curve) IGESToBRep_BasicCurve::Transfer2dLine
1283 (const Handle(IGESGeom_Line)& start)
1285 Handle(Geom2d_Curve) res;
1286 if (start.IsNull()) {
1287 Message_Msg msg1005("IGES_1005");
1288 SendFail(start, msg1005);
1294 if (!GetModeTransfer() && start->HasTransf()) {
1295 beg.SetCoord(start->TransformedStartPoint().X(),
1296 start->TransformedStartPoint().Y());
1297 end.SetCoord(start->TransformedEndPoint().X(),
1298 start->TransformedEndPoint().Y());
1301 beg.SetCoord(start->StartPoint().X(),
1302 start->StartPoint().Y());
1303 end.SetCoord(start->EndPoint().X(),
1304 start->EndPoint().Y());
1307 if (!beg.IsEqual(end,Precision::PConfusion())) { //:l3 abv 11 Jan 99: GetEpsCoeff())) {
1308 gp_Lin2d line2d(beg, gp_Dir2d(gp_Vec2d(beg,end)));
1309 Standard_Real t1 = ElCLib::Parameter(line2d, beg);
1310 Standard_Real t2 = ElCLib::Parameter(line2d, end);
1311 Handle(Geom2d_Line) Gline2d = new Geom2d_Line(line2d);
1312 if (Precision::IsNegativeInfinite(t1)) t1 = -Precision::Infinite();
1313 if (Precision::IsPositiveInfinite(t2)) t2 = Precision::Infinite();
1314 res = new Geom2d_TrimmedCurve(Gline2d, t1, t2);
1316 //added by rln 18/12/97 CSR# CTS18544 entity 25168 and 31273
1317 //generating fail the same as above
1319 Message_Msg msg1225("IGES_1225");
1320 SendFail(start, msg1225); // StartPoint and EndPoint of the 2d line are the same Point
1327 //=======================================================================
1328 //function : TransferTransformation
1330 //=======================================================================
1332 Handle(Geom_Transformation) IGESToBRep_BasicCurve::TransferTransformation
1333 (const Handle(IGESGeom_TransformationMatrix)& start)
1336 Handle(Geom_Transformation) res;
1337 if (start.IsNull()) {
1338 Message_Msg msg1005("IGES_1005");
1339 SendFail(start, msg1005);
1344 if ( IGESData_ToolLocation::ConvertLocation
1345 (GetEpsilon(),start->Value(),resultat) )
1346 res = new Geom_Transformation(resultat);
1348 Message_Msg msg1036("IGES_1036");
1349 SendFail(start, msg1036); // Transformation : not a similarity
1357 //=======================================================================
1358 //function : TransferCopiousData
1360 //=======================================================================
1362 Handle(Geom_BSplineCurve) IGESToBRep_BasicCurve::TransferCopiousData
1363 (const Handle(IGESGeom_CopiousData)& start)
1366 Handle(Geom_BSplineCurve) res;
1367 if (start.IsNull()) {
1368 Message_Msg msg1005("IGES_1005");
1369 SendFail(start, msg1005);
1373 Standard_Integer FormNb = start->FormNumber();
1374 if (!(FormNb==11 || FormNb==12 || FormNb==63)) {
1375 Message_Msg msg1240("IGES_1240");
1376 SendWarning( start, msg1240);
1377 // "Copious Data : Form number is different from 11, 12 or 63 so the vector treatement is skipped");
1380 Standard_Integer NbPoints = start->NbPoints();
1382 Message_Msg msg1195("IGES_1195");
1383 SendFail(start, msg1195); // Count of points lower than 2
1387 // Filling array of poles :
1388 // ========================
1390 TColgp_Array1OfPnt TempPole(1,NbPoints);
1391 Standard_Integer TempIndex = TempPole.Lower();
1393 if (!GetModeTransfer() && start->HasTransf()) {
1394 TempPole.SetValue(TempIndex,start->TransformedPoint(1));
1397 TempPole.SetValue(TempIndex,start->Point(1));
1401 Standard_Integer i;// svv Jan 10 2000 : porting on DEC
1402 for (i=2; i <= NbPoints; i++) {
1404 if (!GetModeTransfer() && start->HasTransf())
1405 aPole = start->TransformedPoint(i);
1407 aPole = start->Point(i);
1408 // #2 pdn 7 May 1998 BUC50028
1409 // delete GetUnitFactor()
1410 // if (!aPole.IsEqual(TempPole(TempIndex-1),GetEpsGeom()))
1411 //S4054: some filter must be kept UKI60556 entity 7 (two equal points)
1412 if (!aPole.IsEqual(TempPole(TempIndex-1), gp::Resolution()))
1413 TempPole.SetValue(TempIndex++,aPole);
1416 NbPoints = TempIndex - TempPole.Lower();
1418 // #1 pdn 7 May 1998 BUC50028 entity 6307
1419 if ( NbPoints == 1) {
1420 Message_Msg msg1235("IGES_1235");
1421 SendFail(start, msg1235);
1422 // The curve degenerates to a point");
1425 TColgp_Array1OfPnt Pole(1,NbPoints);
1427 TempIndex = TempPole.Lower();
1428 for (i=Pole.Lower(); i<=Pole.Upper(); i++)
1429 Pole.SetValue(i,TempPole.Value(TempIndex++));
1432 // Filling array of knots :
1433 // ========================
1435 TColStd_Array1OfReal Knot(1,NbPoints);
1437 Knot.SetValue(Knot.Lower(),0.0);
1439 for (i=Knot.Lower()+1; i <= Knot.Upper(); i++) {
1440 gp_Pnt Pole1 = Pole.Value(i);
1441 gp_Pnt Pole2 = Pole.Value(i-1);
1442 Standard_Real KnotDist = Pole1.Distance(Pole2);
1443 Knot.SetValue(i, Knot.Value(i-1)+KnotDist);
1446 Standard_Integer Degree = 1;
1448 TColStd_Array1OfInteger Mult(1, NbPoints);
1450 Mult.SetValue(Mult.Lower(),Degree+1);
1451 Mult.SetValue(Mult.Upper(),Degree+1);
1453 res = new Geom_BSplineCurve(Pole, Knot, Mult, Degree);
1455 IGESConvGeom::IncreaseCurveContinuity (res, Max(GetEpsGeom()/10.,Precision::Confusion()), GetContinuity());
1460 // ================================
1461 // == TRANSFER 2D Copious data ==
1462 // ================================
1464 Handle(Geom2d_BSplineCurve) IGESToBRep_BasicCurve::Transfer2dCopiousData(const Handle(IGESGeom_CopiousData)& start)
1466 Handle(Geom2d_BSplineCurve) res;
1467 if (start.IsNull()) {
1468 Message_Msg msg1005("IGES_1005");
1469 SendFail(start, msg1005);
1473 Standard_Integer FormNb = start->FormNumber();
1474 if (!(FormNb==11 || FormNb==12 || FormNb==63)) {
1475 Message_Msg msg1240("IGES_1240");
1476 SendWarning( start, msg1240);
1477 // "Copious Data : Form number is different from 11, 12 or 63 so the vector treatement is skipped");
1480 Standard_Integer NbPoints = start->NbPoints();
1482 Message_Msg msg1195("IGES_1195");
1483 SendFail(start, msg1195); // Count of points lower than 2
1487 // Filling array of poles :
1488 // ========================
1490 TColgp_Array1OfPnt2d TempPole(1,NbPoints);
1491 Standard_Integer TempIndex = TempPole.Lower();
1493 if (!GetModeTransfer() && start->HasTransf())
1494 TempPole.SetValue(TempIndex,gp_Pnt2d(start->TransformedPoint(1).X(),
1495 start->TransformedPoint(1).Y()));
1497 TempPole.SetValue(TempIndex,gp_Pnt2d(start->Point(1).X(),
1498 start->Point(1).Y()));
1502 Standard_Integer i;//svv Jan 10 2000 : porting on DEC
1503 for (i=2; i <= NbPoints; i++) {
1505 if (!GetModeTransfer() && start->HasTransf())
1506 aPole = gp_Pnt2d(start->TransformedPoint(i).X(),
1507 start->TransformedPoint(i).Y());
1509 aPole = gp_Pnt2d(start->Point(i).X(),
1510 start->Point(i).Y());
1511 // if (!aPole.IsEqual(TempPole(TempIndex-1), GetEpsCoeff())) //modified by rln 16/12/97 CSR# PRO11641 entity 46GetEpsGeom()*GetUnitFactor()
1512 //S4054: some filter must be kept UKI60556 entity 7 (two equal points)
1513 if (!aPole.IsEqual(TempPole(TempIndex-1), gp::Resolution()))
1514 TempPole.SetValue(TempIndex++,aPole);
1517 NbPoints = TempIndex - TempPole.Lower();
1518 //added by rln on 26/12/97 to avoid exception when creating Bspline from one point
1519 if (NbPoints == 1) {
1520 Message_Msg msg1235("IGES_1235");
1521 SendFail(start, msg1235);
1522 // The curve degenerates to a point");
1525 TColgp_Array1OfPnt2d Pole(1,NbPoints);
1527 TempIndex = TempPole.Lower();
1528 for (i=Pole.Lower(); i<=Pole.Upper(); i++)
1529 Pole.SetValue(i,TempPole.Value(TempIndex++));
1532 // Filling array of knots :
1533 // ========================
1535 TColStd_Array1OfReal Knot(1,NbPoints);
1537 Knot.SetValue(Knot.Lower(),0.0);
1539 for (i=Knot.Lower()+1; i <= Knot.Upper(); i++) {
1540 gp_Pnt2d Pole1 = Pole.Value(i);
1541 gp_Pnt2d Pole2 = Pole.Value(i-1);
1542 Standard_Real KnotDist = Pole1.Distance(Pole2);
1543 Knot.SetValue(i, Knot.Value(i-1)+KnotDist);
1546 const Standard_Integer Degree = 1;
1548 TColStd_Array1OfInteger Mult(1, NbPoints);
1550 Mult.SetValue(Mult.Lower(),Degree+1);
1551 Mult.SetValue(Mult.Upper(),Degree+1);
1553 res = new Geom2d_BSplineCurve(Pole, Knot, Mult, Degree);
1555 Standard_Real epsGeom = GetEpsGeom();
1556 Standard_Real anUVResolution = GetUVResolution();
1558 IGESConvGeom::IncreaseCurveContinuity (res, Max(Precision::Confusion(),epsGeom*anUVResolution), GetContinuity());