HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_AttributeRefMapOffsetMap.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_AttributeRefMapOffsetMap.h ( GA Library, C++)
7  *
8  * COMMENTS: A mapping from a particular element to the corresponding
9  * elements in other index maps, updated on the fly.
10  */
11 
12 #ifndef __GA_AttributeRefMapOffsetMap__
13 #define __GA_AttributeRefMapOffsetMap__
14 
15 #include "GA_API.h"
16 #include "GA_Attribute.h"
17 #include "GA_Detail.h"
18 #include "GA_Types.h"
19 
20 #include <SYS/SYS_Types.h>
21 
22 
24 {
25 private:
26  GA_Offset myOffsets[GA_ATTRIB_OWNER_N];
27  GA_AttributeOwner myOwner;
28 
29 #if !defined(GA_STRICT_TYPES)
30  static const GA_Offset theNeedLookup = (GA_INVALID_OFFSET-1);
31 #else
32  static const GA_Offset theNeedLookup;
33 #endif
34 
35 public:
37  : myOwner(owner)
38  {
39  for (int i = 0; i < GA_ATTRIB_OWNER_N; ++i)
40  myOffsets[i] = theNeedLookup;
41  myOffsets[owner] = off;
42  myOffsets[GA_ATTRIB_DETAIL] = GA_Offset(0);
43  }
44 
45  SYS_FORCE_INLINE void
47  {
48  for (int i = 0; i < GA_ATTRIB_OWNER_N; ++i)
49  myOffsets[i] = theNeedLookup;
50  myOffsets[owner] = off;
51  myOffsets[GA_ATTRIB_DETAIL] = GA_Offset(0);
52  myOwner = owner;
53  }
54 
56  getOwnerOffset() const { return myOffsets[myOwner]; }
57 
59  getOffset(const GA_Attribute *attrib)
60  {
61  GA_AttributeOwner aowner = attrib->getOwner();
62  if (myOffsets[aowner] == theNeedLookup)
63  {
64  if (aowner == GA_ATTRIB_GLOBAL)
65  return myOffsets[aowner] = GA_Offset(0);
66 
67  if (myOwner == GA_ATTRIB_VERTEX)
68  {
69  const GA_Detail &gdp = attrib->getDetail();
70  if (aowner == GA_ATTRIB_POINT)
71  return myOffsets[aowner] = gdp.vertexPoint(
72  myOffsets[myOwner]);
73  if (aowner == GA_ATTRIB_PRIMITIVE)
74  return myOffsets[aowner] = gdp.vertexPrimitive(
75  myOffsets[myOwner]);
76  }
77 
78  return myOffsets[aowner] = GA_INVALID_OFFSET;
79  }
80 
81  return myOffsets[aowner];
82  }
83 };
84 
85 #endif // __GA_AttributeRefMapOffsetMap__
Definition of a geometry attribute.
Definition: GA_Attribute.h:190
const GA_Detail & getDetail() const
SYS_FORCE_INLINE GA_Offset getOwnerOffset() const
#define GA_API
Definition: GA_API.h:12
SYS_FORCE_INLINE GA_Offset getOffset(const GA_Attribute *attrib)
png_uint_32 i
Definition: png.h:2877
#define GA_INVALID_OFFSET
Definition: GA_Types.h:654
GA_Size GA_Offset
Definition: GA_Types.h:617
SYS_FORCE_INLINE void reset(GA_AttributeOwner owner, GA_Offset off)
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
SYS_FORCE_INLINE GA_Offset vertexPoint(GA_Offset vertex) const
Given a vertex, return the point it references.
Definition: GA_Detail.h:473
GA_AttributeOwner getOwner() const
SYS_FORCE_INLINE GA_Offset vertexPrimitive(GA_Offset vertex) const
Definition: GA_Detail.h:481
GA_AttributeOwner
Definition: GA_Types.h:33
Container class for all geometry.
Definition: GA_Detail.h:95
GA_AttributeRefMapOffsetMap(GA_AttributeOwner owner, GA_Offset off)