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: sh6settop.c,v 1.2 2001-03-19 16:06:03 afr Exp $
45  *
46  */
47 
48 
49 #define SH6SETTOP
50 
51 #include "sislP.h"
52 
53 #if defined(SISLNEEDPROTOTYPES)
54 void
sh6settop(SISLIntpt * pt,int ilist,int left1,int right1,int left2,int right2,int * jstat)55       sh6settop(SISLIntpt *pt,int ilist,int left1,int right1,int left2,int right2,int *jstat)
56 #else
57 void sh6settop(pt,ilist,left1,right1,left2,right2,jstat)
58    SISLIntpt *pt;
59    int       ilist;
60    int       left1;
61    int       right1;
62    int       left2;
63    int       right2;
64    int       *jstat;
65 #endif
66 /*
67 *********************************************************************
68 *
69 *********************************************************************
70 *
71 * PURPOSE    : Given an Intpt and a list which it lies in, set the
72 *              pre-topology information. If list does not
73 *              exist give an error message.
74 *
75 *
76 * INPUT      : pt       - Pointer to the Intpt.
77 *              ilist    - Index specifying a list.
78 *              left1    - pre-topology data.
79 *              right1   - pre-topology data.
80 *              left2    - pre-topology data.
81 *              right2   - pre-topology data.
82 *
83 *
84 * OUTPUT     : pt       - Pointer to the updated Intpt.
85 *              jstat    - Error flag.
86 *                         jstat =  0  => OK.
87 *                         jstat = -1  => ilist is out of range.
88 *                         jstat = -2  => Error.
89 *
90 *
91 * METHOD     :
92 *
93 *
94 * REFERENCES :
95 *
96 * WRITTEN BY : Michael Floater, SI, Oslo, Norway. June 91.
97 *
98 *********************************************************************
99 */
100 {
101    *jstat=0;
102 
103    /* Check pt. */
104 
105    if(pt == SISL_NULL) goto err2;
106 
107    /* Check ilist. */
108 
109    if(ilist >= 0 && ilist < pt->no_of_curves)
110    {
111        pt->left_obj_1[ilist]=left1;
112        pt->right_obj_1[ilist]=right1;
113        pt->left_obj_2[ilist]=left2;
114        pt->right_obj_2[ilist]=right2;
115    }
116    else if(pt->no_of_curves == 0 && ilist == 0)
117    {
118        pt->left_obj_1[0]=left1;
119        pt->right_obj_1[0]=right1;
120        pt->left_obj_2[0]=left2;
121        pt->right_obj_2[0]=right2;
122    }
123    else if(ilist == -1)
124    {
125        pt->left_obj_1[0]=left1;
126        pt->right_obj_1[0]=right1;
127        pt->left_obj_2[0]=left2;
128        pt->right_obj_2[0]=right2;
129    }
130    else goto err1;
131 
132 
133    /* Data is set. */
134 
135    goto out;
136 
137 
138 err1:
139    /* Error. ilist is out of range. */
140 
141    *jstat = -1;
142    s6err("sh6settop",*jstat,0);
143    goto out;
144 
145 err2:
146    /* Error in input. pt is SISL_NULL. */
147 
148    *jstat = -2;
149    s6err("sh6settop",*jstat,0);
150    goto out;
151 
152 
153    out :
154       return;
155 }
156