HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_PrimPatch.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_PrimPatch.h ( GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_PrimPatch__
12 #define __GT_PrimPatch__
13 
14 #include "GT_API.h"
15 #include "GT_Primitive.h"
16 
17 /// @brief A mesh of linear or cubic patches
19 {
20 public:
21  GT_PrimPatch();
23  : GT_Primitive(src)
24  , myVertex(src.myVertex)
25  , myUniform(src.myUniform)
26  , myDetail(src.myDetail)
27  , myNu(src.myNu)
28  , myNv(src.myNv)
29  , myBasis(src.myBasis)
30  , myUWrap(src.myUWrap)
31  , myVWrap(src.myVWrap)
32  {
33  }
36  const GT_AttributeListHandle &uniform,
37  const GT_AttributeListHandle &detail)
38  : GT_Primitive(src)
39  , myVertex(vertex)
40  , myUniform(uniform)
41  , myDetail(detail)
42  , myNu(src.myNu)
43  , myNv(src.myNv)
44  , myBasis(src.myBasis)
45  , myUWrap(src.myUWrap)
46  , myVWrap(src.myVWrap)
47  {
48  }
49  GT_PrimPatch(GT_Basis basis, int nu, bool uwrap, int nv, bool vwrap,
51  const GT_AttributeListHandle &uniform,
52  const GT_AttributeListHandle &detail)
53  {
54  init(basis, nu, uwrap, nv, vwrap, vertex, uniform, detail);
55  }
56  ~GT_PrimPatch() override;
57 
58  const char *className() const override { return "GT_PrimPatch"; }
59  bool save(UT_JSONWriter &w) const override;
60 
61  /// @{
62  /// Methods defined on GT_Primitive
63  void enlargeBounds(UT_BoundingBox boxes[],
64  int nsegments) const override;
65  int getPrimitiveType() const override;
66  bool refine(GT_Refine &refiner,
67  const GT_RefineParms *parms) const override;
68  int getMotionSegments() const override;
69  int64 getMemoryUsage() const override;
70  /// @}
71 
72  /// Construct a simple patch:
73  /// - @c nu @n Number of columns
74  /// - @c nv @n Number of rows
75  /// - @c uwrap @n
76  /// Whether the patch is connected between the last and first columns.
77  /// - @c vwrap @n
78  /// Whether the patch is connected between the last and first rows.
79  /// - @c vertex @n Attribute data per vertex (nu * nv elements)
80  /// - @c uniform @n Uniform values for patch faces. The number of
81  /// entries should be:
82  /// - Linear: (nu + uwrapped - 1) * (nv + vwrapped - 1)
83  bool init(GT_Basis basis,
84  int nu, bool uwrap,
85  int nv, bool vwrap,
87  const GT_AttributeListHandle &uniform,
88  const GT_AttributeListHandle &detail);
89 
90  /// @{
91  /// Construct a curve mesh from a patch of vertices
92  static GT_PrimitiveHandle makePatchRows(GT_Basis basis,
93  int nu, bool uwrap,
94  int nv, bool vwrap,
96  const GT_AttributeListHandle &detail);
97  static GT_PrimitiveHandle makePatchCols(GT_Basis basis,
98  int nu, bool uwrap,
99  int nv, bool vwrap,
101  const GT_AttributeListHandle &detail);
102  static GT_PrimitiveHandle makePatchRowsCols(GT_Basis basis,
103  int nu, bool uwrap,
104  int nv, bool vwrap,
106  const GT_AttributeListHandle &detail);
107  static GT_PrimitiveHandle makePatchTriangles(
108  int nu, bool uwrap,
109  int nv, bool vwrap,
111  const GT_AttributeListHandle &detail);
112  static GT_PrimitiveHandle makePatchAlternatingTriangles(
113  int nu, bool uwrap,
114  int nv, bool vwrap,
116  const GT_AttributeListHandle &detail);
117  static GT_PrimitiveHandle makePatchReverseTriangles(
118  int nu, bool uwrap,
119  int nv, bool vwrap,
121  const GT_AttributeListHandle &detail);
122  /// @}
123 
124  /// @{
125  /// Accessor
126  GT_Basis getBasis() const { return myBasis; }
127  int getNu() const { return myNu; }
128  int getNv() const { return myNv; }
129  bool getUWrap() const { return myUWrap; }
130  bool getVWrap() const { return myVWrap; }
131  const GT_AttributeListHandle &getVertex() const { return myVertex; }
132  const GT_AttributeListHandle &getUniform() const { return myUniform; }
133  const GT_AttributeListHandle &getDetail() const { return myDetail; }
134  int getNuWrapped() const { return myUWrap ? myNu+1 : myNu; }
135  int getNvWrapped() const { return myVWrap ? myNv+1 : myNv; }
136  /// @}
137 
138  /// Harden all attributes so there are no dangling dependencies
139  GT_PrimitiveHandle doHarden() const override;
141  { return new GT_PrimPatch(*this); }
142 
143  /// The virtual implementation of attribute merging
145  const GT_Primitive &src,
146  const UT_StringMMPattern *vertex,
147  const UT_StringMMPattern *point,
148  const UT_StringMMPattern *uniform,
149  const UT_StringMMPattern *detail
150  ) const override;
151 
152  /// @{
153  /// Access attributes
155  { return myVertex; }
157  { return myUniform; }
159  { return myDetail; }
160  /// @}
161 
162  /// Refine to a single polygon mesh.
163  bool refineToPolyMesh(GT_Refine &refine,
164  const GT_RefineParms *parms=NULL) const;
165 private:
166  GT_AttributeListHandle myVertex;
167  GT_AttributeListHandle myUniform;
168  GT_AttributeListHandle myDetail;
169  int myNu, myNv;
171  bool myUWrap, myVWrap;
172 };
173 
174 #endif
SIM_API const UT_StringHolder vertex
virtual int getMotionSegments() const =0
int getNu() const
Definition: GT_PrimPatch.h:127
virtual bool refine(GT_Refine &refiner, const GT_RefineParms *parms=NULL) const
virtual int getPrimitiveType() const
A mesh of linear or cubic patches.
Definition: GT_PrimPatch.h:18
int getNvWrapped() const
Definition: GT_PrimPatch.h:135
const GT_AttributeListHandle & getUniformAttributes() const override
Definition: GT_PrimPatch.h:156
#define GT_API
Definition: GT_API.h:13
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:37
const GT_AttributeListHandle & getVertexAttributes() const override
Definition: GT_PrimPatch.h:154
GT_PrimPatch(const GT_PrimPatch &src)
Definition: GT_PrimPatch.h:22
long long int64
Definition: SYS_Types.h:116
GT_PrimPatch(const GT_PrimPatch &src, const GT_AttributeListHandle &vertex, const GT_AttributeListHandle &uniform, const GT_AttributeListHandle &detail)
Definition: GT_PrimPatch.h:34
GT_PrimitiveHandle doSoftCopy() const override
Definition: GT_PrimPatch.h:140
The base class for all GT primitive types.
Definition: GT_Primitive.h:43
int getNuWrapped() const
Definition: GT_PrimPatch.h:134
virtual GT_PrimitiveHandle doHarden() const
virtual int64 getMemoryUsage() const =0
Processes primitives generated by refinement process.
Definition: GT_Refine.h:20
GT_Basis myBasis
Definition: GT_CurveEval.h:262
bool getUWrap() const
Definition: GT_PrimPatch.h:129
GT_PrimPatch(GT_Basis basis, int nu, bool uwrap, int nv, bool vwrap, const GT_AttributeListHandle &vertex, const GT_AttributeListHandle &uniform, const GT_AttributeListHandle &detail)
Definition: GT_PrimPatch.h:49
GT_Basis getBasis() const
Definition: GT_PrimPatch.h:126
const GT_AttributeListHandle & getDetail() const
Definition: GT_PrimPatch.h:133
virtual bool save(UT_JSONWriter &w) const
int getNv() const
Definition: GT_PrimPatch.h:128
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
GT_Basis
Definition: GT_Types.h:55
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.
const GT_AttributeListHandle & getVertex() const
Definition: GT_PrimPatch.h:131
const GT_AttributeListHandle & getDetailAttributes() const override
Definition: GT_PrimPatch.h:158
virtual void enlargeBounds(UT_BoundingBox boxes[], int nsegments) const =0
bool getVWrap() const
Definition: GT_PrimPatch.h:130
const char * className() const override
Definition: GT_PrimPatch.h:58
const GT_AttributeListHandle & getUniform() const
Definition: GT_PrimPatch.h:132
GLenum src
Definition: glcorearb.h:1793