HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_PrimPatchMesh.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_PrimPatchMesh.h ( GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_PrimPatchMesh__
12 #define __GT_PrimPatchMesh__
13 
14 #include "GT_API.h"
15 #include "GT_DataArray.h"
16 #include "GT_CountArray.h"
17 #include "GT_Primitive.h"
18 
19 class GT_PrimPatch;
20 
21 /// A virtual container used by sphere, circle and tube meshes
23 {
24 public:
25  /// Default c-tor
27  : myUMerge(NULL)
28  { }
29 
30  /// Construct a full list of patches. All patches have the same basis.
31  /// For @c npatches, the lengths of each array should be
32  /// - @nu, @uwrap, @nv, @vwrap @n
33  /// @c npatches (i.e. one for each patch)
34  /// - @vertex @n
35  /// One for each vertex in each patch. That is sum(nu*nv)
36  /// - @uniform @n
37  /// One for each patch. There is currently no way to specify an
38  /// attribute per-face for each patch in the patch mesh. You can use a
39  /// collection of GT_PrimPatch objects if you need this behaviour.
40  /// - @detail @n
41  /// A single value
43  const GT_DataArrayHandle &nu,
44  const GT_DataArrayHandle &uwrap,
45  const GT_DataArrayHandle &nv,
46  const GT_DataArrayHandle &vwrap,
48  const GT_AttributeListHandle &uniform,
49  const GT_AttributeListHandle &detail)
50  : myUMerge(NULL)
51  {
52  init(basis, nu, uwrap, nv, vwrap, vertex, uniform, detail);
53  }
54 
56  : GT_Primitive(src)
57  , myNu(src.myNu)
58  , myUWrap(src.myUWrap)
59  , myNv(src.myNv)
60  , myVWrap(src.myVWrap)
61  , myVertexOffsets(src.myVertexOffsets)
62  , myVertex(src.myVertex)
63  , myUniform(src.myUniform)
64  , myDetail(src.myDetail)
65  , myUMerge(NULL) // Uniform/Detail merge
66  , myBasis(src.myBasis)
67  {
68  }
71  const GT_AttributeListHandle &uniform,
72  const GT_AttributeListHandle &detail)
73  : myNu(src.myNu)
74  , myUWrap(src.myUWrap)
75  , myNv(src.myNv)
76  , myVWrap(src.myVWrap)
77  , myVertexOffsets(src.myVertexOffsets)
78  , myVertex(vertex)
79  , myUniform(uniform)
80  , myDetail(detail)
81  , myUMerge(NULL) // Uniform/Detail merge
82  , myBasis(src.myBasis)
83  {
84  }
85 
86  ~GT_PrimPatchMesh() override;
87 
88  /// Construct a mesh from a single patch
90 
91  const char *className() const override { return "GT_PrimPatchMesh"; }
92  bool save(UT_JSONWriter &w) const override
93  {
94  jsonWriter j(w, "PatchMesh");
95  return myNu->save(*j) &&
96  myNv->save(*j) &&
97  myUWrap->save(*j) &&
98  myVWrap->save(*j) &&
99  myVertexOffsets.save(*j) &&
100  saveAttributeLists(*j);
101  }
102 
103  /// @{
104  /// Methods defined on GT_Primitive
105  void enlargeBounds(UT_BoundingBox boxes[],
106  int nsegments) const override;
107  int getMotionSegments() const override;
108  int64 getMemoryUsage() const override;
109  bool refine(GT_Refine &refiner,
110  const GT_RefineParms *parms) const override;
111 
112  int getPrimitiveType() const override;
113  /// @}
114 
115  /// Initialize the quadric mesh
116  bool init(GT_Basis basis,
117  const GT_DataArrayHandle &nu,
118  const GT_DataArrayHandle &uwrap,
119  const GT_DataArrayHandle &nv,
120  const GT_DataArrayHandle &vwrap,
122  const GT_AttributeListHandle &uniform,
123  const GT_AttributeListHandle &detail);
124 
125  /// @{
126  /// Accessors
128  { return myNu ? myNu->entries():0; }
130  { return myBasis; }
131  const GT_DataArrayHandle &getNu() const
132  { return myNu; }
134  { return myUWrap; }
135  const GT_DataArrayHandle &getNv() const
136  { return myNv; }
138  { return myVWrap; }
140  { return myVertex; }
142  { return myUniform; }
144  { return myDetail; }
145  /// @}
146 
147  /// @{
148  /// Access attributes
150  { return myVertex; }
152  { return myUniform; }
154  { return myDetail; }
155  /// @}
156 
157  /// Construct a single patch
158  GT_PrimitiveHandle makePatch(exint patch,
159  const GT_RefineParms *parms) const;
160 
161  /// Harden all attributes so there are no dangling dependencies
162  GT_PrimitiveHandle doHarden() const override;
164  { return new GT_PrimPatchMesh(*this); }
165 
166  /// The virtual implementation of attribute merging
168  const GT_Primitive &src,
169  const UT_StringMMPattern *vertex,
170  const UT_StringMMPattern *point,
171  const UT_StringMMPattern *uniform,
172  const UT_StringMMPattern *detail
173  ) const override;
174 protected:
175  void makeMergeMap();
176 
185  GT_AttributeMerge *myUMerge; // Uniform/Detail merge
187 };
188 
189 #endif
SIM_API const UT_StringHolder vertex
virtual int getMotionSegments() const =0
Keep track of merging of attribute maps.
GT_PrimPatchMesh(const GT_PrimPatchMesh &src, const GT_AttributeListHandle &vertex, const GT_AttributeListHandle &uniform, const GT_AttributeListHandle &detail)
GT_Size getPatchCount() const
virtual bool refine(GT_Refine &refiner, const GT_RefineParms *parms=NULL) const
GT_AttributeListHandle myUniform
A virtual container used by sphere, circle and tube meshes.
bool save(UT_JSONWriter &w) const override
virtual int getPrimitiveType() const
A mesh of linear or cubic patches.
Definition: GT_PrimPatch.h:18
#define GT_API
Definition: GT_API.h:13
int64 exint
Definition: SYS_Types.h:125
GT_Basis getBasis() const
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:37
GLdouble GLdouble GLdouble q
Definition: glad.h:2445
const GT_DataArrayHandle & getUWrap() const
const char * className() const override
GT_AttributeMerge * myUMerge
GT_PrimPatchMesh()
Default c-tor.
GT_PrimitiveHandle doSoftCopy() const override
GT_DataArrayHandle myNu
const GT_AttributeListHandle & getVertexAttributes() const override
const GT_AttributeListHandle & getDetailAttributes() const override
GT_CountArray myVertexOffsets
long long int64
Definition: SYS_Types.h:116
GT_PrimPatchMesh(const GT_PrimPatchMesh &src)
const GT_DataArrayHandle & getNu() const
The base class for all GT primitive types.
Definition: GT_Primitive.h:43
virtual GT_PrimitiveHandle doHarden() const
virtual int64 getMemoryUsage() const =0
Processes primitives generated by refinement process.
Definition: GT_Refine.h:20
GLint j
Definition: glad.h:2733
int64 GT_Size
Definition: GT_Types.h:128
const GT_DataArrayHandle & getNv() const
const GT_DataArrayHandle & getVWrap() const
const GT_AttributeListHandle & getDetail() const
GT_DataArrayHandle myNv
GT_Basis myBasis
Definition: GT_CurveEval.h:262
GT_PrimPatchMesh(GT_Basis basis, const GT_DataArrayHandle &nu, const GT_DataArrayHandle &uwrap, const GT_DataArrayHandle &nv, const GT_DataArrayHandle &vwrap, const GT_AttributeListHandle &vertex, const GT_AttributeListHandle &uniform, const GT_AttributeListHandle &detail)
GT_DataArrayHandle myUWrap
bool saveAttributeLists(UT_JSONWriter &w) const
GT_AttributeListHandle myVertex
const GT_AttributeListHandle & getUniform() const
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
const GT_AttributeListHandle & getVertex() const
GT_Basis
Definition: GT_Types.h:55
GT_AttributeListHandle myDetail
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.
virtual void enlargeBounds(UT_BoundingBox boxes[], int nsegments) const =0
const GT_AttributeListHandle & getUniformAttributes() const override
GT_DataArrayHandle myVWrap
GLenum src
Definition: glcorearb.h:1793