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
255  SYS_DEPRECATED_REPLACE(20.5, "buildPrimitiveSets")
257  const GT_GEOOffsetList &prim_offsets,
258  int faceset_mode
259  ) const
260  {
261  return buildPrimitiveSets(prim_offsets, faceset_mode);
262  }
263  /// Build primitive sets. Please see GT_RefineParms for the values for
264  /// faceset_mode
266  const GT_GEOOffsetList &prim_offsets,
267  int faceset_mode
268  ) const;
269  /// Build point sets from point groups. Please see GT_RefineParms for the
270  /// values for faceset_mode.
272  const GT_DataArrayHandle &point_ids,
273  int faceset_mode
274  ) const;
275 
276  /// Create vertex attributes for a list of primitives for *this* geometry
278  int nsegments,
280  const GT_GEOAttributeFilter *f=NULL
281  ) const
282  {
283  return createVertexAttributes(myList, list, nsegments, pt, f);
284  }
285  /// Create primitive & vertex attributes for a list of primitives of *this*
286  /// geometry.
288  const GEO_Primitive *const* list,
289  int nsegments,
292  const GT_GEOAttributeFilter *f=NULL
293  ) const
294  {
295  return createPrimitiveVertexAttributes(myList, list,
296  nsegments, pt, det, f);
297  }
298  /// Create primitive attributes for a list of primitives for *this*
299  /// geometry, optionally including detail attributes for the list.
301  const GEO_Primitive *const* list,
302  int nsegments,
304  bool add_topology_data_id=true,
305  const GT_GEOAttributeFilter *f=NULL
306  ) const
307  {
308  return createPrimitiveAttributes(myList, list, nsegments, det,
309  add_topology_data_id, f);
310  }
311  /// Create detail attributes for *this* geometry
313  const GEO_Primitive *const* list,
314  int nsegments,
315  bool add_topology_data_id=true,
316  const GT_GEOAttributeFilter *f=NULL
317  ) const
318  {
319  return createDetailAttributes(myList, list, nsegments,
320  add_topology_data_id, f);
321  }
322 
323 
324  /// Create vertex attributes for a list of primitives. This will verify
325  /// that all primitives have the same number and offsets of vertices.
326  /// If this is not the case, the method will return an empty handle.
327  /// If the user requests to @c include_point_attributes, these attributes
328  /// will be included in the list of returned attributes.
330  const GU_ConstDetailHandle *dlist,
331  const GEO_Primitive *const* list,
332  int nsegments,
334  const GT_GEOAttributeFilter *f=NULL
335  );
336  /// Create primitive & vertex attributes for a list of primitives. Each
337  /// primitive should have a single vertex. If the user requests to @c
338  /// include_point_attributes, these attributes will be included in the list
339  /// of returned attributes.
341  const GU_ConstDetailHandle *dlist,
342  const GEO_Primitive *const* list,
343  int nsegments,
346  const GT_GEOAttributeFilter *f=NULL,
347  GT_DataArrayHandle mat_id = NULL
348  );
349  /// Create primitive attributes for a list of primitives, optionally
350  /// including detail attributes for the list.
352  const GU_ConstDetailHandle *dlist,
353  const GEO_Primitive *const* list,
354  int nsegments,
356  bool add_topology_data_id=true,
357  const GT_GEOAttributeFilter *f=NULL
358  );
359  /// Create a detail attribute list for a list of primitives.
361  const GU_ConstDetailHandle *dlist,
362  const GEO_Primitive *const* list,
363  int nsegments,
364  bool add_topology_data_id=true,
365  const GT_GEOAttributeFilter *f=NULL
366  );
367 private:
368  void clear();
369  void copyFrom(const GU_ConstDetailHandle *list, int size);
370 #if 0
371  void copyFrom(const GU_ConstDetailhandle *detail_list,
372  const GEO_Primitive *const*list, int size);
373 #endif
374 
375  GU_ConstDetailHandle *myList;
376  GU_ConstDetailHandle myBuffer[4];
377  int mySize;
378  GA_Offset myPrimitiveId;
379  GA_Offset myPointId;
380  GA_Offset myVertexId;
381 };
382 
384 
385 #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:687
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)
#define SYS_DEPRECATED_REPLACE(__V__, __R__)
GA_Size GA_Offset
Definition: GA_Types.h:646
#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.
GT_ElementSetMapPtr buildPointSets(const GT_DataArrayHandle &point_ids, int faceset_mode) const
GLsizeiptr size
Definition: glcorearb.h:664
GA_AttributeOwner
Definition: GA_Types.h:35
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_ElementSetMapPtr buildPrimitiveSets(const GT_GEOOffsetList &prim_offsets, int faceset_mode) const
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:1571
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