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: s1988.c,v 1.2 2001-03-19 15:58:58 afr Exp $
45 *
46 */
47
48
49 #define S1988
50
51 #include "sislP.h"
52
53
54 #if defined(SISLNEEDPROTOTYPES)
s1988(SISLCurve * pc,double ** emax,double ** emin,int * jstat)55 void s1988(SISLCurve *pc,double **emax,double **emin,int *jstat)
56 #else
57 void s1988(pc,emax,emin,jstat)
58 SISLCurve *pc;
59 double **emax;
60 double **emin;
61 int *jstat;
62 #endif
63 /*
64 *********************************************************************
65 *
66 *********************************************************************
67 *
68 * PURPOSE : Find the bounding box of the SISLCurve. NB. The geometric
69 * bounding box is returned also in the rational case, that
70 * is the box in homogenous coordinates is NOT computed.
71 *
72 *
73 * INPUT : pc - SISLCurve to treat.
74 *
75 * OUTPUT : emin - Array of dimension idim containing
76 * the minimum values of the bounding box,
77 * i.e. down-left corner of the box.
78 * emax - Array of dimension idim containing
79 * the maximum values of the bounding box,
80 * i.e. top-right corner of the box.
81 * jstat - status messages
82 * > 0 : warning
83 * = 0 : ok
84 * < 0 : error
85 *
86 *
87 *
88 * METHOD :
89 *
90 *
91 * REFERENCES :
92 *
93 * CALLS :
94 *
95 * WRITTEN BY : Christophe Rene Birkeland, SINTEF Oslo, July 1993.
96 *
97 *********************************************************************
98 */
99 {
100 int i,j; /* Loop control variables */
101 int kpos = 0; /* Position of error. */
102 int bsdim;
103 int len;
104 int in = pc->in;
105 double *coeff;
106 double *minim=SISL_NULL;
107 double *maxim=SISL_NULL;
108
109 /* initialize variables */
110
111 bsdim = pc->idim;
112 coeff = pc->ecoef;
113 len = bsdim;
114
115 minim = newarray(bsdim, DOUBLE);
116 maxim = newarray(bsdim, DOUBLE);
117 if(minim == SISL_NULL || maxim == SISL_NULL) goto err101;
118
119 for(j=0; j<bsdim; j++)
120 {
121 minim[j] = coeff[j];
122 maxim[j] = coeff[j];
123 }
124 for(i=1, len=bsdim; i<in; i++, len+=bsdim)
125 for(j=0; j<bsdim; j++)
126 {
127 minim[j] = MIN(minim[j], coeff[len+j]);
128 maxim[j] = MAX(maxim[j], coeff[len+j]);
129 }
130 *emin = minim;
131 *emax = maxim;
132
133 /* Success ! */
134
135 *jstat = 0;
136 goto out;
137
138
139 /* Error in space allocation. */
140
141 err101:
142 *jstat = -101;
143 s6err("s1988",*jstat,kpos);
144 goto out;
145
146 out:
147 return;
148 }
149