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  }
35  const GT_AttributeListHandle &vertex,
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,
50  const GT_AttributeListHandle &vertex,
51  const GT_AttributeListHandle &uniform,
52  const GT_AttributeListHandle &detail)
53  {
54  init(basis, nu, uwrap, nv, vwrap, vertex, uniform, detail);
55  }
56  virtual ~GT_PrimPatch();
57 
58  virtual const char *className() const { return "GT_PrimPatch"; }
59  virtual bool save(UT_JSONWriter &w) const;
60 
61  /// @{
62  /// Methods defined on GT_Primitive
63  virtual void enlargeBounds(UT_BoundingBox boxes[],
64  int nsegments) const;
65  virtual int getPrimitiveType() const;
66  virtual bool refine(GT_Refine &refiner,
67  const GT_RefineParms *parms) const;
68  virtual int getMotionSegments() const;
69  virtual int64 getMemoryUsage() const;
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,
86  const GT_AttributeListHandle &vertex,
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,
95  const GT_AttributeListHandle &vertex,
96  const GT_AttributeListHandle &detail);
97  static GT_PrimitiveHandle makePatchCols(GT_Basis basis,
98  int nu, bool uwrap,
99  int nv, bool vwrap,
100  const GT_AttributeListHandle &vertex,
101  const GT_AttributeListHandle &detail);
102  static GT_PrimitiveHandle makePatchRowsCols(GT_Basis basis,
103  int nu, bool uwrap,
104  int nv, bool vwrap,
105  const GT_AttributeListHandle &vertex,
106  const GT_AttributeListHandle &detail);
107  static GT_PrimitiveHandle makePatchTriangles(
108  int nu, bool uwrap,
109  int nv, bool vwrap,
110  const GT_AttributeListHandle &vertex,
111  const GT_AttributeListHandle &detail);
112  static GT_PrimitiveHandle makePatchAlternatingTriangles(
113  int nu, bool uwrap,
114  int nv, bool vwrap,
115  const GT_AttributeListHandle &vertex,
116  const GT_AttributeListHandle &detail);
117  static GT_PrimitiveHandle makePatchReverseTriangles(
118  int nu, bool uwrap,
119  int nv, bool vwrap,
120  const GT_AttributeListHandle &vertex,
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  virtual GT_PrimitiveHandle doHarden() const;
141  { return new GT_PrimPatch(*this); }
142 
143  /// The virtual implementation of attribute merging
145  const UT_StringMMPattern *vertex,
146  const UT_StringMMPattern *point,
147  const UT_StringMMPattern *uniform,
148  const UT_StringMMPattern *detail) const;
149 
150  /// @{
151  /// Access attributes
153  { return myVertex; }
155  { return myUniform; }
157  { return myDetail; }
158  /// @}
159 
160  /// Refine to a single polygon mesh.
161  bool refineToPolyMesh(GT_Refine &refine,
162  const GT_RefineParms *parms=NULL) const;
163 private:
164  GT_AttributeListHandle myVertex;
165  GT_AttributeListHandle myUniform;
166  GT_AttributeListHandle myDetail;
167  int myNu, myNv;
169  bool myUWrap, myVWrap;
170 };
171 
172 #endif
virtual int getMotionSegments() const =0
virtual const char * className() const
Definition: GT_PrimPatch.h:58
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
virtual const GT_AttributeListHandle & getDetailAttributes() const
Definition: GT_PrimPatch.h:156
virtual GT_PrimitiveHandle doSoftCopy() const
Definition: GT_PrimPatch.h:140
int getNvWrapped() const
Definition: GT_PrimPatch.h:135
#define GT_API
Definition: GT_API.h:11
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:32
long long int64
Definition: SYS_Types.h:107
virtual const GT_AttributeListHandle & getVertexAttributes() const
Definition: GT_PrimPatch.h:152
GT_PrimPatch(const GT_PrimPatch &src)
Definition: GT_PrimPatch.h:22
GT_PrimPatch(const GT_PrimPatch &src, const GT_AttributeListHandle &vertex, const GT_AttributeListHandle &uniform, const GT_AttributeListHandle &detail)
Definition: GT_PrimPatch.h:34
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 const GT_AttributeListHandle & getUniformAttributes() const
Definition: GT_PrimPatch.h:154
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:856
GT_Basis
Definition: GT_Types.h:52
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
virtual void enlargeBounds(UT_BoundingBox boxes[], int nsegments) const =0
bool getVWrap() const
Definition: GT_PrimPatch.h:130
const GT_AttributeListHandle & getUniform() const
Definition: GT_PrimPatch.h:132
GLenum src
Definition: glcorearb.h:1792