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;
27 class GA_SaveMap;
29 class UT_JSONParser;
31 
32 #if defined(GA_STRICT_TYPES)
33 #include <SYS/SYS_TypeTraits.h>
34 
35 class GA_API_TMPL GA_ElementGroupOrderIndexTag {};
36 typedef GA_OrdinalType<GA_ElementGroupOrderIndexTag, GA_Size>
39 #else
41 #endif
42 
44 {
45 public:
48  const GA_ElementGroupOrder &src);
50 
51  /// Return the total number of entries, mixed or not.
52  GA_Size entries() const;
53 
54  /// Return the number of un-mixed entries.
55  /// ie. those indices available to getElement()
57  { return (entries() - mixedEntries()); }
58 
59  /// Return the number of mixed entries.
60  /// ie. those indices available to getMixed()
61  GA_Size mixedEntries() const;
62 
63  /// Will return -1 if the i'th entry is a mixed entry.
64  GA_Offset operator()(GA_ElementGroupOrderIndex i) const { return getElement(i); }
65  /// Will return -1 if the i'th entry is a mixed entry.
66  GA_Offset getElement(GA_ElementGroupOrderIndex i) const;
67 
68  /// Query the i'th entry as a mixed entry. Secondary is set to NULL when
69  /// not mixed.
70  void getMixed(GA_ElementGroupOrderIndex i,
71  GA_Offset &element,
72  const GA_SecondaryLookupInfo *&secondary) const;
73 
74  void clear();
75 
76  void swapRange(GA_Offset a, GA_Offset b, GA_Size n);
77  void moveRange(GA_Offset a, GA_Offset b, GA_Size n);
78  void defragment(const GA_Defragment &defrag);
79 
80  void append(GA_Offset element);
81  bool remove(GA_Offset element);
82 
83  void appendMix(GA_Offset element,
84  const GA_SecondaryLookupInfo *secondary);
85  bool removeMix(GA_Offset element,
86  const GA_SecondaryLookupInfo *secondary);
87  int removeAll(GA_Offset element);
88  int removeAll(const GA_RangeMemberQuery &range_query);
89  int removeAllMix(GA_Offset element,
90  const GA_SecondaryLookupInfo *secondary_prefix,
91  const GA_RangeMemberQuery &secondary_range_query);
92 
93  bool removeIndex(GA_ElementGroupOrderIndex i);
94 
95  /// Return the index of the item passed in (or -1). This is O(N) which
96  /// easily leads to O(N*N) algorithms and should be avoided at all costs.
97  GA_ElementGroupOrderIndex findOffset(GA_Offset item) const;
98 
99  /// Return the index of the mixed entry passed in (or -1). This is O(N)
100  /// which easily leads to O(N*N) algorithms and should be avoided at all
101  /// costs.
102  GA_ElementGroupOrderIndex findMix(GA_Offset element,
103  const GA_SecondaryLookupInfo *s) const;
104 
105  /// Append any elements in src that are being merged, in order.
106  void merge(const GA_ElementGroupOrder &src,
107  const GA_MergeOffsetMap &map,
108  const GA_DataBitArray &orig);
109 
110  /// Save data to a JSON file for an UNMIXED order.
111  /// @section JSON-GA_ElementGroupOrder JSON Schema: GA_ElementGroupOrder
112  /// @code
113  /// {
114  /// "name" : "GA_ElementGroupOrder",
115  /// "description" : "An array of ordered elements",
116  /// "type" : { "$ref" : "GA_OffsetList" },
117  /// }
118  /// @endcode
119  /// @see @ref JSON_FileFormat
120  bool jsonSave(UT_JSONWriter &w, const GA_SaveMap &save) const;
121 
122  /// Load the element list from the JSON stream.
123  bool jsonLoad(UT_JSONParser &p, const GA_LoadMap &load);
124 
125  /// Save data to a JSON file for a MIXED order.
126  /// @section JSON-GA_ElementGroupOrder JSON Schema: GA_ElementGroupOrder
127  /// @code
128  /// {
129  /// "name" : "GA_ElementGroupOrder",
130  /// "description" : "An array of ordered elements",
131  /// "type" : { "$ref" : "GA_OffsetList" },
132  /// }
133  /// @endcode
134  /// @see @ref JSON_FileFormat
135  bool jsonSaveMix(UT_JSONWriter &w, const GA_SaveMap &save) const;
136 
137  /// Load the element list from the JSON stream.
138  bool jsonLoadMix(UT_JSONParser &p, const GA_LoadMap &load);
139 
140 private:
141  GA_Attribute &myAttribute;
143  UT_Array<GA_SecondaryLookupInfo *> mySecondaryElements;
144 
145  /// This tracks the number of mixed entries in the group. A mixed entry
146  /// is something like a nurbs surface and its profile curve.
147  ///
148  /// mySecondaryElements is only relevant if myMixCount > 0.
149  GA_Size myMixCount;
150 };
151 
152 #endif
Definition of a geometry attribute.
Definition: GA_Attribute.h:198
Used to pass options and map offset values during saving.
Definition: GA_SaveMap.h:48
GA_Size elementEntries() const
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:37
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:235
GA_Size GA_Offset
Definition: GA_Types.h:641
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
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