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  ~GA_RTIElementGroup() override;
64 
65  /// @{
66  /// RangeTypeInterface implementation
67  GA_RangeTypeInterface *copy() const override;
68  bool isSplittable() const override;
69  bool isEmpty() const override;
70  GA_Size getMaxEntries() const override;
71  GA_Size getEntries() const override;
72  bool split(GA_RangeTypeInterface *list[2]) const override;
73  bool isEqual(const GA_RangeTypeInterface &src) const override;
74  void iterateCopy(GA_IteratorState &dest,
75  const GA_IteratorState &src) const override;
76  bool isOrdered() const override;
77  bool areTraversalDeletionsSafe() const override;
78  bool canContainDuplicates() const override { return false; }
79  const GA_RangeMemberQuery *allocMemberQuery() const override;
80  GA_Size getPageCount() const override;
82  GA_Size, GA_Size) const override;
83  GA_Offset getFirstOffsetInPage(GA_Size) const override;
84  /// @}
85 
86  /// We partially override these iterates. We pass down to the
87  /// RTISingle for ordered groups, but unordered groups we can
88  /// do a fast path.
89 
90  /// Rewind the iterator (i.e. reset the iterator state). The start/offset
91  /// should be initialized so that they define the first contiguous "block"
92  /// for iteration. If the range is empty, @c start should be greater than
93  /// @c end
94  void iterateRewind(
95  GA_IteratorState &state,
96  GA_Offset &start, GA_Offset &end) const override;
97 
98  /// Choose the next contiguous range. If the iteration is complete,
99  /// @c start should be set to a value greater than @c end.
100  void iterateNext(
101  GA_IteratorState &state,
102  GA_Offset &start, GA_Offset &end) const override;
103 
104  /// Get a GA_RangeTypeInterface representing the remainder of the range
105  /// after iterating over part of it, as specified by state and current.
106  /// NOTE: The caller is responsible for deleting the returned
107  /// GA_RangeTypeInterface!
108  virtual GA_RangeTypeInterface *getRemainder(
109  const GA_IteratorState &state,
110  const GA_Offset current) const;
111 
112 protected:
113  /// Constructor used in splitting range
114  GA_RTIElementGroup(const GA_ElementGroup &group,
115  GA_Offset start, GA_Offset end, bool complement);
116  /// @{
117  /// RangeTypeInterface implementation
118  void singleRewind(GA_IteratorState &state) const override;
119  bool singleGet(const GA_IteratorState &state,
120  GA_Offset &value) const override;
121  void singleNext(GA_IteratorState &state) const override;
122  /// @}
123 
124  /// Move to the next span
125  void nextSpan(GA_IteratorState &state) const;
126  /// Move to the next offset in the current span
127  void incState(GA_IteratorState &state) const;
128 
129  /// Test if the group is ordered. When the range specifies the complement
130  /// of the group, there can be no order.
131  bool ordered() const
132  { return myOrder != NULL && !myComplement; }
133 
134 private:
135  const GA_ElementGroup *myGroup;
137  GA_Offset myStart, myEnd;
138  bool myComplement;
139 };
140 
141 #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:14
Abstract base class for a range membership query object.
GLuint const GLchar * name
Definition: glcorearb.h:785
GLenum src
Definition: glcorearb.h:1792
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:234
A range of elements in an index-map.
Definition: GA_Range.h:42
GA_Size GA_Offset
Definition: GA_Types.h:640
virtual bool getPageElementRange(GA_Range &range, GA_Size relative_page, GA_Size npages=1) const =0
GLuint GLuint end
Definition: glcorearb.h:474
void iterateNext(GA_IteratorState &state, GA_Offset &start, GA_Offset &end) const override
Abstract implementation of a range.
virtual void singleNext(GA_IteratorState &state) const =0
void iterateRewind(GA_IteratorState &state, GA_Offset &start, GA_Offset &end) const override
bool canContainDuplicates() const override
virtual GA_Size getPageCount() const =0
For splittable ranges, return the number of pages contained in the range.
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
GLboolean GLuint group
Definition: glew.h:2750
GLsizei const GLfloat * value
Definition: glcorearb.h:823
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