1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
18 //=======================================================================
21 // 21.12.98 rln, gka S4054
22 //:k5 abv 25 Dec 98: PRO8803 1901: extending method of fixing Multi > Degree
23 // 28.12.98 dce S3767 New messaging system
25 //#60 rln 29.12.98 PRO17015
26 //:l3 abv 11.01.99: CATIA01.igs: using less values for checking short lines
27 //%11 pdn 12.01.98 CTS22023 correcting used tolerances
28 //sln 29.12.2001 OCC90 : Method checkBSplineCurve and varification before creation of bspline curves were added
29 //=======================================================================
32 #include <IGESToBRep_BasicCurve.ixx>
34 #include <IGESToBRep.hxx>
35 #include <IGESToBRep_CurveAndSurface.hxx>
39 #include <Geom_BSplineCurve.hxx>
40 #include <Geom_Circle.hxx>
41 #include <Geom_Ellipse.hxx>
42 #include <Geom_Line.hxx>
43 #include <Geom_Hyperbola.hxx>
44 #include <Geom_Parabola.hxx>
45 #include <Geom_Transformation.hxx>
46 #include <Geom_TrimmedCurve.hxx>
48 #include <Geom2d_BSplineCurve.hxx>
49 #include <Geom2d_Circle.hxx>
50 #include <Geom2d_Ellipse.hxx>
51 #include <Geom2d_Hyperbola.hxx>
52 #include <Geom2d_Line.hxx>
53 #include <Geom2d_Parabola.hxx>
54 #include <Geom2d_TrimmedCurve.hxx>
57 #include <gp_Ax2d.hxx>
59 #include <gp_Dir2d.hxx>
60 #include <gp_GTrsf.hxx>
62 #include <gp_Pnt2d.hxx>
63 #include <gp_Trsf.hxx>
68 #include <IGESData_IGESEntity.hxx>
69 #include <IGESData_ToolLocation.hxx>
71 #include <IGESGeom_BSplineCurve.hxx>
72 #include <IGESGeom_CircularArc.hxx>
73 #include <IGESGeom_ConicArc.hxx>
74 #include <IGESGeom_Point.hxx>
75 #include <IGESGeom_SplineCurve.hxx>
76 #include <IGESGeom_TransformationMatrix.hxx>
78 #include <IGESConvGeom.hxx>
80 #include <Interface_Macros.hxx>
82 #include <Precision.hxx>
84 #include <TColgp_Array1OfPnt2d.hxx>
85 #include <TColgp_HArray1OfPnt.hxx>
86 #include <TColgp_HArray2OfPnt.hxx>
87 #include <TColgp_HArray1OfPnt2d.hxx>
89 #include <TColGeom_SequenceOfCurve.hxx>
91 #include <TColStd_Array1OfInteger.hxx>
92 #include <TColStd_Array1OfReal.hxx>
93 #include <TColStd_HArray1OfInteger.hxx>
94 #include <TColStd_HArray1OfReal.hxx>
95 #include <TColStd_SequenceOfInteger.hxx>
98 #include <Standard_ErrorHandler.hxx>
99 #include <Standard_Failure.hxx>
101 #include <Message_Msg.hxx>
102 #include <ShapeConstruct_Curve.hxx>
103 #include <gp_Hypr.hxx>
105 //=======================================================================
106 //function : CheckBSplineCurve
107 //purpose : Check coincidede knots Check whether knots are in ascending
108 // order and difference between vaues of weights more than 1000.
109 // Send corresponding messages. The function returns Standard_False
110 // if curve can not be created, Standard_True otherwise.
111 //=======================================================================
112 static Standard_Boolean checkBSplineCurve(IGESToBRep_BasicCurve* theCurve,
113 const Handle(IGESGeom_BSplineCurve)& theBSplineCurve,
114 TColStd_Array1OfReal& CKnots,
115 const TColStd_Array1OfReal& CWeights)
117 // check whether difference between vaues of weights more than 1000.
118 if(!theBSplineCurve->IsPolynomial()) {
119 Standard_Real aMinValue = CWeights.Value(CWeights.Lower());
120 Standard_Real aMaxValue = CWeights.Value(CWeights.Lower());
121 for(Standard_Integer i = CWeights.Lower()+1; i<= CWeights.Upper(); i++) {
122 if(CWeights.Value(i) < aMinValue) aMinValue = CWeights.Value(i);
123 if(CWeights.Value(i) > aMaxValue) aMaxValue = CWeights.Value(i);
125 if(aMaxValue - aMinValue > 1000) {
126 Message_Msg msg1374("IGES_1374"); // WARNING - Difference between weights is too big.
127 theCurve->SendWarning(theBSplineCurve, msg1374);
131 Standard_Boolean aResult = Standard_True;
133 //check whether knots are in ascending order.
134 for (Standard_Integer i = CKnots.Lower(); i < CKnots.Upper(); i++)
135 if(CKnots.Value (i+1) < CKnots.Value (i)) {
136 Message_Msg msg1373("IGES_1373"); // FAIL - Knots are not in ascending order
137 theCurve->SendFail(theBSplineCurve, msg1373);
138 aResult = Standard_False;
140 //Fix coincided knots
141 if(aResult) ShapeConstruct_Curve::FixKnots(CKnots);
149 //=======================================================================
150 //function : IGESToBRep_BasicCurve
152 //=======================================================================
153 IGESToBRep_BasicCurve::IGESToBRep_BasicCurve()
154 :IGESToBRep_CurveAndSurface()
156 SetModeTransfer(Standard_False);
160 //=======================================================================
161 //function : IGESToBRep_BasicCurve
163 //=======================================================================
164 IGESToBRep_BasicCurve::IGESToBRep_BasicCurve
165 (const IGESToBRep_CurveAndSurface& CS)
166 :IGESToBRep_CurveAndSurface(CS)
171 //=======================================================================
172 //function : IGESToBRep_BasicCurve
174 //=======================================================================
175 IGESToBRep_BasicCurve::IGESToBRep_BasicCurve
176 (const Standard_Real eps,
177 const Standard_Real epsCoeff,
178 const Standard_Real epsGeom,
179 const Standard_Boolean mode,
180 const Standard_Boolean modeapprox,
181 const Standard_Boolean optimized)
182 :IGESToBRep_CurveAndSurface(eps, epsCoeff, epsGeom, mode,
183 modeapprox,optimized)
188 //=======================================================================
189 //function : TransferBasicCurve
191 //=======================================================================
193 Handle(Geom_Curve) IGESToBRep_BasicCurve::TransferBasicCurve
194 (const Handle(IGESData_IGESEntity)& start)
196 Handle(Geom_Curve) res;
197 if (start.IsNull()) {
198 Message_Msg msg1005("IGES_1005");
199 SendFail(start, msg1005);
202 try { //:36 by abv 11.12.97: Geom_BSplineCurve fails if somw weights are <=0
205 if (start->IsKind(STANDARD_TYPE(IGESGeom_BSplineCurve))) {
206 DeclareAndCast(IGESGeom_BSplineCurve, st126, start);
207 res = TransferBSplineCurve(st126);
209 else if (start->IsKind(STANDARD_TYPE(IGESGeom_Line))) {
210 DeclareAndCast(IGESGeom_Line, st110, start);
211 res = TransferLine(st110);
213 else if (start->IsKind(STANDARD_TYPE(IGESGeom_CircularArc))) {
214 DeclareAndCast(IGESGeom_CircularArc, st100, start);
215 res = TransferCircularArc(st100);
217 else if (start->IsKind(STANDARD_TYPE(IGESGeom_ConicArc))) {
218 DeclareAndCast(IGESGeom_ConicArc, st104, start);
219 res = TransferConicArc(st104);
221 else if (start->IsKind(STANDARD_TYPE(IGESGeom_CopiousData))) {
222 DeclareAndCast(IGESGeom_CopiousData, st106, start);
223 res = TransferCopiousData(st106);
225 else if (start->IsKind(STANDARD_TYPE(IGESGeom_SplineCurve))) {
226 DeclareAndCast(IGESGeom_SplineCurve, st112, start);
227 res = TransferSplineCurve(st112);
230 // AddFail(start, "The IGESEntity is not a basic curve.");
231 // This case can not occur
236 catch(Standard_Failure) {
238 cout << "\n** Exception in IGESToBRep_BasicCurve::TransferBasicCurve : ";
239 Standard_Failure::Caught()->Print(cout);
243 // AddFail(start, "The IGESEntity cannot be transfered.");
244 // The more specific function have ever add a fail message for this entity
247 res->Scale(gp_Pnt(0,0,0),GetUnitFactor());
251 //=======================================================================
252 //function : Transfer2dBasicCurve
254 //=======================================================================
256 Handle(Geom2d_Curve) IGESToBRep_BasicCurve::Transfer2dBasicCurve
257 (const Handle(IGESData_IGESEntity)& start)
259 Handle(Geom2d_Curve) res;
260 if (start.IsNull()) {
261 Message_Msg msg1005("IGES_1005");
262 SendFail(start, msg1005);
265 try { //:h8 abv 15 Jul 98: BUC60291 43693: Bspline Multiplicity > Degree+1 -> exception
269 if (start->IsKind(STANDARD_TYPE(IGESGeom_BSplineCurve))) {
270 DeclareAndCast(IGESGeom_BSplineCurve, st126, start);
271 res = Transfer2dBSplineCurve(st126);
273 else if (start->IsKind(STANDARD_TYPE(IGESGeom_Line))) {
274 DeclareAndCast(IGESGeom_Line, st110, start);
275 res = Transfer2dLine(st110);
277 else if (start->IsKind(STANDARD_TYPE(IGESGeom_CircularArc))) {
278 DeclareAndCast(IGESGeom_CircularArc, st100, start);
279 res = Transfer2dCircularArc(st100);
281 else if (start->IsKind(STANDARD_TYPE(IGESGeom_ConicArc))) {
282 DeclareAndCast(IGESGeom_ConicArc, st104, start);
283 res = Transfer2dConicArc(st104);
285 else if (start->IsKind(STANDARD_TYPE(IGESGeom_CopiousData))) {
286 DeclareAndCast(IGESGeom_CopiousData, st106, start);
287 res = Transfer2dCopiousData(st106);
289 else if (start->IsKind(STANDARD_TYPE(IGESGeom_SplineCurve))) {
290 DeclareAndCast(IGESGeom_SplineCurve, st112, start);
291 res = Transfer2dSplineCurve(st112);
294 // AddFail(start, "The IGESEntity is not a basic curve.");
295 // This case can not occur
299 catch(Standard_Failure) {
301 cout << "\n** Exception in IGESToBRep_BasicCurve::Transfer2dBasicCurve : ";
302 Standard_Failure::Caught()->Print(cout);
310 //=======================================================================
311 //function : TransferConicArc
313 //=======================================================================
315 // A,B,C,D,E,F are the coefficients recorded in IGES. a,b,c,d,e,f are used to
316 // simplify the equations of convertion. They are already used in Euclid.
318 Handle(Geom_Curve) IGESToBRep_BasicCurve::TransferConicArc
319 (const Handle(IGESGeom_ConicArc)& st)
321 Handle(Geom_Curve) res;
323 Message_Msg msg1005("IGES_1005");
324 SendFail(st, msg1005);
327 // If the Conic is closed, the start and end points will be ignored.
328 if (!st->ComputedFormNumber()) {
329 Message_Msg msg1155("IGES_1155");
330 SendFail(st, msg1155);
331 // AddFail(st, "Coefficients do not define correctly a conic.");
335 // Conic = ax2+bxy+cy2+dx+ey+f=0 in the plane z=ZT.
336 Standard_Real a,b,c,d,e,f,ZT;
337 st->Equation(a, b, c, d, e, f);
341 gp_Pnt center, startPoint, endPoint;
342 gp_Dir mainAxis ,normAxis;
343 Standard_Real minorRadius, majorRadius;
345 if (!GetModeTransfer() && st->HasTransf()) {
347 st->TransformedDefinition(center ,mainAxis, minorRadius, majorRadius);
348 normAxis = st->TransformedAxis();
350 startPoint = st->TransformedStartPoint();
351 endPoint = st->TransformedEndPoint();
354 st->Definition(center ,mainAxis, minorRadius, majorRadius);
355 normAxis = st->Axis();
357 startPoint.SetCoord(st->StartPoint().X(), st->StartPoint().Y(), ZT);
358 endPoint.SetCoord (st->EndPoint().X() , st->EndPoint().Y() , ZT);
360 gp_Ax2 frame(center, normAxis, mainAxis);
361 Standard_Real t1 =0.0, t2 =0.0;
362 if (st->IsFromEllipse()) {
364 //#60 rln 29.12.98 PRO17015 reading back face#67: ellipse with big radii produces
366 //The dimensions should be also obliged:
368 //if ( (Abs(a-c) <= GetEpsGeom()) && (Abs(b) < GetEpsCoeff()))
369 Standard_Real eps2 = Precision::PConfusion() * Precision::PConfusion();
370 if ( (Abs(a-c) <= eps2) && (Abs(b) < eps2)) {
376 res = new Geom_Circle(frame, minorRadius);
378 if (!st->IsClosed()) {
380 gp_Circ circ(frame, minorRadius);
382 t1 = ElCLib::Parameter(circ, startPoint);
383 t2 = ElCLib::Parameter(circ, endPoint);
384 if (t1 > t2 && (t1 - t2) > Precision::Confusion()) t2 += 2.*M_PI;
385 if (Abs(t1 - t2) <= Precision::Confusion()) { // t1 = t2
386 Message_Msg msg1160("IGES_1160");
387 SendWarning(st, msg1160);
390 res = new Geom_TrimmedCurve(res, t1, t2);
395 // This is a no circular ellipse which will be computed with
396 // the hyperbola at the end of this member.
399 else if (st->IsFromParabola()) {
401 // ===================
403 // ===================
405 Standard_Real focal = minorRadius;
408 gp_Parab parab(frame, focal);
410 res = new Geom_Parabola(frame, focal);
412 t1 = ElCLib::Parameter(parab, startPoint);
413 t2 = ElCLib::Parameter(parab, endPoint);
414 if (Abs(t1 - t2) <= Precision::Confusion()) { // t1 = t2
415 Message_Msg msg1160("IGES_1160");
416 SendWarning(st, msg1160);
417 //AddWarning(st, "The trim of the parabola is not correct.");
420 // if t1 > t2, the course of the curve is going to be reversed.
421 res = new Geom_TrimmedCurve(res, t1, t2);
426 // Same computing for the ellipse and the hyperbola.
428 // =============================================
429 // == Hyperbola or a no circular Ellipse 3D. ==
430 // =============================================
433 if (st->IsFromEllipse()) {
434 res = new Geom_Ellipse(frame, majorRadius, minorRadius);
436 if (!st->IsClosed()) {
437 gp_Elips elips(frame, majorRadius, minorRadius);
439 t1 = ElCLib::Parameter(elips, startPoint);
440 t2 = ElCLib::Parameter(elips, endPoint);
441 if (t2 < t1 && (t1 -t2) > Precision::Confusion()) t2 += 2.*M_PI;
442 if (Abs(t1 - t2) <= Precision::Confusion()) { // t1 = t2
443 Message_Msg msg1160("IGES_1160");
444 SendWarning(st, msg1160);
445 //AddWarning(st, "The trim of the ellipse is not correct, the result will be a ellipse.");
448 res = new Geom_TrimmedCurve(res, t1, t2);
453 gp_Hypr hpr(frame, majorRadius, minorRadius);
455 t1 = ElCLib::Parameter(hpr, startPoint);
456 t2 = ElCLib::Parameter(hpr, endPoint);
458 res = new Geom_Hyperbola(frame, majorRadius, minorRadius);
460 //pdn taking PConfusion for parameters.
461 if (Abs(t1 - t2) <= Precision::PConfusion()) { // t1 = t2
462 Message_Msg msg1160("IGES_1160");
463 SendWarning(st, msg1160);
466 res = new Geom_TrimmedCurve(res, t2, t1); // inversion des parametres.
468 res = new Geom_TrimmedCurve(res, t1, t2);
475 //=======================================================================
476 //function : Transfer2dConicArc
477 //purpose : Transfer 2d of a ConicArc to be used as a boundary of a Face
478 //=======================================================================
480 Handle(Geom2d_Curve) IGESToBRep_BasicCurve::Transfer2dConicArc
481 (const Handle(IGESGeom_ConicArc)& st)
483 Handle(Geom2d_Curve) res;
485 Message_Msg msg1005("IGES_1005");
486 SendFail(st, msg1005);
490 if (!st->ComputedFormNumber()) {
491 Message_Msg msg1155("IGES_1155");
492 SendFail(st, msg1155);
496 Standard_Real a,b,c,d,e,f;
497 // Conic = ax2+bxy+cy2+dx+ey+f=0.
498 st->Equation(a, b, c, d, e, f);
502 gp_Pnt2d startPoint, endPoint;
503 Standard_Real minorRadius, majorRadius;
506 if (!st->TransformedAxis().IsParallel /*#45 rln 23.11.98 IsEqual*/(st->Axis(), GetEpsilon())) {
507 SetModeTransfer(Standard_True);
508 // Only not to use Trsf.
509 // the normal axis is not parallel with Z axis.
510 SendWarning(st, "The Trsf is not compatible with a transfer2d, it will not applied.");
513 if (!GetModeTransfer() && st->HasTransf()) {
515 st->TransformedDefinition(center3d,
519 startPoint.SetCoord(st->TransformedStartPoint().X(),
520 st->TransformedStartPoint().Y());
521 endPoint.SetCoord(st->TransformedEndPoint().X(),
522 st->TransformedEndPoint().Y());
525 st->Definition(center3d, mainAxis3d, minorRadius, majorRadius);
526 startPoint = st->StartPoint();
527 endPoint = st->EndPoint();
530 gp_Pnt2d center(center3d.X(), center3d.Y());
531 gp_Dir2d mainAxis(mainAxis3d.X(), mainAxis3d.Y());
532 gp_Ax2d frame(center, mainAxis);
533 Standard_Real t1 =0.0, t2=0.0;
534 if (st->IsFromEllipse()) {
536 //#60 rln 29.12.98 PRO17015
537 //if ( (Abs(a-c) <= GetEpsGeom()) && (Abs(b) < GetEpsCoeff()))
538 Standard_Real eps2 = Precision::PConfusion() * Precision::PConfusion();
539 if ( (Abs(a-c) <= eps2) && (Abs(b) < eps2)) {
545 res = new Geom2d_Circle(frame, minorRadius);
547 if (st->TransformedAxis().IsOpposite (st->Axis(), GetEpsilon()))
550 if (!st->IsClosed()) {
552 gp_Circ2d circ = Handle(Geom2d_Circle)::DownCast(res)->Circ2d();//#45 rln (frame, minorRadius);
554 t1 = ElCLib::Parameter(circ, startPoint);
555 t2 = ElCLib::Parameter(circ, endPoint);
557 if (t2 < t1 && (t1 -t2) > Precision::PConfusion()) t2 += 2.*M_PI;
558 if (Abs(t1 - t2) <= Precision::PConfusion()) { // t1 = t2
559 Message_Msg msg1160("IGES_1160");
560 SendWarning(st, msg1160);
563 res = new Geom2d_TrimmedCurve(res, t1, t2);
568 // This is a no circular ellipse, it will be computed with the hyperbola.
571 else if (st->IsFromParabola()) {
573 // ===================
575 // ===================
577 Standard_Real focal = minorRadius;
580 res = new Geom2d_Parabola(frame, focal);
582 if (st->TransformedAxis().IsOpposite (st->Axis(), GetEpsilon()))
585 gp_Parab2d parab = Handle(Geom2d_Parabola)::DownCast(res)->Parab2d();//#45 rln (frame, focal);
587 t1 = ElCLib::Parameter(parab, startPoint);
588 t2 = ElCLib::Parameter(parab, endPoint);
589 if (Abs(t1 - t2) <= Precision::PConfusion()) { // t1 = t2
590 Message_Msg msg1160("IGES_1160");
591 SendWarning(st, msg1160);
594 res = new Geom2d_TrimmedCurve(res, t2, t1); // inversion des parametres.
596 res = new Geom2d_TrimmedCurve(res, t1, t2);
600 /* Same computing for the ellipse2d and the hyperbola2d. */
602 // ============================================
603 // == Hyperbola or a no circular Ellipse 2D ==
604 // ============================================
606 if (st->IsFromEllipse()) {
608 res = new Geom2d_Ellipse(frame, majorRadius, minorRadius);
610 if (st->TransformedAxis().IsOpposite (st->Axis(), GetEpsilon()))
613 if (!st->IsClosed()) {
615 gp_Elips2d elips = Handle(Geom2d_Ellipse)::DownCast(res)->Elips2d();//#45 rln (frame, majorRadius, minorRadius);
617 t1 = ElCLib::Parameter(elips, startPoint);
618 t2 = ElCLib::Parameter(elips, endPoint);
619 if (t2 < t1 && (t1 - t2) > Precision::PConfusion()) t2 += 2.*M_PI;
620 if (Abs(t1 - t2) <= Precision::PConfusion()) { // t1 = t2
621 Message_Msg msg1160("IGES_1160");
622 SendWarning(st, msg1160);
625 res = new Geom2d_TrimmedCurve(res, t1, t2);
630 res = new Geom2d_Hyperbola(frame, majorRadius, minorRadius);
632 if (st->TransformedAxis().IsOpposite (st->Axis(), GetEpsilon()))
635 gp_Hypr2d hpr = Handle(Geom2d_Hyperbola)::DownCast(res)->Hypr2d();//#45 rln (frame, majorRadius, minorRadius);
637 t1 = ElCLib::Parameter(hpr, startPoint);
638 t2 = ElCLib::Parameter(hpr, endPoint);
640 if (Abs(t1 - t2) <= Precision::PConfusion()) { // t1 = t2
641 Message_Msg msg1160("IGES_1160");
642 SendWarning(st, msg1160);
645 res = new Geom2d_TrimmedCurve(res, t2, t1); // inversion des parametres.
647 res = new Geom2d_TrimmedCurve(res, t1, t2);
654 //=======================================================================
655 //function : TransferCircularArc
657 //=======================================================================
659 Handle(Geom_Curve) IGESToBRep_BasicCurve::TransferCircularArc
660 (const Handle(IGESGeom_CircularArc)& st)
662 Handle(Geom_Curve) res;
664 Message_Msg msg1005("IGES_1005");
665 SendFail(st,msg1005);
669 gp_Dir tNormAxis, tMainAxis;
671 gp_Pnt startPoint, endPoint;
673 if (!GetModeTransfer() && st->HasTransf()) {
675 tNormAxis = st->TransformedAxis();
677 gp_GTrsf loc = st->Location();
678 loc.SetTranslationPart (gp_XYZ(0.,0.,0.));
679 gp_XYZ mainAxis(1., 0., 0.);
680 loc.Transforms(mainAxis);
681 tMainAxis = gp_Dir(mainAxis);
683 startPoint = st->TransformedStartPoint();
684 endPoint = st->TransformedEndPoint();
686 frame = gp_Ax2(st->TransformedCenter(), tNormAxis, tMainAxis);
689 tNormAxis = st->Axis();
690 tMainAxis.SetCoord(1., 0., 0.);
692 Standard_Real ZT = st->ZPlane();
693 startPoint.SetCoord(st->StartPoint().X(), st->StartPoint().Y(), ZT);
694 endPoint.SetCoord (st->EndPoint().X() , st->EndPoint().Y() , ZT);
695 gp_Pnt centerPoint (st->Center().X() , st->Center().Y() , ZT);
697 frame = gp_Ax2(centerPoint, tNormAxis, tMainAxis);
700 res = new Geom_Circle(frame, st->Radius());
702 gp_Circ circ(frame, st->Radius());
704 Standard_Real t1 =0.0, t2 =0.0;
706 t1 = ElCLib::Parameter(circ, startPoint);
707 t2 = ElCLib::Parameter(circ, endPoint);
709 if ( st->IsClosed() && t1>=GetEpsGeom()) t2 = t1 + 2.*M_PI;
710 if (!st->IsClosed() && fabs(t1 - t2) <=Precision::PConfusion()) {
712 // cky 27 Aout 1996 : t2-t1 vaut distance(start,end)/rayon
713 t2 = t1 + startPoint.Distance(endPoint)/st->Radius();
715 if (!st->IsClosed() || t1>=GetEpsGeom()) {
716 if (t2 < t1) t2 += 2.*M_PI;
717 res = new Geom_TrimmedCurve(res, t1, t2);
723 //=======================================================================
724 //function : Transfer2dCircularArc
726 //=======================================================================
728 Handle(Geom2d_Curve) IGESToBRep_BasicCurve::Transfer2dCircularArc
729 (const Handle(IGESGeom_CircularArc)& st)
731 Handle(Geom2d_Curve) res;
733 Message_Msg msg1005("IGES_1005");
734 SendFail(st,msg1005);
738 gp_XYZ center(st->Center().X(), st->Center().Y(), 0.);
739 gp_XYZ mainAxis(1., 0., 0.);
742 if (!st->TransformedAxis().IsParallel /*#45 rln 23.11.98 IsEqual*/(st->Axis(), GetEpsilon())) {
743 SetModeTransfer(Standard_True); // Only not to use Trsf
744 Message_Msg msg1165("IGES_1165");
745 SendWarning(st, msg1165); //"The Trsf is not compatible with a transfer2d, it will not applied."
748 if (!GetModeTransfer() && st->HasTransf()) {
749 gp_GTrsf loc = st->Location();
750 loc.Transforms(center);
751 loc.SetTranslationPart (gp_XYZ(0.,0.,0.));
752 loc.Transforms(mainAxis);
754 gp_Pnt2d tCenter(center.X(), center.Y());
755 gp_Dir2d tMainAxis(mainAxis.X(), mainAxis.Y());
756 gp_Ax2d frame(tCenter, tMainAxis);
758 res = new Geom2d_Circle(frame, st->Radius());
760 gp_Pnt2d startPoint, endPoint;
761 if (!GetModeTransfer() && st->HasTransf()) {
762 startPoint.SetCoord(st->TransformedStartPoint().X(),
763 st->TransformedStartPoint().Y());
764 endPoint.SetCoord(st->TransformedEndPoint().X(),
765 st->TransformedEndPoint().Y());
767 if (st->TransformedAxis().IsOpposite (st->Axis(), GetEpsilon()))
771 startPoint = st->StartPoint();
772 endPoint = st->EndPoint();
775 gp_Circ2d circ = Handle(Geom2d_Circle)::DownCast(res)->Circ2d();//#45 rln (frame, st->Radius());
777 Standard_Real t1 =0.0, t2 =0.0;
779 t1 = ElCLib::Parameter(circ, startPoint);
780 t2 = ElCLib::Parameter(circ, endPoint);
782 if ( st->IsClosed() && t1>=GetEpsGeom()) t2 = t1 + 2.*M_PI;
783 if (!st->IsClosed() && fabs(t1 -t2) <= Precision::PConfusion()) {
785 // cky 27 Aout 1996 : t2-t1 vaut distance(start,end)/rayon
786 t2 = t1 + startPoint.Distance(endPoint)/st->Radius();
788 if (!st->IsClosed() || t1>= GetEpsGeom()) {
789 if (t2 < t1) t2 += 2.*M_PI;
790 res = new Geom2d_TrimmedCurve(res, t1, t2);
797 //=======================================================================
798 //function : TransferSplineCurve
800 //=======================================================================
802 Handle(Geom_BSplineCurve) IGESToBRep_BasicCurve::TransferSplineCurve
803 (const Handle(IGESGeom_SplineCurve)& st)
805 Handle(Geom_BSplineCurve) resconv;
807 Message_Msg msg1005("IGES_1005");
808 SendFail(st,msg1005);
812 Standard_Real epscoef = GetEpsCoeff();
813 Standard_Real epsgeom = GetEpsGeom();
815 Standard_Integer result = IGESConvGeom::SplineCurveFromIGES(st, epscoef, epsgeom, resconv);
819 Message_Msg msg246("XSTEP_246");
820 SendFail(st, msg246);
821 // less than on segment (no result produced)
825 Message_Msg msg1170("IGES_1170");
826 SendFail(st, msg1170);
827 // Polynomial equation is not correct ( no result produced
830 Message_Msg msg1175("IGES_1175");
831 SendFail(st, msg1175);
832 // Error during creation of control points ( no result produced)
835 Message_Msg msg1180("IGES_1180");
836 SendFail(st, msg1180);
837 //SplineType not processed (allowed : max 3) (no result produced)
843 // Checking C2 and C1 continuity :
844 // ===============================
845 IGESConvGeom::IncreaseCurveContinuity (resconv, Min(Precision::Confusion(),epsgeom), GetContinuity());
851 //=======================================================================
852 //function : Transfer2dSplineCurve
854 //=======================================================================
856 Handle(Geom2d_BSplineCurve) IGESToBRep_BasicCurve::Transfer2dSplineCurve
857 (const Handle(IGESGeom_SplineCurve)& st)
859 Handle(Geom2d_BSplineCurve) res;
861 Message_Msg msg1005("IGES_1005");
862 SendFail(st, msg1005);
868 // The same Presision as in BSpline 2d is used
869 Standard_Real epsGeom = GetEpsGeom();
870 SetEpsGeom(Precision::PConfusion());
871 Handle(Geom_BSplineCurve) res3d = TransferSplineCurve(st);
874 return res; // The transfer was not over the top.
879 Standard_Integer nbPoles = res3d->NbPoles();
880 Standard_Integer nbKnots = res3d->NbKnots();
882 TColgp_Array1OfPnt2d bspoles2d(1, nbPoles);
883 TColStd_Array1OfReal knots(1, nbKnots);
884 TColStd_Array1OfInteger multi(1, nbKnots);
887 res3d->Multiplicities(multi);
889 for (Standard_Integer i = bspoles2d.Lower(); i <= bspoles2d.Upper(); i++)
890 bspoles2d.SetValue(i, gp_Pnt2d(res3d->Pole(i).X(), res3d->Pole(i).Y()));
892 res = new Geom2d_BSplineCurve (bspoles2d, knots, multi, res3d->Degree());
896 //=======================================================================
897 //function : TransferBSplineCurve
899 //=======================================================================
901 Handle(Geom_Curve) IGESToBRep_BasicCurve::TransferBSplineCurve
902 (const Handle(IGESGeom_BSplineCurve)& start)
905 Handle(Geom_BSplineCurve) BSplineRes;
906 Handle(Geom_Curve) res;
908 if (start.IsNull()) {
909 Message_Msg msg1005("IGES_1005");
910 SendFail(start,msg1005);
914 Standard_Integer Degree = start->Degree();
916 if (Degree<=0 || Degree>Geom_BSplineCurve::MaxDegree()) {
917 Message_Msg msg1190("IGES_1190");
918 SendFail(start, msg1190);
919 // Improper degree either lower or equal to 0 or upper to MaxDegree
924 // Filling poles array :
925 // =====================
927 Standard_Integer NbPoles = start->NbPoles();
928 Standard_Integer newNbPoles = NbPoles;
931 Message_Msg msg1195("IGES_1195");
932 SendFail(start, msg1195);
933 // Transfer aborted for a BSpline Curve : Number of poles lower than 2
937 TColgp_Array1OfPnt Pole(1,NbPoles);
938 Standard_Integer PoleIndex = Pole.Lower();
939 Standard_Integer i; //szv#4:S4163:12Mar99 j unused
941 if (!GetModeTransfer() && start->HasTransf())
942 for (i=0; i<=start->UpperIndex(); i++)
943 Pole.SetValue(PoleIndex++, start->TransformedPole(i));
945 for (i=0; i<=start->UpperIndex(); i++)
946 Pole.SetValue(PoleIndex++, start->Pole(i));
949 // Filling knots & multiplicities arraies :
950 // ========================================
952 Standard_Integer NbKnots = start->NbKnots();
953 TColStd_Array1OfReal TempKnot(1,NbKnots);
954 TColStd_Array1OfInteger TempMult(1,NbKnots);
956 Standard_Integer KnotIndex = TempKnot.Lower();
958 TempKnot.SetValue(KnotIndex, start->Knot(-Degree));
960 // If several identical IGES knots are encountered, corresponding
961 // multiplicity is increased
962 // ==============================================================
964 for (i=1-Degree; i<NbKnots-Degree; i++) {
966 Standard_Real Knot1 = start->Knot(i);
967 Standard_Real Knot2 = start->Knot(i-1);
968 // Standard_Real ek = Epsilon(Knot1);
970 if (Abs(Knot1 - Knot2) <= Epsilon(Knot1))
971 TempMult.SetValue(KnotIndex, TempMult.Value(KnotIndex)+1);
973 TempKnot.SetValue(++KnotIndex, Knot1);
977 // Final knots & multiplicities arraies are dimensionned so as to be fully
979 // =======================================================================
981 TColStd_Array1OfReal Knot(1,KnotIndex);
982 TColStd_Array1OfInteger Mult(1,KnotIndex);
984 Standard_Integer SumOfMult=0;
986 TColStd_SequenceOfInteger SeqIndex;
987 Standard_Integer DelIndex;
988 Standard_Integer OldSumOfMult = 0;
989 for (i=1; i <= KnotIndex; i++) { //:k5 abv 25 Dec 98: cycle modified
990 Standard_Integer aMult = TempMult.Value(i);
991 Standard_Integer maxMult = ( i==1 || i == KnotIndex ? Degree + 1 : Degree );
992 if (aMult > maxMult) {
993 Message_Msg msg1200("IGES_1200");//#61 rln 05.01.99
994 const Standard_CString vide ("");
998 SendWarning(start, msg1200);//Multiplicity > Degree (or Degree+1 at end); corrected
999 for ( DelIndex = OldSumOfMult + 1; aMult > maxMult; DelIndex++, aMult-- ) {
1001 SeqIndex.Append(DelIndex);
1004 OldSumOfMult += TempMult.Value(i);
1005 Knot.SetValue(i, TempKnot.Value(i));
1006 Mult.SetValue(i, aMult);
1010 // Mise a jour du tableau des poles lors de la correction de la multiplicite
1011 TColgp_Array1OfPnt Poles(1,newNbPoles);
1012 TColStd_SequenceOfInteger PoleInd;
1014 if ( newNbPoles < NbPoles) {
1015 for (i=1; i<=NbPoles; i++) PoleInd.Append(i);
1016 Standard_Integer Offset = 0;
1017 for (Standard_Integer itab = 1; itab <= SeqIndex.Length(); itab++) {
1018 DelIndex = SeqIndex.Value(itab) - Offset;
1019 PoleInd.Remove(DelIndex);
1022 Standard_Integer nbseq = PoleInd.Length();
1023 if ( nbseq == newNbPoles) {
1024 Standard_Integer indj = 1;
1025 for ( i=1; i<= newNbPoles; i++) {
1026 Poles.SetValue(i, Pole.Value(PoleInd.Value(indj++)));
1032 for ( i=1; i<= newNbPoles; i++) {
1033 Poles.SetValue (i, Pole.Value(i));
1038 if (! (SumOfMult == newNbPoles + Degree + 1)) {
1039 Message_Msg msg1210("IGES_1210");
1040 const Standard_CString vide ("");
1043 SendWarning(start, msg1210);
1044 //Sum of multiplicities not equal to the sum : Count of poles + Degree + 1
1047 // Output BSpline curve with the array of pole weights if any :
1048 // ============================================================
1050 TColStd_Array1OfReal Weight(1,newNbPoles);
1052 if (start->IsPolynomial()) {
1053 //:5 BSplineC = new Geom_BSplineCurve(Poles, Knot, Mult, Degree);
1056 TColStd_Array1OfReal PoleWeight(1,NbPoles);
1057 Standard_Boolean polynomial = Standard_True;
1058 Standard_Real WeightReference = start->Weight(0);
1059 Standard_Integer WeightIndex = PoleWeight.Lower();
1061 for (i=0; i <= start->UpperIndex(); i++) {
1062 polynomial = Abs(start->Weight(i) - WeightReference) <=
1063 Epsilon(WeightReference) && polynomial;
1064 //:39 by abv 15.12.97
1065 Standard_Real weight = start->Weight(i);
1066 if ( weight < Precision::PConfusion() ) {
1067 Message_Msg msg1215("IGES_1215");
1068 SendFail(start, msg1215);
1069 // Some weights are not positive
1072 PoleWeight.SetValue(WeightIndex++, weight);
1073 //:39 PoleWeight.SetValue(WeightIndex++, start->Weight(i));
1076 Message_Msg msg1220("IGES_1220");
1077 msg1220.Arg("curve");
1078 SendWarning(start, msg1220);
1079 // Rational curve is polynomial
1081 // Mise a jour du tableau des Weight lors de la correction de la multiplicite
1082 if ( newNbPoles < NbPoles) {
1083 Standard_Integer indj = 1;
1084 for ( i=1; i<= newNbPoles; i++) {
1085 Weight.SetValue(i, PoleWeight.Value(PoleInd.Value(indj++)));
1089 for ( i=1; i<= newNbPoles; i++) {
1090 Weight.SetValue (i, PoleWeight.Value(i));
1093 //:5 BSplineC = new Geom_BSplineCurve(Poles, Weight, Knot, Mult, Degree);
1096 //sln 29.12.2001 OCC90 : If curve can not be created do nothing
1097 if(!checkBSplineCurve(this, start, Knot, Weight)) return BSplineRes;
1102 if (start->IsPolynomial())
1103 BSplineRes = new Geom_BSplineCurve(Poles, Knot, Mult, Degree);
1105 BSplineRes = new Geom_BSplineCurve(Poles, Weight, Knot, Mult, Degree);
1107 catch(Standard_Failure) {
1109 cout << "\n** Exception in IGESToBRep_BasicCurve::TransferBSplineCurve during creation of Geom_BSplineCurve : ";
1110 Standard_Failure::Caught()->Print(cout);
1115 Standard_Real First = BSplineRes->FirstParameter();
1116 Standard_Real Last = BSplineRes->LastParameter();
1117 Standard_Real Udeb = start->UMin();
1118 Standard_Real Ufin = start->UMax();
1119 //%11 pdn 12.01.98 CTS22023
1120 //if ( (Udeb-First) > Precision::PConfusion() || (Last-Ufin) > Precision::PConfusion() )
1121 // BSplineRes->Segment(Udeb, Ufin);
1124 // IGESConvGeom::IncreaseCurveContinuity (BSplineRes,Min(Precision::Confusion(),GetEpsGeom()), GetContinuity());
1126 // skl 21.02.2002 (exception in OCC133 and for file
1127 // "/dn04/OS/USINOR/UIdev/src/IsoLim/dat/igs/ps1002-v5.igs")
1128 Handle(Geom_BSplineCurve) BSplineRes2 = BSplineRes;
1129 if (((Udeb-First)>-Precision::PConfusion() &&
1130 (Last-Ufin)>-Precision::PConfusion()) && Udeb<=Ufin ) {
1133 BSplineRes->Segment(Udeb, Ufin);
1136 catch (Standard_Failure) {
1137 Handle(Geom_TrimmedCurve) gtc = new Geom_TrimmedCurve(BSplineRes2,Udeb,Ufin);
1149 //=======================================================================
1150 //function : Transfer2dBSplineCurve
1152 //=======================================================================
1154 Handle(Geom2d_Curve) IGESToBRep_BasicCurve::Transfer2dBSplineCurve
1155 (const Handle(IGESGeom_BSplineCurve)& start)
1157 Handle(Geom2d_Curve) res;
1158 if (start.IsNull()) {
1159 Message_Msg msg1005("IGES_1005");
1160 SendFail(start, msg1005);
1164 Handle(Geom2d_BSplineCurve) BSplineC;
1165 Handle(Geom_BSplineCurve) Bspline;
1166 Standard_Boolean IsTrimmed = Standard_False;
1167 Standard_Real Deb=0., Fin=0.;
1169 // 3d transfer first :
1170 // ===================
1171 // Standard_Real epsGeom = GetEpsGeom();
1172 // SetEpsGeom(Precision::PConfusion());
1173 Handle(Geom_Curve) res3d = TransferBSplineCurve(start);
1174 // SetEpsGeom(epsGeom);
1175 if (res3d.IsNull()) {
1180 if (res3d->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
1181 DeclareAndCast(Geom_TrimmedCurve, TrimC, res3d);
1182 Handle(Geom_Curve) BasicCurve = TrimC->BasisCurve();
1183 Deb = TrimC->FirstParameter();
1184 Fin = TrimC->LastParameter();
1185 IsTrimmed = Standard_True;
1186 if (BasicCurve->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) {
1187 DeclareAndCast(Geom_BSplineCurve, BSpline, BasicCurve);
1194 else if (res3d->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) {
1195 DeclareAndCast(Geom_BSplineCurve, BSpline, res3d);
1200 // Creating 2d poles :
1201 // ===================
1203 Standard_Integer NbPoles = Bspline->NbPoles();
1204 TColgp_Array1OfPnt2d Pole(1,NbPoles);
1206 for (Standard_Integer i=1; i<=NbPoles; i++){
1207 gp_Pnt2d aPole2d(Bspline->Pole(i).X(),Bspline->Pole(i).Y());
1208 Pole.SetValue(i,aPole2d);
1211 // Knots and multiplicities are the same :
1212 // =======================================
1214 Standard_Integer NbKnots = Bspline->NbKnots();
1216 TColStd_Array1OfReal Knot(1,NbKnots);
1217 Bspline->Knots(Knot);
1219 TColStd_Array1OfInteger Mult(1,NbKnots);
1220 Bspline->Multiplicities(Mult);
1222 Standard_Integer Degree = Bspline->Degree();
1224 if (Bspline->IsRational()) {
1225 TColStd_Array1OfReal Weight(1,NbPoles);
1226 Bspline->Weights(Weight);
1227 BSplineC = new Geom2d_BSplineCurve(Pole, Weight, Knot, Mult, Degree);
1229 else BSplineC = new Geom2d_BSplineCurve(Pole, Knot, Mult, Degree);
1233 // cas ou la Bspline est trimmee.
1235 Handle(Geom2d_TrimmedCurve) TC = new Geom2d_TrimmedCurve
1236 (BSplineC, Deb, Fin, Standard_True);
1245 //=======================================================================
1246 //function : TransferLine
1248 //=======================================================================
1250 Handle(Geom_Curve) IGESToBRep_BasicCurve::TransferLine
1251 (const Handle(IGESGeom_Line)& start)
1253 Handle(Geom_Curve) res;
1254 if (start.IsNull()) {
1255 Message_Msg msg1005("IGES_1005");
1256 SendFail(start, msg1005);
1262 if (!GetModeTransfer() && start->HasTransf()) {
1263 Ps = start->TransformedStartPoint();
1264 Pe = start->TransformedEndPoint();
1267 Ps = start->StartPoint();
1268 Pe = start->EndPoint();
1271 // modif du 15/10/97 : test moins severe
1272 // beaucoup de points confondus a GetEpsGeom()*GetUnitFactor()
1273 if (!Ps.IsEqual(Pe,Precision::Confusion())) { //:l3 abv 11 Jan 99: GetEpsGeom()*GetUnitFactor()/10.)) {
1274 gp_Lin line(Ps, gp_Dir(gp_Vec(Ps,Pe)));
1275 Standard_Real t1 = ElCLib::Parameter(line, Ps);
1276 Standard_Real t2 = ElCLib::Parameter(line, Pe);
1277 Handle(Geom_Line) Gline = new Geom_Line(line);
1278 if (Precision::IsNegativeInfinite(t1)) t1 = -Precision::Infinite();
1279 if (Precision::IsPositiveInfinite(t2)) t2 = Precision::Infinite();
1280 res = new Geom_TrimmedCurve(Gline, t1, t2);
1283 Message_Msg msg1225("IGES_1225");
1284 SendFail(start, msg1225);
1285 // StartPoint and EndPoint of the line are the same Point
1293 //=======================================================================
1294 //function : Transfer2dLine
1296 //=======================================================================
1298 Handle(Geom2d_Curve) IGESToBRep_BasicCurve::Transfer2dLine
1299 (const Handle(IGESGeom_Line)& start)
1301 Handle(Geom2d_Curve) res;
1302 if (start.IsNull()) {
1303 Message_Msg msg1005("IGES_1005");
1304 SendFail(start, msg1005);
1310 if (!GetModeTransfer() && start->HasTransf()) {
1311 beg.SetCoord(start->TransformedStartPoint().X(),
1312 start->TransformedStartPoint().Y());
1313 end.SetCoord(start->TransformedEndPoint().X(),
1314 start->TransformedEndPoint().Y());
1317 beg.SetCoord(start->StartPoint().X(),
1318 start->StartPoint().Y());
1319 end.SetCoord(start->EndPoint().X(),
1320 start->EndPoint().Y());
1323 if (!beg.IsEqual(end,Precision::PConfusion())) { //:l3 abv 11 Jan 99: GetEpsCoeff())) {
1324 gp_Lin2d line2d(beg, gp_Dir2d(gp_Vec2d(beg,end)));
1325 Standard_Real t1 = ElCLib::Parameter(line2d, beg);
1326 Standard_Real t2 = ElCLib::Parameter(line2d, end);
1327 Handle(Geom2d_Line) Gline2d = new Geom2d_Line(line2d);
1328 if (Precision::IsNegativeInfinite(t1)) t1 = -Precision::Infinite();
1329 if (Precision::IsPositiveInfinite(t2)) t2 = Precision::Infinite();
1330 res = new Geom2d_TrimmedCurve(Gline2d, t1, t2);
1332 //added by rln 18/12/97 CSR# CTS18544 entity 25168 and 31273
1333 //generating fail the same as above
1335 Message_Msg msg1225("IGES_1225");
1336 SendFail(start, msg1225); // StartPoint and EndPoint of the 2d line are the same Point
1343 //=======================================================================
1344 //function : TransferTransformation
1346 //=======================================================================
1348 Handle(Geom_Transformation) IGESToBRep_BasicCurve::TransferTransformation
1349 (const Handle(IGESGeom_TransformationMatrix)& start)
1352 Handle(Geom_Transformation) res;
1353 if (start.IsNull()) {
1354 Message_Msg msg1005("IGES_1005");
1355 SendFail(start, msg1005);
1360 if ( IGESData_ToolLocation::ConvertLocation
1361 (GetEpsilon(),start->Value(),resultat) )
1362 res = new Geom_Transformation(resultat);
1364 Message_Msg msg1036("IGES_1036");
1365 SendFail(start, msg1036); // Transformation : not a similarity
1373 //=======================================================================
1374 //function : TransferCopiousData
1376 //=======================================================================
1378 Handle(Geom_BSplineCurve) IGESToBRep_BasicCurve::TransferCopiousData
1379 (const Handle(IGESGeom_CopiousData)& start)
1382 Handle(Geom_BSplineCurve) res;
1383 if (start.IsNull()) {
1384 Message_Msg msg1005("IGES_1005");
1385 SendFail(start, msg1005);
1389 Standard_Integer FormNb = start->FormNumber();
1390 if (!(FormNb==11 || FormNb==12 || FormNb==63)) {
1391 Message_Msg msg1240("IGES_1240");
1392 SendWarning( start, msg1240);
1393 // "Copious Data : Form number is different from 11, 12 or 63 so the vector treatement is skipped");
1396 Standard_Integer NbPoints = start->NbPoints();
1398 Message_Msg msg1195("IGES_1195");
1399 SendFail(start, msg1195); // Count of points lower than 2
1403 // Filling array of poles :
1404 // ========================
1406 TColgp_Array1OfPnt TempPole(1,NbPoints);
1407 Standard_Integer TempIndex = TempPole.Lower();
1409 if (!GetModeTransfer() && start->HasTransf()) {
1410 TempPole.SetValue(TempIndex,start->TransformedPoint(1));
1413 TempPole.SetValue(TempIndex,start->Point(1));
1417 Standard_Integer i;// svv Jan 10 2000 : porting on DEC
1418 for (i=2; i <= NbPoints; i++) {
1420 if (!GetModeTransfer() && start->HasTransf())
1421 aPole = start->TransformedPoint(i);
1423 aPole = start->Point(i);
1424 // #2 pdn 7 May 1998 BUC50028
1425 // delete GetUnitFactor()
1426 // if (!aPole.IsEqual(TempPole(TempIndex-1),GetEpsGeom()))
1427 //S4054: some filter must be kept UKI60556 entity 7 (two equal points)
1428 if (!aPole.IsEqual(TempPole(TempIndex-1), gp::Resolution()))
1429 TempPole.SetValue(TempIndex++,aPole);
1432 NbPoints = TempIndex - TempPole.Lower();
1434 // #1 pdn 7 May 1998 BUC50028 entity 6307
1435 if ( NbPoints == 1) {
1436 Message_Msg msg1235("IGES_1235");
1437 SendFail(start, msg1235);
1438 // The curve degenerates to a point");
1441 TColgp_Array1OfPnt Pole(1,NbPoints);
1443 TempIndex = TempPole.Lower();
1444 for (i=Pole.Lower(); i<=Pole.Upper(); i++)
1445 Pole.SetValue(i,TempPole.Value(TempIndex++));
1448 // Filling array of knots :
1449 // ========================
1451 TColStd_Array1OfReal Knot(1,NbPoints);
1453 Knot.SetValue(Knot.Lower(),0.0);
1455 for (i=Knot.Lower()+1; i <= Knot.Upper(); i++) {
1456 gp_Pnt Pole1 = Pole.Value(i);
1457 gp_Pnt Pole2 = Pole.Value(i-1);
1458 Standard_Real KnotDist = Pole1.Distance(Pole2);
1459 Knot.SetValue(i, Knot.Value(i-1)+KnotDist);
1462 Standard_Integer Degree = 1;
1464 TColStd_Array1OfInteger Mult(1, NbPoints);
1466 Mult.SetValue(Mult.Lower(),Degree+1);
1467 Mult.SetValue(Mult.Upper(),Degree+1);
1469 res = new Geom_BSplineCurve(Pole, Knot, Mult, Degree);
1471 IGESConvGeom::IncreaseCurveContinuity (res, Max(GetEpsGeom()/10.,Precision::Confusion()), GetContinuity());
1476 // ================================
1477 // == TRANSFER 2D Copious data ==
1478 // ================================
1480 Handle(Geom2d_BSplineCurve) IGESToBRep_BasicCurve::Transfer2dCopiousData(const Handle(IGESGeom_CopiousData)& start)
1482 Handle(Geom2d_BSplineCurve) res;
1483 if (start.IsNull()) {
1484 Message_Msg msg1005("IGES_1005");
1485 SendFail(start, msg1005);
1489 Standard_Integer FormNb = start->FormNumber();
1490 if (!(FormNb==11 || FormNb==12 || FormNb==63)) {
1491 Message_Msg msg1240("IGES_1240");
1492 SendWarning( start, msg1240);
1493 // "Copious Data : Form number is different from 11, 12 or 63 so the vector treatement is skipped");
1496 Standard_Integer NbPoints = start->NbPoints();
1498 Message_Msg msg1195("IGES_1195");
1499 SendFail(start, msg1195); // Count of points lower than 2
1503 // Filling array of poles :
1504 // ========================
1506 TColgp_Array1OfPnt2d TempPole(1,NbPoints);
1507 Standard_Integer TempIndex = TempPole.Lower();
1509 if (!GetModeTransfer() && start->HasTransf())
1510 TempPole.SetValue(TempIndex,gp_Pnt2d(start->TransformedPoint(1).X(),
1511 start->TransformedPoint(1).Y()));
1513 TempPole.SetValue(TempIndex,gp_Pnt2d(start->Point(1).X(),
1514 start->Point(1).Y()));
1518 Standard_Integer i;//svv Jan 10 2000 : porting on DEC
1519 for (i=2; i <= NbPoints; i++) {
1521 if (!GetModeTransfer() && start->HasTransf())
1522 aPole = gp_Pnt2d(start->TransformedPoint(i).X(),
1523 start->TransformedPoint(i).Y());
1525 aPole = gp_Pnt2d(start->Point(i).X(),
1526 start->Point(i).Y());
1527 // if (!aPole.IsEqual(TempPole(TempIndex-1), GetEpsCoeff())) //modified by rln 16/12/97 CSR# PRO11641 entity 46GetEpsGeom()*GetUnitFactor()
1528 //S4054: some filter must be kept UKI60556 entity 7 (two equal points)
1529 if (!aPole.IsEqual(TempPole(TempIndex-1), gp::Resolution()))
1530 TempPole.SetValue(TempIndex++,aPole);
1533 NbPoints = TempIndex - TempPole.Lower();
1534 //added by rln on 26/12/97 to avoid exception when creating Bspline from one point
1535 if (NbPoints == 1) {
1536 Message_Msg msg1235("IGES_1235");
1537 SendFail(start, msg1235);
1538 // The curve degenerates to a point");
1541 TColgp_Array1OfPnt2d Pole(1,NbPoints);
1543 TempIndex = TempPole.Lower();
1544 for (i=Pole.Lower(); i<=Pole.Upper(); i++)
1545 Pole.SetValue(i,TempPole.Value(TempIndex++));
1548 // Filling array of knots :
1549 // ========================
1551 TColStd_Array1OfReal Knot(1,NbPoints);
1553 Knot.SetValue(Knot.Lower(),0.0);
1555 for (i=Knot.Lower()+1; i <= Knot.Upper(); i++) {
1556 gp_Pnt2d Pole1 = Pole.Value(i);
1557 gp_Pnt2d Pole2 = Pole.Value(i-1);
1558 Standard_Real KnotDist = Pole1.Distance(Pole2);
1559 Knot.SetValue(i, Knot.Value(i-1)+KnotDist);
1562 const Standard_Integer Degree = 1;
1564 TColStd_Array1OfInteger Mult(1, NbPoints);
1566 Mult.SetValue(Mult.Lower(),Degree+1);
1567 Mult.SetValue(Mult.Upper(),Degree+1);
1569 res = new Geom2d_BSplineCurve(Pole, Knot, Mult, Degree);
1571 Standard_Real epsGeom = GetEpsGeom();
1572 Standard_Real anUVResolution = GetUVResolution();
1574 IGESConvGeom::IncreaseCurveContinuity (res, Max(Precision::Confusion(),epsGeom*anUVResolution), GetContinuity());