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 
165  {
166  myList = src.myList;
167  myCurr = src.myCurr;
168  mySize = src.mySize;
169  return *this;
170  }
171 
172  void rewind() { myCurr = 0; }
173  void advance() { myCurr++; }
174  bool atEnd() const { return myCurr >= mySize; }
175  iterator &operator++() { advance(); return *this; }
176  // No post increment as it is dangerous.
177 
178  int getSegment() const
179  { return myCurr; }
181  { return myList->getGeometry(myCurr); }
182  private:
183  iterator(const GT_GEODetailList *list)
184  : myList(list), myCurr(0), mySize(myList->entries())
185  {
186  }
187  const GT_GEODetailList *myList;
188  int myCurr;
189  int mySize;
190  friend class GT_GEODetailList;
191  };
192  iterator begin() const { return iterator(this); }
193 
194  /// Whether to include point attributes when creating vertex attribute
195  /// lists
197  {
198  GEO_SKIP_POINT = false,
200  };
201  /// Whether to include primitive attributes when creating vertex attribute
202  /// lists
204  {
207  };
208  /// Whether to include detail attributes when creating vertex/primitive
209  /// attribute lists
211  {
214  };
215 
216  /// Get an attribute handle list for point attributes
219  const GT_GEOOffsetList *pt_offsets=NULL,
220  bool add_point_id_attribute=false,
221  bool add_point_normals_if_missing=false
222  ) const;
223 
224  /// Get an attribute handle list for vertex attributes
227  const GT_GEOOffsetList *vtx_offsets=NULL,
229  GA_AttributeOwner add_normals_to_if_missing=GA_ATTRIB_INVALID,
230  float cusp_angle=GEO_DEFAULT_ADJUSTED_CUSP_ANGLE
231  ) const;
232  /// Get attribute handle for the primitive attributes
235  const GT_GEOOffsetList *prim_offsets=NULL,
237  bool add_topology_data_id=true,
238  GT_DataArrayHandle mat_id = NULL,
239  GT_DataArrayHandle mat_remap = NULL
240  ) const;
241  /// Return the attribute list for primitives that have a single vertex.
244  const GT_GEOOffsetList &prim_offsets,
245  const GT_GEOOffsetList &vertex_offsets,
248  GT_DataArrayHandle mat_id = NULL,
249  GT_DataArrayHandle mat_remap = NULL
250  ) const;
251 
252 
253  /// Get the attribute list handle for the detail attributes
256  bool add_topology_data_id=true,
257  GT_DataArrayHandle mat_id = NULL,
258  GT_DataArrayHandle mat_remap = NULL
259  ) const;
260 
261  /// Build face sets. Please see GT_RefineParms for the values for
262  /// faceset_mode
264  const GT_GEOOffsetList &prim_offsets,
265  int faceset_mode
266  ) const;
267 
268  /// Create vertex attributes for a list of primitives for *this* geometry
270  int nsegments,
272  const GT_GEOAttributeFilter *f=NULL
273  ) const
274  {
275  return createVertexAttributes(myList, list, nsegments, pt, f);
276  }
277  /// Create primitive & vertex attributes for a list of primitives of *this*
278  /// geometry.
280  const GEO_Primitive *const* list,
281  int nsegments,
284  const GT_GEOAttributeFilter *f=NULL
285  ) const
286  {
287  return createPrimitiveVertexAttributes(myList, list,
288  nsegments, pt, det, f);
289  }
290  /// Create primitive attributes for a list of primitives for *this*
291  /// geometry, optionally including detail attributes for the list.
293  const GEO_Primitive *const* list,
294  int nsegments,
296  bool add_topology_data_id=true,
297  const GT_GEOAttributeFilter *f=NULL
298  ) const
299  {
300  return createPrimitiveAttributes(myList, list, nsegments, det,
301  add_topology_data_id, f);
302  }
303  /// Create detail attributes for *this* geometry
305  const GEO_Primitive *const* list,
306  int nsegments,
307  bool add_topology_data_id=true,
308  const GT_GEOAttributeFilter *f=NULL
309  ) const
310  {
311  return createDetailAttributes(myList, list, nsegments,
312  add_topology_data_id, f);
313  }
314 
315 
316  /// Create vertex attributes for a list of primitives. This will verify
317  /// that all primitives have the same number and offsets of vertices.
318  /// If this is not the case, the method will return an empty handle.
319  /// If the user requests to @c include_point_attributes, these attributes
320  /// will be included in the list of returned attributes.
322  const GU_ConstDetailHandle *dlist,
323  const GEO_Primitive *const* list,
324  int nsegments,
326  const GT_GEOAttributeFilter *f=NULL
327  );
328  /// Create primitive & vertex attributes for a list of primitives. Each
329  /// primitive should have a single vertex. If the user requests to @c
330  /// include_point_attributes, these attributes will be included in the list
331  /// of returned attributes.
333  const GU_ConstDetailHandle *dlist,
334  const GEO_Primitive *const* list,
335  int nsegments,
338  const GT_GEOAttributeFilter *f=NULL,
339  GT_DataArrayHandle mat_id = NULL
340  );
341  /// Create primitive attributes for a list of primitives, optionally
342  /// including detail attributes for the list.
344  const GU_ConstDetailHandle *dlist,
345  const GEO_Primitive *const* list,
346  int nsegments,
348  bool add_topology_data_id=true,
349  const GT_GEOAttributeFilter *f=NULL
350  );
351  /// Create a detail attribute list for a list of primitives.
353  const GU_ConstDetailHandle *dlist,
354  const GEO_Primitive *const* list,
355  int nsegments,
356  bool add_topology_data_id=true,
357  const GT_GEOAttributeFilter *f=NULL
358  );
359 private:
360  void clear();
361  void copyFrom(const GU_ConstDetailHandle *list, int size);
362 #if 0
363  void copyFrom(const GU_ConstDetailhandle *detail_list,
364  const GEO_Primitive *const*list, int size);
365 #endif
366 
367  GU_ConstDetailHandle *myList;
368  GU_ConstDetailHandle myBuffer[4];
369  int mySize;
370  GA_Offset myPrimitiveId;
371  GA_Offset myPointId;
372  GA_Offset myVertexId;
373 };
374 
376 
377 #endif
GT_GEODetailList(const GU_ConstDetailHandle &gdp)
GT_Storage
Definition: GT_Types.h:17
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.
Keeps a list of GU_Detail pointers.
Class to filter attributes when building GT_AttributeLists.
#define GT_API
Definition: GT_API.h:11
GT_FaceSetMapPtr buildFaceSets(const GT_GEOOffsetList &prim_offsets, int faceset_mode) const
const GU_ConstDetailHandle & getGeometry(int segment) const
Return a specific element.
GLsizeiptr size
Definition: glcorearb.h:663
#define GA_INVALID_OFFSET
Definition: GA_Types.h:654
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:617
#define GEO_DEFAULT_ADJUSTED_CUSP_ANGLE
Definition: GEO_Normal.h:28
GLfloat f
Definition: glcorearb.h:1925
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:28
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.
GLintptr offset
Definition: glcorearb.h:664
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.
GA_AttributeOwner
Definition: GA_Types.h:33
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.
png_infop png_sPLT_tpp entries
Definition: png.h:2481
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
getOption("OpenEXR.storage") storage
Definition: HDK_Image.dox:276
iterator & operator=(const iterator &src)
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:1368
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:1296
GLenum src
Definition: glcorearb.h:1792