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: s1854.c,v 1.2 2001-03-19 15:58:54 afr Exp $
45  *
46  */
47 
48 
49 #define S1854
50 
51 #include "sislP.h"
52 
53 #if defined(SISLNEEDPROTOTYPES)
s1854(SISLSurf * ps1,double etop[],double eaxis[],double econe[],int idim,double aepsco,double aepsge,int * jpt,double ** gpar,int * jcrv,SISLIntcurve *** wcurve,int * jstat)54 void s1854(SISLSurf *ps1,double etop[],double eaxis[],double econe[],int idim,
55 	   double aepsco,double aepsge,
56 	   int *jpt,double **gpar,int *jcrv,SISLIntcurve ***wcurve,int *jstat)
57 #else
58 void s1854(ps1,etop,eaxis,econe,idim,aepsco,aepsge,
59 	   jpt,gpar,jcrv,wcurve,jstat)
60      SISLSurf     *ps1;
61      double   etop[];
62      double   eaxis[];
63      double   econe[];
64      int      idim;
65      double   aepsco;
66      double   aepsge;
67      int      *jpt;
68      double   **gpar;
69      int      *jcrv;
70      SISLIntcurve ***wcurve;
71      int      *jstat;
72 #endif
73 /*
74 *********************************************************************
75 *
76 *********************************************************************
77 *
78 * PURPOSE    : Find all intersections between a tensor-product surface
79 *              and a cone.
80 *
81 *
82 *
83 * INPUT      : ps1      - Pointer to surface.
84 *              etop     - Top point of the cone.
85 *              eaxis    - SISLPoint on the axis of the cone. eaxis is not
86 *                         equal to etop.
87 *              econe    - SISLPoint on the cone surface. econe is not equal
88 *                         to etop.
89 *              idim     - Dimension of the space in which the cone lies.
90 *              aepsco   - Computational resolution.
91 *              aepsge   - Geometry resolution.
92 *
93 *
94 *
95 * OUTPUT     : *jpt   - Number of single intersection points.
96 *              gpar   - Array containing the parameter values of the
97 *                       single intersection points in the parameter
98 *                       plane of the surface. The points lie continuous.
99 *                       Intersection curves are stored in wcurve.
100 *              *jcrv  - Number of intersection curves.
101 *              wcurve  - Array containing descriptions of the intersection
102 *                       curves. The curves are only described by points
103 *                       in the parameter plane. The curve-pointers points
104 *                       to nothing. (See description of Intcurve
105 *                       in intcurve.dcl).
106 *              jstat  - status messages
107 *                                         > 0      : warning
108 *                                         = 0      : ok
109 *                                         < 0      : error
110 *
111 *
112 * METHOD     : The vertices of the surface are put into the equation of
113 *              the cone achieving a surface in the one-dimentional space.
114 *              Then the zeroes of this surface is found.
115 *
116 *
117 * REFERENCES : Main routine written by Vibeke Skytt, SI, 1988.
118 *
119 * CALLS      : sh1854, s6err.
120 *
121 * WRITTEN BY : Christophe Rene Birkeland, SINTEF, 93-06.
122 *
123 *********************************************************************
124 */
125 {
126   int kstat = 0;              /* Local status variable.                      */
127   int kpos = 0;               /* Position of error.                          */
128   int i;
129   int trackflag = 0;
130   int jtrack;
131   SISLTrack **wtrack=SISL_NULL;
132   int jsurf;
133   SISLIntsurf **wsurf=SISL_NULL;
134   int *pretop=SISL_NULL;
135 
136   sh1854(ps1,etop,eaxis,econe,idim,aepsco,aepsge,trackflag,&jtrack,
137 	 &wtrack,jpt,gpar,&pretop,jcrv,wcurve,&jsurf,&wsurf,&kstat);
138   if(kstat < 0) goto error;
139 
140   if(pretop != SISL_NULL) freearray(pretop);
141 
142   for(i=0; i<jsurf; i++)
143     freeIntsurf(wsurf[i]);
144   if(wsurf != SISL_NULL) freearray(wsurf);
145 
146   if(jsurf > 0)
147     *jstat=10;
148   else
149     *jstat = 0;
150   goto out;
151 
152   /* Error in lower level routine.  */
153 
154   error:
155     *jstat = kstat;
156     s6err("s1854",*jstat,kpos);
157     goto out;
158 
159   out:
160     return;
161 }
162