HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GT_PrimNuPatch.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_PrimNuPatch.h ( GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_PrimNuPatch__
12 #define __GT_PrimNuPatch__
13 
14 #include "GT_API.h"
15 #include "GT_Primitive.h"
16 
17 class GT_TrimNuCurves;
18 
19 /// @brief A simple representation of a NURBS surface
20 ///
21 /// The NURBS patch attributes are specified by a hull/mesh of control vertices
22 /// and a constant attribute for the entire patch.
23 ///
24 /// Given a patch with:
25 /// - @c uorder = The order in the U direction
26 /// - @c uknots = The U knot vector (with length given by @c ulen)
27 /// - @c vorder = The order in the V direction
28 /// - @c vknots = The V knot vector (with length given by @c vlen)
29 /// The number of control vertices is given by: @code
30 /// nu = len(uknots) - uorder
31 /// nv = len(vknots) - vorder
32 /// nvertices = nu * nv
33 /// @endcode
34 ///
35 /// When specifying rational NURBS patches, the "P" attribute should always be
36 /// specified as the non-homogeneous 3-tuple coordinates. An optional "Pw"
37 /// float array can be specified, and if it exists, the homogeneous positions
38 /// will be defined as @code:
39 /// P = (x,y,z)
40 /// Pw = (w)
41 /// P' = (w*x, w*y, w*z, w)
42 /// @endcode
44 {
45 public:
48  GT_PrimNuPatch(const GT_PrimNuPatch &src,
49  const GT_AttributeListHandle &vertex,
50  const GT_AttributeListHandle &detail);
51  GT_PrimNuPatch(int uorder, const GT_DataArrayHandle &uknots,
52  int vorder, const GT_DataArrayHandle &vknots,
53  const GT_AttributeListHandle &vertex,
54  const GT_AttributeListHandle &detail);
55  virtual ~GT_PrimNuPatch();
56 
57  /// @{
58  /// Methods defined on GT_Primitive
59  virtual const char *className() const { return "GT_PrimNuPatch"; }
60  virtual bool save(UT_JSONWriter &w) const;
61 
62  virtual void enlargeBounds(UT_BoundingBox boxes[],
63  int nsegments) const;
64  virtual int getPrimitiveType() const;
65  virtual bool refine(GT_Refine &refiner,
66  const GT_RefineParms *parms) const;
67  virtual int getMotionSegments() const;
68  virtual int64 getMemoryUsage() const;
69  /// @}
70 
71 
72  /// @{
73  /// Accessor
74  int getNu() const { return myUKnots->entries() - myUOrder; }
75  int getNv() const { return myVKnots->entries() - myVOrder; }
76  int getUOrder() const { return myUOrder; }
77  int getVOrder() const { return myVOrder; }
78  const GT_DataArrayHandle &getUKnots() const { return myUKnots; }
79  const GT_DataArrayHandle &getVKnots() const { return myVKnots; }
81  { return myVertex; }
83  { return myDetail; }
84  /// @}
85 
86  /// Check if trimmed
87  bool isTrimmed() const { return myTrims != NULL; }
88 
89  /// Get trim curves
91  { return myTrims; }
92  /// Set trim curves. Ownership of the curves is @b not assumed by the patch
93  void setTrimCurves(const GT_TrimNuCurves *curves);
94  /// Set trim curves, adopting ownership of the trim curves passed in
95  void adoptTrimCurves(GT_TrimNuCurves *curves);
96 
97  /// Houdini stores it's vertices in row-major order. This is not the case
98  /// for all software. This method will transpose the vertex into
99  /// column-major order. This operation is reversible by calling it
100  /// multiple times.
101  GT_PrimitiveHandle transposeVertex() const;
102 
103  /// @{
104  /// Virtual access to attributes
106  { return myVertex; }
108  { return myDetail; }
109  /// @}
110 
111  /// Build the hull of the primitive
112  GT_PrimitiveHandle buildHull(bool copy_xform = true) const;
113 
114  /// Refine to a polygonal surface
115  GT_PrimitiveHandle buildSurface(const GT_RefineParms *parms,
116  bool copy_xform = true) const;
117 
118  /// Harden all attributes and arrays
119  virtual GT_PrimitiveHandle doHarden() const;
120 
122  { return new GT_PrimNuPatch(*this); }
123 
124  /// The virtual implementation of attribute merging
126  const UT_StringMMPattern *vertex,
127  const UT_StringMMPattern *point,
128  const UT_StringMMPattern *uniform,
129  const UT_StringMMPattern *detail) const;
130 
131 protected:
132  void hardenAttributes();
133 
134 private:
135  GT_AttributeListHandle myVertex;
136  GT_AttributeListHandle myDetail;
137  GT_DataArrayHandle myUKnots;
138  GT_DataArrayHandle myVKnots;
139  GT_TrimNuCurves *myTrims;
140  int myUOrder;
141  int myVOrder;
142 };
143 
144 #endif
145 
virtual int getMotionSegments() const =0
virtual bool refine(GT_Refine &refiner, const GT_RefineParms *parms=NULL) const
virtual int getPrimitiveType() const
const GT_AttributeListHandle & getVertex() const
int getUOrder() const
#define GT_API
Definition: GT_API.h:11
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:32
bool isTrimmed() const
Check if trimmed.
long long int64
Definition: SYS_Types.h:106
int getVOrder() const
int getNv() const
int getNu() const
The base class for all GT primitive types.
Definition: GT_Primitive.h:41
virtual GT_PrimitiveHandle doHarden() const
const GT_TrimNuCurves * getTrimCurves() const
Get trim curves.
virtual int64 getMemoryUsage() const =0
const GT_DataArrayHandle & getUKnots() const
Processes primitives generated by refinement process.
Definition: GT_Refine.h:20
const GT_DataArrayHandle & getVKnots() const
virtual const GT_AttributeListHandle & getVertexAttributes() const
virtual const GT_AttributeListHandle & getDetailAttributes() const
virtual bool save(UT_JSONWriter &w) const
virtual const char * className() const
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
A simple representation of a NURBS surface.
virtual GT_PrimitiveHandle doSoftCopy() const
virtual GT_PrimitiveHandle doAttributeMerge(const GT_Primitive &src, const UT_StringMMPattern *vertex, const UT_StringMMPattern *point, const UT_StringMMPattern *uniform, const UT_StringMMPattern *detail) const
The virtual implementation of attribute merging.
Trim loops specified by a number of individual NURBS curves.
virtual void enlargeBounds(UT_BoundingBox boxes[], int nsegments) const =0
const GT_AttributeListHandle & getDetail() const
GLenum src
Definition: glcorearb.h:1792