-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path3dSurf.c
737 lines (698 loc) · 18.1 KB
/
3dSurf.c
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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
/*****************************************************************************
* File: 3dSurfaces.c
*
* Purpose: General Cubic Spline Surfaces
*
* © 1989 Mark M. Owen. All rights reserved.
*****************************************************************************
*/
#include "3dSurf.h"
#include "3dFMath.h"
typedef Point3d *p3d;
typedef p3d ap3d[1];
typedef ap3d *(pap3d);
enum surfaceBlends defaultBlend = splineAvgY;
#if XVT_CC_PROTO
static int SplineSurface(enum surfaceBlends,int,Point3d _huge *,int,Point3d _huge *,int*,Point3d _huge **);
static int SplineSurface4(enum surfaceBlends,int,Point3d _huge *,int,Point3d _huge *,Point3d _huge *,Point3d _huge *,int*,Point3d _huge **);
static void papDispose(pap3d,int);
#else
static int SplineSurface();
static int SplineSurface4();
static void papDispose();
#endif
/******************************************************************
*
* Function: SplineSurface
*
* Scope: local, private
*
* Purpose: Generates a surface from two spline curves using a
* specified blending function to alter the Y values.
* The input curves are for the X and Z axes.
*
* Returns: FALSE if any; or noErr if successful.
*
******************************************************************
*/
static int
#if XVT_CC_PROTO
SplineSurface (enum surfaceBlends theBlend, int nP0,
Point3d _huge *P0, /* the z spline */
int nP1,
Point3d _huge *P1, /* the x spline */
int *nP,
Point3d _huge **ppP)
#else
SplineSurface (theBlend, nP0, P0, nP1, P1, nP, ppP)
enum surfaceBlends theBlend;
int nP0;
Point3d _huge *P0; /* the z spline */
int nP1;
Point3d _huge *P1; /* the x spline */
int *nP;
Point3d _huge **ppP;
#endif
{
int i,j,k=0;
Fixed Dx,Dz,Sx0;
*ppP = (Point3d _huge *)xvt_mem_halloc(nP0*nP1, sizeof(Point3d));
if( !*ppP )
return FALSE;
Dx = P0[nP0-1].x-P0[0].x;
Dz = P1[nP1-1].z-P1[0].z;
Dx = fixdiv(1.0,FxAbs(Dx));
Dz = fixdiv(1.0,FxAbs(Dz));
for( i=0; i<nP0; i++ )
{
Sx0 = fixmul(FxAbs(P0[i].x-P0[0].x),Dx);
for( j=0; j<nP1; j++ )
{
(*ppP)[k].x = P0[i].x;
(*ppP)[k].z = P1[j].z;
switch((short)theBlend)
{
case splineSumY:
(*ppP)[k].y = P1[j].y+P0[i].y;
break;
case splineAvgY:
(*ppP)[k].y = fixmul( P1[j].y + P0[i].y, 0.5 );
break;
case splineProductY:
(*ppP)[k].y = fixmul(fixmul(P1[j].y,P0[i].y),0.5);
break;
case wtSplineSumY:
(*ppP)[k].y = fixmul(P0[i].y,1.0 -fixmul(FxAbs(P1[j].z-P1[0].z),Dz))
+ fixmul(P1[j].y,Sx0);
break;
case wtSplineAvgY:
(*ppP)[k].y =
fixmul( fixmul(P0[i].y,1.0 -fixmul(FxAbs(P1[j].z-P1[0].z),Dz))
+ fixmul(P1[j].y,Sx0)
, 0.5
);
break;
}
k++;
}
}
*nP = nP0*nP1;
return TRUE;
}
/******************************************************************
*
* Function: SplineSurface4
*
* Scope: local, private
*
* Purpose: Generates a surface from four spline curves using a
* specified blending function to alter the Y values.
* The input curves are for the limits of X and Z axes.
*
* Returns: FALSE if any; or TRUE if successful.
*
******************************************************************
*/
static int
#if XVT_CC_PROTO
SplineSurface4(enum surfaceBlends theBlend, int nP0,
Point3d _huge *P0, /* the z spline */
int nP1,
Point3d _huge *P1, /* the x spline */
Point3d _huge *P2, /* the z spline same control point array size as P0 */
Point3d _huge *P3, /* the x spline same control point array size as P1 */
int *nP,
Point3d _huge**ppP
)
#else
SplineSurface4(theBlend, nP0, P0, nP1, P1, P2, P3, nP, ppP)
enum surfaceBlends theBlend;
int nP0;
Point3d _huge *P0; /* the z spline */
int nP1;
Point3d _huge *P1; /* the x spline */
Point3d _huge *P2; /* the z spline same control point array size as P0 */
Point3d _huge *P3; /* the x spline same control point array size as P1 */
int *nP;
Point3d _huge**ppP;
#endif
{
int i,j,k=0;
Fixed Dx0,Dz1,Dx2,Dz3;
Fixed Sx0,rSx2;
*ppP = (Point3d _huge *)xvt_mem_halloc(nP0*nP1, sizeof(Point3d));
if( !*ppP )
return FALSE;
Dx0 = P0[nP0-1].x-P0[0].x;
Dz1 = P1[nP1-1].z-P1[0].z;
Dx0 = fixdiv(1.0,FxAbs(Dx0));
Dz1 = fixdiv(1.0,FxAbs(Dz1));
Dx2 = P2[nP0-1].x-P2[0].x;
Dz3 = P3[nP1-1].z-P3[0].z;
Dx2 = fixdiv(1.0,FxAbs(Dx2));
Dz3 = fixdiv(1.0,FxAbs(Dz3));
for( i=0; i<nP0; i++ )
{
Sx0 = fixmul(FxAbs(P0[i].x-P0[0].x),Dx0);
rSx2 = 1.0 - fixmul(FxAbs(P2[i].x-P2[0].x),Dx2);
for( j=0; j<nP1; j++ )
{
(*ppP)[k].x = fixmul(P0[i].x,1.0 -fixmul(FxAbs(P1[j].z-P1[0].z),Dz1))
+ fixmul(P2[i].x,fixmul(FxAbs(P3[j].z-P3[0].z),Dz3));
(*ppP)[k].z = fixmul(P1[j].z,Sx0)
+ fixmul(P3[j].z,rSx2);
switch((short)theBlend)
{
case splineSumY:
(*ppP)[k].y = P0[i].y+P1[j].y+P2[i].y+P3[j].y;
break;
case splineAvgY:
(*ppP)[k].y = fixmul( P0[i].y+P1[j].y+P2[i].y+P3[j].y, 0.25 );
break;
case splineProductY:
(*ppP)[k].y = fixmul(P0[i].y,P1[j].y);
(*ppP)[k].y = fixmul((*ppP)[k].y,P2[i].y);
(*ppP)[k].y = fixmul((*ppP)[k].y,P3[j].y);
break;
case wtSplineSumY:
(*ppP)[k].y = fixmul(P0[i].y,1.0 -fixmul(FxAbs(P1[j].z-P1[0].z),Dz1))
+ fixmul(P1[j].y, Sx0)
+ fixmul(P2[i].y, fixmul(FxAbs(P3[j].z-P3[0].z),Dz3))
+ fixmul(P3[j].y, rSx2);
break;
case wtSplineAvgY:
(*ppP)[k].y =
fixmul( fixmul(P0[i].y,1.0 -fixmul(FxAbs(P1[j].z-P1[0].z),Dz1))
+ fixmul(P1[j].y, Sx0)
+ fixmul(P2[i].y, fixmul(FxAbs(P3[j].z-P3[0].z),Dz3))
+ fixmul(P3[j].y, rSx2)
, 0.25
);
break;
}
k++;
}
}
*nP = nP0*nP1;
return TRUE;
}
/*****************************************************************************
*
* Function: BSplineSurface(É)
*
* Purpose: Given control points for two BSplines generates a matrix of
* vertices equivalent to a surface interpolated from the splines
* the control points approximate.
*
* Returns: FALSE if memory allocation fails
* BSpline3d if error in generating the splines
* TRUE if successfull
*
*****************************************************************************
*/
int
#if XVT_CC_PROTO
BSplineSurface(int nSteps, int *np0,
Point3d _huge *p0, /* the z spline */
int *np1,
Point3d _huge *p1, /* the x spline */
int *nP,
Point3d _huge **ppP)
#else
BSplineSurface(nSteps, np0, p0, np1, p1, nP, ppP)
int nSteps;
int *np0;
Point3d _huge *p0; /* the z spline */
int *np1;
Point3d _huge *p1; /* the x spline */
int *nP;
Point3d _huge **ppP;
#endif
{
Point3d _huge *P0;
Point3d _huge *P1;
int nP0,nP1;
int err;
if( (err = BSpline3d( nSteps, *np0, p0, &nP0, &P0 )) )
return err;
if( (err = BSpline3d( nSteps, *np1, p1, &nP1, &P1 )) )
{
xvt_mem_hfree( (char _huge *) P0 );
return err;
}
if( !(err = SplineSurface( defaultBlend, nP0, P0, nP1, P1, nP, ppP )) )
{
*np0 = nP0;
*np1 = nP1;
}
xvt_mem_hfree( (char _huge *) P1 );
xvt_mem_hfree( (char _huge *) P0 );
return TRUE;
}
/*****************************************************************************
*
* Function: HermiteSplineSurface(É)
*
* Purpose: Given the data points of 2 Hermite curves, generates a matrix
* equivalent to a surface, interpolated from the 2 curves.
*
* Returns: FALSE if memory allocation fails
* HermiteCurve3d if error in generating the curves
* TRUE if successfull
*
*****************************************************************************
*/
int
#if XVT_CC_PROTO
HermiteSplineSurface(BOOLEAN bClosed, int nSteps, int *np0,
Point3d _huge *p0, /* the z spline */
int *np1,
Point3d _huge *p1, /* the x spline */
int *nP,
Point3d _huge **ppP)
#else
HermiteSplineSurface(bClosed, nSteps, np0, p0, np1, p1, nP, ppP)
BOOLEAN bClosed;
int nSteps, *np0;
Point3d _huge *p0; /* the z spline */
int *np1;
Point3d _huge *p1; /* the x spline */
int *nP;
Point3d _huge **ppP;
#endif
{
Point3d _huge *P0;
Point3d _huge *P1;
int nP0, nP1;
int err;
if( (err = HermiteCurve3d( bClosed, nSteps, *np0, p0, &nP0, &P0 )) )
return err;
if( (err = HermiteCurve3d( bClosed, nSteps, *np1, p1, &nP1, &P1 )) )
{
xvt_mem_hfree((char _huge *) P0);
return err;
}
if( !(err = SplineSurface( defaultBlend, nP0, P0, nP1, P1, nP, ppP )) )
{
*np0 = nP0;
*np1 = nP1;
}
xvt_mem_hfree((char _huge *) P1);
xvt_mem_hfree((char _huge *) P0);
return err;
}
/*****************************************************************************
*
* Function: BSplineSurface4(É)
*
* Purpose: Given control points for four BSplines generates a matrix of
* vertices equivalent to a surface interpolated from the splines
* the control points approximate.
*
* Returns: FALSE if memory allocation fails
* BSpline3d if error in generating the splines
* TRUE if successfull
*
*****************************************************************************
*/
int
#if XVT_CC_PROTO
BSplineSurface4(int nSteps, int *np0,
Point3d _huge *p0, /* the z spline */
int *np1,
Point3d _huge *p1, /* the x spline */
Point3d _huge *p2, /* the z spline */
Point3d _huge *p3, /* the x spline */
int *nP,
Point3d _huge **ppP
)
#else
BSplineSurface4(nSteps, np0, p0, np1, p1, p2, p3, nP, ppP)
int nSteps, *np0;
Point3d _huge *p0; /* the z spline */
int *np1;
Point3d _huge *p1; /* the x spline */
Point3d _huge *p2; /* the z spline */
Point3d _huge *p3; /* the x spline */
int *nP;
Point3d _huge **ppP;
#endif
{
Point3d _huge *P0;
Point3d _huge *P1;
Point3d _huge *P2;
Point3d _huge *P3;
int nP0,nP1;
int err;
if( (err = BSpline3d( nSteps, *np0, p0, &nP0, &P0 )) )
return err;
if( (err = BSpline3d( nSteps, *np1, p1, &nP1, &P1 )) )
{
xvt_mem_hfree( (char _huge *) P0 );
return err;
}
if( (err = BSpline3d( nSteps, *np0, p2, &nP0, &P2 )) )
{
xvt_mem_hfree( (char _huge *) P0 );
xvt_mem_hfree( (char _huge *) P1 );
return err;
}
if( (err = BSpline3d( nSteps, *np1, p3, &nP1, &P3 )) )
{
xvt_mem_hfree( (char _huge *) P0 );
xvt_mem_hfree( (char _huge *) P1 );
xvt_mem_hfree( (char _huge *) P2 );
return err;
}
if( !(err = SplineSurface4( defaultBlend, nP0, P0, nP1, P1, P2, P3, nP, ppP )) )
{
*np0 = nP0;
*np1 = nP1;
}
xvt_mem_hfree((char _huge *) P0);
xvt_mem_hfree((char _huge *) P1);
xvt_mem_hfree((char _huge *) P2);
xvt_mem_hfree((char _huge *) P3);
return err;
}
/*****************************************************************************
*
* Function: HermiteSplineSurface4(É)
*
* Purpose: Given the data points of 4 Hermite curves, generates a matrix
* equivalent to a surface, interpolated from the 4 curves.
*
* Returns: FALSE if memory allocation fails
* HermiteCurve3d if error in generating the curves
* TRUE if successfull
*
*****************************************************************************
*/
int
#if XVT_CC_PROTO
HermiteSplineSurface4(BOOLEAN bClosed, int nSteps, int *np0,
Point3d _huge *p0, /* the z spline */
int *np1,
Point3d _huge *p1, /* the x spline */
Point3d _huge *p2, /* the z spline */
Point3d _huge *p3, /* the x spline */
int *nP,
Point3d _huge **ppP
)
#else
HermiteSplineSurface4(bClosed, nSteps, np0, p0, np1, p1, p2, p3, nP, ppP)
BOOLEAN bClosed;
int nSteps;
int *np0;
Point3d _huge *p0; /* the z spline */
int *np1;
Point3d _huge *p1; /* the x spline */
Point3d _huge *p2; /* the z spline */
Point3d _huge *p3; /* the x spline */
int *nP;
Point3d _huge **ppP;
#endif
{
Point3d _huge *P0;
Point3d _huge *P1;
Point3d _huge *P2;
Point3d _huge *P3;
int nP0,nP1;
int err;
if( (err = HermiteCurve3d( bClosed, nSteps, *np0, p0, &nP0, &P0 )) )
return err;
if( (err = HermiteCurve3d( bClosed, nSteps, *np1, p1, &nP1, &P1 )) )
{
xvt_mem_hfree( (char _huge *) P0 );
return err;
}
if( (err = HermiteCurve3d( bClosed, nSteps, *np0, p2, &nP0, &P2 )) )
{
xvt_mem_hfree( (char _huge *) P0 );
xvt_mem_hfree( (char _huge *) P1 );
return err;
}
if( (err = HermiteCurve3d( bClosed, nSteps, *np1, p3, &nP1, &P3 )) )
{
xvt_mem_hfree( (char _huge *) P0 );
xvt_mem_hfree( (char _huge *) P1 );
xvt_mem_hfree( (char _huge *) P2 );
return err;
}
if( !(err = SplineSurface4( defaultBlend, nP0, P0, nP1, P1, P2, P3, nP, ppP )) )
{
*np0 = nP0;
*np1 = nP1;
}
xvt_mem_hfree( (char _huge *) P0 );
xvt_mem_hfree( (char _huge *) P1 );
xvt_mem_hfree( (char _huge *) P2 );
xvt_mem_hfree( (char _huge *) P3 );
return err;
}
/*****************************************************************************
*
* Function: papDispose(É)
*
* Purpose: Deallocates the storage for an array of pointers to arrays of
* 3d points.
*
* Returns: Nothing
*
*****************************************************************************
*/
static void
#if XVT_CC_PROTO
papDispose(pap3d pap, int n)
#else
papDispose(pap, n)
pap3d pap;
int n;
#endif
{
while(n--)
if((*pap)[n])
xvt_mem_free((char *) (*pap)[n]);
xvt_mem_free((char *) pap);
}
/*****************************************************************************
*
* Function: BSplineMesh(É)
*
* Purpose: Given a matrix of control points, returns a matrix of points
* equivalent to a surface approximated by the control points.
*
* Returns: FALSE if memory allocation fails
* BSpline3d if error in generating the curves
* TRUE if successfull
*
*****************************************************************************
*/
int
#if XVT_CC_PROTO
BSplineMesh (
int nSteps, /* number of segments between control points */
int npRow, /* number of points per row */
int *nPts, /* number of input control points */
Point3d _huge *p, /* array of input control points */
int *nP, /* returned number of generated curve vertices */
Point3d _huge **ppP /* returned array of generated curve vertices */
)
#else
BSplineMesh (nSteps, npRow, nPts, p, nP, ppP)
int nSteps; /* number of segments between control points */
int npRow; /* number of points per row */
int *nPts; /* number of input control points */
Point3d _huge *p;/* array of input control points */
int *nP; /* returned number of generated curve vertices */
Point3d _huge **ppP; /* returned array of generated curve vertices */
#endif
{
long i,j;
pap3d papSRow;
pap3d papSCol;
p3d pwSCol;
p3d pRow;
int nRows;
int nCols;
int nSRow;
int nSCol;
int err;
if(*nPts%npRow)
return -1;
nRows = *nPts / npRow;
papSRow = (pap3d)xvt_mem_alloc(nRows*sizeof(char *));
if(!papSRow)
return FALSE;
pRow = p;
for(i=0;i<nRows;i++)
{
err=BSpline3d(nSteps,npRow,pRow,&nSRow, (Point3d _huge **) &(*papSRow)[i]);
if(err)
{
papDispose((pap3d) papSRow, (int) i);
return err;
}
pRow+=npRow;
}
nCols = nSRow;
papSCol = (pap3d)xvt_mem_halloc(nCols, sizeof(char *));
if(!papSCol)
{
err = FALSE;
papDispose(papSRow, nRows);
return err;
}
pwSCol = (p3d)xvt_mem_halloc(nSRow, sizeof(Point3d));
if(!pwSCol)
{
err = FALSE;
papDispose(papSRow,nRows);
xvt_mem_free((char *)papSCol);
return err;
}
for(i=0;i<nCols;i++)
{
for(j=0;j<nRows;j++)
pwSCol[j] = ((*papSRow)[j])[i];
err=BSpline3d(nSteps,nRows,pwSCol,&nSCol,(Point3d _huge **) &(*papSCol)[i]);
if(err)
{
papDispose(papSRow,nRows);
papDispose((pap3d) papSCol, (int) i);
xvt_mem_free((char *)pwSCol);
return err;
}
}
xvt_mem_free((char *)pwSCol);
papDispose(papSRow,nRows);
*ppP = (p3d)xvt_mem_alloc(nCols*nSCol*sizeof(Point3d));
if(!*ppP)
{
err = FALSE;
papDispose(papSCol,nCols);
return err;
}
pwSCol = *ppP;
for(i=0;i<nCols;i++)
{
memcpy((char *)pwSCol, (char *)(*papSCol)[i], nSCol*sizeof(Point3d));
pwSCol+=nSCol;
}
papDispose(papSCol,nCols);
*nPts = nCols;
*nP = nCols*nSCol;
return TRUE;
}
/*****************************************************************************
*
* Function: HermiteSplineMesh(É)
*
* Purpose: Given a matrix of control points, returns a matrix of points
* equivalent to a surface interpolated from the control points.
*
* Returns: FALSE if memory allocation fails
* HermiteCurve3d if error in generating the curves
* TRUE if successfull
*
*****************************************************************************
*/
int
#if XVT_CC_PROTO
HermiteSplineMesh
(
BOOLEAN closed, /* true if a closed curve function is wanted */
int nSteps, /* number of segments between control points */
int npRow, /* number of points per row */
int *nPts, /* number of input control points */
Point3d _huge *p, /* array of input control points */
int *nP, /* returned number of generated curve vertices */
Point3d _huge **ppP /* returned array of generated curve vertices */
)
#else
HermiteSplineMesh (closed, nSteps, npRow, nPts, p, nP, ppP)
BOOLEAN closed; /* true if a closed curve function is wanted */
int nSteps; /* number of segments between control points */
int npRow; /* number of points per row */
int *nPts; /* number of input control points */
Point3d _huge *p; /* array of input control points */
int *nP; /* returned number of generated curve vertices */
Point3d _huge **ppP; /* returned array of generated curve vertices */
#endif
{
long i,j;
pap3d papSRow;
pap3d papSCol;
p3d pwSCol;
p3d pRow;
int nRows;
int nCols;
int nSRow;
int nSCol;
int err;
if(*nPts%npRow)
return -1;
nRows = *nPts / npRow;
papSRow = (pap3d)xvt_mem_alloc(nRows*sizeof(char *));
if(!papSRow)
return FALSE;
pRow = p;
for(i=0;i<nRows;i++)
{
err=HermiteCurve3d(closed,nSteps,npRow,pRow,&nSRow,&(*papSRow)[i]);
if(err)
{
papDispose((pap3d) papSRow, (int) i);
return err;
}
pRow+=npRow;
}
nCols = nSRow;
papSCol = (pap3d)xvt_mem_alloc(nCols*sizeof(char *));
if(!papSCol)
{
err = FALSE;
papDispose(papSRow, nRows);
return err;
}
pwSCol = (p3d)xvt_mem_alloc(nSRow*sizeof(Point3d));
if(!pwSCol)
{
err = FALSE;
papDispose(papSRow,nRows);
xvt_mem_free((char *)papSCol);
return err;
}
for(i=0;i<nCols;i++)
{
for(j=0;j<nRows;j++)
pwSCol[j] = ((*papSRow)[j])[i];
err=HermiteCurve3d(closed,nSteps,nRows,pwSCol,&nSCol,&(*papSCol)[i]);
if(err)
{
papDispose(papSRow,nRows);
papDispose((pap3d) papSCol, (int) i);
xvt_mem_free((char *)pwSCol);
return err;
}
}
xvt_mem_free((char *)pwSCol);
papDispose(papSRow,nRows);
*ppP = (p3d)xvt_mem_alloc(nCols*nSCol*sizeof(Point3d));
if(!*ppP)
{
err = FALSE;
papDispose(papSCol,nCols);
return err;
}
pwSCol = *ppP;
for(i=0;i<nCols;i++)
{
memcpy((char *) pwSCol, (char *) (*papSCol)[i], nSCol*sizeof(Point3d));
pwSCol+=nSCol;
}
papDispose(papSCol,nCols);
*nPts = nCols;
*nP = nCols*nSCol;
return TRUE;
}