Debian Codegraph @

apps/tools/ivnorm/Edges.c++

raw symbols SCIP
1 /*
2 *
3 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27 * Mountain View, CA 94043, or:
28 *
29 * http://www.sgi.com
30 *
31 * For further information regarding this notice, see:
32 *
33 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34 *
35 */
36
37 //
38 // Code for the edges class, that supports fast querying of the faces
39 // around an edge.
40 //
41
42 #include <assert.h>
43 #include "Faces.h"cxx . . $ `<file>/apps/tools/ivnorm/Faces.h`/
44 #include "Edges.h"cxx . . $ `<file>/apps/tools/ivnorm/Edges.h`/
45
46 EdgeDictcxx . . $ EdgeDict#::EdgeDictcxx . . $ EdgeDict#EdgeDict(d4f767463ce0a6b3).(int initial_size)
47 {
48 assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(initial_size > 0);
49
50 hash_tablecxx . . $ EdgeDict#hash_table. = new Edgecxx . . $ Edge#[initial_size];
51 for (int i = 0; i < initial_size; i++)
52 {
53 hash_tablecxx . . $ EdgeDict#hash_table.[i].v1cxx . . $ Edge#v1. = hash_tablecxx . . $ EdgeDict#hash_table.[i].v2cxx . . $ Edge#v2. = (-1);
54 hash_tablecxx . . $ EdgeDict#hash_table.[i].facescxx . . $ Edge#faces..truncatecxx . . $ SbPList#truncate(d4f767463ce0a6b3).(0);
55 }
56 n_hashcxx . . $ EdgeDict#n_hash. = initial_size;
57 n_edgescxx . . $ EdgeDict#n_edges. = 0;
58 }
59
60 EdgeDictcxx . . $ EdgeDict#::~cxx . . $ EdgeDict#`~EdgeDict`(49f6e7a06ebc5aa8).EdgeDictcxx . . $ EdgeDict#()
61 {
62 delete[] hash_tablecxx . . $ EdgeDict#hash_table.;
63 }
64
65 void
66 EdgeDictcxx . . $ EdgeDict#::Addcxx . . $ EdgeDict#Add(9178463185742b1d).(Facecxx . . $ Face# *f, int32_tcxx . . $ int32_t# v1, int32_tcxx . . $ int32_t# v2)
67 {
68 if (v1 > v2) { int32_tcxx . . $ int32_t# t = v1; v1 = v2; v2 = t; }
69
70 if (v1 == v2)
71 {
72 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Warning: Degenerate edge found"
73 " (v1 = v2 = %d)\n", v1 /*, v2 */);
74 return;
75 }
76 assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(f != NULL);
77
78 Edgecxx . . $ Edge# *e = Entercxx . . $ EdgeDict#Enter(c90c583077f83658).(v1, v2);
79 assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(e != NULL);
80
81 e->facescxx . . $ Edge#faces..appendcxx . . $ FaceList#append(f7003f3e368fe0fc).(f);
82 }
83
84 void
85 EdgeDictcxx . . $ EdgeDict#::OtherFacescxx . . $ EdgeDict#OtherFaces(1a26c159804da3b).(Facecxx . . $ Face# *f, int32_tcxx . . $ int32_t# v1, int32_tcxx . . $ int32_t# v2, FaceListcxx . . $ FaceList# &result)
86 {
87 assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(f != NULL);
88
89 result.truncatecxx . . $ SbPList#truncate(d4f767463ce0a6b3).(0); // Empty list
90
91 if (v1 == v2) return; // Degenerate edge, no neighbors
92
93 Edgecxx . . $ Edge# *e = Findcxx . . $ EdgeDict#Find(c90c583077f83658).(v1, v2);
94
95 for (int i = 0; i < e->facescxx . . $ Edge#faces..getLengthcxx . . $ SbPList#getLength(455f465bc33b4cdf).(); i++)
96 {
97 if (e->facescxx . . $ Edge#faces.[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).i] != f) result.appendcxx . . $ FaceList#append(f7003f3e368fe0fc).(e->facescxx . . $ Edge#faces.[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).i]);
98 }
99 }
100
101 Edgecxx . . $ Edge# *
102 EdgeDictcxx . . $ EdgeDict#::Entercxx . . $ EdgeDict#Enter(c90c583077f83658).(int32_tcxx . . $ int32_t# v1, int32_tcxx . . $ int32_t# v2)
103 {
104 assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(v1 != v2);
105
106 int32_tcxx . . $ int32_t# t;
107 if (v1 > v2) { t = v1; v1 = v2; v2 = t; }
108
109 Edgecxx . . $ Edge# *e = Findcxx . . $ EdgeDict#Find(c90c583077f83658).(v1, v2);
110
111 if (e != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) return e;
112
113 // Create a new entry.
114 // First, see if we need to dynamically increase the hash table's
115 // size.
116 ++n_edgescxx . . $ EdgeDict#n_edges.;
117 if (n_edgescxx . . $ EdgeDict#n_edges.*2 >= n_hashcxx . . $ EdgeDict#n_hash.) ReHashcxx . . $ EdgeDict#ReHash(d4f767463ce0a6b3).(n_hashcxx . . $ EdgeDict#n_hash.*2);
118
119 //
120 // Look for an empty spot in the table
121 //
122 int hpos = HashFunccxx . . $ EdgeDict#HashFunc(9b79fb6aee4c0440).(v1, v2);
123 while (hash_tablecxx . . $ EdgeDict#hash_table.[hpos].v1cxx . . $ Edge#v1. != (-1))
124 {
125 hpos = (hpos+1) % n_hashcxx . . $ EdgeDict#n_hash.;
126 }
127
128 hash_tablecxx . . $ EdgeDict#hash_table.[hpos].v1cxx . . $ Edge#v1. = v1;
129 hash_tablecxx . . $ EdgeDict#hash_table.[hpos].v2cxx . . $ Edge#v2. = v2;
130
131 return hash_tablecxx . . $ EdgeDict#hash_table.+hpos;
132 }
133
134 //
135 // These fairly large prime numbers were picked randomly.
136 //
137 int
138 EdgeDictcxx . . $ EdgeDict#::HashFunccxx . . $ EdgeDict#HashFunc(9b79fb6aee4c0440).(int32_tcxx . . $ int32_t# v1, int32_tcxx . . $ int32_t# v2)
139 {
140 int result = (v1*1400627 + v2*79823) % n_hashcxx . . $ EdgeDict#n_hash.;
141 return (result > 0 ? result : -result);
142 }
143
144 void
145 EdgeDictcxx . . $ EdgeDict#::ReHashcxx . . $ EdgeDict#ReHash(d4f767463ce0a6b3).(int newsize)
146 {
147 int i;
148 int oldsize = n_hashcxx . . $ EdgeDict#n_hash.;
149 Edgecxx . . $ Edge# *old_table = hash_tablecxx . . $ EdgeDict#hash_table.;
150
151 hash_tablecxx . . $ EdgeDict#hash_table. = new Edgecxx . . $ Edge#[newsize];
152 for (i = 0; i < newsize; i++)
153 {
154 hash_tablecxx . . $ EdgeDict#hash_table.[i].v1cxx . . $ Edge#v1. = hash_tablecxx . . $ EdgeDict#hash_table.[i].v2cxx . . $ Edge#v2. = (-1);
155 hash_tablecxx . . $ EdgeDict#hash_table.[i].facescxx . . $ Edge#faces..truncatecxx . . $ SbPList#truncate(d4f767463ce0a6b3).(0);
156 }
157 n_hashcxx . . $ EdgeDict#n_hash. = newsize;
158
159 for (i = 0; i < oldsize; i++)
160 {
161 const Edgecxx . . $ Edge# *old = old_table+i;
162 if (old->v1cxx . . $ Edge#v1. != (-1))
163 {
164 Edgecxx . . $ Edge# *n = Entercxx . . $ EdgeDict#Enter(c90c583077f83658).(old->v1cxx . . $ Edge#v1., old->v2cxx . . $ Edge#v2.);
165 n->facescxx . . $ Edge#faces..copycxx . . $ SbPList#copy(77684fc585f5010a).(old->facescxx . . $ Edge#faces.);
166 }
167 }
168 delete[] old_table;
169 }
170
171
172 Edgecxx . . $ Edge# *
173 EdgeDictcxx . . $ EdgeDict#::Findcxx . . $ EdgeDict#Find(c90c583077f83658).(int32_tcxx . . $ int32_t# v1, int32_tcxx . . $ int32_t# v2)
174 {
175 int32_tcxx . . $ int32_t# t;
176 if (v1 > v2) { t = v1; v1 = v2; v2 = t; }
177
178 int hpos = HashFunccxx . . $ EdgeDict#HashFunc(9b79fb6aee4c0440).(v1, v2);
179
180 while (1)
181 {
182 Edgecxx . . $ Edge# *e = hash_tablecxx . . $ EdgeDict#hash_table.+hpos;
183 if (e->v1cxx . . $ Edge#v1. == (-1)) return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
184 if (e->v1cxx . . $ Edge#v1. == v1 && e->v2cxx . . $ Edge#v2. == v2) return e;
185
186 hpos = (hpos+1)%n_hashcxx . . $ EdgeDict#n_hash.; // Look in next bucket
187 }
188 }
189
190