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: s1501.c,v 1.3 2001-03-19 15:58:49 afr Exp $
45  *
46  */
47 
48 
49 #define S1501
50 
51 #include "sislP.h"
52 
53 #if defined(SISLNEEDPROTOTYPES)
54 void
s1501(SISLSurf * ps1,double * base,double * norm,double * axisA,double alpha,double ratio,int idim,double aepsco,double aepsge,double amax,SISLIntcurve * pintcr,int icur,int igraph,int * jstat)55      s1501(SISLSurf *ps1,double *base,double *norm,double *axisA,double alpha,double ratio,int idim,
56 	   double aepsco,double aepsge,double amax,SISLIntcurve *pintcr,
57 	   int icur,int igraph,int *jstat)
58 #else
59 void s1501(ps1,base,norm,axisA,alpha,ratio,idim,aepsco,aepsge,amax,pintcr,
60            icur,igraph,jstat)
61      SISLSurf     *ps1;
62      double   *base;
63      double   *norm;
64      double   *axisA;
65      double   alpha;
66      double   ratio;
67      int      idim;
68      double   aepsco;
69      double   aepsge;
70      double   amax;
71      SISLIntcurve *pintcr;
72      int      icur;
73      int      igraph;
74      int      *jstat;
75 #endif
76 /*
77 *********************************************************************
78 *
79 *********************************************************************
80 *
81 * PURPOSE    : To march an intersection curve desribed by parameter pairs
82 *              in an intersection curve object, a B-spline surface and
83 *              an elliptic cone.
84 *
85 *
86 * INPUT      : ps1    - Pointer to surface.
87 *              base   - Base point of cone
88 *              norm   - Direction of cone axis
89 *              axisA  - One of the two ellipse axis vectors
90 *              alpha  - The opening angle of the cone at axisA
91 *              ratio  - The ratio of axisA to axisB
92 *              idim   - Dimension of the space in which the plane lies.
93 *              aepsco - Computational resolution.
94 *              aepsge - Geometry resolution.
95 *              amax   - Maximal allowed step length. If amax <=aepsge
96 *                       amax is neglected.
97 *              icur   - Indicator telling if a 3-D curve is to be made
98 *                        0 - Don't make 3-D curve
99 *                        1 - Make 3-D curve
100 *                        2 - Make 3-D curve and curves in parameter plane
101 *              igraph - Indicator telling if the curve is to be output
102 *                       through function calls:
103 *                        0 - don't output curve through function call
104 *                        1 - output as straight line segments through
105 *                            s6move and s6line.
106 *
107 *
108 *
109 * INPUT/OUTPUT:pintcr - The intersection curve. When coming as input
110 *                       only parameter values in the parameter plane
111 *                       exist. When coming as output the 3-D geometry
112 *                       and possibly the curve in the parameter plane
113 *                       of the surface are added.
114 *
115 * OUTPUT:      jstat  - status messages
116 *                         = 3      : Iteration stopped due to singular
117 *                                    point or degenerate surface. A part
118 *                                    of intersection curve may have been
119 *                                    traced out. If no curve is traced out
120 *                                    the curve pointers in the Intcurve
121 *                                    object point to SISL_NULL.
122 *                         = 0      : ok
123 *                         < 0      : error
124 *                         = -185   : No points produced on intersection curve.
125 *
126 *
127 * METHOD     : An implicit description of the cone is made and then
128 *              a routine for intersecting implicit represented geometry
129 *              by a B-spline surface is used.
130 *
131 * REFERENCES :
132 *
133 *-
134 * CALLS      : s6err, s1313, s1500
135 * WRITTEN BY : Mike Floater, SI, Oslo, Norway, 22 Oct, 1988
136 *
137 *********************************************************************
138 */
139 {
140   int kpos=0;         /* Position of error                                  */
141   int kdeg=2;         /* The degree of the implicit equation of the plane   */
142   int knumb=1;        /* Number of implicit representations to be made      */
143   int kstat;          /* Local status variable                              */
144   double simpli[16];  /* Array containing the implicit description of sphere*/
145 
146   if (idim != 3) goto err104;
147 
148   /* Make description of cone */
149 
150   s1500(base,norm,axisA,alpha,ratio,idim,knumb,simpli,&kstat);
151   if (kstat < 0) goto error;
152 
153   /* Make intersection of implicit surface and B-spline surface */
154 
155   s1313(ps1,simpli,kdeg,aepsco,aepsge,amax,pintcr,icur,igraph,&kstat);
156   if (kstat == -185) goto err185;
157   if (kstat < 0) goto error;
158 
159   *jstat = kstat;
160   goto out;
161   /* Dimension not 3 */
162 
163  err104:
164   *jstat = -104;
165   s6err("s1501",*jstat,kpos);
166   goto out;
167 
168   /* Couldn't march */
169 
170  err185:
171   *jstat = -185;
172   goto out;
173 
174   /* Error in lower level routine.  */
175 
176   error:
177   *jstat = kstat;
178   s6err("s1501",*jstat,kpos);
179   goto out;
180 
181  out:
182   return;
183 }
184