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: sh6trmlist.c,v 1.2 2001-03-19 16:06:04 afr Exp $
45 *
46 */
47
48
49 #define SH6TRIMLIST
50
51 #include "sislP.h"
52
53
54 #if defined(SISLNEEDPROTOTYPES)
55 void
sh6trimlist(SISLIntpt * pt,SISLIntpt *** ptlist,int * no_of_points,int * no_alloc)56 sh6trimlist (SISLIntpt * pt, SISLIntpt *** ptlist, int *no_of_points,
57 int *no_alloc)
58 #else
59 void
60 sh6trimlist (pt, ptlist, no_of_points, no_alloc)
61 SISLIntpt *pt;
62 SISLIntpt ***ptlist;
63 int *no_of_points;
64 int *no_alloc;
65
66 #endif
67 /*
68 *********************************************************************
69 *
70 *********************************************************************
71 *
72 * PURPOSE : To find the maximal trim boundary (of coincidence)
73 * containg the given point pt.
74 *
75 *
76 * INPUT : pt - Pointer to int point to be examined
77 *
78 *
79 * INPUT/OUTP: ptlist - Pointer to an array containing
80 * pointers to all intersection points
81 * that are contigous trim neighbours.
82 * no_of_points - Number of points in ptlist array
83 * no_alloc - Allocation size of ptlist array
84 * OUTPUT :
85 * jstat - Error flag.
86 * jstat = 0 => OK.
87 * jstat = -1 => Data structure inconsistent.
88 *
89 *
90 * METHOD :
91 *
92 *
93 * REFERENCES :
94 *
95 * WRITTEN BY : Ulf J. Krystad, SI, Oslo, Norway. October 91.
96 *
97 *********************************************************************
98 */
99 {
100 int clean_up = FALSE; /* Clean up on top level */
101 int incr = 20; /* Allocation size */
102 int ki; /* Loop control */
103 /* --------------------------------------------------- */
104
105
106 /* Check if point is a TRIM point */
107 if (pt->iinter != SI_TRIM)
108 goto out;
109
110 /* Check if point is treated */
111 if (pt->marker == -90)
112 goto out;
113
114 /* Mark point as treated */
115 pt->marker = -90;
116
117
118 if (*no_alloc <= *no_of_points)
119 {
120 if (*no_alloc == 0)
121 {
122 clean_up = TRUE;
123 (*no_alloc) += incr;
124 *ptlist = newarray (*no_alloc, SISLIntpt *);
125 if (*ptlist == SISL_NULL)
126 goto out;
127 }
128 else
129 {
130 clean_up = FALSE;
131 (*no_alloc) += incr;
132 *ptlist = increasearray (*ptlist, *no_alloc, SISLIntpt *);
133 if (*ptlist == SISL_NULL)
134 goto out;
135 }
136 }
137
138 /* Fill in */
139 (*ptlist)[*no_of_points] = pt;
140 (*no_of_points)++;
141
142 /* Treat all neighbours */
143 for (ki = 0; ki < pt->no_of_curves; ki++)
144 sh6trimlist (pt->pnext[ki], ptlist, no_of_points, no_alloc);
145
146
147 /* Must unmark the points in array if no_alloc == 0 */
148 if (clean_up)
149 for (ki = 0; ki < (*no_of_points); ki++)
150 (*ptlist)[ki]->marker = 0;
151
152 goto out;
153
154
155 out:
156 return;
157 }
158