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