0030686: Visualization, SelectMgr_ViewerSelector - sorting issues of transformation...
[occt.git] / src / GeomToStep / GeomToStep_MakeBSplineCurveWithKnots_gen.pxx
1 // Created on: 1993-08-05
2 // Created by: Martine LANGLOIS
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 Handle(StepGeom_BSplineCurveWithKnots) BSWK;
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   BSWK = new StepGeom_BSplineCurveWithKnots; 
78   Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString("");
79   BSWK->Init(name, Deg, Listpoints, Form, Fermeture, Selfinter, Mult, 
80              ListKnots, KnotSpec );
81
82   theBSplineCurveWithKnots = BSWK;
83   done = Standard_True;