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: s1858.c,v 1.2 2001-03-19 15:58:54 afr Exp $
45  *
46  */
47 
48 
49 #define S1858
50 
51 #include "sislP.h"
52 
53 #if defined(SISLNEEDPROTOTYPES)
s1858(SISLSurf * ps1,SISLCurve * pc1,double aepsco,double aepsge,int * jpt,double ** gpar1,double ** gpar2,int * jcrv,SISLIntcurve *** wcurve,int * jstat)54 void s1858(SISLSurf *ps1,SISLCurve *pc1,double aepsco,double aepsge,
55 	   int *jpt,double **gpar1,double **gpar2,int *jcrv,
56 	   SISLIntcurve ***wcurve,int *jstat)
57 #else
58 void s1858(ps1,pc1,aepsco,aepsge,jpt,gpar1,gpar2,jcrv,wcurve,jstat)
59      SISLSurf     *ps1;
60      SISLCurve    *pc1;
61      double   aepsco;
62      double   aepsge;
63      int      *jpt;
64      double   **gpar1;
65      double   **gpar2;
66      int      *jcrv;
67      SISLIntcurve ***wcurve;
68      int      *jstat;
69 #endif
70 /*
71 *********************************************************************
72 *
73 *********************************************************************
74 *
75 * PURPOSE    : Find all intersections between a B-spline surface
76 *              and a B-spline curve.
77 *
78 *
79 *
80 * INPUT      : ps1    - Pointer to the surface.
81 *              pc1    - Pointer to the curve.
82 *              aepsco - Computational resolution.
83 *              aepsge - Geometry resolution.
84 *
85 *
86 *
87 * OUTPUT     : jpt    - Number of single intersection points.
88 *              gpar1  - Array containing the parameter values of the
89 *                       single intersection points in the parameter
90 *                       interval of the first curve. The points lie
91 *                       continuous. Intersection curves are stored in wcurve.
92 *              gpar2  - Array containing the parameter values of the
93 *                       single intersection points in the parameter
94 *                       interval of the second curve.
95 *              jcrv   - Number of intersection curves.
96 *              wcurve - Array containing descriptions of the intersection
97 *                       curves. The curves are only described by points
98 *                       in the parameter plane. The curve-pointers points
99 *                       to nothing. (See description of Intcurve
100 *                       in intcurve.dcl).
101 *                       If the curves given as input are degnenerate an
102 *                       intersection point can be returned as an intersection
103 *                       curve. Use s1327 to decide if an intersection curve
104 *                       is a point on one of the curves.
105 *              jstat  - status messages
106 *                                         > 0      : warning
107 *                                         = 0      : ok
108 *                                         < 0      : error
109 *
110 *
111 * REFERENCES : Main routine written by Vibeke Skytt, SI, 1988.
112 *
113 * CALLS      : sh1858, s6err.
114 *
115 * WRITTEN BY : Christophe Rene Birkeland, SINTEF, 93-06.
116 *
117 *********************************************************************
118 */
119 {
120   int kstat = 0;           /* Local status variable.                       */
121   int kpos = 0;            /* Position of error.                           */
122   int trackflag = 0;
123   int jtrack;
124   int *pretop=SISL_NULL;
125   SISLTrack **wtrack=SISL_NULL;
126 
127   sh1858(ps1,pc1,aepsco,aepsge,trackflag,&jtrack,&wtrack,jpt,
128 	 gpar1,gpar2,&pretop,jcrv,wcurve,&kstat);
129   if(kstat < 0) goto error;
130 
131   if(pretop != SISL_NULL) freearray(pretop);
132 
133   /*
134    * Intersections found.
135    * --------------------
136    */
137 
138   *jstat = 0;
139   goto out;
140 
141   /* Error in lower level routine.  */
142 
143   error :
144     *jstat = kstat;
145     s6err("s1858",*jstat,kpos);
146     goto out;
147 
148   out:
149     return;
150 }
151