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: sh6getprev.c,v 1.2 2001-03-19 15:59:07 afr Exp $
45  *
46  */
47 
48 
49 #define SH6GETPREV
50 
51 #include "sislP.h"
52 
53 #if defined(SISLNEEDPROTOTYPES)
54 int
sh6getprev(SISLIntpt * pt1,SISLIntpt * pt2)55       sh6getprev(SISLIntpt *pt1,SISLIntpt *pt2)
56 #else
57 int sh6getprev(pt1,pt2)
58    SISLIntpt *pt1;
59    SISLIntpt *pt2;
60 #endif
61 /*
62 *********************************************************************
63 *
64 *********************************************************************
65 *
66 * PURPOSE    : Given an Intpt pt1 and a pointer to another Intpt pt2,
67 *              fetch the index of the pt1 array corresponding
68 *              to pt2. If no such index exists return -1.
69 *
70 *
71 * INPUT      : pt1       - Pointer to the Intpt.
72 *              pt2     - Pointer to another Intpt.
73 *
74 *
75 *
76 * METHOD     :
77 *
78 *
79 * REFERENCES :
80 *
81 * WRITTEN BY : Michael Floater, SI, Oslo, Norway. May 91.
82 *
83 *********************************************************************
84 */
85 {
86    int       ncurv;   /* number of curves pt1 is connected to       */
87    int       index;   /* index number for pnext array              */
88 
89    index = -1;
90 
91    if(pt1 == SISL_NULL || pt2 == SISL_NULL) goto out;
92 
93    ncurv = pt1->no_of_curves;  /* note ncurv can be zero */
94 
95    index=0;
96    while(index < ncurv && pt1->pnext[index] != pt2) index++;
97    if(index == ncurv) index = -1;  /* no index found */
98 
99    goto out;
100 
101    out :
102       return index;
103 }
104