b311480e |
1 | // Created on: 1993-06-23 |
2 | // Created by: Martine LANGLOIS |
3 | // Copyright (c) 1993-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
b311480e |
16 | |
17 | Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve) BSWK; |
7fd59977 |
18 | Standard_Integer Deg, N, i, Nknots, itampon; |
19 | Standard_Real rtampon; |
20 | Handle(StepGeom_CartesianPoint) Pt = new StepGeom_CartesianPoint; |
21 | Handle(StepGeom_HArray1OfCartesianPoint) Listpoints; |
22 | StepGeom_BSplineCurveForm Form; |
23 | StepData_Logical Fermeture, Selfinter; |
24 | Handle(TColStd_HArray1OfInteger) Mult; |
25 | Handle(TColStd_HArray1OfReal) ListKnots, ListWeights; |
26 | GeomAbs_BSplKnotDistribution Distribution; |
27 | StepGeom_KnotType KnotSpec; |
28 | |
29 | Deg = BS->Degree(); |
30 | |
31 | N = BS->NbPoles(); |
32 | Array1OfPnt_gen P(1,N); |
33 | BS->Poles(P); |
34 | Listpoints = new StepGeom_HArray1OfCartesianPoint(1,N); |
35 | for ( i=P.Lower(); i<=P.Upper(); i++) { |
36 | GeomToStep_MakeCartesianPoint MkPoint(P.Value(i)); |
37 | Pt = MkPoint.Value(); |
38 | Listpoints->SetValue(i, Pt); |
39 | } |
40 | |
41 | Form = StepGeom_bscfUnspecified; |
42 | |
43 | if (BS->IsClosed()) |
44 | Fermeture = StepData_LTrue; |
45 | else |
46 | Fermeture = StepData_LFalse; |
47 | |
48 | Selfinter = StepData_LFalse; |
49 | |
50 | Nknots = BS->NbKnots(); |
51 | TColStd_Array1OfInteger M(1,Nknots); |
52 | BS->Multiplicities(M); |
53 | Mult = new TColStd_HArray1OfInteger(1,Nknots); |
54 | for ( i=M.Lower(); i<=M.Upper(); i++) { |
55 | itampon = M.Value(i); |
56 | Mult->SetValue(i, itampon); |
57 | } |
58 | |
59 | TColStd_Array1OfReal K(1,Nknots); |
60 | BS->Knots(K); |
61 | ListKnots = new TColStd_HArray1OfReal(1,Nknots); |
62 | for ( i=K.Lower(); i<=K.Upper(); i++) { |
63 | rtampon = K.Value(i); |
64 | ListKnots->SetValue(i, rtampon); |
65 | } |
66 | |
67 | Distribution = BS->KnotDistribution(); |
68 | if ( Distribution == GeomAbs_NonUniform ) |
69 | KnotSpec = StepGeom_ktUnspecified; |
70 | else if ( Distribution == GeomAbs_Uniform ) |
71 | KnotSpec = StepGeom_ktUniformKnots; |
72 | else if ( Distribution == GeomAbs_QuasiUniform ) |
73 | KnotSpec = StepGeom_ktQuasiUniformKnots; |
74 | else |
75 | KnotSpec = StepGeom_ktPiecewiseBezierKnots; |
76 | |
77 | TColStd_Array1OfReal W(1,N); |
78 | BS->Weights(W); |
79 | ListWeights = new TColStd_HArray1OfReal(1,N); |
80 | for ( i=W.Lower(); i<=W.Upper(); i++) { |
81 | rtampon = W.Value(i); |
82 | ListWeights->SetValue(i, rtampon); |
83 | } |
84 | |
85 | BSWK = new StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve; |
86 | Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString(""); |
87 | BSWK->Init(name, Deg, Listpoints, Form, Fermeture, Selfinter, Mult, |
88 | ListKnots, KnotSpec, ListWeights ); |
89 | |
90 | theBSplineCurveWithKnotsAndRationalBSplineCurve = BSWK; |
91 | done = Standard_True; |