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,
47  const GT_AttributeListHandle &vertex,
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  }
70  const GT_AttributeListHandle &vertex,
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  virtual ~GT_PrimPatchMesh();
87 
88  /// Construct a mesh from a single patch
90 
91  virtual const char *className() const { return "GT_PrimPatchMesh"; }
92  virtual bool save(UT_JSONWriter &w) const
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  virtual void enlargeBounds(UT_BoundingBox boxes[],
106  int nsegments) const;
107  virtual int getMotionSegments() const;
108  virtual int64 getMemoryUsage() const;
109  virtual bool refine(GT_Refine &refiner,
110  const GT_RefineParms *parms) const;
111 
112  virtual int getPrimitiveType() const;
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,
121  const GT_AttributeListHandle &vertex,
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  virtual GT_PrimitiveHandle doHarden() const;
164  { return new GT_PrimPatchMesh(*this); }
165 
166  /// The virtual implementation of attribute merging
168  const UT_StringMMPattern *vertex,
169  const UT_StringMMPattern *point,
170  const UT_StringMMPattern *uniform,
171  const UT_StringMMPattern *detail) const;
172 protected:
173  void makeMergeMap();
174 
183  GT_AttributeMerge *myUMerge; // Uniform/Detail merge
185 };
186 
187 #endif
virtual bool save(UT_JSONWriter &w) const
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.
virtual int getPrimitiveType() const
A mesh of linear or cubic patches.
Definition: GT_PrimPatch.h:18
virtual GT_PrimitiveHandle doSoftCopy() const
#define GT_API
Definition: GT_API.h:11
GT_Basis getBasis() const
virtual const GT_AttributeListHandle & getVertexAttributes() const
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:32
const GT_DataArrayHandle & getUWrap() const
GT_AttributeMerge * myUMerge
GT_PrimPatchMesh()
Default c-tor.
GT_DataArrayHandle myNu
long long int64
Definition: SYS_Types.h:107
int64 exint
Definition: SYS_Types.h:116
GT_CountArray myVertexOffsets
GT_PrimPatchMesh(const GT_PrimPatchMesh &src)
const GT_DataArrayHandle & getNu() const
virtual const GT_AttributeListHandle & getDetailAttributes() 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
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:856
const GT_AttributeListHandle & getVertex() const
GT_Basis
Definition: GT_Types.h:52
GT_AttributeListHandle myDetail
virtual const GT_AttributeListHandle & getUniformAttributes() const
int64 GT_Size
Definition: GT_Types.h:112
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 const char * className() const
virtual void enlargeBounds(UT_BoundingBox boxes[], int nsegments) const =0
GT_DataArrayHandle myVWrap
GLenum src
Definition: glcorearb.h:1792