summaryrefslogtreecommitdiff
path: root/src/GeomToStep/GeomToStep_MakeBSplineCurveWithKnots_gen.pxx
blob: c135a3d9c66cf98f3183ce7d52df3baa390e41ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// File:	GeomToStep_MakeBSplineCurveWithKnots_gen.gxx
// Created:	Thu Aug  5 16:13:17 1993
// Author:	Martine LANGLOIS
//		<mla@mastox>

 
  Handle(StepGeom_BSplineCurveWithKnots) BSWK;
  Standard_Integer Deg, N, i, Nknots, itampon;
  Standard_Real rtampon;
  Handle(StepGeom_CartesianPoint) Pt = new StepGeom_CartesianPoint; 
  Handle(StepGeom_HArray1OfCartesianPoint) Listpoints;
  StepGeom_BSplineCurveForm Form;
  StepData_Logical Fermeture, Selfinter;
  Handle(TColStd_HArray1OfInteger) Mult;
  Handle(TColStd_HArray1OfReal) ListKnots, ListWeights;
  GeomAbs_BSplKnotDistribution Distribution;
  StepGeom_KnotType KnotSpec;

  Deg = BS->Degree();

  N   = BS->NbPoles();
  Array1OfPnt_gen P(1,N);
  BS->Poles(P);
  Listpoints = new StepGeom_HArray1OfCartesianPoint(1,N);
  for ( i=P.Lower(); i<=P.Upper(); i++) {
    GeomToStep_MakeCartesianPoint MkPoint(P.Value(i));
    Pt = MkPoint.Value();
    Listpoints->SetValue(i, Pt);
  }

  Form = StepGeom_bscfUnspecified;

  if (BS->IsClosed())
    Fermeture = StepData_LTrue;
  else
    Fermeture = StepData_LFalse;

  Selfinter = StepData_LFalse;

  Nknots = BS->NbKnots();
  TColStd_Array1OfInteger M(1,Nknots);
  BS->Multiplicities(M);
  Mult = new TColStd_HArray1OfInteger(1,Nknots);
  for ( i=M.Lower(); i<=M.Upper(); i++) { 
    itampon = M.Value(i);
    Mult->SetValue(i, itampon);
  }

  TColStd_Array1OfReal K(1,Nknots);
  BS->Knots(K);
  ListKnots = new TColStd_HArray1OfReal(1,Nknots);
  for ( i=K.Lower(); i<=K.Upper(); i++) { 
    rtampon = K.Value(i);
    ListKnots->SetValue(i, rtampon);
  }

  Distribution = BS->KnotDistribution();
  if ( Distribution == GeomAbs_NonUniform )
    KnotSpec = StepGeom_ktUnspecified;
  else if ( Distribution == GeomAbs_Uniform )
    KnotSpec = StepGeom_ktUniformKnots;
  else if ( Distribution == GeomAbs_QuasiUniform )
    KnotSpec = StepGeom_ktQuasiUniformKnots;
  else 
    KnotSpec = StepGeom_ktPiecewiseBezierKnots;
  
  BSWK = new StepGeom_BSplineCurveWithKnots; 
  Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString("");
  BSWK->Init(name, Deg, Listpoints, Form, Fermeture, Selfinter, Mult, 
	     ListKnots, KnotSpec );

  theBSplineCurveWithKnots = BSWK;
  done = Standard_True;