1 // Created on: 1993-07-02
2 // Created by: Martine LANGLOIS
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
23 Handle(StepGeom_BSplineCurveWithKnots) BSCW;
24 Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve) BSCWR;
26 if (SC->IsKind(STANDARD_TYPE(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve))) {
28 Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve)
31 Handle(StepGeom_BSplineCurveWithKnots)
32 ::DownCast(BSCWR->BSplineCurveWithKnots());
35 BSCW = Handle(StepGeom_BSplineCurveWithKnots)::DownCast(SC);
37 const Standard_Integer Deg = BSCW->Degree();
38 const Standard_Integer NbPoles = BSCW->NbControlPointsList();
39 //aControlPointsList = new StepGeom_HArray1OfCartesianPoint(1,NbPoles);
40 const Handle(StepGeom_HArray1OfCartesianPoint)& aControlPointsList = BSCW->ControlPointsList();
41 Array1OfPnt_gen Poles(1,NbPoles);
45 for (i=1; i<=NbPoles; i++)
47 if (StepToGeom_MakeCartesianPoint_gen::Convert(aControlPointsList->Value(i),P))
48 Poles.SetValue(i,P->Pnt_fonc());
50 return Standard_False;
53 const Standard_Integer NbKnots = BSCW->NbKnotMultiplicities();
55 //aKnotMultiplicities = new TColStd_HArray1OfInteger(1,NbKnots);
56 const Handle(TColStd_HArray1OfInteger)& aKnotMultiplicities = BSCW->KnotMultiplicities();
57 TColStd_Array1OfInteger Mult(1,NbKnots);
58 for (i=1; i<=NbKnots; i++) {
59 Mult.SetValue(i,aKnotMultiplicities->Value(i));
62 //aKnots = new TColStd_HArray1OfReal(1,NbKnots);
63 const Handle(TColStd_HArray1OfReal)& aKnots = BSCW->Knots();
64 TColStd_Array1OfReal Kn(1,NbKnots);
65 for (i=1; i<=NbKnots; i++) {
66 Kn.SetValue(i,aKnots->Value(i));
69 // --- Does the Curve descriptor LOOKS like a periodic descriptor ? ---
71 Standard_Integer SumMult = 0;
72 for (i=1; i<=NbKnots; i++) {
73 SumMult += aKnotMultiplicities->Value(i);
76 Standard_Boolean shouldBePeriodic;
77 if (SumMult == (NbPoles + Deg + 1)) {
78 shouldBePeriodic = Standard_False;
80 else if ((aKnotMultiplicities->Value(1) ==
81 aKnotMultiplicities->Value(NbKnots)) &&
82 ((SumMult - aKnotMultiplicities->Value(1)) == NbPoles)) {
83 shouldBePeriodic = Standard_True;
85 else { // --- What is that ??? ---
86 shouldBePeriodic = Standard_False;
87 //cout << "Strange BSpline Curve Descriptor" << endl;
90 if (SC->IsKind(STANDARD_TYPE(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve))) {
91 const Handle(TColStd_HArray1OfReal)& aWeight = BSCWR->WeightsData();
92 TColStd_Array1OfReal W(1,NbPoles);
93 for (i=1; i<=NbPoles; i++)
94 W.SetValue(i,aWeight->Value(i));
95 CC = new BSplineCurve_gen(Poles, W, Kn, Mult, Deg, shouldBePeriodic);
98 CC = new BSplineCurve_gen(Poles, Kn, Mult, Deg, shouldBePeriodic);
100 // abv 04.07.00 CAX-IF TRJ4: trj4_k1_top-md-203.stp #716 (face #581):
101 // force periodicity on closed curves
102 if ( SC->ClosedCurve() && CC->Degree() >1 && CC->IsClosed() ) {
105 // cout << "Warning: "__FILE__": Closed curve made periodic" << endl;
108 return Standard_True;