HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_GEODetailList.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_GEODetailList.h ( GEO Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_GEODetailList__
12 #define __GT_GEODetailList__
13 
14 #include "GT_API.h"
15 #include <UT/UT_SharedPtr.h>
16 #include "GT_Handles.h"
17 #include "GT_Types.h"
18 #include "GT_FaceSetMap.h"
19 #include <GA/GA_Types.h>
20 #include <GU/GU_DetailHandle.h>
21 #include <GEO/GEO_Normal.h>
22 
23 class GEO_Primitive;
24 class GT_GEOOffsetList;
26 
27 /// @brief Keeps a list of GU_Detail pointers
29 {
30 public:
31  /// Default constructor
33  : myList(myBuffer)
34  , mySize(0)
35  , myPrimitiveId(GA_INVALID_OFFSET)
36  , myVertexId(GA_INVALID_OFFSET)
37  , myPointId(GA_INVALID_OFFSET)
38  {}
39  /// Useful constructor
41  : myList(NULL)
42  , mySize(0)
43  , myPrimitiveId(GA_INVALID_OFFSET)
44  , myVertexId(GA_INVALID_OFFSET)
45  , myPointId(GA_INVALID_OFFSET)
46  {
47  copyFrom(list, size);
48  }
49 #if 0
50  GT_GEODetailList(const GU_ConstDetailHandle *detail_list,
51  const GEO_Primitive *const* list,
52  int size)
53  : myList(NULL)
54  , mySize(0)
55  , myPrimitiveId(GA_INVALID_OFFSET)
56  , myVertexId(GA_INVALID_OFFSET)
57  , myPointId(GA_INVALID_OFFSET)
58  {
59  copyFrom(detail_list, list, size);
60  }
61 #endif
63  : myList(NULL)
64  , mySize(0)
65  , myPrimitiveId(GA_INVALID_OFFSET)
66  , myVertexId(GA_INVALID_OFFSET)
67  , myPointId(GA_INVALID_OFFSET)
68  {
69  copyFrom(&gdp, 1);
70  }
71  /// Copy constructor
73  : myList(NULL)
74  , mySize(0)
75  , myPrimitiveId(src.myPrimitiveId)
76  , myVertexId(src.myVertexId)
77  , myPointId(src.myPointId)
78  {
79  copyFrom(src.myList, src.mySize);
80  }
82  {
83  clear();
84  }
85 
86  /// Assignment operator
88  {
89  if (this != &src)
90  {
91  clear();
92  copyFrom(src.myList, src.mySize);
93  myPrimitiveId = src.myPrimitiveId;
94  myVertexId = src.myVertexId;
95  myPointId = src.myPointId;
96  }
97  return *this;
98  }
99 
100  /// Return number of details in the list
101  int entries() const
102  { return mySize; }
103 
104  /// Return number of details in the list
105  int getMotionSegments() const
106  { return mySize; }
107 
108  /// @{
109  /// Access to primitive/vertex/point offset overrides
110  GA_Offset primitiveId() const { return myPrimitiveId; }
112  { myPrimitiveId = offset; }
113  GA_Offset vertexId() const { return myVertexId; }
115  { myVertexId = offset; }
116  GA_Offset pointId() const { return myPointId; }
118  { myPointId = offset; }
119  /// @}
120 
121  /// Return a list of all the GU_ConstDetailHandles associated with this list
122  GU_ConstDetailHandle *detailHandles() const { return myList; }
123 
124  /// Return a specific element
125  const GU_ConstDetailHandle &getGeometry(int segment) const
126  { return myList[SYSmin(segment, mySize-1)]; }
127 
128  /// () operator
129  const GU_ConstDetailHandle &operator()(int segment) const
130  { return getGeometry(segment); }
131 
132  /// Fill the primitive list for the given offset. Returns false if there
133  /// are mis-matched primitives:
134  /// - The primitives have different factories
135  /// - The detail has different
136  bool fillPrimitiveSegments(const GEO_Primitive **list,
137  GA_Offset prim_offset) const;
138 
139  /// Create a data array containing the value of primitive intrinsic
140  /// attributes. The code handles the case where the attribute name is
141  /// prefixed with "intrinsic:". The method uses the __primitive_id to
142  /// perform the value lookup.
143  static GT_DataArrayHandle fillPrimitiveIntrinsic(
144  const GU_Detail &gdp,
145  const char *intrinsic_name,
146  const GT_Primitive &prim);
147 
148  /// Check intrinsic information for a given primtiive. Like
149  /// fillPrimitiveIntrinsic(), this uses the __primtiive_id to perform the
150  /// checks.
151  static bool findPrimitiveIntrinsic(
152  const GU_Detail &gdp,
153  const char *intrinsic_name,
154  const GT_Primitive &prim,
156  int &tuple_size);
157 
158  /// Class to traverse over the geometry for each segment
160  {
161  public:
162  iterator() : myList(0), myCurr(0), mySize(0) {}
163 
164  void rewind() { myCurr = 0; }
165  void advance() { myCurr++; }
166  bool atEnd() const { return myCurr >= mySize; }
167  iterator &operator++() { advance(); return *this; }
168  // No post increment as it is dangerous.
169 
170  int getSegment() const
171  { return myCurr; }
173  { return myList->getGeometry(myCurr); }
174  private:
175  iterator(const GT_GEODetailList *list)
176  : myList(list), myCurr(0), mySize(myList->entries())
177  {
178  }
179  const GT_GEODetailList *myList;
180  int myCurr;
181  int mySize;
182  friend class GT_GEODetailList;
183  };
184  iterator begin() const { return iterator(this); }
185 
186  /// Whether to include point attributes when creating vertex attribute
187  /// lists
189  {
190  GEO_SKIP_POINT = false,
192  };
193  /// Whether to include primitive attributes when creating vertex attribute
194  /// lists
196  {
199  };
200  /// Whether to include detail attributes when creating vertex/primitive
201  /// attribute lists
203  {
206  };
207 
208  /// Get an attribute handle list for point attributes
211  const GT_GEOOffsetList *pt_offsets=NULL,
212  bool add_point_id_attribute=false,
213  bool add_point_normals_if_missing=false
214  ) const;
215 
216  /// Get an attribute handle list for vertex attributes
219  const GT_GEOOffsetList *vtx_offsets=NULL,
221  GA_AttributeOwner add_normals_to_if_missing=GA_ATTRIB_INVALID,
222  float cusp_angle=GEO_DEFAULT_ADJUSTED_CUSP_ANGLE
223  ) const;
224  /// Get attribute handle for the primitive attributes
227  const GT_GEOOffsetList *prim_offsets=NULL,
229  bool add_topology_data_id=true,
230  GT_DataArrayHandle mat_id = NULL,
231  GT_DataArrayHandle mat_remap = NULL
232  ) const;
233  /// Return the attribute list for primitives that have a single vertex.
236  const GT_GEOOffsetList &prim_offsets,
237  const GT_GEOOffsetList &vertex_offsets,
240  GT_DataArrayHandle mat_id = NULL,
241  GT_DataArrayHandle mat_remap = NULL
242  ) const;
243 
244 
245  /// Get the attribute list handle for the detail attributes
248  bool add_topology_data_id=true,
249  GT_DataArrayHandle mat_id = NULL,
250  GT_DataArrayHandle mat_remap = NULL
251  ) const;
252 
253  /// Build face sets. Please see GT_RefineParms for the values for
254  /// faceset_mode
256  const GT_GEOOffsetList &prim_offsets,
257  int faceset_mode
258  ) const;
259 
260  /// Create vertex attributes for a list of primitives for *this* geometry
262  int nsegments,
264  const GT_GEOAttributeFilter *f=NULL
265  ) const
266  {
267  return createVertexAttributes(myList, list, nsegments, pt, f);
268  }
269  /// Create primitive & vertex attributes for a list of primitives of *this*
270  /// geometry.
272  const GEO_Primitive *const* list,
273  int nsegments,
276  const GT_GEOAttributeFilter *f=NULL
277  ) const
278  {
279  return createPrimitiveVertexAttributes(myList, list,
280  nsegments, pt, det, f);
281  }
282  /// Create primitive attributes for a list of primitives for *this*
283  /// geometry, optionally including detail attributes for the list.
285  const GEO_Primitive *const* list,
286  int nsegments,
288  bool add_topology_data_id=true,
289  const GT_GEOAttributeFilter *f=NULL
290  ) const
291  {
292  return createPrimitiveAttributes(myList, list, nsegments, det,
293  add_topology_data_id, f);
294  }
295  /// Create detail attributes for *this* geometry
297  const GEO_Primitive *const* list,
298  int nsegments,
299  bool add_topology_data_id=true,
300  const GT_GEOAttributeFilter *f=NULL
301  ) const
302  {
303  return createDetailAttributes(myList, list, nsegments,
304  add_topology_data_id, f);
305  }
306 
307 
308  /// Create vertex attributes for a list of primitives. This will verify
309  /// that all primitives have the same number and offsets of vertices.
310  /// If this is not the case, the method will return an empty handle.
311  /// If the user requests to @c include_point_attributes, these attributes
312  /// will be included in the list of returned attributes.
314  const GU_ConstDetailHandle *dlist,
315  const GEO_Primitive *const* list,
316  int nsegments,
318  const GT_GEOAttributeFilter *f=NULL
319  );
320  /// Create primitive & vertex attributes for a list of primitives. Each
321  /// primitive should have a single vertex. If the user requests to @c
322  /// include_point_attributes, these attributes will be included in the list
323  /// of returned attributes.
325  const GU_ConstDetailHandle *dlist,
326  const GEO_Primitive *const* list,
327  int nsegments,
330  const GT_GEOAttributeFilter *f=NULL,
331  GT_DataArrayHandle mat_id = NULL
332  );
333  /// Create primitive attributes for a list of primitives, optionally
334  /// including detail attributes for the list.
336  const GU_ConstDetailHandle *dlist,
337  const GEO_Primitive *const* list,
338  int nsegments,
340  bool add_topology_data_id=true,
341  const GT_GEOAttributeFilter *f=NULL
342  );
343  /// Create a detail attribute list for a list of primitives.
345  const GU_ConstDetailHandle *dlist,
346  const GEO_Primitive *const* list,
347  int nsegments,
348  bool add_topology_data_id=true,
349  const GT_GEOAttributeFilter *f=NULL
350  );
351 private:
352  void clear();
353  void copyFrom(const GU_ConstDetailHandle *list, int size);
354 #if 0
355  void copyFrom(const GU_ConstDetailhandle *detail_list,
356  const GEO_Primitive *const*list, int size);
357 #endif
358 
359  GU_ConstDetailHandle *myList;
360  GU_ConstDetailHandle myBuffer[4];
361  int mySize;
362  GA_Offset myPrimitiveId;
363  GA_Offset myPointId;
364  GA_Offset myVertexId;
365 };
366 
368 
369 #endif
GT_GEODetailList(const GU_ConstDetailHandle &gdp)
GT_Storage
Definition: GT_Types.h:19
iterator begin() const
static GT_AttributeListHandle createVertexAttributes(const GU_ConstDetailHandle *dlist, const GEO_Primitive *const *list, int nsegments, GT_GEOIncludePoint pt=GEO_SKIP_POINT, const GT_GEOAttributeFilter *f=NULL)
GU_ConstDetailHandle * detailHandles() const
Return a list of all the GU_ConstDetailHandles associated with this list.
GT_GEODetailList(const GT_GEODetailList &src)
Copy constructor.
getFileOption("OpenEXR:storage") storage
Definition: HDK_Image.dox:276
Keeps a list of GU_Detail pointers.
Class to filter attributes when building GT_AttributeLists.
#define GT_API
Definition: GT_API.h:13
GT_FaceSetMapPtr buildFaceSets(const GT_GEOOffsetList &prim_offsets, int faceset_mode) const
const GU_ConstDetailHandle & getGeometry(int segment) const
Return a specific element.
#define GA_INVALID_OFFSET
Definition: GA_Types.h:678
static GT_AttributeListHandle createPrimitiveVertexAttributes(const GU_ConstDetailHandle *dlist, const GEO_Primitive *const *list, int nsegments, GT_GEOIncludePoint pt=GEO_SKIP_POINT, GT_GEOIncludeDetail det=GEO_SKIP_DETAIL, const GT_GEOAttributeFilter *f=NULL, GT_DataArrayHandle mat_id=NULL)
GA_Size GA_Offset
Definition: GA_Types.h:641
#define GEO_DEFAULT_ADJUSTED_CUSP_ANGLE
Definition: GEO_Normal.h:28
GLfloat f
Definition: glcorearb.h:1926
GLintptr offset
Definition: glcorearb.h:665
GT_AttributeListHandle createDetail(const GEO_Primitive *const *list, int nsegments, bool add_topology_data_id=true, const GT_GEOAttributeFilter *f=NULL) const
Create detail attributes for this geometry.
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:36
static GT_AttributeListHandle createDetailAttributes(const GU_ConstDetailHandle *dlist, const GEO_Primitive *const *list, int nsegments, bool add_topology_data_id=true, const GT_GEOAttributeFilter *f=NULL)
Create a detail attribute list for a list of primitives.
GT_GEODetailList(const GU_ConstDetailHandle *list, int size)
Useful constructor.
Class to traverse over the geometry for each segment.
static GT_AttributeListHandle createPrimitiveAttributes(const GU_ConstDetailHandle *dlist, const GEO_Primitive *const *list, int nsegments, GT_GEOIncludeDetail det=GEO_SKIP_DETAIL, bool add_topology_data_id=true, const GT_GEOAttributeFilter *f=NULL)
GT_AttributeListHandle createVertex(const GEO_Primitive *const *list, int nsegments, GT_GEOIncludePoint pt=GEO_SKIP_POINT, const GT_GEOAttributeFilter *f=NULL) const
Create vertex attributes for a list of primitives for this geometry.
The base class for all GT primitive types.
Definition: GT_Primitive.h:43
GA_Offset vertexId() const
GA_Offset primitiveId() const
int getMotionSegments() const
Return number of details in the list.
GT_AttributeListHandle getVertexAttributes(const GT_GEOAttributeFilter &filter, const GT_GEOOffsetList *vtx_offsets=NULL, GT_GEOIncludePoint pt=GEO_SKIP_POINT, GA_AttributeOwner add_normals_to_if_missing=GA_ATTRIB_INVALID, float cusp_angle=GEO_DEFAULT_ADJUSTED_CUSP_ANGLE) const
Get an attribute handle list for vertex attributes.
GT_AttributeListHandle getPrimitiveVertexAttributes(const GT_GEOAttributeFilter &filter, const GT_GEOOffsetList &prim_offsets, const GT_GEOOffsetList &vertex_offsets, GT_GEOIncludePoint pt=GEO_SKIP_POINT, GT_GEOIncludeDetail det=GEO_SKIP_DETAIL, GT_DataArrayHandle mat_id=NULL, GT_DataArrayHandle mat_remap=NULL) const
Return the attribute list for primitives that have a single vertex.
GLsizeiptr size
Definition: glcorearb.h:664
GA_AttributeOwner
Definition: GA_Types.h:34
GT_GEODetailList()
Default constructor.
GT_AttributeListHandle getDetailAttributes(const GT_GEOAttributeFilter &filter, bool add_topology_data_id=true, GT_DataArrayHandle mat_id=NULL, GT_DataArrayHandle mat_remap=NULL) const
Get the attribute list handle for the detail attributes.
GT_AttributeListHandle createPrimitiveVertex(const GEO_Primitive *const *list, int nsegments, GT_GEOIncludePoint pt=GEO_SKIP_POINT, GT_GEOIncludeDetail det=GEO_SKIP_DETAIL, const GT_GEOAttributeFilter *f=NULL) const
GT_AttributeListHandle getPrimitiveAttributes(const GT_GEOAttributeFilter &filter, const GT_GEOOffsetList *prim_offsets=NULL, GT_GEOIncludeDetail det=GEO_SKIP_DETAIL, bool add_topology_data_id=true, GT_DataArrayHandle mat_id=NULL, GT_DataArrayHandle mat_remap=NULL) const
Get attribute handle for the primitive attributes.
GA_Offset pointId() const
const GU_ConstDetailHandle & getGeometry() const
GT_AttributeListHandle getPointAttributes(const GT_GEOAttributeFilter &filter, const GT_GEOOffsetList *pt_offsets=NULL, bool add_point_id_attribute=false, bool add_point_normals_if_missing=false) const
Get an attribute handle list for point attributes.
GT_AttributeListHandle createPrimitive(const GEO_Primitive *const *list, int nsegments, GT_GEOIncludeDetail det=GEO_SKIP_DETAIL, bool add_topology_data_id=true, const GT_GEOAttributeFilter *f=NULL) const
const GU_ConstDetailHandle & operator()(int segment) const
() operator
void setPrimitiveId(GA_Offset offset)
UT_SharedPtr< GT_GEODetailList > GT_GEODetailListHandle
void setPointId(GA_Offset offset)
void setVertexId(GA_Offset offset)
#define SYSmin(a, b)
Definition: SYS_Math.h:1539
int entries() const
Return number of details in the list.
GT_GEODetailList & operator=(const GT_GEODetailList &src)
Assignment operator.
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glcorearb.h:1297
GLenum src
Definition: glcorearb.h:1793