HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_DAIndirect.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: GT_DAIndirect.h ( GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_DAIndirect__
12 #define __GT_DAIndirect__
13 
14 #include "GT_API.h"
15 #include "GT_DAInherit.h"
16 
17 /// @brief An array to handle indirect references (i.e. shared items)
18 ///
19 /// This class takes two GT_DataArrays. The indirect array should be an array
20 /// of integers which are used to perform indirect lookup into the shared data
21 /// array.
22 /// For example: @code
23 /// GT_DataArray VertexList = [ 1, 4, 2, 3 ]
24 /// GT_DataArray &PointAttributes;
25 /// GT_DAIndirect attribs(VertexList, PointAttributes);
26 /// @endcode
27 /// This allows the point attributes to be referenced by vertex number.
29 public:
30  /// Default constructor
32  : myIndirect()
33  , GT_DAInherit()
34  { }
35  /// Convenience constructor
37  const GT_DataArrayHandle &data,
38  bool flatten_nested = false)
39  : myIndirect()
40  , GT_DAInherit()
41  {
42  init(indirect, data, flatten_nested);
43  }
44  /// Copy constructor
46  : myIndirect()
47  , GT_DAInherit()
48  {
49  init(src.myIndirect, src.myData, true);
50  }
51  /// Destructor
52  virtual ~GT_DAIndirect();
53 
54  virtual const char *className() const { return "GT_DAIndirect"; }
55 
56  virtual bool isValid() const
57  { return myIndirect && myData &&
58  myIndirect->isValid() && myData->isValid(); }
59  virtual void updateGeoDetail(const GU_ConstDetailHandle &dtl,
60  const char *attrib_name,
61  GT_Owner attrib_owner,
62  const int expected_size);
63 
64 
65  /// Initialize data from an indirect array of indices and a data array
66  void init(const GT_DataArrayHandle &indirect,
67  const GT_DataArrayHandle &data,
68  bool flatten_nested);
69 
70  GT_DataArrayHandle getIndirect() { return myIndirect; }
71  virtual int64 getDataId() const;
72 
73  static int getUnmapThreshold();
74 
75  GT_IMPL_INHERIT_ARRAY(getIndirect, myIndirect->entries())
76 
77 private:
78  /// Map the requested offset to the offset in my data
79  inline GT_Offset getIndirect(GT_Offset offset) const
80  { return myIndirect->getI64(offset); }
81 
82  GT_DataArrayHandle myIndirect;
83 };
84 
85 #endif
86 
virtual void updateGeoDetail(const GU_ConstDetailHandle &dtl, const char *attrib_name, GT_Owner attrib_owner, const int expected_size)
Definition: GT_DAInherit.h:53
GT_DAIndirect(const GT_DAIndirect &src)
Copy constructor.
Definition: GT_DAIndirect.h:45
GT_DataArrayHandle myData
Definition: GT_DAInherit.h:114
virtual const char * className() const
Definition: GT_DAIndirect.h:54
#define GT_API
Definition: GT_API.h:11
GT_DAIndirect()
Default constructor.
Definition: GT_DAIndirect.h:31
virtual bool isValid() const
Definition: GT_DAIndirect.h:56
long long int64
Definition: SYS_Types.h:107
An array to handle indirect references (i.e. shared items)
Definition: GT_DAIndirect.h:28
virtual int64 getDataId() const
Definition: GT_DAInherit.h:52
GLintptr offset
Definition: glcorearb.h:664
GLboolean * data
Definition: glcorearb.h:130
GT_DAIndirect(const GT_DataArrayHandle &indirect, const GT_DataArrayHandle &data, bool flatten_nested=false)
Convenience constructor.
Definition: GT_DAIndirect.h:36
GT_Owner
Definition: GT_Types.h:75
Base class for a data array which references another data array.
Definition: GT_DAInherit.h:18
GT_DataArrayHandle getIndirect()
Definition: GT_DAIndirect.h:70
#define GT_IMPL_INHERIT_ARRAY(MAP_INDEX, SIZE)
Definition: GT_DAInherit.h:71
const void * indirect
Definition: glcorearb.h:1794
void init(const GT_DataArrayHandle &data)
Definition: GT_DAInherit.h:32
int64 GT_Offset
Definition: GT_Types.h:113
GLenum src
Definition: glcorearb.h:1792