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: s1437.c,v 1.2 2001-03-19 15:58:49 afr Exp $
45 *
46 */
47
48
49 #define S1437
50
51 #include "sislP.h"
52
53 #if defined(SISLNEEDPROTOTYPES)
54 void
s1437(SISLSurf * ps1,double apar,SISLCurve ** rcurve,int * jstat)55 s1437(SISLSurf *ps1,double apar,SISLCurve **rcurve,int *jstat)
56 #else
57 void s1437(ps1,apar,rcurve,jstat)
58 SISLSurf *ps1;
59 double apar;
60 SISLCurve **rcurve;
61 int *jstat;
62 #endif
63 /*
64 *********************************************************************
65 *
66 *********************************************************************
67 *
68 * PURPOSE : Make constant parameter curve in the surface. The
69 * constant parameter value used is apar and is in the
70 * first parameter direction.
71 *
72 *
73 *
74 * INPUT : ps1 - Surface.
75 * apar - Parameter value to use whe picking out constant
76 * parameter curve in first parameter direction.
77 *
78 *
79 *
80 * OUTPUT : rcurve - Constant parameter curve.
81 * jstat - status messages
82 * > 0 : warning
83 * = 0 : ok
84 * < 0 : error
85 *
86 *
87 * METHOD : First the parameter directions of the surface is
88 * interchanged. Then the surface is viewed as a
89 * (ps1->idim*ps1->in2)-dimensional curve with
90 * knot vector ps1->et1, and evaluated in apar.
91 * The result of the evalutation is when viewed as
92 * a curve with ps1->in2 vertices and knot vector
93 * ps1->et2, the curve we are looking for.
94 *
95 *
96 * REFERENCES :
97 *
98 *-
99 * CALLS : s1221 - Evaluate curve in given parameter value.
100 * s6chpar - Change parameter direction of vertices of
101 * surface.
102 * newCurve - Create and initialize new curve.
103 *
104 * WRITTEN BY : Vibeke Skytt, SI, 88-11.
105 * REWISED BY : Per Evensen, SI, 89-3; Prepared for rational description.
106 * REWISED BY : Per Evensen, SI, 90-9; Corrected arguments in last call to newCurve.
107 *
108 *********************************************************************
109 */
110 {
111 int kstat = 0; /* Local status variable. */
112 int kpos = 0; /* Position of error. */
113 int kind = 0; /* Kind of curve
114 = 1 : Polynomial B-spline curve.
115 = 2 : Rational B-spline curve.
116 = 3 : Polynomial Bezier curve.
117 = 4 : Rational Bezier curve. */
118 int kdim; /* Dimension of the space in which the surface lies.*/
119 int kder = 0; /* Number of derivatives of curve to evaluate. */
120 int kleft = 0; /* Parameter used in evalutation of curve. */
121 double *ecoef = SISL_NULL; /* Pointer to vertices */
122 double *scoef = SISL_NULL; /* Vertices of surface with changed parameter
123 directions. */
124 double *scurve = SISL_NULL; /* Vertices of constant parameter curve. */
125 SISLCurve *qc = SISL_NULL; /* Intermediate curve. */
126
127 /* Get dimension of space. */
128
129 kdim = ps1 -> idim;
130 kind = ps1->ikind;
131
132 /* Prepare for rational description. */
133
134 if(ps1->ikind == 2 || ps1->ikind == 4)
135 {
136 ecoef = ps1->rcoef;
137 kdim = kdim+1;
138 }
139 else
140 {
141 ecoef = ps1->ecoef;
142 }
143
144
145 /* Allocate space for coefficients of constant parameter curve
146 and of surface with changed parameter direction. */
147
148 if ((scurve = newarray(kdim*ps1->in2,double)) == SISL_NULL) goto err101;
149 if ((scoef = newarray(kdim*ps1->in1*ps1->in2,double)) == SISL_NULL) goto err101;
150
151 /* Change parameter directions of surface. */
152
153 s6chpar(ecoef,ps1->in1,ps1->in2,kdim,scoef);
154
155 /* Create curve to evaluate. */
156
157 qc = newCurve(ps1->in1,ps1->ik1,ps1->et1,scoef,1,kdim*ps1->in2,0);
158 if (qc == SISL_NULL) goto err101;
159
160 /* Evaluate this curve in given parameter value. */
161
162 s1221(qc,kder,apar,&kleft,scurve,&kstat);
163 if (kstat < 0) goto error;
164
165 /* Create constant parameter curve. */
166
167 *rcurve = newCurve(ps1->in2,ps1->ik2,ps1->et2,scurve,kind,ps1->idim,1);
168 if (*rcurve == SISL_NULL) goto err101;
169
170 /* Set periodicity flag. */
171
172 (*rcurve)->cuopen = ps1->cuopen_2;
173
174 /* Curve picked. */
175
176 *jstat = 0;
177 goto out;
178
179 /* Error in space allocation. */
180
181 err101: *jstat = -101;
182 s6err("s1437",*jstat,kpos);
183 goto out;
184
185 /* Error in lower level routine. */
186
187 error : *jstat = kstat;
188 s6err("s1437",*jstat,kpos);
189 goto out;
190
191 out:
192
193 /* Free space occupied by local arrays. */
194
195 if (scoef != SISL_NULL) freearray(scoef);
196 if (scurve != SISL_NULL) freearray(scurve);
197 if (qc != SISL_NULL) freeCurve(qc);
198
199 return;
200 }
201