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: sh6gettop.c,v 1.2 2001-03-19 15:59:08 afr Exp $
45  *
46  */
47 
48 
49 #define SH6GETTOP
50 
51 #include "sislP.h"
52 
53 #if defined(SISLNEEDPROTOTYPES)
54 void
sh6gettop(SISLIntpt * pt,int ilist,int * left1,int * right1,int * left2,int * right2,int * jstat)55       sh6gettop(SISLIntpt *pt,int ilist,int *left1,int *right1,int *left2,int *right2,int *jstat)
56 #else
57 void sh6gettop(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, get 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 *
79 *
80 * OUTPUT     : pt       - Pointer to the updated Intpt.
81 *              left1    - pre-topology data.
82 *              right1   - pre-topology data.
83 *              left2    - pre-topology data.
84 *              right2   - pre-topology data.
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    if(ilist >= 0 && ilist < pt->no_of_curves)
108    {
109        *left1=pt->left_obj_1[ilist];
110        *right1=pt->right_obj_1[ilist];
111        *left2=pt->left_obj_2[ilist];
112        *right2=pt->right_obj_2[ilist];
113    }
114    else if(pt->no_of_curves == 0 && ilist == 0)
115    {
116        *left1=pt->left_obj_1[0];
117        *right1=pt->right_obj_1[0];
118        *left2=pt->left_obj_2[0];
119        *right2=pt->right_obj_2[0];
120    }
121    /* UJK */
122    else if( ilist == -1)
123    {
124        *left1=pt->left_obj_1[0];
125        *right1=pt->right_obj_1[0];
126        *left2=pt->left_obj_2[0];
127        *right2=pt->right_obj_2[0];
128    }
129    else goto err1;
130 
131 
132    /* Data is set. */
133 
134    goto out;
135 
136 
137 err1:
138    /* Error. ilist is out of range. */
139 
140    *jstat = -1;
141    s6err("sh6gettop",*jstat,0);
142    goto out;
143 
144 err2:
145    /* Error in input. pt is SISL_NULL. */
146 
147    *jstat = -2;
148    s6err("sh6gettop",*jstat,0);
149    goto out;
150 
151 
152    out :
153       return;
154 }
155