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