Subversion Repositories gelsvn

Rev

Rev 512 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

/*
* Written by Christian Thode Larsen 2009-2010
* Contact: thode2d@gmail.com
* Based on original work by J. Andreas Baerentzen
* Inspired by OpenMesh (www.openmesh.org)
*/

#ifndef __HMESH_CONNECTIVITY_KERNEL_H__
#define __HMESH_CONNECTIVITY_KERNEL_H__

#include <vector>
#include "ItemVector.h"
#include "Items.h"

namespace HMesh
{
        class ConnectivityKernel
        {
        public:
                VertexID add_vertex();
                FaceID add_face();
                HalfEdgeID add_halfedge();

                void remove_vertex(VertexID id);
        void remove_face(FaceID id);
        void remove_halfedge(HalfEdgeID id);

                void resize_vertices(IndexType size);
                void resize_faces(IndexType size);
                void resize_halfedges(IndexType size);

                HalfEdgeID next(HalfEdgeID id) const;
                HalfEdgeID prev(HalfEdgeID id) const;
                HalfEdgeID opp(HalfEdgeID id) const;
                HalfEdgeID out(VertexID id) const;
                HalfEdgeID last(FaceID id) const;
                VertexID vert(HalfEdgeID id) const;
                FaceID face(HalfEdgeID id) const;

                void set_next(HalfEdgeID id, HalfEdgeID next);
                void set_prev(HalfEdgeID id, HalfEdgeID prev);
                void set_opp(HalfEdgeID id, HalfEdgeID opp);
                void set_out(VertexID id, HalfEdgeID out);
                void set_last(FaceID id, HalfEdgeID last);
                void set_vert(HalfEdgeID id, VertexID vert);
                void set_face(HalfEdgeID id, FaceID face);

                IndexType no_vertices(bool active = true) const;
                IndexType no_faces(bool active = true) const;
                IndexType no_halfedges(bool active = true) const;

                bool in_use(VertexID id) const;
                bool in_use(FaceID id) const;
                bool in_use(HalfEdgeID id) const;

                VertexID vertices_next(VertexID id, bool skip = true) const;
                HalfEdgeID halfedges_next(HalfEdgeID id, bool skip = true) const;
                FaceID faces_next(FaceID id, bool skip = true) const;

                VertexID vertices_prev(VertexID id, bool skip = true) const;
                HalfEdgeID halfedges_prev(HalfEdgeID id, bool skip = true) const;
                FaceID faces_prev(FaceID id, bool skip = true) const;
                
                VertexID vertices_begin(bool skip = true) const;
        HalfEdgeID halfedges_begin(bool skip = true) const;
        FaceID faces_begin(bool skip = true) const;

        VertexID vertices_end() const;
        HalfEdgeID halfedges_end() const;
        FaceID faces_end() const;

                void cleanup();
                void clear();

        private:
                ItemVector<Vertex> vertices;
                ItemVector<Face> faces;
                ItemVector<HalfEdge> halfedges;
        };

        inline VertexID ConnectivityKernel::add_vertex()
        {
                vertices.add(Vertex());
                return VertexID(vertices.size());
        }

        inline FaceID ConnectivityKernel::add_face()
        {
                faces.add(Face());
                return FaceID(faces.size());
        }

        inline HalfEdgeID ConnectivityKernel::add_halfedge()
        {
                halfedges.add(HalfEdge());
                return HalfEdgeID(halfedges.size());
        }



        inline void ConnectivityKernel::remove_vertex(VertexID id)
        { vertices.remove(id.idx()); }

        inline void ConnectivityKernel::remove_face(FaceID id)
        { faces.remove(id.idx()); }

        inline void ConnectivityKernel::remove_halfedge(HalfEdgeID id)
        { halfedges.remove(id.idx()); }



        inline void ConnectivityKernel::resize_vertices(IndexType size)
        {  vertices.resize(size); }

        inline void ConnectivityKernel::resize_faces(IndexType size)
        {  faces.resize(size); }

        inline void ConnectivityKernel::resize_halfedges(IndexType size)
        {  halfedges.resize(size); }


        inline HalfEdgeID ConnectivityKernel::next(HalfEdgeID id) const
        { return HalfEdgeID(halfedges[id.idx()].next); }

        inline HalfEdgeID ConnectivityKernel::prev(HalfEdgeID id) const
        { return HalfEdgeID(halfedges[id.idx()].prev); }

