Subversion Repositories gelsvn

Rev

Rev 512 | Rev 518 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 512 Rev 515
Line 11... Line 11...
11
 
11
 
12
#ifndef __HMESH_CONNECTIVITY_KERNEL_H__
12
#ifndef __HMESH_CONNECTIVITY_KERNEL_H__
13
#define __HMESH_CONNECTIVITY_KERNEL_H__
13
#define __HMESH_CONNECTIVITY_KERNEL_H__
14
 
14
 
15
#include <vector>
15
#include <vector>
-
 
16
#include <map>
16
#include "ItemVector.h"
17
#include "ItemVector.h"
17
#include "Items.h"
18
#include "Items.h"
18
 
19
 
19
namespace HMesh
20
namespace HMesh
20
{
21
{
-
 
22
    typedef std::map<VertexID, VertexID> VertexIDRemap;
-
 
23
    typedef std::map<FaceID, FaceID> FaceIDRemap;
-
 
24
    typedef std::map<HalfEdgeID, HalfEdgeID> HalfEdgeIDRemap;
-
 
25
 
-
 
26
    struct IDRemap
-
 
27
    {
-
 
28
        VertexIDRemap vmap;
-
 
29
        FaceIDRemap fmap;
-
 
30
        HalfEdgeIDRemap hmap;
-
 
31
    };
-
 
32
 
21
    class ConnectivityKernel
33
    class ConnectivityKernel
22
    {
34
    {
23
    public:
35
    public:
24
        VertexID add_vertex();
36
        VertexID add_vertex();
25
        FaceID add_face();
37
        FaceID add_face();
26
        HalfEdgeID add_halfedge();
38
        HalfEdgeID add_halfedge();
27
 
39
 
-
 
40
 
28
        void remove_vertex(VertexID id);
41
        void remove_vertex(VertexID id);
29
        void remove_face(FaceID id);
42
        void remove_face(FaceID id);
30
        void remove_halfedge(HalfEdgeID id);
43
        void remove_halfedge(HalfEdgeID id);
31
 
44
 
32
        void resize_vertices(IndexType size);
45
        void resize_vertices(IndexType size);
Line 55... Line 68...
55
 
68
 
56
        bool in_use(VertexID id) const;
69
        bool in_use(VertexID id) const;
57
        bool in_use(FaceID id) const;
70
        bool in_use(FaceID id) const;
58
        bool in_use(HalfEdgeID id) const;
71
        bool in_use(HalfEdgeID id) const;
59
 
72
 
-
 
73
 
60
        VertexID vertices_next(VertexID id, bool skip = true) const;
74
        VertexID vertices_next(VertexID id, bool skip = true) const;
61
        HalfEdgeID halfedges_next(HalfEdgeID id, bool skip = true) const;
75
        HalfEdgeID halfedges_next(HalfEdgeID id, bool skip = true) const;
62
        FaceID faces_next(FaceID id, bool skip = true) const;
76
        FaceID faces_next(FaceID id, bool skip = true) const;
63
 
77
 
64
        VertexID vertices_prev(VertexID id, bool skip = true) const;
78
        VertexID vertices_prev(VertexID id, bool skip = true) const;
Line 71... Line 85...
71
 
85
 
72
        VertexID vertices_end() const;
86
        VertexID vertices_end() const;
73
        HalfEdgeID halfedges_end() const;
87
        HalfEdgeID halfedges_end() const;
74
        FaceID faces_end() const;
88
        FaceID faces_end() const;
75
 
89
 
-
 
90
        /// Clean up unused space in vectors - WARNING! Invalidates existing handles!
76
        void cleanup();
91
        void cleanup(IDRemap& map);
-
 
92
 
77
        void clear();
93
        void clear();
78
 
94
 
79
    private:
95
    private:
80
        ItemVector<Vertex> vertices;
96
        ItemVector<Vertex> vertices;
81
        ItemVector<Face> faces;
97
        ItemVector<Face> faces;
Line 100... Line 116...
100
        return HalfEdgeID(halfedges.size() - 1);
116
        return HalfEdgeID(halfedges.size() - 1);
101
    }
117
    }
102
 
118
 
103
 
119
 
104
 
120
 
-
 
121
 
105
    inline void ConnectivityKernel::remove_vertex(VertexID id)
122
    inline void ConnectivityKernel::remove_vertex(VertexID id)
106
    { vertices.remove(id.idx()); }
123
    { vertices.remove(id.index); }
107
 
124
 
108
    inline void ConnectivityKernel::remove_face(FaceID id)
125
    inline void ConnectivityKernel::remove_face(FaceID id)
109
    { faces.remove(id.idx()); }
126
    { faces.remove(id.index); }
110
 
127
 
111
    inline void ConnectivityKernel::remove_halfedge(HalfEdgeID id)
128
    inline void ConnectivityKernel::remove_halfedge(HalfEdgeID id)
112
    { halfedges.remove(id.idx()); }
129
    { halfedges.remove(id.index); }
113
 
130
 
114
 
131
 
115
 
132
 
116
    inline void ConnectivityKernel::resize_vertices(IndexType size)
133
    inline void ConnectivityKernel::resize_vertices(IndexType size)
117
    {  vertices.resize(size); }
134
    {  vertices.resize(size); }
Line 122... Line 139...
122
    inline void ConnectivityKernel::resize_halfedges(IndexType size)
139
    inline void ConnectivityKernel::resize_halfedges(IndexType size)
123
    {  halfedges.resize(size); }
140
    {  halfedges.resize(size); }
124
 
141
 
125
 
142
 
126
    inline HalfEdgeID ConnectivityKernel::next(HalfEdgeID id) const
143
    inline HalfEdgeID ConnectivityKernel::next(HalfEdgeID id) const
127
    { return HalfEdgeID(halfedges[id.idx()].next); }
144
    { return HalfEdgeID(halfedges[id.index].next); }
128
 
145
 
129
    inline HalfEdgeID ConnectivityKernel::prev(HalfEdgeID id) const
146
    inline HalfEdgeID ConnectivityKernel::prev(HalfEdgeID id) const
130
    { return HalfEdgeID(halfedges[id.idx()].prev); }
147
    { return HalfEdgeID(halfedges[id.index].prev); }
131
 
148
 
132
    inline HalfEdgeID ConnectivityKernel::opp(HalfEdgeID id) const
149
    inline HalfEdgeID ConnectivityKernel::opp(HalfEdgeID id) const
133
    { return HalfEdgeID(halfedges[id.idx()].opp); }
150
    { return HalfEdgeID(halfedges[id.index].opp); }
134
 
151
 
135
    inline HalfEdgeID ConnectivityKernel::out(VertexID id) const
152
    inline HalfEdgeID ConnectivityKernel::out(VertexID id) const
136
    { return HalfEdgeID(vertices[id.idx()].out); }
153
    { return HalfEdgeID(vertices[id.index].out); }
137
 
154
 
138
    inline HalfEdgeID ConnectivityKernel::last(FaceID id) const
155
    inline HalfEdgeID ConnectivityKernel::last(FaceID id) const
139
    { return HalfEdgeID(faces[id.idx()].last); }
156
    { return HalfEdgeID(faces[id.index].last); }
140
 
157
 
141
    inline VertexID ConnectivityKernel::vert(HalfEdgeID id) const
158
    inline VertexID ConnectivityKernel::vert(HalfEdgeID id) const
142
    { return VertexID(halfedges[id.idx()].vert); }
159
    { return VertexID(halfedges[id.index].vert); }
143
 
160
 
144
    inline FaceID ConnectivityKernel::face(HalfEdgeID id) const
161
    inline FaceID ConnectivityKernel::face(HalfEdgeID id) const
145
    { return FaceID(halfedges[id.idx()].face); }
162
    { return FaceID(halfedges[id.index].face); }
146
 
163
 
147
    inline void ConnectivityKernel::set_next(HalfEdgeID id, HalfEdgeID next)
164
    inline void ConnectivityKernel::set_next(HalfEdgeID id, HalfEdgeID next)
148
    { halfedges[id.idx()].next = next; }
165
    { halfedges[id.index].next = next; }
149
 
166
 
150
    inline void ConnectivityKernel::set_prev(HalfEdgeID id, HalfEdgeID prev)
167
    inline void ConnectivityKernel::set_prev(HalfEdgeID id, HalfEdgeID prev)
151
    { halfedges[id.idx()].prev = prev; }
168
    { halfedges[id.index].prev = prev; }
152
 
169
 
153
    inline void ConnectivityKernel::set_opp(HalfEdgeID id, HalfEdgeID opp)
170
    inline void ConnectivityKernel::set_opp(HalfEdgeID id, HalfEdgeID opp)
154
    {halfedges[id.idx()].opp = opp; }
171
    {halfedges[id.index].opp = opp; }
155
 
172
 
156
    inline void ConnectivityKernel::set_out(VertexID id, HalfEdgeID out)
173
    inline void ConnectivityKernel::set_out(VertexID id, HalfEdgeID out)
157
    { vertices[id.idx()].out = out; }
174
    { vertices[id.index].out = out; }
158
 
175
 
159
    inline void ConnectivityKernel::set_last(FaceID id, HalfEdgeID last)
176
    inline void ConnectivityKernel::set_last(FaceID id, HalfEdgeID last)
160
    { faces[id.idx()].last = last; }
177
    { faces[id.index].last = last; }
161
 
178
 
162
    inline void ConnectivityKernel::set_vert(HalfEdgeID id, VertexID vert)
179
    inline void ConnectivityKernel::set_vert(HalfEdgeID id, VertexID vert)
163
    { halfedges[id.idx()].vert = vert; }
180
    { halfedges[id.index].vert = vert; }
164
 
181
 
165
    inline void ConnectivityKernel::set_face(HalfEdgeID id, FaceID face)
182
    inline void ConnectivityKernel::set_face(HalfEdgeID id, FaceID face)
166
    { halfedges[id.idx()].face = face; }
183
    { halfedges[id.index].face = face; }
167
 
184
 
168
    inline IndexType ConnectivityKernel::no_vertices(bool active) const
185
    inline IndexType ConnectivityKernel::no_vertices(bool active) const
169
    { return vertices.size(active); }
186
    { return vertices.size(active); }
170
 
187
 
171
    inline IndexType ConnectivityKernel::no_faces(bool active) const
188
    inline IndexType ConnectivityKernel::no_faces(bool active) const
172
    { return faces.size(active); }
189
    { return faces.size(active); }
173
 
190
 
174
    inline IndexType ConnectivityKernel::no_halfedges(bool active) const
191
    inline IndexType ConnectivityKernel::no_halfedges(bool active) const
175
    { return halfedges.size(active); }
192
    { return halfedges.size(active); }
176
 
193
 
-
 
194
 
-
 
195
 
177
    inline bool ConnectivityKernel::in_use(VertexID id) const
196
    inline bool ConnectivityKernel::in_use(VertexID id) const
178
    { return vertices.in_use(id.idx()); }
197
    { return vertices.in_use(id.index); }
179
 
198
 
180
    inline bool ConnectivityKernel::in_use(FaceID id) const
199
    inline bool ConnectivityKernel::in_use(FaceID id) const
181
    { return faces.in_use(id.idx()); }
200
    { return faces.in_use(id.index); }
182
 
201
 
183
    inline bool ConnectivityKernel::in_use(HalfEdgeID id) const
202
    inline bool ConnectivityKernel::in_use(HalfEdgeID id) const
184
    { return halfedges.in_use(id.idx()); }
203
    { return halfedges.in_use(id.index); }
-
 
204
 
-
 
205
 
185
 
206
 
186
    inline VertexID ConnectivityKernel::vertices_next(VertexID id, bool skip) const
207
    inline VertexID ConnectivityKernel::vertices_next(VertexID id, bool skip) const
187
    { return vertices.index_next(id.idx(), skip); }
208
    { return vertices.index_next(id.index, skip); }
188
 
209
 
189
    inline HalfEdgeID ConnectivityKernel::halfedges_next(HalfEdgeID id, bool skip) const
210
    inline HalfEdgeID ConnectivityKernel::halfedges_next(HalfEdgeID id, bool skip) const
190
    { return halfedges.index_next(id.idx(), skip); }
211
    { return halfedges.index_next(id.index, skip); }
191
 
212
 
192
    inline FaceID ConnectivityKernel::faces_next(FaceID id, bool skip) const
213
    inline FaceID ConnectivityKernel::faces_next(FaceID id, bool skip) const
193
    { return faces.index_next(id.idx(), skip); }
214
    { return faces.index_next(id.index, skip); }
194
 
215
 
195
    inline VertexID ConnectivityKernel::vertices_prev(VertexID id, bool skip) const
216
    inline VertexID ConnectivityKernel::vertices_prev(VertexID id, bool skip) const
196
    { return vertices.index_prev(id.idx(), skip); }
217
    { return vertices.index_prev(id.index, skip); }
197
 
218
 
198
    inline HalfEdgeID ConnectivityKernel::halfedges_prev(HalfEdgeID id, bool skip) const
219
    inline HalfEdgeID ConnectivityKernel::halfedges_prev(HalfEdgeID id, bool skip) const
199
    { return halfedges.index_prev(id.idx(), skip); }
220
    { return halfedges.index_prev(id.index, skip); }
200
 
221
 
201
    inline FaceID ConnectivityKernel::faces_prev(FaceID id, bool skip) const
222
    inline FaceID ConnectivityKernel::faces_prev(FaceID id, bool skip) const
202
    { return faces.index_prev(id.idx(), skip); }
223
    { return faces.index_prev(id.index, skip); }
203
 
224
 
204
    inline VertexID ConnectivityKernel::vertices_begin(bool skip) const
225
    inline VertexID ConnectivityKernel::vertices_begin(bool skip) const
205
    { return vertices.index_begin(skip); }
226
    { return vertices.index_begin(skip); }
206
 
227
 
207
    inline HalfEdgeID ConnectivityKernel::halfedges_begin(bool skip) const
228
    inline HalfEdgeID ConnectivityKernel::halfedges_begin(bool skip) const
Line 223... Line 244...
223
    {
244
    {
224
        vertices.clear();
245
        vertices.clear();
225
        faces.clear();
246
        faces.clear();
226
        halfedges.clear();
247
        halfedges.clear();
227
    }
248
    }
228
 
-
 
229
    inline void ConnectivityKernel::cleanup()
-
 
230
    {
-
 
231
        vertices.cleanup();
-
 
232
        faces.cleanup();
-
 
233
        halfedges.cleanup();
-
 
234
    }
-
 
235
}
249
}
236
 
250
 
237
#endif
251
#endif
238
 
252