HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_RTIElementGroup.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GA_RTIElementGroup.h ( GA Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #pragma once
12 
13 #ifndef __GA_RTIElementGroup__
14 #define __GA_RTIElementGroup__
15 
16 #include "GA_API.h"
17 #include "GA_RTISingle.h"
18 #include "GA_Types.h"
19 
20 class GA_ElementGroup;
22 class GA_IndexMap;
23 class GA_IteratorState;
24 class GA_Range;
27 
28 
29 /// @brief Iterate over a group of elements
30 /// Iterate over a group of elements. If no group is specified, this is
31 /// is an empty range.
32 ///
33 /// There are some caveats when specifying the complement of a group:
34 /// - The order of elements is undefined, even if the group is ordered
35 /// - If there is no group specified, the range will be empty
36 /// The first caveate may be expected, the second may be non-intuitive.
37 ///
38 /// @see GA_RangeTypeInterface
40 {
41 public:
42  /// Construct given a group name (may be NULL)
43  ///
44  /// If @c complement is false, the range will be composed of elements in
45  /// the group. If @c complement is true, the complement of the group will
46  /// be contained in the range.
47  GA_RTIElementGroup(const GA_IndexMap &index_map,
48  const char *name,
49  bool complement,
50  bool ignore_order);
51 
52  /// Construct given an optional group (the group owner should match the
53  /// index map owner)
54  GA_RTIElementGroup(const GA_IndexMap &index_map,
55  const GA_ElementGroup *group,
56  bool complement,
57  bool ignore_order);
58 
59  /// Copy constructor
61 
62  /// Destructor
63  virtual ~GA_RTIElementGroup();
64 
65  /// @{
66  /// RangeTypeInterface implementation
67  virtual GA_RangeTypeInterface *copy() const;
68  virtual bool isSplittable() const;
69  virtual bool isEmpty() const;
70  virtual GA_Size getMaxEntries() const;
71  virtual GA_Size getEntries() const;
72  virtual bool split(GA_RangeTypeInterface *list[2]) const;
73  virtual bool isEqual(const GA_RangeTypeInterface &src) const;
74  virtual void iterateCopy(GA_IteratorState &dest,
75  const GA_IteratorState &src) const;
76  virtual bool isOrdered() const;
77  virtual bool areTraversalDeletionsSafe() const;
78  virtual bool canContainDuplicates() const { return false; }
79  virtual const GA_RangeMemberQuery *allocMemberQuery() const;
80  virtual GA_Size getPageCount() const;
81  virtual bool getPageElementRange(GA_Range &, GA_Size, GA_Size) const;
82  virtual GA_Offset getFirstOffsetInPage(GA_Size) const;
83  /// @}
84 
85  /// We partially override these iterates. We pass down to the
86  /// RTISingle for ordered groups, but unordered groups we can
87  /// do a fast path.
88 
89  /// Rewind the iterator (i.e. reset the iterator state). The start/offset
90  /// should be initialized so that they define the first contiguous "block"
91  /// for iteration. If the range is empty, @c start should be greater than
92  /// @c end
93  virtual void iterateRewind(GA_IteratorState &state,
94  GA_Offset &start, GA_Offset &end) const;
95 
96  /// Choose the next contiguous range. If the iteration is complete,
97  /// @c start should be set to a value greater than @c end.
98  virtual void iterateNext(GA_IteratorState &state,
99  GA_Offset &start, GA_Offset &end) const;
100 
101  /// Get a GA_RangeTypeInterface representing the remainder of the range
102  /// after iterating over part of it, as specified by state and current.
103  /// NOTE: The caller is responsible for deleting the returned
104  /// GA_RangeTypeInterface!
105  virtual GA_RangeTypeInterface *getRemainder(
106  const GA_IteratorState &state,
107  const GA_Offset current) const;
108 
109 protected:
110  /// Constructor used in splitting range
111  GA_RTIElementGroup(const GA_ElementGroup &group,
112  GA_Offset start, GA_Offset end, bool complement);
113  /// @{
114  /// RangeTypeInterface implementation
115  virtual void singleRewind(GA_IteratorState &state) const;
116  virtual bool singleGet(const GA_IteratorState &state,
117  GA_Offset &value) const;
118  virtual void singleNext(GA_IteratorState &state) const;
119  /// @}
120 
121  /// Move to the next span
122  void nextSpan(GA_IteratorState &state) const;
123  /// Move to the next offset in the current span
124  void incState(GA_IteratorState &state) const;
125 
126  /// Test if the group is ordered. When the range specifies the complement
127  /// of the group, there can be no order.
128  bool ordered() const
129  { return myOrder != NULL && !myComplement; }
130 
131 private:
132  const GA_ElementGroup *myGroup;
134  GA_Offset myStart, myEnd;
135  bool myComplement;
136 };
137 
138 #endif
A class to manage an ordered array which has fixed offset handles.
Definition: GA_IndexMap.h:63
virtual const GA_RangeMemberQuery * allocMemberQuery() const
virtual bool isEmpty() const =0
Check whether the range is empty.
virtual GA_RangeTypeInterface * copy() const =0
Method to create a copy of this selection.
virtual bool isSplittable() const =0
virtual bool singleGet(const GA_IteratorState &state, GA_Offset &value) const =0
virtual void iterateCopy(GA_IteratorState &dest, const GA_IteratorState &src) const =0
Copy iterator state. The dest state will not have been constructed.
int myOrder
Definition: GT_CurveEval.h:263
virtual bool split(GA_RangeTypeInterface *list[2]) const =0
GLuint start
Definition: glcorearb.h:474
Iterate over a group of elements Iterate over a group of elements. If no group is specified...
virtual bool isOrdered() const
Query if the RTI is ordered according to the index.
#define GA_API
Definition: GA_API.h:12
Abstract base class for a range membership query object.
png_uint_32 i
Definition: png.h:2877
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:211
virtual void iterateRewind(GA_IteratorState &state, GA_Offset &start, GA_Offset &end) const
A range of elements in an index-map.
Definition: GA_Range.h:42
GA_Size GA_Offset
Definition: GA_Types.h:617
virtual bool getPageElementRange(GA_Range &range, GA_Size relative_page, GA_Size npages=1) const =0
GLuint GLuint end
Definition: glcorearb.h:474
virtual void iterateNext(GA_IteratorState &state, GA_Offset &start, GA_Offset &end) const
GLuint const GLchar * name
Definition: glcorearb.h:785
Abstract implementation of a range.
virtual void singleNext(GA_IteratorState &state) const =0
virtual bool canContainDuplicates() const
virtual GA_Size getPageCount() const =0
For splittable ranges, return the number of pages contained in the range.
GLsizei const GLfloat * value
Definition: glcorearb.h:823
virtual GA_Size getMaxEntries() const =0
Get an upper bound on the size of the range.
virtual void singleRewind(GA_IteratorState &state) const =0
virtual GA_Offset getFirstOffsetInPage(GA_Size relative_page) const =0
virtual GA_Size getEntries() const =0
Base class for ranges providing consolidation to contiguous blocks.
Definition: GA_RTISingle.h:31
virtual bool areTraversalDeletionsSafe() const
virtual bool isEqual(const GA_RangeTypeInterface &src) const =0
GLenum src
Definition: glcorearb.h:1792