512 |
s042372 |
1 |
/* ----------------------------------------------------------------------- *
|
|
|
2 |
* This file is part of GEL, www.imm.dtu.dk/GEL
|
|
|
3 |
* Copyright (C) the authors (see AUTHORS.txt) and DTU Informatics
|
|
|
4 |
*
|
|
|
5 |
* Principal authors:
|
|
|
6 |
* Christian Thode Larsen (thode2d@gmail.com)
|
|
|
7 |
* J. Andreas Baerentzen (jab@imm.dtu.dk)
|
|
|
8 |
*
|
|
|
9 |
* See LICENSE.txt for licensing information
|
|
|
10 |
* ----------------------------------------------------------------------- */
|
511 |
s042372 |
11 |
|
|
|
12 |
#ifndef __HMESH_CONNECTIVITY_KERNEL_H__
|
|
|
13 |
#define __HMESH_CONNECTIVITY_KERNEL_H__
|
|
|
14 |
|
|
|
15 |
#include <vector>
|
|
|
16 |
#include "ItemVector.h"
|
|
|
17 |
#include "Items.h"
|
|
|
18 |
|
|
|
19 |
namespace HMesh
|
|
|
20 |
{
|
512 |
s042372 |
21 |
class ConnectivityKernel
|
|
|
22 |
{
|
|
|
23 |
public:
|
|
|
24 |
VertexID add_vertex();
|
|
|
25 |
FaceID add_face();
|
|
|
26 |
HalfEdgeID add_halfedge();
|
511 |
s042372 |
27 |
|
512 |
s042372 |
28 |
void remove_vertex(VertexID id);
|
511 |
s042372 |
29 |
void remove_face(FaceID id);
|
|
|
30 |
void remove_halfedge(HalfEdgeID id);
|
|
|
31 |
|
512 |
s042372 |
32 |
void resize_vertices(IndexType size);
|
|
|
33 |
void resize_faces(IndexType size);
|
|
|
34 |
void resize_halfedges(IndexType size);
|
511 |
s042372 |
35 |
|
512 |
s042372 |
36 |
HalfEdgeID next(HalfEdgeID id) const;
|
|
|
37 |
HalfEdgeID prev(HalfEdgeID id) const;
|
|
|
38 |
HalfEdgeID opp(HalfEdgeID id) const;
|
|
|
39 |
HalfEdgeID out(VertexID id) const;
|
|
|
40 |
HalfEdgeID last(FaceID id) const;
|
|
|
41 |
VertexID vert(HalfEdgeID id) const;
|
|
|
42 |
FaceID face(HalfEdgeID id) const;
|
511 |
s042372 |
43 |
|
512 |
s042372 |
44 |
void set_next(HalfEdgeID id, HalfEdgeID next);
|
|
|
45 |
void set_prev(HalfEdgeID id, HalfEdgeID prev);
|
|
|
46 |
void set_opp(HalfEdgeID id, HalfEdgeID opp);
|
|
|
47 |
void set_out(VertexID id, HalfEdgeID out);
|
|
|
48 |
void set_last(FaceID id, HalfEdgeID last);
|
|
|
49 |
void set_vert(HalfEdgeID id, VertexID vert);
|
|
|
50 |
void set_face(HalfEdgeID id, FaceID face);
|
511 |
s042372 |
51 |
|
512 |
s042372 |
52 |
IndexType no_vertices(bool active = true) const;
|
|
|
53 |
IndexType no_faces(bool active = true) const;
|
|
|
54 |
IndexType no_halfedges(bool active = true) const;
|
511 |
s042372 |
55 |
|
512 |
s042372 |
56 |
bool in_use(VertexID id) const;
|
|
|
57 |
bool in_use(FaceID id) const;
|
|
|
58 |
bool in_use(HalfEdgeID id) const;
|
511 |
s042372 |
59 |
|
512 |
s042372 |
60 |
VertexID vertices_next(VertexID id, bool skip = true) const;
|
|
|
61 |
HalfEdgeID halfedges_next(HalfEdgeID id, bool skip = true) const;
|
|
|
62 |
FaceID faces_next(FaceID id, bool skip = true) const;
|
511 |
s042372 |
63 |
|
512 |
s042372 |
64 |
VertexID vertices_prev(VertexID id, bool skip = true) const;
|
|
|
65 |
HalfEdgeID halfedges_prev(HalfEdgeID id, bool skip = true) const;
|
|
|
66 |
FaceID faces_prev(FaceID id, bool skip = true) const;
|
|
|
67 |
|
|
|
68 |
VertexID vertices_begin(bool skip = true) const;
|
511 |
s042372 |
69 |
HalfEdgeID halfedges_begin(bool skip = true) const;
|
|
|
70 |
FaceID faces_begin(bool skip = true) const;
|
|
|
71 |
|
|
|
72 |
VertexID vertices_end() const;
|
|
|
73 |
HalfEdgeID halfedges_end() const;
|
|
|
74 |
FaceID faces_end() const;
|
|
|
75 |
|
512 |
s042372 |
76 |
void cleanup();
|
|
|
77 |
void clear();
|
511 |
s042372 |
78 |
|
512 |
s042372 |
79 |
private:
|
|
|
80 |
ItemVector<Vertex> vertices;
|
|
|
81 |
ItemVector<Face> faces;
|
|
|
82 |
ItemVector<HalfEdge> halfedges;
|
|
|
83 |
};
|
511 |
s042372 |
84 |
|
512 |
s042372 |
85 |
inline VertexID ConnectivityKernel::add_vertex()
|
|
|
86 |
{
|
|
|
87 |
vertices.add(Vertex());
|
|
|
88 |
return VertexID(vertices.size() - 1);
|
|
|
89 |
}
|
511 |
s042372 |
90 |
|
512 |
s042372 |
91 |
inline FaceID ConnectivityKernel::add_face()
|
|
|
92 |
{
|
|
|
93 |
faces.add(Face());
|
|
|
94 |
return FaceID(faces.size() - 1);
|
|
|
95 |
}
|
511 |
s042372 |
96 |
|
512 |
s042372 |
97 |
inline HalfEdgeID ConnectivityKernel::add_halfedge()
|
|
|
98 |
{
|
|
|
99 |
halfedges.add(HalfEdge());
|
|
|
100 |
return HalfEdgeID(halfedges.size() - 1);
|
|
|
101 |
}
|
511 |
s042372 |
102 |
|
|
|
103 |
|
|
|
104 |
|
512 |
s042372 |
105 |
inline void ConnectivityKernel::remove_vertex(VertexID id)
|
|
|
106 |
{ vertices.remove(id.idx()); }
|
511 |
s042372 |
107 |
|
512 |
s042372 |
108 |
inline void ConnectivityKernel::remove_face(FaceID id)
|
|
|
109 |
{ faces.remove(id.idx()); }
|
511 |
s042372 |
110 |
|
512 |
s042372 |
111 |
inline void ConnectivityKernel::remove_halfedge(HalfEdgeID id)
|
|
|
112 |
{ halfedges.remove(id.idx()); }
|
511 |
s042372 |
113 |
|
|
|
114 |
|
|
|
115 |
|
512 |
s042372 |
116 |
inline void ConnectivityKernel::resize_vertices(IndexType size)
|
|
|
117 |
{ vertices.resize(size); }
|
511 |
s042372 |
118 |
|
512 |
s042372 |
119 |
inline void ConnectivityKernel::resize_faces(IndexType size)
|
|
|
120 |
{ faces.resize(size); }
|
511 |
s042372 |
121 |
|
512 |
s042372 |
122 |
inline void ConnectivityKernel::resize_halfedges(IndexType size)
|
|
|
123 |
{ halfedges.resize(size); }
|
511 |
s042372 |
124 |
|
|
|
125 |
|
512 |
s042372 |
126 |
inline HalfEdgeID ConnectivityKernel::next(HalfEdgeID id) const
|
|
|
127 |
{ return HalfEdgeID(halfedges[id.idx()].next); }
|
511 |
s042372 |
128 |
|
512 |
s042372 |
129 |
inline HalfEdgeID ConnectivityKernel::prev(HalfEdgeID id) const
|
|
|
130 |
{ return HalfEdgeID(halfedges[id.idx()].prev); }
|
511 |
s042372 |
131 |
|
512 |
s042372 |
132 |
inline HalfEdgeID ConnectivityKernel::opp(HalfEdgeID id) const
|
|
|
133 |
{ return HalfEdgeID(halfedges[id.idx()].opp); }
|
511 |
s042372 |
134 |
|
512 |
s042372 |
135 |
inline HalfEdgeID ConnectivityKernel::out(VertexID id) const
|
|
|
136 |
{ return HalfEdgeID(vertices[id.idx()].out); }
|
511 |
s042372 |
137 |
|
512 |
s042372 |
138 |
inline HalfEdgeID ConnectivityKernel::last(FaceID id) const
|
|
|
139 |
{ return HalfEdgeID(faces[id.idx()].last); }
|
511 |
s042372 |
140 |
|
512 |
s042372 |
141 |
inline VertexID ConnectivityKernel::vert(HalfEdgeID id) const
|
|
|
142 |
{ return VertexID(halfedges[id.idx()].vert); }
|
511 |
s042372 |
143 |
|
512 |
s042372 |
144 |
inline FaceID ConnectivityKernel::face(HalfEdgeID id) const
|
|
|
145 |
{ return FaceID(halfedges[id.idx()].face); }
|
511 |
s042372 |
146 |
|
512 |
s042372 |
147 |
inline void ConnectivityKernel::set_next(HalfEdgeID id, HalfEdgeID next)
|
|
|
148 |
{ halfedges[id.idx()].next = next; }
|
511 |
s042372 |
149 |
|
512 |
s042372 |
150 |
inline void ConnectivityKernel::set_prev(HalfEdgeID id, HalfEdgeID prev)
|
|
|
151 |
{ halfedges[id.idx()].prev = prev; }
|
511 |
s042372 |
152 |
|
512 |
s042372 |
153 |
inline void ConnectivityKernel::set_opp(HalfEdgeID id, HalfEdgeID opp)
|
|
|
154 |
{halfedges[id.idx()].opp = opp; }
|
511 |
s042372 |
155 |
|
512 |
s042372 |
156 |
inline void ConnectivityKernel::set_out(VertexID id, HalfEdgeID out)
|
|
|
157 |
{ vertices[id.idx()].out = out; }
|
511 |
s042372 |
158 |
|
512 |
s042372 |
159 |
inline void ConnectivityKernel::set_last(FaceID id, HalfEdgeID last)
|
|
|
160 |
{ faces[id.idx()].last = last; }
|
511 |
s042372 |
161 |
|
512 |
s042372 |
162 |
inline void ConnectivityKernel::set_vert(HalfEdgeID id, VertexID vert)
|
|
|
163 |
{ halfedges[id.idx()].vert = vert; }
|
511 |
s042372 |
164 |
|
512 |
s042372 |
165 |
inline void ConnectivityKernel::set_face(HalfEdgeID id, FaceID face)
|
|
|
166 |
{ halfedges[id.idx()].face = face; }
|
511 |
s042372 |
167 |
|
512 |
s042372 |
168 |
inline IndexType ConnectivityKernel::no_vertices(bool active) const
|
|
|
169 |
{ return vertices.size(active); }
|
511 |
s042372 |
170 |
|
512 |
s042372 |
171 |
inline IndexType ConnectivityKernel::no_faces(bool active) const
|
|
|
172 |
{ return faces.size(active); }
|
511 |
s042372 |
173 |
|
512 |
s042372 |
174 |
inline IndexType ConnectivityKernel::no_halfedges(bool active) const
|
|
|
175 |
{ return halfedges.size(active); }
|
511 |
s042372 |
176 |
|
512 |
s042372 |
177 |
inline bool ConnectivityKernel::in_use(VertexID id) const
|
|
|
178 |
{ return vertices.in_use(id.idx()); }
|
511 |
s042372 |
179 |
|
512 |
s042372 |
180 |
inline bool ConnectivityKernel::in_use(FaceID id) const
|
|
|
181 |
{ return faces.in_use(id.idx()); }
|
511 |
s042372 |
182 |
|
512 |
s042372 |
183 |
inline bool ConnectivityKernel::in_use(HalfEdgeID id) const
|
|
|
184 |
{ return halfedges.in_use(id.idx()); }
|
511 |
s042372 |
185 |
|
512 |
s042372 |
186 |
inline VertexID ConnectivityKernel::vertices_next(VertexID id, bool skip) const
|
|
|
187 |
{ return vertices.index_next(id.idx(), skip); }
|
511 |
s042372 |
188 |
|
512 |
s042372 |
189 |
inline HalfEdgeID ConnectivityKernel::halfedges_next(HalfEdgeID id, bool skip) const
|
|
|
190 |
{ return halfedges.index_next(id.idx(), skip); }
|
511 |
s042372 |
191 |
|
512 |
s042372 |
192 |
inline FaceID ConnectivityKernel::faces_next(FaceID id, bool skip) const
|
|
|
193 |
{ return faces.index_next(id.idx(), skip); }
|
511 |
s042372 |
194 |
|
512 |
s042372 |
195 |
inline VertexID ConnectivityKernel::vertices_prev(VertexID id, bool skip) const
|
|
|
196 |
{ return vertices.index_prev(id.idx(), skip); }
|
511 |
s042372 |
197 |
|
512 |
s042372 |
198 |
inline HalfEdgeID ConnectivityKernel::halfedges_prev(HalfEdgeID id, bool skip) const
|
|
|
199 |
{ return halfedges.index_prev(id.idx(), skip); }
|
511 |
s042372 |
200 |
|
512 |
s042372 |
201 |
inline FaceID ConnectivityKernel::faces_prev(FaceID id, bool skip) const
|
|
|
202 |
{ return faces.index_prev(id.idx(), skip); }
|
511 |
s042372 |
203 |
|
512 |
s042372 |
204 |
inline VertexID ConnectivityKernel::vertices_begin(bool skip) const
|
|
|
205 |
{ return vertices.index_begin(skip); }
|
|
|
206 |
|
511 |
s042372 |
207 |
inline HalfEdgeID ConnectivityKernel::halfedges_begin(bool skip) const
|
512 |
s042372 |
208 |
{ return halfedges.index_begin(skip); }
|
511 |
s042372 |
209 |
|
|
|
210 |
inline FaceID ConnectivityKernel::faces_begin(bool skip) const
|
512 |
s042372 |
211 |
{ return faces.index_begin(skip); }
|
511 |
s042372 |
212 |
|
|
|
213 |
inline VertexID ConnectivityKernel::vertices_end() const
|
512 |
s042372 |
214 |
{ return vertices.index_end(); }
|
511 |
s042372 |
215 |
|
|
|
216 |
inline HalfEdgeID ConnectivityKernel::halfedges_end() const
|
512 |
s042372 |
217 |
{ return halfedges.index_end(); }
|
511 |
s042372 |
218 |
|
|
|
219 |
inline FaceID ConnectivityKernel::faces_end() const
|
512 |
s042372 |
220 |
{ return faces.index_end(); }
|
511 |
s042372 |
221 |
|
512 |
s042372 |
222 |
inline void ConnectivityKernel::clear()
|
|
|
223 |
{
|
|
|
224 |
vertices.clear();
|
|
|
225 |
faces.clear();
|
|
|
226 |
halfedges.clear();
|
|
|
227 |
}
|
511 |
s042372 |
228 |
|
512 |
s042372 |
229 |
inline void ConnectivityKernel::cleanup()
|
|
|
230 |
{
|
|
|
231 |
vertices.cleanup();
|
|
|
232 |
faces.cleanup();
|
|
|
233 |
halfedges.cleanup();
|
|
|
234 |
}
|
511 |
s042372 |
235 |
}
|
|
|
236 |
|
|
|
237 |
#endif
|