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: sh6disconn.c,v 1.1 1994-04-21 12:10:42 boh Exp $ 45 * 46 */ 47 48 49 #define SH6DISCONNECT 50 51 #include "sislP.h" 52 53 #if defined(SISLNEEDPROTOTYPES) 54 void sh6disconnect(SISLIntpt * pt1,SISLIntpt * pt2,int * jstat)55 sh6disconnect(SISLIntpt *pt1,SISLIntpt *pt2,int *jstat) 56 #else 57 void sh6disconnect(pt1,pt2,jstat) 58 SISLIntpt *pt1; 59 SISLIntpt *pt2; 60 int *jstat; 61 #endif 62 /* 63 ********************************************************************* 64 * 65 ********************************************************************* 66 * 67 * PURPOSE : Remove the connection between pt1 and pt2 (which 68 * must be unique) if any. 69 * 70 * INPUT : pt1 - First point. 71 * pt2 - Second point. 72 * jstat - Error flag. 73 * jstat = 0 => Successful. 74 * jstat = 1 => pt1 and pt2 are not connected 75 * jstat = -1 => Error in data structure. 76 * 77 * 78 * METHOD : 79 * 80 * CALLS : s6err - Gives error message. 81 * 82 * REFERENCES : 83 * 84 * WRITTEN BY : Michael Floater, SI, Oslo, Norway. June 91. 85 * 86 ********************************************************************* 87 */ 88 { 89 int kstat; /* Local status variable. */ 90 int index1,index2; /* Indices for pt1 and pt2. */ 91 92 *jstat = 0; 93 94 95 /* Check if pt1 and pt2 are connected. */ 96 97 sh6getlist(pt1,pt2,&index1,&index2,&kstat); 98 if(kstat < 0) goto err1; 99 if(kstat == 1) 100 { 101 *jstat = 1; 102 goto out; 103 } 104 105 106 /* Disconnect. */ 107 108 pt1->no_of_curves--; 109 pt1->pnext[index1] = pt1->pnext[pt1->no_of_curves]; 110 pt1->curve_dir[index1] = pt1->curve_dir[pt1->no_of_curves]; 111 112 pt2->no_of_curves--; 113 pt2->pnext[index2] = pt2->pnext[pt2->no_of_curves]; 114 pt2->curve_dir[index2] = pt2->curve_dir[pt2->no_of_curves]; 115 116 117 goto out; 118 119 120 121 /* No connection exists. */ 122 123 err1 : *jstat = -1; 124 s6err("sh6disconnect",*jstat,0); 125 goto out; 126 127 out: ; 128 } 129