HDK
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  *
9  */
10
11 #ifndef __GT_PrimNuPatch__
12 #define __GT_PrimNuPatch__
13
14 #include "GT_API.h"
15 #include "GT_Primitive.h"
16
17 #include <UT/UT_UniquePtr.h>
18
19 class GT_TrimNuCurves;
20
21 /// @brief A simple representation of a NURBS surface
22 ///
23 /// The NURBS patch attributes are specified by a hull/mesh of control vertices
24 /// and a constant attribute for the entire patch.
25 ///
26 /// Given a patch with:
27 /// - @c uorder = The order in the U direction
28 /// - @c uknots = The U knot vector (with length given by @c ulen)
29 /// - @c vorder = The order in the V direction
30 /// - @c vknots = The V knot vector (with length given by @c vlen)
31 /// The number of control vertices is given by: @code
32 /// nu = len(uknots) - uorder
33 /// nv = len(vknots) - vorder
34 /// nvertices = nu * nv
35 /// @endcode
36 ///
37 /// When specifying rational NURBS patches, the "P" attribute should always be
38 /// specified as the non-homogeneous 3-tuple coordinates. An optional "Pw"
39 /// float array can be specified, and if it exists, the homogeneous positions
40 /// will be defined as @code:
41 /// P = (x,y,z)
42 /// Pw = (w)
43 /// P' = (w*x, w*y, w*z, w)
44 /// @endcode
46 {
47 public:
50  GT_PrimNuPatch(const GT_PrimNuPatch &src,
52  const GT_AttributeListHandle &detail);
53  GT_PrimNuPatch(int uorder, const GT_DataArrayHandle &uknots,
54  int vorder, const GT_DataArrayHandle &vknots,
55  const GT_AttributeListHandle &vertex,
56  const GT_AttributeListHandle &detail);
57  ~GT_PrimNuPatch() override;
58
59  /// @{
60  /// Methods defined on GT_Primitive
61  const char *className() const override { return "GT_PrimNuPatch"; }
62  bool save(UT_JSONWriter &w) const override;
63
64  void enlargeBounds(UT_BoundingBox boxes[],
65  int nsegments) const override;
66  int getPrimitiveType() const override;
67  bool refine(GT_Refine &refiner,
68  const GT_RefineParms *parms) const override;
69  int getMotionSegments() const override;
70  int64 getMemoryUsage() const override;
71  /// @}
72
73
74  /// @{
75  /// Accessor
76  int getNu() const { return myUKnots->entries() - myUOrder; }
77  int getNv() const { return myVKnots->entries() - myVOrder; }
78  int getUOrder() const { return myUOrder; }
79  int getVOrder() const { return myVOrder; }
80  const GT_DataArrayHandle &getUKnots() const { return myUKnots; }
81  const GT_DataArrayHandle &getVKnots() const { return myVKnots; }
83  { return myVertex; }
85  { return myDetail; }
86  /// @}
87
88  /// Check if trimmed
89  bool isTrimmed() const { return myTrims != NULL; }
90
91  /// Get trim curves
93  { return myTrims.get(); }
94  /// Set trim curves. Ownership of the curves is @b not assumed by the patch
95  void copyTrimCurves(const GT_TrimNuCurves *curves);
96  /// Set trim curves, adopting ownership of the trim curves passed in
97  void setTrimCurves(
99
100  /// Houdini stores it's vertices in row-major order. This is not the case
101  /// for all software. This method will transpose the vertex into
102  /// column-major order. This operation is reversible by calling it
103  /// multiple times.
104  GT_PrimitiveHandle transposeVertex() const;
105
106  /// Reverses U for the surface.
107  UT_IntrusivePtr<GT_PrimNuPatch> reverseU() const;
108
109  /// @{
112  { return myVertex; }
114  { return myDetail; }
115  /// @}
116
117  /// Build the hull of the primitive
118  GT_PrimitiveHandle buildHull(bool copy_xform = true) const;
119
120  /// Refine to a polygonal surface
121  GT_PrimitiveHandle buildSurface(const GT_RefineParms *parms,
122  bool copy_xform = true) const;
123
124  /// Harden all attributes and arrays
125  GT_PrimitiveHandle doHarden() const override;
126
128  { return new GT_PrimNuPatch(*this); }
129
130  /// The virtual implementation of attribute merging
132  const GT_Primitive &src,
133  const UT_StringMMPattern *vertex,
134  const UT_StringMMPattern *point,
135  const UT_StringMMPattern *uniform,
136  const UT_StringMMPattern *detail
137  ) const override;
138
139 protected:
140  void hardenAttributes();
141
142 private:
143  GT_AttributeListHandle myVertex;
144  GT_AttributeListHandle myDetail;
145  GT_DataArrayHandle myUKnots;
146  GT_DataArrayHandle myVKnots;
148  int myUOrder;
149  int myVOrder;
150 };
151
152 #endif
153
SIM_API const UT_StringHolder vertex
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
GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint vorder
int getUOrder() const
#define GT_API
Definition: GT_API.h:13
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:37
bool isTrimmed() const
Check if trimmed.
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
int getVOrder() const
int getNv() const
int getNu() const
const char * className() const override
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
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
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
GLdouble GLdouble GLint GLint uorder