0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / BSplCLib / BSplCLib_BzSyntaxes.cxx
CommitLineData
b311480e 1// Created on: 1995-09-08
2// Created by: Laurent BOURESCHE
3// Copyright (c) 1995-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.
7fd59977 16
17#include <BSplCLib.hxx>
18#include <TColStd_Array1OfInteger.hxx>
19#include <TColStd_Array1OfReal.hxx>
20
21#define No_Standard_RangeError
22#define No_Standard_OutOfRange
23
24//=======================================================================
25//struct : BSplCLib_BezierArrays
26//purpose: Auxiliary structure providing standard definitions of bspline
27// knots for bezier (using stack allocation)
28//=======================================================================
29
30class BSplCLib_BezierArrays
31{
32 public:
33 BSplCLib_BezierArrays (Standard_Integer Degree)
34 : knots (aKnots[0], 1, 2), mults (aMults[0], 1, 2)
35 {
36 aKnots[0] = 0.;
37 aKnots[1] = 1.;
38 aMults[0] = aMults[1] = Degree + 1;
39 }
40
41 private:
42 Standard_Real aKnots[2];
43 Standard_Integer aMults[2];
44
45 public:
46 TColStd_Array1OfReal knots;
47 TColStd_Array1OfInteger mults;
48};
49
50//=======================================================================
51//function : IncreaseDegree
52//purpose :
53//=======================================================================
54
55void BSplCLib::IncreaseDegree(const Standard_Integer NewDegree,
56 const TColgp_Array1OfPnt& Poles,
0e14656b 57 const TColStd_Array1OfReal* Weights,
7fd59977 58 TColgp_Array1OfPnt& NewPoles,
0e14656b 59 TColStd_Array1OfReal* NewWeights)
7fd59977 60{
61 Standard_Integer deg = Poles.Length() - 1;
62 BSplCLib_BezierArrays bzarr(deg);
63 BSplCLib::IncreaseDegree(deg, NewDegree, 0,
64 Poles, Weights, bzarr.knots, bzarr.mults,
65 NewPoles, NewWeights, bzarr.knots, bzarr.mults);
66}
67
68//=======================================================================
69//function : IncreaseDegree
70//purpose :
71//=======================================================================
72
73void BSplCLib::IncreaseDegree(const Standard_Integer NewDegree,
74 const TColgp_Array1OfPnt2d& Poles,
0e14656b 75 const TColStd_Array1OfReal* Weights,
7fd59977 76 TColgp_Array1OfPnt2d& NewPoles,
0e14656b 77 TColStd_Array1OfReal* NewWeights)
7fd59977 78{
79 Standard_Integer deg = Poles.Length() - 1;
80 BSplCLib_BezierArrays bzarr(deg);
81 BSplCLib::IncreaseDegree(deg, NewDegree, 0,
82 Poles, Weights, bzarr.knots, bzarr.mults,
83 NewPoles, NewWeights, bzarr.knots, bzarr.mults);
84}
85
86//=======================================================================
87//function : PolesCoefficients
88//purpose :
89//=======================================================================
90
91void BSplCLib::PolesCoefficients(const TColgp_Array1OfPnt& Poles,
0e14656b 92 const TColStd_Array1OfReal* Weights,
7fd59977 93 TColgp_Array1OfPnt& CachePoles,
0e14656b 94 TColStd_Array1OfReal* CacheWeights)
7fd59977 95{
96 Standard_Integer deg = Poles.Length() - 1;
97 TColStd_Array1OfReal bidflatknots (FlatBezierKnots(deg), 1, 2*(deg+1));
98 BSplCLib::BuildCache(0.,1.,0,deg,bidflatknots,
99 Poles, Weights, CachePoles,CacheWeights);
100}
101
102//=======================================================================
103//function : PolesCoefficients
104//purpose :
105//=======================================================================
106
107void BSplCLib::PolesCoefficients(const TColgp_Array1OfPnt2d& Poles,
0e14656b 108 const TColStd_Array1OfReal* Weights,
7fd59977 109 TColgp_Array1OfPnt2d& CachePoles,
0e14656b 110 TColStd_Array1OfReal* CacheWeights)
7fd59977 111{
112 Standard_Integer deg = Poles.Length() - 1;
113 TColStd_Array1OfReal bidflatknots (FlatBezierKnots(deg), 1, 2*(deg+1));
114 BSplCLib::BuildCache(0.,1.,0,deg,bidflatknots,
115 Poles, Weights, CachePoles,CacheWeights);
116}
117
118//=======================================================================
119//function : D0
120//purpose :
121//=======================================================================
122
123void BSplCLib::D0(const Standard_Real U,
124 const TColgp_Array1OfPnt& Poles,
0e14656b 125 const TColStd_Array1OfReal* Weights,
7fd59977 126 gp_Pnt& P)
127{
128 Standard_Integer deg = Poles.Length() - 1;
129 BSplCLib_BezierArrays bzarr(deg);
0e14656b 130 BSplCLib::D0(U, 1, deg, 0, Poles, Weights, bzarr.knots, &bzarr.mults, P);
7fd59977 131}
132
133//=======================================================================
134//function : D0
135//purpose :
136//=======================================================================
137
138void BSplCLib::D0(const Standard_Real U,
139 const TColgp_Array1OfPnt2d& Poles,
0e14656b 140 const TColStd_Array1OfReal* Weights,
7fd59977 141 gp_Pnt2d& P)
142{
143 Standard_Integer deg = Poles.Length() - 1;
144 BSplCLib_BezierArrays bzarr(deg);
0e14656b 145 BSplCLib::D0(U, 1, deg, 0, Poles, Weights, bzarr.knots, &bzarr.mults, P);
7fd59977 146}
147
148//=======================================================================
149//function : D1
150//purpose :
151//=======================================================================
152
153void BSplCLib::D1(const Standard_Real U,
154 const TColgp_Array1OfPnt& Poles,
0e14656b 155 const TColStd_Array1OfReal* Weights,
7fd59977 156 gp_Pnt& P,
157 gp_Vec& V)
158{
159 Standard_Integer deg = Poles.Length() - 1;
160 BSplCLib_BezierArrays bzarr(deg);
0e14656b 161 BSplCLib::D1(U, 1, deg, 0, Poles, Weights, bzarr.knots, &bzarr.mults, P, V);
7fd59977 162}
163
164//=======================================================================
165//function : D1
166//purpose :
167//=======================================================================
168
169void BSplCLib::D1(const Standard_Real U,
170 const TColgp_Array1OfPnt2d& Poles,
0e14656b 171 const TColStd_Array1OfReal* Weights,
7fd59977 172 gp_Pnt2d& P,
173 gp_Vec2d& V)
174{
175 Standard_Integer deg = Poles.Length() - 1;
176 BSplCLib_BezierArrays bzarr(deg);
0e14656b 177 BSplCLib::D1(U, 1, deg, 0, Poles, Weights, bzarr.knots, &bzarr.mults, P, V);
7fd59977 178}
179
180
181//=======================================================================
182//function : D2
183//purpose :
184//=======================================================================
185
186void BSplCLib::D2(const Standard_Real U,
187 const TColgp_Array1OfPnt& Poles,
0e14656b 188 const TColStd_Array1OfReal* Weights,
7fd59977 189 gp_Pnt& P,
190 gp_Vec& V1,
191 gp_Vec& V2)
192{
193 Standard_Integer deg = Poles.Length() - 1;
194 BSplCLib_BezierArrays bzarr(deg);
0e14656b 195 BSplCLib::D2(U, 1, deg, 0, Poles, Weights, bzarr.knots, &bzarr.mults, P, V1, V2);
7fd59977 196}
197
198//=======================================================================
199//function : D2
200//purpose :
201//=======================================================================
202
203void BSplCLib::D2(const Standard_Real U,
204 const TColgp_Array1OfPnt2d& Poles,
0e14656b 205 const TColStd_Array1OfReal* Weights,
7fd59977 206 gp_Pnt2d& P,
207 gp_Vec2d& V1,
208 gp_Vec2d& V2)
209{
210 Standard_Integer deg = Poles.Length() - 1;
211 BSplCLib_BezierArrays bzarr(deg);
0e14656b 212 BSplCLib::D2(U, 1, deg, 0, Poles, Weights, bzarr.knots, &bzarr.mults, P, V1, V2);
7fd59977 213}
214
215
216//=======================================================================
217//function : D3
218//purpose :
219//=======================================================================
220
221void BSplCLib::D3(const Standard_Real U,
222 const TColgp_Array1OfPnt& Poles,
0e14656b 223 const TColStd_Array1OfReal* Weights,
7fd59977 224 gp_Pnt& P,
225 gp_Vec& V1,
226 gp_Vec& V2,
227 gp_Vec& V3)
228{
229 Standard_Integer deg = Poles.Length() - 1;
230 BSplCLib_BezierArrays bzarr(deg);
0e14656b 231 BSplCLib::D3(U, 1, deg, 0, Poles, Weights, bzarr.knots, &bzarr.mults,
7fd59977 232 P, V1, V2, V3);
233}
234
235//=======================================================================
236//function : D3
237//purpose :
238//=======================================================================
239
240void BSplCLib::D3(const Standard_Real U,
241 const TColgp_Array1OfPnt2d& Poles,
0e14656b 242 const TColStd_Array1OfReal* Weights,
7fd59977 243 gp_Pnt2d& P,
244 gp_Vec2d& V1,
245 gp_Vec2d& V2,
246 gp_Vec2d& V3)
247{
248 Standard_Integer deg = Poles.Length() - 1;
249 BSplCLib_BezierArrays bzarr(deg);
0e14656b 250 BSplCLib::D3(U, 1, deg, 0, Poles, Weights, bzarr.knots, &bzarr.mults,
7fd59977 251 P, V1, V2, V3);
252}
253