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: s6newbox.c,v 1.2 2001-03-19 15:59:02 afr Exp $
45  *
46  */
47 
48 
49 #define S6NEWBOX
50 
51 #include "sislP.h"
52 
53 #if defined(SISLNEEDPROTOTYPES)
s6newbox(SISLbox * pbox,int inum,int itype,double aepsge,int * jstat)54 void s6newbox(SISLbox *pbox,int inum,int itype,
55 	      double aepsge,int *jstat)
56 #else
57 void s6newbox(pbox,inum,itype,aepsge,jstat)
58      SISLbox *pbox;
59      int    inum;
60      int    itype;
61      double aepsge;
62      int    *jstat;
63 #endif
64 /*
65 *********************************************************************
66 *
67 *********************************************************************
68 *
69 * PURPOSE    : Create a particular box exist within an existing
70 *              box instance.
71 *
72 *
73 *
74 * INPUT      : pbox   - Box to modify.
75 *              inum   - Number of elements in min- and max-arrays.
76 *              itype  - Kind of box to create.
77 *                       = 0 : Do not expand box.
78 *                       = 1 : Make a totally expanded box.
79 *                       = 2 : Make a box expanded in the inner of the
80 *                             object, and reduced along the edges/endpoints.
81 *              aepsge - Geometry resolution.
82 *
83 * OUTPUT     :  jstat  - status messages
84 *                                         > 0      : warning
85 *                                         = 0      : ok
86 *                                         < 0      : error
87 *
88 *
89 *
90 * METHOD     :
91 *
92 *
93 * REFERENCES :
94 *
95 *-
96 * CALLS      :
97 *
98 * WRITTEN BY : Vibeke Skytt, SI, 91-01.
99 *
100 *********************************************************************
101 */
102 {
103    int knum = (inum == 1) ? inum : 2*inum;  /* If the geometry space has
104 					       dimension larger than 1,
105 					       a double set of min- and
106 					       max-arrays is to be made. */
107 
108    if (itype < 0 || itype > 2) goto err126;
109 
110    /* Test no such box exist, create the necessary arrays.  */
111 
112    if (pbox->e2min[itype] == SISL_NULL)
113    {
114       if ((pbox->e2min[itype] = newarray(knum,DOUBLE)) == SISL_NULL) goto err101;
115       if ((pbox->e2max[itype] = newarray(knum,DOUBLE)) == SISL_NULL) goto err101;
116    }
117 
118    /* Set the tolerance. */
119 
120    if (itype != 0) pbox->etol[itype] = aepsge;
121 
122    *jstat = 0;
123    goto out;
124 
125    /* Error in scratch allocation.  */
126 
127    err101 : *jstat = -101;
128    goto out;
129 
130    /* Error in input.  Kind of box do not exist.  */
131 
132    err126 : *jstat = -126;
133    goto out;
134 
135    out :
136       return;
137 }
138