1 /*
2 * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF ICT,
3 * Applied Mathematics, Norway.
4 *
5 * Contact information: E-mail: tor.dokken@sintef.no
6 * SINTEF ICT, Department of Applied Mathematics,
7 * P.O. Box 124 Blindern,
8 * 0314 Oslo, Norway.
9 *
10 * This file is part of SISL.
11 *
12 * SISL is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Affero General Public License as
14 * published by the Free Software Foundation, either version 3 of the
15 * License, or (at your option) any later version.
16 *
17 * SISL is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Affero General Public License for more details.
21 *
22 * You should have received a copy of the GNU Affero General Public
23 * License along with SISL. If not, see
24 * <http://www.gnu.org/licenses/>.
25 *
26 * In accordance with Section 7(b) of the GNU Affero General Public
27 * License, a covered work must retain the producer line in every data
28 * file that is created or manipulated using SISL.
29 *
30 * Other Usage
31 * You can be released from the requirements of the license by purchasing
32 * a commercial license. Buying such a license is mandatory as soon as you
33 * develop commercial activities involving the SISL library without
34 * disclosing the source code of your own applications.
35 *
36 * This file may be used in accordance with the terms contained in a
37 * written agreement between you and SINTEF ICT.
38 */
39
40 #include "sisl-copyright.h"
41
42 #define S1534
43
44 #include "sislP.h"
45
46 #if defined(SISLNEEDPROTOTYPES)
s1534(double points[],double der10[],double der01[],double der11[],int im1,int im2,int idim,int ipar,int con1,int con2,int con3,int con4,int order1,int order2,int iopen1,int iopen2,SISLSurf ** rsurf,int * jstat)47 void s1534(double points[],double der10[], double der01[],
48 double der11[],int im1,int im2,int idim,int ipar,
49 int con1,int con2,int con3,int con4, int order1,
50 int order2,int iopen1,int iopen2,SISLSurf **rsurf,int *jstat)
51 #else
52 void s1534(points,der10,der01,der11,im1,im2,idim,ipar,con1,con2,con3,
53 con4,order1, order2,iopen1,iopen2,rsurf,jstat)
54 double points[];
55 double der10[];
56 double der01[];
57 double der11[];
58 int im1;
59 int im2;
60 int idim;
61 int ipar;
62 int con1;
63 int con2;
64 int con3;
65 int con4;
66 int order1;
67 int order2;
68 int iopen1;
69 int iopen2;
70 SISLSurf **rsurf;
71 int *jstat;
72 #endif
73 /*
74 ************************************************************************
75 *
76 * PURPOSE: To compute a B-spline tensor surface interpolating a set
77 * of points.
78 *
79 * INPUT:
80 * points - Array of dimension idim*im1*im2 containing
81 * the positions of the nodes (using the same ordering
82 * as ecoef in the SISLSurf structure).
83 *
84 * der10 - Array of dimension idim*im1*im2 containing the first
85 * derivatives in the first parameter direction.
86 *
87 * der01 - Array of dimension idim*im1*im2 containing the first
88 * derivatives in the second parameter direction.
89 *
90 * der11 - Array of dimension idim*im1*im2 containing the cross
91 * derivatives (the twists).
92 *
93 * im1 - The number of interpolation points in the
94 * first parameter direction.
95 *
96 * im2 - The number of interpolation points in the
97 * second parameter direction.
98 *
99 * idim - Dimension of the space we are working in.
100 *
101 * ipar - Flag showing the desired parametrization to be used:
102 * = 1: Mean accumulated cord-length parameterization.
103 * = 2: Uniform parametrization.
104 *
105 *
106 * ^ Second par. direction
107 * |
108 * | (2.)
109 * |-----------|
110 * | |
111 * (3.) | | (4.)
112 * | |
113 * | |
114 * |-----------|-> First par. direction
115 * (1.)
116 *
117 * con1 - Additional condition along edge 1:
118 * = 0: No additional condition.
119 * = 1: Zero curvature.
120 *
121 * con2 - Additional condition along edge 2:
122 * = 0: No additional condition.
123 * = 1: Zero curvature.
124 *
125 * con3 - Additional condition along edge 3:
126 * = 0: No additional condition.
127 * = 1: Zero curvature.
128 *
129 * con4 - Additional condition along edge 4:
130 * = 0: No additional condition.
131 * = 1: Zero curvature.
132 *
133 * order1 - Order of surface in first parameter direction.
134 *
135 * order2 - Order of surface in second parameter direction.
136 *
137 * iopen1 - Open/closed parameter in first parameter direction.
138 * = 1 : open surface.
139 * = 0 : closed surface.
140 * = -1 : closed, periodic surface.
141 *
142 * iopen2 - Open/closed parameter in second parameter direction.
143 * = 1 : open surface.
144 * = 0 : closed surface.
145 * = -1 : closed, periodic surface.
146 *
147 *
148 * Output:
149 * rsurf - Pointer to the surf produced
150 * jstat - Status variable
151 * < 0 - Error.
152 *
153 * Method:
154 * First, a suitable parametrization is calculated according
155 * to indicator variable ipar.
156 * Then the interpolation is accomplished by using a one dimensional
157 * routine for spline interpolation called several times.
158 * First, the datapoints
159 * are considered to be idim*im1 dimentional and so on...
160 *
161 *
162 * REFERENCES :
163 *
164 * CALLS : s1528, s1535.
165 *
166 * WRITTEN BY : Christophe Rene Birkeland, SINTEF, May 1993.
167 *
168 *********************************************************************
169 */
170 {
171 int kstat=0; /* Status variable */
172 int kpos=0; /* Position of error */
173 double *par1=SISL_NULL; /* Transposed positions (in rpos) */
174 double *par2=SISL_NULL; /* Transposed derivatives (in rder) */
175
176
177 /* Check input */
178
179 if (ipar < 1 || ipar > 3) goto err102;
180
181 /* Generate parametrizations */
182
183 s1528(idim, im1, im2, points, ipar, iopen1, iopen2, &par1, &par2, &kstat);
184 if(kstat < 0) goto error;
185
186 /* Interpolation */
187
188 s1535(points,der10,der01,der11,im1,im2,idim,par1,par2,
189 con1,con2,con3,con4,order1, order2, iopen1, iopen2, rsurf,&kstat);
190 if (kstat < 0) goto error;
191
192 /* Success */
193
194 *jstat = 0;
195 goto out;
196
197 /* Error in input data. */
198
199 err102: *jstat = -102;
200 s6err("s1534",*jstat,kpos);
201 goto out;
202
203 /* Error in lower level routine. */
204
205 error: *jstat =kstat;
206 s6err("s1534",*jstat,kpos);
207 goto out;
208
209 out:
210 if(par1 != SISL_NULL) freearray(par1);
211 if(par2 != SISL_NULL) freearray(par2);
212 return;
213 }
214