        inline HalfEdgeID ConnectivityKernel::opp(HalfEdgeID id) const
        { return HalfEdgeID(halfedges[id.idx()].opp); }

        inline HalfEdgeID ConnectivityKernel::out(VertexID id) const
        { return HalfEdgeID(vertices[id.idx()].out); }

        inline HalfEdgeID ConnectivityKernel::last(FaceID id) const
        { return HalfEdgeID(faces[id.idx()].last); }

        inline VertexID ConnectivityKernel::vert(HalfEdgeID id) const
        { return VertexID(halfedges[id.idx()].vert); }

        inline FaceID ConnectivityKernel::face(HalfEdgeID id) const
        { return FaceID(halfedges[id.idx()].face); }

        inline void ConnectivityKernel::set_next(HalfEdgeID id, HalfEdgeID next)
        { halfedges[id.idx()].next = next; }

        inline void ConnectivityKernel::set_prev(HalfEdgeID id, HalfEdgeID prev)
        { halfedges[id.idx()].prev = prev; }

        inline void ConnectivityKernel::set_opp(HalfEdgeID id, HalfEdgeID opp)
        {halfedges[id.idx()].opp = opp; }

        inline void ConnectivityKernel::set_out(VertexID id, HalfEdgeID out)
        { vertices[id.idx()].out = out; }

        inline void ConnectivityKernel::set_last(FaceID id, HalfEdgeID last)
        { faces[id.idx()].last = last; }

        inline void ConnectivityKernel::set_vert(HalfEdgeID id, VertexID vert)
        { halfedges[id.idx()].vert = vert; }

        inline void ConnectivityKernel::set_face(HalfEdgeID id, FaceID face)
        { halfedges[id.idx()].face = face; }

        inline IndexType ConnectivityKernel::no_vertices(bool active) const
        { return vertices.size(active); }

        inline IndexType ConnectivityKernel::no_faces(bool active) const
        { return faces.size(active); }

        inline IndexType ConnectivityKernel::no_halfedges(bool active) const
        { return halfedges.size(active); }

        inline bool ConnectivityKernel::in_use(VertexID id) const
        { return vertices.in_use(id.idx()); }

        inline bool ConnectivityKernel::in_use(FaceID id) const
        { return faces.in_use(id.idx()); }

        inline bool ConnectivityKernel::in_use(HalfEdgeID id) const
        { return halfedges.in_use(id.idx()); }

        inline VertexID ConnectivityKernel::vertices_next(VertexID id, bool skip) const
        { return vertices.index_next(id.idx(), skip); }

        inline HalfEdgeID ConnectivityKernel::halfedges_next(HalfEdgeID id, bool skip) const
        { return halfedges.index_next(id.idx(), skip); }

        inline FaceID ConnectivityKernel::faces_next(FaceID id, bool skip) const
        { return faces.index_next(id.idx(), skip); }

        inline VertexID ConnectivityKernel::vertices_prev(VertexID id, bool skip) const
        { return vertices.index_prev(id.idx(), skip); }

        inline HalfEdgeID ConnectivityKernel::halfedges_prev(HalfEdgeID id, bool skip) const
        { return halfedges.index_prev(id.idx(), skip); }

        inline FaceID ConnectivityKernel::faces_prev(FaceID id, bool skip) const
        { return faces.index_prev(id.idx(), skip); }
                
        inline VertexID ConnectivityKernel::vertices_begin(bool skip) const
        { return vertices.index_begin(skip); }

    inline HalfEdgeID ConnectivityKernel::halfedges_begin(bool skip) const
        { return halfedges.index_begin(skip); }

    inline FaceID ConnectivityKernel::faces_begin(bool skip) const
        { return faces.index_begin(skip); }

    inline VertexID ConnectivityKernel::vertices_end() const
        { return vertices.index_end(); }

    inline HalfEdgeID ConnectivityKernel::halfedges_end() const
        { return halfedges.index_end(); }

    inline FaceID ConnectivityKernel::faces_end() const
        { return faces.index_end(); }

        inline void ConnectivityKernel::clear()
        {
                vertices.clear();
                faces.clear();
                halfedges.clear();
        }

        inline void ConnectivityKernel::cleanup()
        {
                vertices.cleanup();
                faces.cleanup();
                halfedges.cleanup();
        }
}

#endif

Generated by GNU Enscript 1.6.6.