Subversion Repositories gelsvn

Rev

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

Rev 515 Rev 518
Line 13... Line 13...
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 <map>
17
#include "ItemVector.h"
17
#include "ItemVector.h"
18
#include "Items.h"
18
#include "ItemID.h"
19
 
19
 
20
namespace HMesh
20
namespace HMesh
21
{
21
{
22
    typedef std::map<VertexID, VertexID> VertexIDRemap;
22
    typedef std::map<VertexID, VertexID> VertexIDRemap;
23
    typedef std::map<FaceID, FaceID> FaceIDRemap;
23
    typedef std::map<FaceID, FaceID> FaceIDRemap;
Line 28... Line 28...
28
        VertexIDRemap vmap;
28
        VertexIDRemap vmap;
29
        FaceIDRemap fmap;
29
        FaceIDRemap fmap;
30
        HalfEdgeIDRemap hmap;
30
        HalfEdgeIDRemap hmap;
31
    };
31
    };
32
 
32
 
-
 
33
    struct Vertex
-
 
34
    { 
-
 
35
        HalfEdgeID out; 
-
 
36
    };
-
 
37
 
-
 
38
    struct Face
-
 
39
    { 
-
 
40
        HalfEdgeID last; 
-
 
41
    };
-
 
42
 
-
 
43
    struct HalfEdge
-
 
44
    {
-
 
45
        HalfEdgeID next;
-
 
46
        HalfEdgeID prev;
-
 
47
        HalfEdgeID opp;
-
 
48
        VertexID vert;
-
 
49
        FaceID face;
-
 
50
    };
-
 
51
 
33
    class ConnectivityKernel
52
    class ConnectivityKernel
34
    {
53
    {
35
    public:
54
    public:
36
        VertexID add_vertex();
55
        VertexID add_vertex();
37
        FaceID add_face();
56
        FaceID add_face();
Line 40... Line 59...
40
 
59
 
41
        void remove_vertex(VertexID id);
60
        void remove_vertex(VertexID id);
42
        void remove_face(FaceID id);
61
        void remove_face(FaceID id);
43
        void remove_halfedge(HalfEdgeID id);
62
        void remove_halfedge(HalfEdgeID id);
44
 
63
 
45
        void resize_vertices(IndexType size);
64
        void resize_vertices(size_t size);
46
        void resize_faces(IndexType size);
65
        void resize_faces(size_t size);
47
        void resize_halfedges(IndexType size);
66
        void resize_halfedges(size_t size);
48
 
67
 
49
        HalfEdgeID next(HalfEdgeID id) const;
68
        HalfEdgeID next(HalfEdgeID id) const;
50
        HalfEdgeID prev(HalfEdgeID id) const;
69
        HalfEdgeID prev(HalfEdgeID id) const;
51
        HalfEdgeID opp(HalfEdgeID id) const;
70
        HalfEdgeID opp(HalfEdgeID id) const;
52
        HalfEdgeID out(VertexID id) const;
71
        HalfEdgeID out(VertexID id) const;
Line 60... Line 79...
60
        void set_out(VertexID id, HalfEdgeID out);
79
        void set_out(VertexID id, HalfEdgeID out);
61
        void set_last(FaceID id, HalfEdgeID last);
80
        void set_last(FaceID id, HalfEdgeID last);
62
        void set_vert(HalfEdgeID id, VertexID vert);
81
        void set_vert(HalfEdgeID id, VertexID vert);
63
        void set_face(HalfEdgeID id, FaceID face);
82
        void set_face(HalfEdgeID id, FaceID face);
64
 
83
 
65
        IndexType no_vertices(bool active = true) const;
84
        size_t no_vertices(bool active = true) const;
66
        IndexType no_faces(bool active = true) const;
85
        size_t no_faces(bool active = true) const;
67
        IndexType no_halfedges(bool active = true) const;
86
        size_t no_halfedges(bool active = true) const;
68
 
87
 
69
        bool in_use(VertexID id) const;
88
        bool in_use(VertexID id) const;
70
        bool in_use(FaceID id) const;
89
        bool in_use(FaceID id) const;
71
        bool in_use(HalfEdgeID id) const;
90
        bool in_use(HalfEdgeID id) const;
72
 
91
 
Line 128... Line 147...
128
    inline void ConnectivityKernel::remove_halfedge(HalfEdgeID id)
147
    inline void ConnectivityKernel::remove_halfedge(HalfEdgeID id)
129
    { halfedges.remove(id.index); }
148
    { halfedges.remove(id.index); }
130
 
149
 
131
 
150
 
132
 
151
 
133
    inline void ConnectivityKernel::resize_vertices(IndexType size)
152
    inline void ConnectivityKernel::resize_vertices(size_t size)
134
    {  vertices.resize(size); }
153
    {  vertices.resize(size); }
135
 
154
 
136
    inline void ConnectivityKernel::resize_faces(IndexType size)
155
    inline void ConnectivityKernel::resize_faces(size_t size)
137
    {  faces.resize(size); }
156
    {  faces.resize(size); }
138
 
157
 
139
    inline void ConnectivityKernel::resize_halfedges(IndexType size)
158
    inline void ConnectivityKernel::resize_halfedges(size_t size)
140
    {  halfedges.resize(size); }
159
    {  halfedges.resize(size); }
141
 
160
 
142
 
161
 
143
    inline HalfEdgeID ConnectivityKernel::next(HalfEdgeID id) const
162
    inline HalfEdgeID ConnectivityKernel::next(HalfEdgeID id) const
144
    { return HalfEdgeID(halfedges[id.index].next); }
163
    { return HalfEdgeID(halfedges[id.index].next); }
Line 180... Line 199...
180
    { halfedges[id.index].vert = vert; }
199
    { halfedges[id.index].vert = vert; }
181
 
200
 
182
    inline void ConnectivityKernel::set_face(HalfEdgeID id, FaceID face)
201
    inline void ConnectivityKernel::set_face(HalfEdgeID id, FaceID face)
183
    { halfedges[id.index].face = face; }
202
    { halfedges[id.index].face = face; }
184
 
203
 
185
    inline IndexType ConnectivityKernel::no_vertices(bool active) const
204
    inline size_t ConnectivityKernel::no_vertices(bool active) const
186
    { return vertices.size(active); }
205
    { return vertices.size(active); }
187
 
206
 
188
    inline IndexType ConnectivityKernel::no_faces(bool active) const
207
    inline size_t ConnectivityKernel::no_faces(bool active) const
189
    { return faces.size(active); }
208
    { return faces.size(active); }
190
 
209
 
191
    inline IndexType ConnectivityKernel::no_halfedges(bool active) const
210
    inline size_t ConnectivityKernel::no_halfedges(bool active) const
192
    { return halfedges.size(active); }
211
    { return halfedges.size(active); }
193
 
212
 
194
 
213
 
195
 
214
 
196
    inline bool ConnectivityKernel::in_use(VertexID id) const
215
    inline bool ConnectivityKernel::in_use(VertexID id) const