Subversion Repositories gelsvn

Rev

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

Rev 630 Rev 631
Line 7... Line 7...
7
/**
7
/**
8
 * @file Manifold.h
8
 * @file Manifold.h
9
 * @brief The Manifold class is the main data structure of HMesh - the actual mesh.
9
 * @brief The Manifold class is the main data structure of HMesh - the actual mesh.
10
 */
10
 */
11
 
11
 
12
#ifndef __HMESH_MANIFOLD_H__
-
 
13
#define __HMESH_MANIFOLD_H__
12
#pragma once
14
 
13
 
15
#include <algorithm>
14
#include <algorithm>
16
#include "../CGLA/Vec3d.h"
15
#include "../CGLA/Vec3d.h"
17
 
16
 
18
#include "ConnectivityKernel.h"
17
#include "ConnectivityKernel.h"
Line 112... Line 111...
112
        /// check if ID of face is in use
111
        /// check if ID of face is in use
113
        bool in_use(FaceID id) const { return kernel.in_use(id);}
112
        bool in_use(FaceID id) const { return kernel.in_use(id);}
114
        /// check if ID of halfedge is in use
113
        /// check if ID of halfedge is in use
115
        bool in_use(HalfEdgeID id) const { return kernel.in_use(id);}
114
        bool in_use(HalfEdgeID id) const { return kernel.in_use(id);}
116
        
115
        
-
 
116
        IDIteratorPair<Vertex> vertices() const {return IDIteratorPair<Vertex>(kernel.vertices_begin(),
-
 
117
                                                                         kernel.vertices_end());}
-
 
118
        IDIteratorPair<Face> faces() const {return IDIteratorPair<Face>(kernel.faces_begin(),
-
 
119
                                                                         kernel.faces_end());}
-
 
120
        IDIteratorPair<HalfEdge> halfedges() const {return IDIteratorPair<HalfEdge>(kernel.halfedges_begin(),
-
 
121
                                                                         kernel.halfedges_end());}
-
 
122
        
117
        /// Iterator to first VertexID, optional argument defines if unused items should be skipped
123
        /// Iterator to first VertexID, optional argument defines if unused items should be skipped
118
        VertexIDIterator vertices_begin(bool skip = true) const { return kernel.vertices_begin();}
124
        VertexIDIterator vertices_begin(bool skip = true) const { return kernel.vertices_begin();}
119
        /// Iterator to first FaceID, optional argument defines if unused items should be skipped
125
        /// Iterator to first FaceID, optional argument defines if unused items should be skipped
120
        FaceIDIterator faces_begin(bool skip = true) const { return kernel.faces_begin();}
126
        FaceIDIterator faces_begin(bool skip = true) const { return kernel.faces_begin();}
121
        /// Iterator to first HalfEdgeID, optional argument defines if unused items should be skipped
127
        /// Iterator to first HalfEdgeID, optional argument defines if unused items should be skipped
Line 206... Line 212...
206
 
212
 
207
        /// Return reference to position given by VertexID
213
        /// Return reference to position given by VertexID
208
        Vec& pos(VertexID id);
214
        Vec& pos(VertexID id);
209
        /// Return const reference to position given by VertexID
215
        /// Return const reference to position given by VertexID
210
        const Vec& pos(VertexID id) const;
216
        const Vec& pos(VertexID id) const;
-
 
217
        
-
 
218
        /// Return a reference to the entire positions attribute vector
-
 
219
        VertexAttributeVector<Vec>& positions_attribute_vector();
211
 
220
 
-
 
221
        /// Return a const reference to the entire positions attribute vector
-
 
222
        const VertexAttributeVector<Vec>& positions_attribute_vector() const;
-
 
223
        
212
        /// Clear the mesh. Remove all faces, halfedges, and vertices.
224
        /// Clear the mesh. Remove all faces, halfedges, and vertices.
213
        void clear();
225
        void clear();
214
 
226
 
215
        /// Remove unused items from Mesh, map argument is to be used for attribute vector cleanups in order to maintain sync.
227
        /// Remove unused items from Mesh, map argument is to be used for attribute vector cleanups in order to maintain sync.
216
        void cleanup(IDRemap& map);
228
        void cleanup(IDRemap& map);
Line 342... Line 354...
342
 
354
 
343
    inline Manifold::Vec& Manifold::pos(VertexID id)
355
    inline Manifold::Vec& Manifold::pos(VertexID id)
344
    { return positions[id]; }
356
    { return positions[id]; }
345
    inline const Manifold::Vec& Manifold::pos(VertexID id) const
357
    inline const Manifold::Vec& Manifold::pos(VertexID id) const
346
    { return positions[id]; }
358
    { return positions[id]; }
-
 
359
    
-
 
360
    inline VertexAttributeVector<Manifold::Vec>& Manifold::positions_attribute_vector()
-
 
361
    {
-
 
362
        return positions;
-
 
363
    }
347
 
364
    
-
 
365
    inline const VertexAttributeVector<Manifold::Vec>& Manifold::positions_attribute_vector() const
-
 
366
    {
-
 
367
        return positions;    
-
 
368
    }
348
 
369
 
349
    inline void Manifold::clear()
