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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
|
// File: Convert_CompPolynomialToPoles.cxx
// Created: Tue May 30 14:34:29 1995
// Author: Xavier BENVENISTE
// <xab@nonox>
// 19-06-96 : JPI : NbPoles doit utiliser ColLength() au lieu de RowLength()
// 16-09-96 : PMN : On ne doit pas se soucier de la continuite lorsqu'il n'y
// qu'un seul segment(PRO5474).
// 11-12-96 : PMN : Respect de l'indicage des tableaux passer en arguments
// TrueIntervals et PolynomialIntervals (BUC40077)
// 15-04-97 : PMN : Constructeurs avec un seul segement ou differentes
// continuitees.
#define No_Standard_OutOfRange
#include <Convert_CompPolynomialToPoles.ixx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <PLib.hxx>
#include <BSplCLib.hxx>
#include <Standard_ConstructionError.hxx>
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
Convert_CompPolynomialToPoles::Convert_CompPolynomialToPoles(
const Standard_Integer NumCurves,
const Standard_Integer Continuity,
const Standard_Integer Dimension,
const Standard_Integer MaxDegree,
const Handle_TColStd_HArray1OfInteger& NumCoeffPerCurve,
const Handle_TColStd_HArray1OfReal& Coefficients,
const Handle_TColStd_HArray2OfReal& PolynomialIntervals,
const Handle_TColStd_HArray1OfReal& TrueIntervals)
: myDone(Standard_False)
{
Standard_Integer ii, delta;
if (NumCurves <= 0 ||
NumCoeffPerCurve.IsNull() ||
Coefficients.IsNull() ||
PolynomialIntervals.IsNull() ||
TrueIntervals.IsNull() ||
Continuity < 0 ||
MaxDegree <= 0 ||
Dimension <= 0 ||
PolynomialIntervals->RowLength() != 2) {
Standard_ConstructionError::
Raise("Convert_CompPolynomialToPoles:bad arguments");
}
myDegree = 0 ;
delta = NumCurves - 1 ;
for (ii = NumCoeffPerCurve->Lower();
ii <= NumCoeffPerCurve->Lower() + delta ;
ii++) {
myDegree = Max(NumCoeffPerCurve->Value(ii)-1,myDegree) ;
}
if ((Continuity > myDegree)&& (NumCurves>1)) {
Standard_ConstructionError::
Raise("Convert_CompPolynomialToPoles:Continuity is too great");
}
//
// prepare output
//
Standard_Integer Tindex, multiplicities ;
myKnots =
new TColStd_HArray1OfReal(1, NumCurves + 1) ;
for (ii = 1, Tindex = TrueIntervals->Lower() ;
ii <= NumCurves + 1 ; ii++,Tindex++ ) {
myKnots->ChangeArray1().SetValue(ii,TrueIntervals->Value(Tindex)) ;
}
multiplicities = myDegree - Continuity ;
myMults =
new TColStd_HArray1OfInteger(1, NumCurves + 1) ;
for (ii = 2 ; ii < NumCurves + 1 ; ii++) {
myMults -> SetValue(ii,multiplicities);
}
myMults -> SetValue(1, myDegree + 1) ;
myMults -> SetValue(NumCurves + 1, myDegree + 1) ;
Perform(NumCurves, MaxDegree, Dimension,
NumCoeffPerCurve->Array1(), Coefficients->Array1(),
PolynomialIntervals->Array2(), TrueIntervals->Array1());
}
Convert_CompPolynomialToPoles::
Convert_CompPolynomialToPoles(const Standard_Integer NumCurves,
const Standard_Integer Dimension,
const Standard_Integer MaxDegree,
const TColStd_Array1OfInteger& Continuity,
const TColStd_Array1OfInteger& NumCoeffPerCurve,
const TColStd_Array1OfReal& Coefficients,
const TColStd_Array2OfReal& PolynomialIntervals,
const TColStd_Array1OfReal& TrueIntervals)
: myDone(Standard_False)
{
Standard_Integer ii, delta;
if (NumCurves <= 0 ||
MaxDegree <= 0 ||
Dimension <= 0 ||
PolynomialIntervals.RowLength() != 2) {
Standard_ConstructionError::
Raise("Convert_CompPolynomialToPoles:bad arguments");
}
myDegree = 0 ;
delta = NumCurves - 1 ;
for (ii = NumCoeffPerCurve.Lower();
ii <= NumCoeffPerCurve.Lower() + delta ;
ii++) {
myDegree = Max(NumCoeffPerCurve.Value(ii)-1,myDegree) ;
}
//
// prepare output
//
Standard_Integer Tindex ;
myKnots =
new TColStd_HArray1OfReal(1, NumCurves + 1) ;
for (ii = 1, Tindex = TrueIntervals.Lower() ;
ii <= NumCurves + 1 ; ii++,Tindex++ ) {
myKnots->ChangeArray1().SetValue(ii,TrueIntervals.Value(Tindex)) ;
}
myMults =
new TColStd_HArray1OfInteger(1, NumCurves + 1) ;
for (ii = 2 ; ii < NumCurves + 1 ; ii++) {
if ((Continuity(ii) > myDegree)&& (NumCurves>1)) {
Standard_ConstructionError::
Raise("Convert_CompPolynomialToPoles:Continuity is too great");
}
myMults -> SetValue(ii, myDegree-Continuity(ii) );
}
myMults -> SetValue(1, myDegree + 1) ;
myMults -> SetValue(NumCurves + 1, myDegree + 1) ;
// Calculs
Perform(NumCurves, MaxDegree, Dimension,
NumCoeffPerCurve, Coefficients,
PolynomialIntervals, TrueIntervals);
}
Convert_CompPolynomialToPoles::
Convert_CompPolynomialToPoles(const Standard_Integer Dimension,
const Standard_Integer MaxDegree,
const Standard_Integer Degree,
const TColStd_Array1OfReal& Coefficients,
const TColStd_Array1OfReal& PolynomialIntervals,
const TColStd_Array1OfReal& TrueIntervals) :
myDegree(Degree) ,
myDone(Standard_False)
{
if (MaxDegree <= 0 ||
Dimension <= 0 ||
PolynomialIntervals.Length() != 2)
{
Standard_ConstructionError::
Raise("Convert_CompPolynomialToPoles:bad arguments");
}
TColStd_Array2OfReal ThePolynomialIntervals(1,1,1,2);
ThePolynomialIntervals.SetValue(1,1,PolynomialIntervals(PolynomialIntervals.Lower()));
ThePolynomialIntervals.SetValue(1,2,PolynomialIntervals(PolynomialIntervals.Upper()));
TColStd_Array1OfInteger NumCoeffPerCurve(1,1);
NumCoeffPerCurve(1) = Degree+1;
myKnots =
new TColStd_HArray1OfReal(1, 2) ;
myKnots->ChangeArray1().SetValue(1, TrueIntervals.Value(TrueIntervals.Lower()));
myKnots->ChangeArray1().SetValue(2, TrueIntervals.Value(TrueIntervals.Lower()+1));
myMults =
new TColStd_HArray1OfInteger(1, 2) ;
myMults->Init( myDegree + 1);
// Calculs
Perform(1, MaxDegree, Dimension,
NumCoeffPerCurve, Coefficients,
ThePolynomialIntervals, TrueIntervals);
}
void Convert_CompPolynomialToPoles::
Perform(const Standard_Integer NumCurves,
const Standard_Integer MaxDegree,
const Standard_Integer Dimension,
const TColStd_Array1OfInteger& NumCoeffPerCurve,
const TColStd_Array1OfReal& Coefficients,
const TColStd_Array2OfReal& PolynomialIntervals,
const TColStd_Array1OfReal& TrueIntervals)
{
Standard_Integer ii,
num_flat_knots,
index, Tindex, Pindex,
coeff_index,
inversion_problem,
poles_index,
num_poles ;
Standard_Real normalized_value,
*coefficient_array,
*poles_array ;
num_flat_knots = 2 * myDegree + 2 ;
for (ii=2; ii<myMults->Length(); ii++) {
num_flat_knots += myMults->Value(ii);
}
num_poles = num_flat_knots - myDegree - 1 ;
myFlatKnots = new TColStd_HArray1OfReal(1,num_flat_knots) ;
BSplCLib::KnotSequence (myKnots->Array1(),
myMults->Array1(),
myDegree,
Standard_False,
myFlatKnots->ChangeArray1());
TColStd_Array1OfReal parameters(1,num_poles) ;
BSplCLib::BuildSchoenbergPoints(myDegree,
myFlatKnots->Array1(),
parameters) ;
myPoles = new TColStd_HArray2OfReal(1, num_poles,
1, Dimension) ;
index = 2;
Tindex = TrueIntervals.Lower()+1;
Pindex = PolynomialIntervals.LowerRow();
poles_array =
(Standard_Real *) &(myPoles->ChangeArray2()).Value(1,1) ;
TColStd_Array1OfInteger contact_array(1,num_poles) ;
poles_index = 0 ;
for (ii = 1 ; ii <= num_poles ; ii++, poles_index += Dimension) {
contact_array.SetValue(ii,0) ;
while (parameters.Value(ii) >= TrueIntervals(Tindex) &&
index <= NumCurves) {
index++; Tindex++; Pindex++;
}
//
// normalized value so that it fits the original intervals for
// the polynomial definition of the curves
//
normalized_value = parameters.Value(ii) - TrueIntervals(Tindex-1) ;
normalized_value /= TrueIntervals(Tindex)
- TrueIntervals(Tindex-1) ;
normalized_value = (1.0e0 -normalized_value) *
PolynomialIntervals(Pindex, PolynomialIntervals.LowerCol())
+ normalized_value *
PolynomialIntervals(Pindex, PolynomialIntervals.UpperCol()) ;
coeff_index = ((index-2) * Dimension * (Max(MaxDegree, myDegree) + 1))
+ Coefficients.Lower();
coefficient_array =
(Standard_Real *) &(Coefficients(coeff_index)) ;
Standard_Integer Deg = NumCoeffPerCurve(NumCoeffPerCurve.Lower()+index-2) - 1;
PLib::NoDerivativeEvalPolynomial
(normalized_value,
Deg,
Dimension,
Deg * Dimension,
coefficient_array[0],
poles_array[poles_index]) ;
}
//
// interpolation at schoenberg points should yield the desired
// result
//
BSplCLib::Interpolate(myDegree,
myFlatKnots->Array1(),
parameters,
contact_array,
Dimension,
poles_array[0],
inversion_problem) ;
if (inversion_problem != 0) {
Standard_ConstructionError::
Raise("Convert_CompPolynomialToPoles:inversion_problem");
}
myDone = Standard_True ;
}
//=======================================================================
//function : NbPoles
//purpose :
//=======================================================================
Standard_Integer Convert_CompPolynomialToPoles::NbPoles() const
{
if (myDone) {
return myPoles->ColLength() ;
}
else
return 0 ;
}
//=======================================================================
//function : Poles
//purpose :
//=======================================================================
void Convert_CompPolynomialToPoles::Poles(
Handle_TColStd_HArray2OfReal& P) const
{ if (myDone) {
P = myPoles ; }
}
//=======================================================================
//function : NbKnots
//purpose :
//=======================================================================
Standard_Integer Convert_CompPolynomialToPoles::NbKnots() const
{
if (myDone) {
return myKnots->Length() ;
}
else
return 0 ;
}
//=======================================================================
//function : Knots
//purpose :
//=======================================================================
void Convert_CompPolynomialToPoles::Knots(
Handle_TColStd_HArray1OfReal& K) const
{ if (myDone) {
K = myKnots ; }
}
//=======================================================================
//function : Knots
//purpose :
//=======================================================================
void Convert_CompPolynomialToPoles::Multiplicities(
Handle_TColStd_HArray1OfInteger& M) const
{ if (myDone) {
M = myMults ; }
}
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
Standard_Boolean Convert_CompPolynomialToPoles::IsDone() const
{ return myDone ; }
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
Standard_Integer Convert_CompPolynomialToPoles::Degree() const
{
if (myDone) {
return myDegree ;
}
return 0 ;
}
|