HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_ElementGroupOrder.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_ElementGroupOrder.h ( GA Library, C++)
7  *
8  * COMMENTS: Element group order information
9  */
10 
11 #ifndef __GA_ElementGroupOrder__
12 #define __GA_ElementGroupOrder__
13 
14 #include "GA_API.h"
15 #include "GA_Types.h"
16 #include "GA_OffsetList.h"
17 
18 #include <UT/UT_Array.h>
19 #include <SYS/SYS_TypeDecorate.h>
20 
21 class GA_Attribute;
22 class GA_DataBitArray;
23 class GA_Defragment;
24 class GA_LoadMap;
25 class GA_MergeOffsetMap;
26 class GA_Range;
28 class GA_SaveMap;
30 class UT_JSONParser;
32 
33 #if defined(GA_STRICT_TYPES)
34 #include <SYS/SYS_TypeTraits.h>
35 
36 class GA_API_TMPL GA_ElementGroupOrderIndexTag {};
37 typedef GA_OrdinalType<GA_ElementGroupOrderIndexTag, GA_Size>
40 #else
42 #endif
43 
45 {
46 public:
49  const GA_ElementGroupOrder &src);
51 
52  /// Return the total number of entries, mixed or not.
53  GA_Size entries() const;
54 
55  /// Return the number of un-mixed entries.
56  /// ie. those indices available to getElement()
58  { return (entries() - mixedEntries()); }
59 
60  /// Return the number of mixed entries.
61  /// ie. those indices available to getMixed()
62  GA_Size mixedEntries() const;
63 
64  /// Will return -1 if the i'th entry is a mixed entry.
65  GA_Offset operator()(GA_ElementGroupOrderIndex i) const { return getElement(i); }
66  /// Will return -1 if the i'th entry is a mixed entry.
67  GA_Offset getElement(GA_ElementGroupOrderIndex i) const;
68 
69  /// Query the i'th entry as a mixed entry. Secondary is set to NULL when
70  /// not mixed.
71  void getMixed(GA_ElementGroupOrderIndex i,
72  GA_Offset &element,
73  const GA_SecondaryLookupInfo *&secondary) const;
74 
75  void clear();
76 
77  void swapRange(GA_Offset a, GA_Offset b, GA_Size n);
78  void moveRange(GA_Offset a, GA_Offset b, GA_Size n);
79  void defragment(const GA_Defragment &defrag);
80 
81  void append(GA_Offset element);
82  bool remove(GA_Offset element);
83  exint remove(const GA_Range &range);
84  exint remove(const GA_RangeMemberQuery &range_query);
85 
86  void appendMix(GA_Offset element,
87  const GA_SecondaryLookupInfo *secondary);
88  bool removeMix(GA_Offset element,
89  const GA_SecondaryLookupInfo *secondary);
90  exint removeAll(GA_Offset element);
91  exint removeAll(const GA_RangeMemberQuery &range_query);
92  exint removeAllMix(GA_Offset element,
93  const GA_SecondaryLookupInfo *secondary_prefix,
94  const GA_RangeMemberQuery &secondary_range_query);
95 
96  bool removeIndex(GA_ElementGroupOrderIndex i);
97 
98  /// Return the index of the item passed in (or -1). This is O(N) which
99  /// easily leads to O(N*N) algorithms and should be avoided at all costs.
100  GA_ElementGroupOrderIndex findOffset(GA_Offset item) const;
101 
102  /// Return the index of the mixed entry passed in (or -1). This is O(N)
103  /// which easily leads to O(N*N) algorithms and should be avoided at all
104  /// costs.
105  GA_ElementGroupOrderIndex findMix(GA_Offset element,
106  const GA_SecondaryLookupInfo *s) const;
107 
108  /// Append any elements in src that are being merged, in order.
109  void merge(const GA_ElementGroupOrder &src,
110  const GA_MergeOffsetMap &map,
111  const GA_DataBitArray &orig);
112 
113  /// Save data to a JSON file for an UNMIXED order.
114  /// @section JSON-GA_ElementGroupOrder JSON Schema: GA_ElementGroupOrder
115  /// @code
116  /// {
117  /// "name" : "GA_ElementGroupOrder",
118  /// "description" : "An array of ordered elements",
119  /// "type" : { "$ref" : "GA_OffsetList" },
120  /// }
121  /// @endcode
122  /// @see @ref JSON_FileFormat
123  bool jsonSave(UT_JSONWriter &w, const GA_SaveMap &save) const;
124 
125  /// Load the element list from the JSON stream.
126  bool jsonLoad(UT_JSONParser &p, const GA_LoadMap &load);
127 
128  /// Save data to a JSON file for a MIXED order.
129  /// @section JSON-GA_ElementGroupOrder JSON Schema: GA_ElementGroupOrder
130  /// @code
131  /// {
132  /// "name" : "GA_ElementGroupOrder",
133  /// "description" : "An array of ordered elements",
134  /// "type" : { "$ref" : "GA_OffsetList" },
135  /// }
136  /// @endcode
137  /// @see @ref JSON_FileFormat
138  bool jsonSaveMix(UT_JSONWriter &w, const GA_SaveMap &save) const;
139 
140  /// Load the element list from the JSON stream.
141  bool jsonLoadMix(UT_JSONParser &p, const GA_LoadMap &load);
142 
143 private:
144  GA_Attribute &myAttribute;
146  UT_Array<GA_SecondaryLookupInfo *> mySecondaryElements;
147 
148  /// This tracks the number of mixed entries in the group. A mixed entry
149  /// is something like a nurbs surface and its profile curve.
150  ///
151  /// mySecondaryElements is only relevant if myMixCount > 0.
152  GA_Size myMixCount;
153 };
154 
155 #endif
Definition of a geometry attribute.
Definition: GA_Attribute.h:203
GLenum GLint * range
Definition: glcorearb.h:1925
Used to pass options and map offset values during saving.
Definition: GA_SaveMap.h:48
GA_Size elementEntries() const
int64 exint
Definition: SYS_Types.h:125
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
GLdouble s
Definition: glad.h:3009
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:87
#define GA_API
Definition: GA_API.h:14
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:39
Abstract base class for a range membership query object.
Information necessary to lookup a secondary primitive.
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:243
A range of elements in an index-map.
Definition: GA_Range.h:42
GA_Size GA_Offset
Definition: GA_Types.h:653
GLdouble n
Definition: glcorearb.h:2008
GA_Size GA_ElementGroupOrderIndex
Keeps track of offset mapping when merging index lists.
#define SYS_DECLARE_IS_POD(T)
Declare a type as POD.
Options during loading.
Definition: GA_LoadMap.h:42
Defragmentation of IndexMaps.
Definition: GA_Defragment.h:45
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
#define GA_API_TMPL
Definition: GA_API.h:15
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
OutGridT XformOp bool bool MergePolicy merge
An array of bits.
GA_Offset operator()(GA_ElementGroupOrderIndex i) const
Will return -1 if the i'th entry is a mixed entry.
GLenum src
Definition: glcorearb.h:1793