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: s1436.c,v 1.2 2001-03-19 15:58:49 afr Exp $
45  *
46  */
47 
48 
49 #define S1436
50 
51 #include "sislP.h"
52 
53 #if defined(SISLNEEDPROTOTYPES)
54 void
s1436(SISLSurf * ps1,double apar,SISLCurve ** rcurve,int * jstat)55 s1436(SISLSurf *ps1,double apar,SISLCurve **rcurve,int *jstat)
56 #else
57 void s1436(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 *              second parameter direction.
71 *
72 *
73 *
74 * INPUT      : ps1    - Surface.
75 *              apar   - Parameter value to use whe picking out constant
76 *                       parameter curve in second 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     : The surface is treated as a (ps1->idim*ps1->in1)-
88 *              dimensional curve with ps1->in2 vertices. The value
89 *              of this curve at apar is calculated. This value is
90 *              then viewed as the vertices of a (ps1->idim)-dimensional
91 *              curve. The curve with these vertices and the knot-vector
92 *              ps1->in2 is the curve we are looking for.
93 *
94 *
95 * REFERENCES :
96 *
97 *-
98 * CALLS      : s1221     - Evaluate curve in given parameter value.
99 *              newCurve  - Create and initialize new curve.
100 *
101 * WRITTEN BY : Vibeke Skytt, SI, 88-11.
102 * REWISED BY : Per Evensen,  SI, 89-3; Prepared for rational description.
103 * REWISED BY : Per Evensen,  SI, 90-9; Corrected arguments in last call to newCurve.
104 * MODIFIED BY : Mike Floater,  SI, 91-01; Use rcoef instead of ecoef if rational.
105 *
106 *********************************************************************
107 */
108 {
109   int kstat = 0;     /* Local status variable.                        */
110   int kpos = 0;      /* Position of error.                            */
111   int kder = 0;      /* Number of derivatives of curve to evalutate.  */
112   int kleft = 0;     /* Parameter used in evaluation of curve.        */
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;
119   double *scoef;     /* Pointer to vertices.                          */
120   double *scurve = SISL_NULL; /* Vertices of constant parameter curve.     */
121   SISLCurve *qc = SISL_NULL;  /* Pointer to intermediate curve.         */
122 
123   /* Prepare for rational description. */
124 
125   kdim = ps1->idim;
126   kind = ps1->ikind;
127   if(ps1->ikind == 2 || ps1->ikind == 4)
128   {
129       scoef = ps1->rcoef;
130       kdim = kdim+1;
131   }
132   else
133   {
134       scoef = ps1->ecoef;
135   }
136 
137   /* Create the curve describing the surface as a curve.  */
138 
139   if ((qc = newCurve(ps1->in2,ps1->ik2,ps1->et2,scoef,1,
140 		     ps1->in1*kdim,0)) == SISL_NULL) goto err101;
141 
142   /* Allocate space for value of curve.  */
143 
144   if ((scurve = newarray(ps1->in1*kdim,double)) == SISL_NULL) goto err101;
145 
146   /* Evaluate this curve at given parameter value.  */
147 
148   s1221(qc,kder,apar,&kleft,scurve,&kstat);
149   if (kstat < 0) goto error;
150 
151   /* Create constant parameter curve.  */
152 
153   *rcurve = newCurve(ps1->in1,ps1->ik1,ps1->et1,scurve,kind,ps1->idim,1);
154   if (*rcurve == SISL_NULL) goto err101;
155 
156   /* Set periodicity flag.      */
157 
158   (*rcurve)->cuopen = ps1->cuopen_1;
159 
160   /* Curve picked.  */
161 
162   *jstat = 0;
163   goto out;
164 
165   /* Error in space allocation.  */
166 
167  err101: *jstat = -101;
168   s6err("s1436",*jstat,kpos);
169   goto out;
170 
171   /* Error in lower level routine.  */
172 
173   error : *jstat = kstat;
174   s6err("s1436",*jstat,kpos);
175   goto out;
176 
177  out:
178 
179   /* Free space occupied by local arrays.  */
180 
181   if (scurve != SISL_NULL) freearray(scurve);
182   if (qc != SISL_NULL) freeCurve(qc);
183 
184   return;
185 }
186