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 /*
43 *
44 * $Id: s1376.c,v 1.2 2001-03-19 15:58:48 afr Exp $
45 *
46 */
47
48
49 #define S1376
50
51 #include "sislP.h"
52
53 #if defined(SISLNEEDPROTOTYPES)
54 void
s1376(double et[],int in,int ik,double ** gt,int * jkn,int * jkk,int * jstat)55 s1376(double et[],int in,int ik,double **gt,int *jkn,int *jkk,int *jstat)
56 #else
57 void s1376(et,in,ik,gt,jkn,jkk,jstat)
58 double et[];
59 int in;
60 int ik;
61 double **gt;
62 int *jkn;
63 int *jkk;
64 int *jstat;
65 #endif
66 /*
67 *********************************************************************
68 *
69 *********************************************************************
70 *
71 * PURPOSE : Make the knot vector for the representing a spline
72 * basis of order 4*(ik-1)+1, with the same knot values as et.
73 * This basis is used for representing a curve or surface
74 * put into a conic equation.
75 *
76 * INPUT : et - Knots of input spline basis
77 * in - Number of vertices in input basis
78 * ik - Order of input basis
79 *
80 * OUTPUT : gt - Pointer to array of knots. The array is allocated
81 * inside this routine.
82 * jkn - Number of vertices
83 * jkk - Order of B-spline basis produced
84 *
85 * jstat - status messages
86 * > 0 : warning
87 * = 0 : ok
88 * < 0 : error
89 * METHOD :
90 *
91 * REFERENCES :
92 *
93 *-
94 * CALLS :
95 *
96 * WRITTEN BY : Tor Dokken, SI, 88-11.
97 *
98 *********************************************************************
99 */
100 {
101 double tval; /* Value of knot */
102 double *sdum; /* Pointer to knot array */
103 int ki,kl; /* Variable in loop */
104 int knumb; /* Number of intervals */
105 int kstop; /* Loop stop variable */
106 int kpos=0; /* Position of error */
107
108 /* Run through the knot vector to decide how many intervals exist */
109
110 knumb = 0;
111 tval = et[ik-1];
112
113 for (ki=ik ; ki<=in ; ki++)
114 {
115 if (tval < et[ki])
116 {
117 /* New knot value found */
118 knumb = knumb + 1;
119 tval = et[ki];
120 }
121 }
122
123 *jkk = 4*(ik-1) + 1;
124 *jkn = (*jkk-1)*(knumb-1) + *jkk;
125
126 sdum = newarray(*jkn+*jkk,DOUBLE);
127 if (sdum == SISL_NULL) goto err101;
128
129 *gt = sdum;
130
131 /* Make knot values */
132
133 tval = et[ik-1];
134
135 /* Make jkk first knot values */
136
137 for (kl=0;kl<*jkk;kl++)
138 {
139 sdum[kl] = tval;
140 }
141
142 /* kl points to the array entry where the next knot value is to be stored
143 */
144
145 for (ki=ik ; ki<=in ; ki++)
146 {
147 if (tval < et[ki])
148 {
149 /* New knot value, remember this and make knots */
150 tval = et[ki];
151 kstop = kl + *jkk-1;
152 for (;kl<kstop;kl++)
153 sdum[kl] = tval;
154 }
155 }
156
157 /* Make last knot value */
158
159 sdum[kl] = tval;
160
161 *jstat = 0;
162 goto out;
163
164 /* Error in space allocation */
165 err101: *jstat = -101;
166 s6err("s1376",*jstat,kpos);
167 goto out;
168 out:
169
170 return;
171 }
172