HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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  ~GT_PrimNuPatch() override;
56 
57  /// @{
58  /// Methods defined on GT_Primitive
59  const char *className() const override { return "GT_PrimNuPatch"; }
60  bool save(UT_JSONWriter &w) const override;
61 
62  void enlargeBounds(UT_BoundingBox boxes[],
63  int nsegments) const override;
64  int getPrimitiveType() const override;
65  bool refine(GT_Refine &refiner,
66  const GT_RefineParms *parms) const override;
67  int getMotionSegments() const override;
68  int64 getMemoryUsage() const override;
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  GT_PrimitiveHandle doHarden() const override;
120 
122  { return new GT_PrimNuPatch(*this); }
123 
124  /// The virtual implementation of attribute merging
126  const GT_Primitive &src,
127  const UT_StringMMPattern *vertex,
128  const UT_StringMMPattern *point,
129  const UT_StringMMPattern *uniform,
130  const UT_StringMMPattern *detail
131  ) const override;
132 
133 protected:
134  void hardenAttributes();
135 
136 private:
137  GT_AttributeListHandle myVertex;
138  GT_AttributeListHandle myDetail;
139  GT_DataArrayHandle myUKnots;
140  GT_DataArrayHandle myVKnots;
141  GT_TrimNuCurves *myTrims;
142  int myUOrder;
143  int myVOrder;
144 };
145 
146 #endif
147 
virtual int getMotionSegments() const =0
GLenum src
Definition: glew.h:2410
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:34
bool isTrimmed() const
Check if trimmed.
GLuint GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint vorder
Definition: glew.h:3448
int getVOrder() const
int getNv() const
int getNu() const
const char * className() const override
GLubyte GLubyte GLubyte GLubyte w
Definition: glew.h:1890
long long int64
Definition: SYS_Types.h:116
The base class for all GT primitive types.
Definition: GT_Primitive.h:43
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
GT_PrimitiveHandle doSoftCopy() const override
const GT_DataArrayHandle & getVKnots() const
const GT_AttributeListHandle & getVertexAttributes() const override
virtual bool save(UT_JSONWriter &w) const
const GT_AttributeListHandle & getDetailAttributes() const override
GLuint GLdouble GLdouble GLint GLint uorder
Definition: glew.h:3448
A simple representation of a NURBS surface.
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