1 /*
2 * l_vertices.cc
3 * AYM 1998-11-22
4 */
5
6
7 /*
8 This file is part of Yadex.
9
10 Yadex incorporates code from DEU 5.21 that was put in the public domain in
11 1994 by Rapha�l Quinet and Brendon Wyber.
12
13 The rest of Yadex is Copyright � 1997-2003 Andr� Majorel and others.
14
15 This program is free software; you can redistribute it and/or modify it under
16 the terms of the GNU General Public License as published by the Free Software
17 Foundation; either version 2 of the License, or (at your option) any later
18 version.
19
20 This program is distributed in the hope that it will be useful, but WITHOUT
21 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
23
24 You should have received a copy of the GNU General Public License along with
25 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
26 Place, Suite 330, Boston, MA 02111-1307, USA.
27 */
28
29
30 #include "yadex.h"
31 #include "bitvec.h"
32 #include "l_vertices.h"
33 #include "levels.h"
34
35
36 /*
37 * bv_vertices_of_linedefs
38 * Return a bit vector of all vertices used by the linedefs.
39 * It's up to the caller to delete the bit vector after use.
40 */
bv_vertices_of_linedefs(bitvec_c * linedefs)41 bitvec_c *bv_vertices_of_linedefs (bitvec_c *linedefs)
42 {
43 bitvec_c *vertices;
44 int n;
45
46 vertices = new bitvec_c (NumVertices);
47 for (n = 0; n < NumLineDefs; n++)
48 if (linedefs->get (n))
49 {
50 vertices->set (LineDefs[n].start);
51 vertices->set (LineDefs[n].end);
52 }
53 return vertices;
54 }
55
56
57 /*
58 * bv_vertices_of_linedefs
59 * Return a bit vector of all vertices used by the linedefs.
60 * It's up to the caller to delete the bit vector after use.
61 */
bv_vertices_of_linedefs(SelPtr list)62 bitvec_c *bv_vertices_of_linedefs (SelPtr list)
63 {
64 bitvec_c *vertices;
65 SelPtr cur;
66
67 vertices = new bitvec_c (NumVertices);
68 for (cur = list; cur; cur = cur->next)
69 {
70 vertices->set (LineDefs[cur->objnum].start);
71 vertices->set (LineDefs[cur->objnum].end);
72 }
73 return vertices;
74 }
75
76
77 /*
78 * list_vertices_of_linedefs
79 * Return a list of all vertices used by the linedefs
80 * It's up to the caller to delete the list after use.
81 */
list_vertices_of_linedefs(SelPtr list)82 SelPtr list_vertices_of_linedefs (SelPtr list)
83 {
84 bitvec_c *vertices_bitvec;
85 SelPtr vertices_list = 0;
86 size_t n;
87
88 vertices_bitvec = bv_vertices_of_linedefs (list);
89 for (n = 0; n < vertices_bitvec->nelements (); n++)
90 {
91 if (vertices_bitvec->get (n))
92 SelectObject (&vertices_list, n);
93 }
94 delete vertices_bitvec;
95 return vertices_list;
96 }
97
98
99