0024158: OpenGl_AspectMarker - debug assert on destruction of Alpha texture shared...
[occt.git] / src / StepToGeom / StepToGeom_MakeBSplineCurve.pxx
CommitLineData
b311480e 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
5//
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.
10//
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.
13//
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.
20
7fd59977 21
22{
23 Handle(StepGeom_BSplineCurveWithKnots) BSCW;
24 Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve) BSCWR;
25
26 if (SC->IsKind(STANDARD_TYPE(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve))) {
27 BSCWR =
28 Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve)
29 ::DownCast(SC);
30 BSCW =
31 Handle(StepGeom_BSplineCurveWithKnots)
32 ::DownCast(BSCWR->BSplineCurveWithKnots());
33 }
34 else
35 BSCW = Handle(StepGeom_BSplineCurveWithKnots)::DownCast(SC);
36
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);
42
43 Standard_Integer i;
44 CartesianPoint_gen P;
45 for (i=1; i<=NbPoles; i++)
46 {
47 if (StepToGeom_MakeCartesianPoint_gen::Convert(aControlPointsList->Value(i),P))
48 Poles.SetValue(i,P->Pnt_fonc());
49 else
50 return Standard_False;
51 }
52
53 const Standard_Integer NbKnots = BSCW->NbKnotMultiplicities();
54
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));
60 }
61
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));
67 }
68
69 // --- Does the Curve descriptor LOOKS like a periodic descriptor ? ---
70
71 Standard_Integer SumMult = 0;
72 for (i=1; i<=NbKnots; i++) {
73 SumMult += aKnotMultiplicities->Value(i);
74 }
75
76 Standard_Boolean shouldBePeriodic;
77 if (SumMult == (NbPoles + Deg + 1)) {
78 shouldBePeriodic = Standard_False;
79 }
80 else if ((aKnotMultiplicities->Value(1) ==
81 aKnotMultiplicities->Value(NbKnots)) &&
82 ((SumMult - aKnotMultiplicities->Value(1)) == NbPoles)) {
83 shouldBePeriodic = Standard_True;
84 }
85 else { // --- What is that ??? ---
86 shouldBePeriodic = Standard_False;
87 //cout << "Strange BSpline Curve Descriptor" << endl;
88 }
89
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);
96 }
97 else
98 CC = new BSplineCurve_gen(Poles, Kn, Mult, Deg, shouldBePeriodic);
99
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() ) {
103 CC->SetPeriodic();
104//#ifdef DEB
105// cout << "Warning: "__FILE__": Closed curve made periodic" << endl;
106//#endif
107 }
108 return Standard_True;
109}