HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_GEOVertexRefine.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_GEOVertexRefine.h ( GEO Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_GEOVertexRefine__
12 #define __GT_GEOVertexRefine__
13 
14 #include "GT_API.h"
15 
16 #include <UT/UT_ValArray.h>
17 #include <UT/UT_IntArray.h>
18 #include <GA/GA_Types.h>
19 #include "GT_Handles.h"
20 
22 class GT_GEOPrimitive;
23 class GEO_Primitive;
24 class GA_Detail;
25 class GA_Attribute;
26 class GA_AttributeDict;
27 class GA_AttributeRefMap;
28 class GEO_Curve;
29 
30 /// Refine points/vertices into unique data arrays (not shared by the detail).
31 ///
32 /// This class can be used to create point/vertex attributes for refined
33 /// primitives. The way to use this would be to: @code
34 /// GT_GEOPrimitive srcprim(initialize);
35 /// GT_GEOAttributeFilter filter;
36 /// GT_GEOVertexRefine vrefine(srcprim, filter, true, 3);
37 /// for (int seg = 0; seg < srcprim.getMotionSegments(); ++seg)
38 /// {
39 /// const GEO_Primitive *prim;
40 /// GA_AttributeRefMap hlist;
41 /// prim = vrefine.bindAttributeHandle(seg, hlist);
42 /// vertex_offsets = getRefinedVertices();
43 /// for (exint v = 0; v < nvertices; ++v)
44 /// prim->evaluate(parms, vertex_offsets[v], hlist);
45 /// vrefine.extractVertices(seg, hlist, vertex_offsets, nvertices);
46 /// }
47 /// @endcode
49 {
50 public:
51  /// Create an attribute list for vertices (and optionally points).
52  /// The @c psize specifies the tuple size for P and is only valid when
53  /// adding point attributes too.
54  /// If @c user_defined_N is true, the N attribute will be added if it's not
55  /// found on points/vertices. Also, the N attribute will @b not be picked
56  /// up for refinement (relying on the user to set the values properly).
57  ///
58  /// This creates the attribute handle list. Refinement of vertex
59  /// attributes is a separate process.
62  bool do_point_attributes,
63  int psize=3,
64  bool user_defined_N=false);
66 
67  /// Get the attribute handle
69  { return myGTAttributes; }
70 
71  /// Bind the attributes to the attribute handle list. The handle list
72  /// should be cleared of entries before calling this.
73  /// The method returns the primitive associated with the segment.
74  GA_AttributeRefMap bindAttributeHandle(int segment);
75 
76  /// Extract the attribute values from the vertices, creating GT data arrays
77  /// for the attribute data.
78  /// This fills out the data arrays on the attribute list handle
79  void extractVertices(int segment,
80  const GA_AttributeRefMap &hlist,
81  const GA_Offset *vertices,
82  GA_Size nvertices);
83 
84  /// Fill attributes for a curve
85  void fillCurveVertices(int segment,
86  const GEO_Curve *curve,
87  const UT_FloatArray &uvals);
88 
89  /// Set the N attribute for vertices. This should only be called if @c
90  /// user_defined_N was set in the constructor. It must be called @b after
91  /// @c extractVertices.
92  void setN(int segment,
93  const UT_Vector3 *N,
94  GA_Size nvertices);
95 
96 private:
97  bool addAttribute(GT_AttributeMap &map,
98  const GA_Attribute *attrib);
99  void addAttributes(GT_AttributeMap &map,
100  const GA_AttributeDict &dict,
101  const GT_GEOAttributeFilter &filter);
102  const GA_Attribute *getDetailAttribute(const GA_Detail *gdp, int idx);
103 
104  const GT_GEOPrimitive *myPrimitive;
105  GT_AttributeListHandle myGTAttributes;
106  UT_ValArray<const GA_Attribute *> myGAAttributes;
107  UT_IntArray myGTOffsets;
108  int myPSize;
109  int myNOffset;
110  bool myUserN;
111 };
112 
113 #endif
Base class for many of the GEO_Primitive objects.
Definition of a geometry attribute.
Definition: GA_Attribute.h:198
A symbol table for attribute data.
Class to filter attributes when building GT_AttributeLists.
#define GT_API
Definition: GT_API.h:13
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:235
A string map of attributes to ease backward compatibility In the GB/GEO/GU library code would often p...
GA_Size GA_Offset
Definition: GA_Types.h:641
A handle to simplify manipulation of multiple attributes.
const GT_AttributeListHandle & getGTAttributes() const
Get the attribute handle.
GA_API const UT_StringHolder N
Container class for all geometry.
Definition: GA_Detail.h:96
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glcorearb.h:1297