HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_SubDivPacking.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: GU_SubDivPacking.h ( GU Library, C++)
7  *
8  * COMMENTS: The subdivision code "packs" floating point attributes into
9  * smaller data structures for efficiency. This class keeps track
10  * of the mapping between the packed and unpacked data.
11  */
12 
13 #ifndef __GU_SubDivPacking__
14 #define __GU_SubDivPacking__
15 
16 #include "GU_API.h"
17 
18 #include <UT/UT_ValArray.h>
19 #include <UT/UT_StringArray.h>
20 #include <UT/UT_IntArray.h>
21 #include <GA/GA_Types.h>
22 
23 class GA_GBElement;
24 class GA_Attribute;
25 class GA_AttributeDict;
26 
28 {
29 public:
30  /// Default constructor
32  /// Constructor which builds all float attributes for a dictionary
34  /// Copy constructor
36  /// Destructor
38 
39  /// Assignment operator
41 
42  /// Clear the packing tables
43  void clear();
44 
45  /// Add all float attributes from the given dictionary
46  void addFloatAttributes(const GA_AttributeDict &dict);
47 
48  /// Add a single attribute. If a tuple size is specified, it will
49  /// override the tuple size fo the attribute. Tuple sizes must be
50  /// <= the actual attribute tuple size.
51  void addAttribute(GA_Attribute *atr,
52  bool check_dups, int tuple_size = -1);
53 
54  /// Pack floats from an object's attributes into a packed buffer
55  template <typename T>
56  void packFloats(T *data, GA_Offset off) const;
57  /// Unpack data in the buffer into the object's attributes
58  template <typename T>
59  void unpackFloats(GA_Offset off, const T *data) const;
60 
61  /// Number of attributes
62  int entries() const { return myAttributes.entries(); }
63 
64  /// Number of floats required for the packed array
65  int getCount() const { return myCount; }
66 
67  /// Offset array into the packed array. This is the offset (not the
68  /// byte-count)
69  const UT_StringArray &getNames() const
70  { return myNames; }
71  /// Offset array into the packed array. This is the offset (not the
72  /// byte-count)
73  const UT_IntArray &getOffsets() const
74  { return myOffsets; }
75  /// Number of floats for each attribute (in floats, not bytes)
76  const UT_IntArray &getSizes() const
77  { return mySizes; }
78 
79  /// Get the attribute offset (i.e. offset into the packed data)
80  int getPackedOffset(const GA_Attribute *atr) const;
81 
82 private:
83  UT_ValArray<GA_Attribute *> myAttributes;
84  UT_StringArray myNames;
85  UT_IntArray myOffsets;
86  UT_IntArray mySizes;
87  int myCount;
88 };
89 
90 #endif
Definition of a geometry attribute.
Definition: GA_Attribute.h:198
int entries() const
Number of attributes.
const UT_StringArray & getNames() const
A string map of attributes to ease backward compatibility In the GB/GEO/GU library code would often p...
int getCount() const
Number of floats required for the packed array.
GA_Size GA_Offset
Definition: GA_Types.h:646
#define GU_API
Definition: GU_API.h:14
const UT_IntArray & getSizes() const
Number of floats for each attribute (in floats, not bytes)
LeafData & operator=(const LeafData &)=delete
const UT_IntArray & getOffsets() const
Definition: format.h:895
GLenum src
Definition: glcorearb.h:1793