Subversion Repositories gelsvn

Rev

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

Rev 519 Rev 520
Line 20... Line 20...
20
{
20
{
21
    template<typename ITEM, typename ITEMID>
21
    template<typename ITEM, typename ITEMID>
22
    class AttributeVector
22
    class AttributeVector
23
    {
23
    {
24
    public:
24
    public:
-
 
25
        /// Construct from optional size and item (size should be identical to number of entities in associated container
25
        AttributeVector(size_t _size = 0, ITEM item = ITEM());
26
        AttributeVector(size_t _size = 0, ITEM item = ITEM());
26
 
27
 
-
 
28
        /// Add an item (possibly not necessary
27
        ITEMID add(const ITEM& item);
29
       // ITEMID add(const ITEM& item);
28
 
30
 
29
        // just returning should be ok; manifold and attribs should always be in sync.
-
 
30
        // const context means manifold and attribs should be const, hence in sync.
31
        /// const reference to item given by ID
31
        const ITEM& get(ITEMID id) const;
32
        const ITEM& get(ITEMID id) const;
-
 
33
 
-
 
34
        /// reference to item given by ID
32
        ITEM& get(ITEMID id);
35
        ITEM& get(ITEMID id);
33
 
36
 
-
 
37
        /// const reference to item given by ID
34
        const ITEM& operator [](ITEMID id) const;
38
        const ITEM& operator [](ITEMID id) const;
-
 
39
 
-
 
40
        /// reference to item given by ID
35
        ITEM& operator [](ITEMID id);
41
        ITEM& operator [](ITEMID id);
36
 
42
 
-
 
43
        /// resize the vector (may be necessary if associated container size grows
37
        void resize(size_t _size, ITEM item = ITEM());
44
        void resize(size_t _size, ITEM item = ITEM());
38
 
45
 
-
 
46
        /// number of attribute items in vector
39
        size_t size() const;
47
        size_t size() const;
40
 
48
 
-
 
49
        /// clear the vector
41
        void clear();
50
        void clear();
42
 
51
 
-
 
52
        /// clenup unused items from the vector, given by remap from associated container
43
        void cleanup(const std::map<ITEMID, ITEMID>& map);
53
        void cleanup(const std::map<ITEMID, ITEMID>& map);
44
 
54
 
45
    private:
55
    private:
46
        std::vector<ITEM> items;
56
        std::vector<ITEM> items;
47
    };
57
    };
Line 102... Line 112...
102
 
112
 
103
    template<typename ITEM, typename ITEMID>
113
    template<typename ITEM, typename ITEMID>
104
    inline size_t AttributeVector<ITEM, ITEMID>::size() const
114
    inline size_t AttributeVector<ITEM, ITEMID>::size() const
105
    { return items.size(); }
115
    { return items.size(); }
106
 
116
 
107
    template<typename ITEM, typename ITEMID>
117
    //template<typename ITEM, typename ITEMID>
108
    inline ITEMID AttributeVector<ITEM, ITEMID>::add(const ITEM& item)
118
   // inline ITEMID AttributeVector<ITEM, ITEMID>::add(const ITEM& item)
109
    { items.push_back(item); return items.size() - 1; }
119
    //{ items.push_back(item); return items.size() - 1; }
110
 
120
 
-
 
121
    // just returning should be ok; manifold and attribs should always be in sync.
-
 
122
    // const context means manifold and attribs should be const, hence in sync.
111
    template<typename ITEM, typename ITEMID>
123
    template<typename ITEM, typename ITEMID>
112
    inline const ITEM& AttributeVector<ITEM, ITEMID>::get(ITEMID id) const
124
    inline const ITEM& AttributeVector<ITEM, ITEMID>::get(ITEMID id) const
113
    { 
125
    { 
114
        assert(id.index < items.size());
126
        assert(id.index < items.size());
115
        return items[id.index]; 
127
        return items[id.index];