370
    inline void Manifold::clear()
350
    { 
371
    { 
351
        kernel.clear();
372
        kernel.clear();
352
        positions.clear();
373
        positions.clear();
Line 369... Line 390...
369
    inline void Manifold::cleanup()
390
    inline void Manifold::cleanup()
370
    {
391
    {
371
        IDRemap map;
392
        IDRemap map;
372
        Manifold::cleanup(map);
393
        Manifold::cleanup(map);
373
    }
394
    }
-
 
395
    
-
 
396
    inline void circulate_vertex_ccw(const Manifold& m, VertexID v, std::function<void(Walker&)> f)
-
 
397
    {
-
 
398
        for(Walker w = m.walker(v); !w.full_circle(); w = w.circulate_vertex_ccw())
-
 
399
            f(w);
-
 
400
    }
-
 
401
    inline void circulate_vertex_ccw(const Manifold& m, VertexID v, std::function<void(VertexID)> f)
-
 
402
    {
-
 
403
        circulate_vertex_ccw(m, v, [&](Walker& w){f(w.vertex());});
-
 
404
    }
-
 
405
    inline void circulate_vertex_ccw(const Manifold& m, VertexID v, std::function<void(FaceID)> f)
-
 
406
    {
-
 
407
        circulate_vertex_ccw(m, v, [&](Walker& w){f(w.face());});
-
 
408
    }
-
 
409
    inline void circulate_vertex_ccw(const Manifold& m, VertexID v, std::function<void(HalfEdgeID)> f)
-
 
410
    {
-
 
411
        circulate_vertex_ccw(m, v, [&](Walker& w){f(w.halfedge());});
-
 
412
    }
-
 
413
    
-
 
414
    inline void circulate_vertex_cw(const Manifold& m, VertexID v, std::function<void(Walker&)> f)
-
 
415
    {
-
 
416
        for(Walker w = m.walker(v); !w.full_circle(); w = w.circulate_vertex_cw())
-
 
417
            f(w);
-
 
418
    }
-
 
419
    inline void circulate_vertex_cw(const Manifold& m, VertexID v, std::function<void(VertexID)> f)
-
 
420
    {
-
 
421
        circulate_vertex_cw(m, v, [&](Walker& w){f(w.vertex());});
-
 
422
    }
-
 
423
    inline void circulate_vertex_cw(const Manifold& m, VertexID v, std::function<void(FaceID)> f)
-
 
424
    {
-
 
425
        circulate_vertex_cw(m, v, [&](Walker& w){f(w.face());});
-
 
426
    }
-
 
427
    inline void circulate_vertex_cw(const Manifold& m, VertexID v, std::function<void(HalfEdgeID)> f)
-
 
428
    {
-
 
429
        circulate_vertex_cw(m, v, [&](Walker& w){f(w.halfedge());});
-
 
430
    }
-
 
431
    
-
 
432
    inline void circulate_face_ccw(const Manifold& m, FaceID f, std::function<void(Walker&)> g)
-
 
433
    {
-
 
434
        for(Walker w = m.walker(f); !w.full_circle(); w = w.circulate_face_ccw())
-
 
435
            g(w);
-
 
436
    }
-
 
437
    inline void circulate_face_ccw(const Manifold& m, FaceID f, std::function<void(VertexID)> g)
-
 
438
    {
-
 
439
        circulate_face_ccw(m, f, [&](Walker& w){g(w.vertex());});
-
 
440
    }
-
 
441
    inline void circulate_face_ccw(const Manifold& m, FaceID f, std::function<void(FaceID)> g)
-
 
442
    {
-
 
443
        circulate_face_ccw(m, f, [&](Walker& w){g(w.face());});
-
 
444
    }
-
 
445
    inline void circulate_face_ccw(const Manifold& m, FaceID f, std::function<void(HalfEdgeID)> g)
-
 
446
    {
-
 
447
        circulate_face_ccw(m, f, [&](Walker& w){g(w.halfedge());});
-
 
448
    }
-
 
449
    
-
 
450
    inline void circulate_face_cw(const Manifold& m, FaceID f, std::function<void(Walker&)> g)
-
 
451
    {
-
 
452
        for(Walker w = m.walker(f); !w.full_circle(); w = w.circulate_face_cw())
-
 
453
            g(w);
-
 
454
    }
-
 
455
    inline void circulate_face_cw(const Manifold& m, FaceID f, std::function<void(VertexID)> g)
-
 
456
    {
-
 
457
        circulate_face_cw(m, f, [&](Walker& w){g(w.vertex());});
-
 
458
    }
-
 
459
    inline void circulate_face_cw(const Manifold& m, FaceID f, std::function<void(FaceID)> g)
-
 
460
    {
-
 
461
        circulate_face_cw(m, f, [&](Walker& w){g(w.face());});
-
 
462
    }
-
 
463
    inline void circulate_face_cw(const Manifold& m, FaceID f, std::function<void(HalfEdgeID)> g)
-
 
464
    {
-
 
465
        circulate_face_cw(m, f, [&](Walker& w){g(w.halfedge());});
374
}
466
    }
375
 
467
    
376
 
468
 
377
#endif
-
 
378
 
469
}
-
 
470