HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GT_OSD3.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_OSD3.h (GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_OSD3__
12 #define __GT_OSD3__
13 
14 #if defined(WIN32)
15  // MSVC does not provide readable alternatives to operators by default
16  // (i.e. && => 'and') so we have to include this header since OpenSubdiv
17  // makes use of some of the alternatives such as 'not', 'and' and 'or'.
18  #include <iso646.h>
19 #endif
20 
21 #include "GT_API.h"
22 #include "GT_Types.h"
23 #include "GT_PrimPolygonMesh.h"
24 #include <opensubdiv/far/primvarRefiner.h>
25 #include <opensubdiv/far/patchTableFactory.h>
26 #include <opensubdiv/far/patchMap.h>
27 
28 class UT_JSONWriter;
29 
30 /// @file
31 /// This file contains code to support OpenSubdiv 3.x for the GT library
32 /// The code in here is primarily used in GT_UtilOpenSubdiv
33 
34 /// Options for topology and refinement
36 {
37 public:
38  using SdcOptions = OpenSubdiv::Sdc::Options;
39  using VtxBoundaryInterpolation = SdcOptions::VtxBoundaryInterpolation;
40  using FVarLinearInterpolation = SdcOptions::FVarLinearInterpolation;
41  using CreasingMethod = SdcOptions::CreasingMethod;
42  using TriangleSubdivision = SdcOptions::TriangleSubdivision;
43 
45  int level = 2,
46  bool adaptive = false,
47  fpreal crease_override = -1,
48  bool remove_holes = true)
49  : myOptions()
50  , myScheme(scheme)
51  , myCreaseOverride(crease_override)
52  , myLevel(level)
53  , myAdaptive(adaptive)
54  , myRemoveHoles(remove_holes)
55  {
56  // Set default behaviour
57  setVtxBoundaryInterpolation(SdcOptions::VTX_BOUNDARY_EDGE_AND_CORNER);
58  setFVarLinearInterpolation(SdcOptions::FVAR_LINEAR_BOUNDARIES);
59  }
60 
61  const SdcOptions &options() const { return myOptions; }
62  void setOptions(const SdcOptions &o) { myOptions = o; }
63 
64  SYS_HashType hash() const;
65  bool isEqual(const GT_OSDOptions &opts) const;
66  bool operator==(const GT_OSDOptions &s) const
67  { return isEqual(s); }
68  bool operator!=(const GT_OSDOptions &s) const
69  { return !isEqual(s); }
70 
71  // Access this object as it were an OpenSubdiv::Sdc::Options
72  SdcOptions &operator->() { return myOptions; }
73  const SdcOptions &operator->() const { return myOptions; }
74  SdcOptions &operator*() { return myOptions; }
75  const SdcOptions &operator*() const { return myOptions; }
76 
77  GT_Scheme scheme() const { return myScheme; }
78  void setScheme(GT_Scheme t) { myScheme = t; }
79 
80  int level() const { return myLevel; }
81  void setLevel(int l) { myLevel = l; }
82 
83  bool adaptive() const { return myAdaptive; }
84  void setAdaptive(bool b) { myAdaptive = b; }
85 
86  bool removeHoles() const { return myRemoveHoles; }
87  void setRemoveHoles(bool v) { myRemoveHoles = v; }
88 
89  bool enableCreaseOverride() const { return myCreaseOverride >= 0; }
90  fpreal creaseOverride() const { return myCreaseOverride; }
91  void setCreaseOverride(fpreal value=-1) { myCreaseOverride = value; }
92 
93 #define GETSET(TYPE, GET) \
94  TYPE GET() const { return myOptions.Get##TYPE(); } \
95  void set##TYPE(TYPE v) { myOptions.Set##TYPE(v); }
96 
97  /// @{
98  /// Simple wrappers on the SdcOptions
99  GETSET(VtxBoundaryInterpolation, vtxBoundaryInterpolation);
100  GETSET(FVarLinearInterpolation, fvarLinearInterpolation);
101  GETSET(CreasingMethod, creasingMethod);
102  GETSET(TriangleSubdivision, triangleSubdivision);
103  /// @}
104 #undef GETSET
105 
106  void dump() const;
107  void dump(UT_JSONWriter &w) const;
108 
109 private:
110  SdcOptions myOptions;
111  GT_Scheme myScheme;
112  fpreal myCreaseOverride;
113  int myLevel;
114  bool myAdaptive;
115  bool myRemoveHoles;
116 };
117 
118 /// Options for setting up limit surface evaluation.
120 {
121 public:
122  using FactoryOptions = OpenSubdiv::Far::PatchTableFactory::Options;
123 
125  : myOptions()
126  {
127  }
128 
129  void dump() const;
130  void dump(UT_JSONWriter &w) const;
131 
132  FactoryOptions &operator*() { return myOptions; }
133  const FactoryOptions &operator*() const { return myOptions; }
134 
135  FactoryOptions::EndCapType endCapType() const
136  { return (FactoryOptions::EndCapType)myOptions.endCapType; }
137  bool generateAllLevels() const
138  { return myOptions.generateAllLevels; }
139  bool triangulateQuads() const
140  { return myOptions.triangulateQuads; }
141  bool useSingleCreasePatch() const
142  { return myOptions.useSingleCreasePatch; }
143  int maxIsolationLevel() const
144  { return myOptions.maxIsolationLevel; }
146  { return myOptions.shareEndCapPatchPoints; }
147  bool generateFVarTables() const
148  { return myOptions.generateFVarTables; }
149  int numFVarChannels() const
150  { return myOptions.numFVarChannels; }
151  const int *fvarChannelIndices() const
152  { return myOptions.fvarChannelIndices; }
153 
154  void setEndCapType(FactoryOptions::EndCapType t)
155  { myOptions.endCapType = (FactoryOptions::EndCapType)t; }
157  { myOptions.generateAllLevels = v; }
159  { myOptions.triangulateQuads = v; }
161  { myOptions.useSingleCreasePatch = v; }
163  { myOptions.maxIsolationLevel = v; }
165  { myOptions.shareEndCapPatchPoints = v; }
167  { myOptions.generateFVarTables = v; }
169  { myOptions.numFVarChannels = n; }
171  { myOptions.fvarChannelIndices = indices; }
172 private:
173  FactoryOptions myOptions;
174 };
175 
176 /// Topology definition for opensubdiv classes
178 {
179 public:
180  using TopologyRefiner = OpenSubdiv::Far::TopologyRefiner;
181  using LevelInfo = OpenSubdiv::Far::TopologyLevel;
182 
183  /// This class stores a definition of the mesh & topology. It can be used
184  /// to determine whether the mesh can be updated with new attribute values.
186  {
187  public:
189  const GT_OSDOptions &options);
190 
191  bool isValid() const { return myPointCount > 0; }
192 
193  bool matchesTopology(const MeshDescriptor &other) const;
194  bool matchesAttributes(const MeshDescriptor &other) const;
195 
196  private:
197  GT_Size myPointCount;
198  GT_CountArray myFaceCounts;
199  GT_DataArrayHandle myVertexList;
200  GT_AttributeMapHandle myPointAttribs;
201  GT_AttributeMapHandle myVertexAttribs;
202  GT_DataArrayHandle myCreaseIndices;
203  GT_DataArrayHandle myCreaseWeights;
204  GT_DataArrayHandle myCornerIndices;
205  GT_DataArrayHandle myCornerWeights;
206  GT_DataArrayHandle myHoleIndices;
207  fpreal myCreaseOverride;
208  };
209 
210  GT_OSDTopology();
211  ~GT_OSDTopology();
212 
213  /// @{
214  /// Debug - dump the topology out
215  void dump() const;
216  void dump(UT_JSONWriter &w) const;
217  /// @}
218 
219  /// Create the topology for the given polygonal hull and options. Note
220  /// that if the mesh is a GT_PrimSubdivisionMesh, crease weights will be
221  /// picked up from the tags on the primitive.
222  bool create(const GT_PrimPolygonMesh &mesh,
223  const GT_OSDOptions &options);
224 
225  /// Number of levels in refinement (note this is the max level + 1)
227  { return myRefiner->GetNumLevels(); }
228 
229  /// Access to the level information for a given refinement level
230  /// This returns the number of vertices, face-varying vertices, faces, etc.
231  /// for each level. Level 0 is the "coarse" mesh.
232  /// - GetNumVertices() - Number of shared points (i.e. Houdini points)
233  /// - GetNumFaces() - Number of faces
234  /// - GetNumEdges() - Number of edges
235  /// - GetNumFaceVertices() - Number of face varying (i.e. Houdini vertices)
236  const LevelInfo &levelInfo(int level) const
237  { return myRefiner->GetLevel(level); }
238  const LevelInfo &lastLevel() const
239  { return levelInfo(myRefiner->GetNumLevels()-1); }
240 
241 
242  /// @{
243  /// Return specific information about the coarse mesh (i.e. level 0)
245  { return levelInfo(0).GetNumFaces(); }
247  { return levelInfo(0).GetNumVertices(); }
249  { return levelInfo(0).GetNumFaceVertices(); }
250  GT_Size coarseVertexCount(GT_Size face_index) const;
251  /// @}
252 
253  /// Access to the refiner
254  const TopologyRefiner *refiner() const { return myRefiner; }
255 
256  /// Test whether this has been built for adaptive refinement
257  bool adaptive() const { return myAdaptive; }
258 
259  /// Create a polygon mesh for a given level
260  GT_PrimitiveHandle createMesh(int level,
261  const GT_AttributeListHandle &point,
262  const GT_AttributeListHandle &vertex,
263  const GT_AttributeListHandle &uniform,
264  const GT_AttributeListHandle &detail,
265  const GT_FaceSetMapPtr &fsets=GT_FaceSetMapPtr()) const;
266 private:
267  TopologyRefiner *myRefiner;
268  bool myAdaptive;
269  bool myRemoveHoles;
270 };
271 
272 // Interface to create and look through a patch table
274 {
275 public:
276  using TopologyRefiner = OpenSubdiv::Far::TopologyRefiner;
277  using PatchTable = OpenSubdiv::Far::PatchTable;
278  using PatchTableFactory = OpenSubdiv::Far::PatchTableFactory;
279  using PatchDescriptor = OpenSubdiv::Far::PatchDescriptor;
280  using ConstIndexArray = OpenSubdiv::Far::ConstIndexArray;
281  using PatchParam = OpenSubdiv::Far::PatchParam;
283  using PtexIndices = OpenSubdiv::Far::PtexIndices;
284  using Handle = PatchTable::PatchHandle;
285 
287 
288  bool create(const GT_OSDTopology &top,
289  bool createPtexMap=false);
290 
291  // Array level queries
292  int arrayCount() const;
293  int arrayPatchCount(int arr) const;
294  int numLocalPoints() const;
295  int numLocalPointsVarying() const;
296  ConstIndexArray vertexArray(int arr) const;
297  ConstIndexArray varyingVertexArray(int arr) const;
298  PatchDescriptor arrayPatchDesc(int arr) const;
299  template<typename T>
300  void computeLocalPoints(T *src, T *dest) const
301  {
302  myTable->ComputeLocalPointValues(src, dest);
303  }
304  template<typename T>
305  void computeLocalFVPoints(T *src, T *dest) const
306  {
307  myTable->ComputeLocalPointValuesFaceVarying(src, dest);
308  }
309 
310  // Patch level queries
311  PatchParam patchParam(int arr, int pat) const;
312  ConstIndexArray patchVertices(const Handle &patch) const;
313  ConstIndexArray patchFVValues(const Handle &patch) const;
314  void evaluateBasis(const Handle &patch, float u, float v,
315  float *w, float *du, float *dv) const;
316  void evaluateBasisFV(const Handle &patch, float u, float v,
317  float *w, float *du, float *dv) const;
318 
319  // For ptex queries
320  int numPtexFaces() const;
321  const int *getPtexMap() const { return myPtexMap.array(); };
322  const UT_Array<int> &getPtexArray() const { return myPtexMap; };
323 
324  PatchTable *getTable() const { return myTable.get(); };
325  bool initialized() const { return myTable != nullptr; };
326 
327 private:
328  UT_UniquePtr<PatchTable> myTable;
329  GT_OSDPatchTableOptions myOptions;
330  UT_Array<int> myPtexMap;
331 };
332 
333 /// Storage arrays for vertex data for opensubdiv classes
335 {
336 public:
337  /// Identifier for an attribute. The first item is the index in the
338  /// attribute list, the second is whether it's a vertex or a point
339  /// attribute.
340  using AttribId = std::pair<int, bool>;
341 
343  ~GT_OSDAttributes();
344 
345  void dump() const;
346  void dump(UT_JSONWriter &w )const;
347 
348  bool create(const GT_OSDTopology &topology,
349  const GT_PrimPolygonMesh &mesh,
350  const GT_OSDPatchTable *table=nullptr);
351 
352  bool update(const GT_OSDTopology &topology,
353  const GT_PrimPolygonMesh &mesh,
354  bool skip_equality_check = false);
355 
356  /// Extract a subdivided mesh for the given topology level
357  GT_PrimitiveHandle extractMesh(const GT_OSDTopology &topology,
358  bool harden,
359  int level = -1);
360 
361  /// Extract the shared/point attributes for a mesh at the given refinement
362  /// level. If @c harden is @c false, the attributes lists will point to
363  /// the temporary buffers (which are over-sized). Passing @c true to @c
364  /// harden will copy out the temporary data into compact arrays.
365  GT_AttributeListHandle extractShared(const GT_OSDTopology &top,
366  int level_index,
367  bool harden) const;
368  /// Extract the vertex/face-varying attributes for a mesh at the given
369  /// refinement level. See @c extractShared for help on @c harden
370  GT_AttributeListHandle extractVertex(const GT_OSDTopology &top,
371  int level_index,
372  bool harden) const;
373  /// Extract the primitive/face attributes for a mesh at the given
374  /// refinement level.
375  GT_AttributeListHandle extractUniform(const GT_OSDTopology &top,
376  int level_index,
377  bool harden) const;
378 
379  /// Extract a face map set for a mesh at the given refinement level
380  GT_FaceSetMapPtr extractFaceSets(const GT_OSDTopology &top,
381  int level_index) const;
382 
383  /// Extract a mapping from fine faces at a given refinement level to
384  /// its corresponding coarse face
385  GT_DataArrayHandle extractFaceMap(const GT_OSDTopology &top,
386  int level_index) const;
387 
388  /// @{
389  /// Find an attribute
390  AttribId findAttribute(const char *name) const;
391  AttribId findAttribute(const char *name, bool vertex_attrib) const;
392  /// @}
393 
394  /// Return the size of a given attribute
395  int tupleSize(const AttribId &attrib) const;
396 
397  /// Extract attributes on the coarse mesh
398  bool coarseValues(const AttribId &attrib,
399  const GT_Size *vertices,
400  GT_Size nvtx,
401  UT_Vector2 *values) const;
402 
404  {
405  public:
407  : myAttribs(nullptr)
408  , myArrays(nullptr)
409  , mySizes(nullptr)
410  , myStorage(nullptr)
411  , myPointers(nullptr)
412  , mySize(0)
413  , myReadOnly(true)
414  {
415  }
417  {
418  clear();
419  }
420 
421  int findAttrib(const char *name) const
422  {
423  return myAttribs ? myAttribs->getIndex(name) : -1;
424  }
425 
426  void init(const GT_AttributeListHandle &list, GT_Size size);
427  bool update(const GT_AttributeListHandle &list,
428  bool skip_equality_check = false);
429 
430  void clear()
431  {
432  mySize = 0;
433  delete [] myArrays;
434  delete [] myStorage;
435  delete [] myPointers;
436  delete [] mySizes;
437  myArrays = nullptr;
438  myStorage = nullptr;
439  myPointers = nullptr;
440  mySizes = nullptr;
441  }
442 
443  /// Extract the attributes for a given level. Note that the array
444  /// returned makes reference to the arrays including the temporary
445  /// vertices. Passing @c harden==true will cause the arrays to be
446  /// duplicated (more memory, but more compact)
447  GT_AttributeListHandle extractLevel(const GT_OSDTopology &topology,
448  int level,
449  bool harden,
450  bool fvar) const;
451 
452  /// Raw access to the attributes
453  const GT_AttributeListHandle &attribList() const { return myAttribs;}
454 
455  /// Access a specific data array in the attributes
456  const GT_DataArrayHandle &attribArray(int attrib) const
457  { return myAttribs->get(attrib); }
458 
459  exint size() const { return mySize; }
460  bool readOnly() const { return myReadOnly; }
461  GT_Size attribSize(int attrib) const { return mySizes[attrib]; }
462  bool attribValid(int attrib) const
463  { return myPointers[attrib] != nullptr; }
464  GT_Storage attribStorage(int attrib) const
465  { return myStorage[attrib]; }
466 
467  template <typename T>
468  T *attribData(int attrib, GT_Size index)
469  {
470  UT_ASSERT(myPointers[attrib]);
471  UT_ASSERT(!myReadOnly);
472  // Here, we cast away the const, but we know that this is not
473  // read-only
474  auto data = (T *)myPointers[attrib];
475  return data + index*mySizes[attrib];
476  }
477  template <typename T>
478  const T *attribData(int attrib, GT_Size index) const
479  {
480  UT_ASSERT(myPointers[attrib]);
481  auto data = (const T *)myPointers[attrib];
482  return data + index*mySizes[attrib];
483  }
484  void dump() const;
485  void dump(UT_JSONWriter &w) const;
486  private:
487  GT_AttributeListHandle myAttribs;
488  GT_DataArrayHandle *myArrays;
489  GT_Size *mySizes;
490  GT_Storage *myStorage;
491  const void **myPointers;
492  GT_Size mySize;
493  bool myReadOnly;
494  };
495 
496  class Vertex
497  {
498  public:
500  : myStorage(nullptr)
501  , myIndex(-1)
502  , myMaxWeight(0)
503  {
504  }
506  {
507  myStorage = &storage;
508  myIndex = index;
509  myMaxWeight = 0;
510  }
511 
512  /// Methods required for OpenSubdiv
513  const VertexStorage *storage() const { return myStorage; }
514  GT_Size index() const { return myIndex; }
515 
516  template <typename T>
517  const T *attribData(int attrib) const
518  {
519  // Make sure to call the const method on myStorage
520  return static_cast<const VertexStorage *>(myStorage)->attribData<T>(attrib, myIndex);
521  }
522 
523  // TODO: Templatize?
524  void extract(int attrib_idx, fpreal32 *data, int size) const;
525 
526  void Clear();
527  void AddWithWeight(const Vertex &src, float weight);
528  void dump() const;
529  void dump(UT_JSONWriter &w) const;
530  private:
531  VertexStorage *myStorage;
532  GT_Size myIndex;
533  float myMaxWeight;
534  };
535 
537  { return myCoarseStorage; }
539  { return myCoarseFVStorage; }
540 
542  { return myVertices; }
543 
545  { return myFVertices; }
546 
547 #if 0
548  /// Given a face on the coarse mesh, a u/v coordinate from an attribute,
549  /// look up the corresponding patch and interpolant. If the attribute is
550  /// invalid, the uv's will be assumed to be the face interpolants using the
551  /// scheme where (0,0) maps to the first vertex, (1,0) maps to nvtx-1, (0,
552  /// 1) maps to vertex 2, (1,1) maps to nvtx-2 and the remaining vertices
553  /// are fit linearly between (0, 1) and (1,1).
554  bool lookupPatch(const GT_OSDTopology &topology,
555  GT_Size coarse_id, fpreal coarse_u, fpreal coarse_v,
556  GT_Size &patch_id, fpreal &patch_u, fpreal &patch_v,
557  const AttribId &attrib) const;
558 
559  /// Inverse of @c lookupPatch. Given a patch, lookup the coarse id and
560  /// interpolants.
561  bool lookupFace(GT_Size patch_id, fpreal patch_u, fpreal patch_v,
562  GT_Size &coarse_id, fpreal &coarse_u, fpreal &coarse_v,
563  const AttribId &attrib) const;
564 #endif
565 
566  const VertexStorage &coarseStorage() const { return myCoarseStorage; }
567  const VertexStorage &fineStorage() const { return myFineStorage; }
568  const VertexStorage &coarseFVStorage() const { return myCoarseFVStorage; }
569  const VertexStorage &fineFVStorage() const { return myFineFVStorage; }
570 
571  /// Return a pointer to the index-th entry in the given attribute array.
572  /// If the index exceeds or equals the number of coarse vertices
573  /// (myFineOffset), then the data is located in the fine attribute
574  /// array. The first element of the fine attribute array has index
575  /// equal to myFineOffset, so we do pointer arithmetic to shift the
576  /// array by myFineOffset entries.
577  template <typename T>
578  const T *getData(int attrib, int index) const
579  {
580  if (index < myFineOffset)
581  {
582  return myCoarseStorage.attribData<T>(attrib, index);
583  }
584  else
585  {
586  int offset = index - myFineOffset;
587  return myFineStorage.attribData<T>(attrib, offset);
588  }
589  }
590 
591  /// Same idea as with getData, but with face varying data
592  template <typename T>
593  const T *getDataFV(int attrib, int index) const
594  {
595  if (index < myFineFVOffset)
596  {
597  return myCoarseFVStorage.attribData<T>(attrib, index);
598  }
599  else
600  {
601  int offset = index - myFineFVOffset;
602  return myFineFVStorage.attribData<T>(attrib, offset);
603  }
604  }
605 
606  int fineOffset() const { return myFineOffset; }
607  int fineFVOffset() const { return myFineFVOffset; }
608 
609 private:
610  // Perform interpolation
611  void interpolateData(const GT_OSDTopology &topology);
612 
613  GT_AttributeListHandle myUniform;
614  GT_AttributeListHandle myDetail;
615  GT_FaceSetMapPtr myFaceSets;
616  VertexStorage myCoarseStorage;
617  VertexStorage myFineStorage;
618  VertexStorage myCoarseFVStorage; // Face vertex coarse storage
619  VertexStorage myFineFVStorage; // Face vertex refined storage
620  UT_Array<Vertex> myVertices;
621  UT_Array<Vertex> myFVertices; // Face vertices
622  exint myFineOffset;
623  exint myFineFVOffset;
624 };
625 
626 /// Interface to perform limit surface evaluation.
628 {
629 public:
630  using TopologyRefiner = OpenSubdiv::Far::TopologyRefiner;
631  using PtexIndices = OpenSubdiv::Far::PtexIndices;
632  using PatchTable = OpenSubdiv::Far::PatchTable;
633  using PatchMap = OpenSubdiv::Far::PatchMap;
634  using PatchTableFactory = OpenSubdiv::Far::PatchTableFactory;
638 
639  GT_OSDLimitSurface(const GT_OSDTopology &topology,
640  const GT_OSDAttributes &attribs,
641  const GT_OSDPatchTableOptions &options,
642  const GT_OSDPatchTable &patchTable,
643  const GT_PrimPolygonMesh &mesh);
645 
646  void dump() const;
647  void dump(UT_JSONWriter &w) const;
648 
649  bool update(const GT_OSDAttributes &attribs);
650 
651  /// Return the number of patches
652  int ptexFaceCount() const;
653 
654  /// Return the first ptex patch associated with the given coarse face
655  int ptexFromFace(GT_Size face_index) const;
656  /// @{
657  /// Return the number of ptex patches for the given coarse face
658  int numPtexPatches(const TopologyRefiner &refiner,
659  GT_Size face_index) const;
661  GT_Size face_index) const
662  { return numPtexPatches(*top.refiner(), face_index); }
663  /// @}
664 
665  /// Return the coarse face associated with the given ptex id
666  GT_Size faceFromPtex(int ptex_id, int &offset) const;
667 
668  /// @{
669  /// Query the points/vertices for a face in the coarse mesh
670  bool coarsePoints(const GT_OSDTopology &topology,
671  GT_Size coarse_face_index,
672  GT_Size *vertices,
673  GT_Size buffer_size) const;
674  bool coarseVertices(const GT_OSDTopology &topology,
675  GT_Size coarse_face_index,
676  GT_Size *vertices,
677  GT_Size buffer_size) const;
678  /// @}
679 
680  /// Evaluate the limit surface (and derivatives) at a given coordinates.
681  /// The @c faces array should have @c npts entries. The @c u and @c v
682  /// arrays should have also have @c npts entries. Each @c u and @c v
683  /// coordinate will be offset by @c uv_stride entries. So, if you have
684  /// uv's that are interleaved (i.e. [u0 v0 u1 v1 u2 v2 ...]), you can
685  /// offset the @c v pointer and set the stride to 2.
686  ///
687  /// Passing a @c nullptr for any of the results will disable evaluation of
688  /// that property.
689  ///
690  /// The method returns the tuple size of the attribute evaluated.
691  int limitSurface(GT_DataArrayHandle *result,
692  GT_DataArrayHandle *result_du,
693  GT_DataArrayHandle *result_dv,
694  const GT_OSDAttributes &alist,
695  const AttribId &attrib,
696  int npts,
697  const int32 *faces,
698  const fpreal32 *u,
699  const fpreal32 *v,
700  int uv_stride = 1) const;
701 
702  /// Evaluation of face-varying attributes on the limit surface
703  int limitSurfaceFVar(const GT_OSDTopology &topology,
704  GT_DataArrayHandle *result,
705  GT_DataArrayHandle *result_du,
706  GT_DataArrayHandle *result_dv,
707  const GT_OSDAttributes &alist,
708  const AttribId &attrib,
709  int npts,
710  const int32 *faces,
711  const fpreal32 *u,
712  const fpreal32 *v,
713  int uv_stride = 1) const;
714 
715 
716 private:
717  // Maps coarse face -> ptex
718  UT_UniquePtr<PtexIndices> myPtexIndices;
719  // Holds all patches and also a map for ptex -> face
720  const GT_OSDPatchTable &myPatches;
721  // Maps (coarse face + (u,v)) -> sub patch
722  UT_UniquePtr<PatchMap> myPatchMap;
723  VertexStorage myStorage;
724  GT_CountArray myFaceOffsets;
725 };
726 
727 #endif
const UT_Array< int > & getPtexArray() const
Definition: GT_OSD3.h:322
OpenSubdiv::Far::ConstIndexArray ConstIndexArray
Definition: GT_OSD3.h:280
UT_IntrusivePtr< GT_FaceSetMap > GT_FaceSetMapPtr
Definition: GT_FaceSetMap.h:24
OpenSubdiv::Far::TopologyRefiner TopologyRefiner
Definition: GT_OSD3.h:630
GT_Storage
Definition: GT_Types.h:17
OpenSubdiv::Far::PatchTableFactory PatchTableFactory
Definition: GT_OSD3.h:278
const int * fvarChannelIndices() const
Definition: GT_OSD3.h:151
FactoryOptions & operator*()
Definition: GT_OSD3.h:132
GLsizei GLenum const void * indices
Definition: glcorearb.h:405
OpenSubdiv::Sdc::Options SdcOptions
Definition: GT_OSD3.h:38
GT_Storage attribStorage(int attrib) const
Definition: GT_OSD3.h:464
OpenSubdiv::Far::PtexIndices PtexIndices
Definition: GT_OSD3.h:283
int numPtexPatches(const GT_OSDTopology &top, GT_Size face_index) const
Definition: GT_OSD3.h:660
void computeLocalPoints(T *src, T *dest) const
Definition: GT_OSD3.h:300
OpenSubdiv::Far::PatchDescriptor::Type PatchType
Definition: GT_OSD3.h:282
A mesh of polygons.
const LevelInfo & lastLevel() const
Definition: GT_OSD3.h:238
SdcOptions & operator->()
Definition: GT_OSD3.h:72
GT_OSDAttributes::AttribId AttribId
Definition: GT_OSD3.h:635
const SdcOptions & operator*() const
Definition: GT_OSD3.h:75
const GLdouble * v
Definition: glcorearb.h:836
const T * attribData(int attrib) const
Definition: GT_OSD3.h:517
void setRemoveHoles(bool v)
Definition: GT_OSD3.h:87
int fineOffset() const
Definition: GT_OSD3.h:606
std::pair< int, bool > AttribId
Definition: GT_OSD3.h:340
const VertexStorage & coarseFVStorage() const
Definition: GT_OSD3.h:568
GT_Size index() const
Definition: GT_OSD3.h:514
bool adaptive() const
Definition: GT_OSD3.h:83
OpenSubdiv::Far::PatchDescriptor PatchDescriptor
Definition: GT_OSD3.h:279
#define GT_API
Definition: GT_API.h:11
GLint level
Definition: glcorearb.h:107
void setMaxIsolationLevel(int v)
Definition: GT_OSD3.h:162
T * attribData(int attrib, GT_Size index)
Definition: GT_OSD3.h:468
const VertexStorage & fineFVStorage() const
Definition: GT_OSD3.h:569
std::size_t SYS_HashType
Define the type for hash values.
Definition: SYS_Hash.h:19
Storage arrays for vertex data for opensubdiv classes.
Definition: GT_OSD3.h:334
int maxIsolationLevel() const
Definition: GT_OSD3.h:143
void setCreaseOverride(fpreal value=-1)
Definition: GT_OSD3.h:91
SdcOptions::VtxBoundaryInterpolation VtxBoundaryInterpolation
Definition: GT_OSD3.h:39
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:32
void init(VertexStorage &storage, GT_Size index)
Definition: GT_OSD3.h:505
OpenSubdiv::Far::PatchTableFactory PatchTableFactory
Definition: GT_OSD3.h:634
void setFVarChannelIndices(const int *indices)
Definition: GT_OSD3.h:170
void setGenerateAllLevels(bool v)
Definition: GT_OSD3.h:156
SdcOptions::FVarLinearInterpolation FVarLinearInterpolation
Definition: GT_OSD3.h:40
GLsizeiptr size
Definition: glcorearb.h:663
Options for setting up limit surface evaluation.
Definition: GT_OSD3.h:119
bool useSingleCreasePatch() const
Definition: GT_OSD3.h:141
fpreal creaseOverride() const
Definition: GT_OSD3.h:90
FactoryOptions::EndCapType endCapType() const
Definition: GT_OSD3.h:135
SdcOptions::CreasingMethod CreasingMethod
Definition: GT_OSD3.h:41
void setEndCapType(FactoryOptions::EndCapType t)
Definition: GT_OSD3.h:154
void setOptions(const SdcOptions &o)
Definition: GT_OSD3.h:62
const FactoryOptions & operator*() const
Definition: GT_OSD3.h:133
GT_Size attribSize(int attrib) const
Definition: GT_OSD3.h:461
int numFVarChannels() const
Definition: GT_OSD3.h:149
GLdouble n
Definition: glcorearb.h:2007
GT_Size coarseVertexCount() const
Definition: GT_OSD3.h:248
bool attribValid(int attrib) const
Definition: GT_OSD3.h:462
const SdcOptions & options() const
Definition: GT_OSD3.h:61
const T * attribData(int attrib, GT_Size index) const
Definition: GT_OSD3.h:478
GT_Scheme
Subdivision schemes.
Definition: GT_Types.h:65
void setNumFVarChannels(int n)
Definition: GT_OSD3.h:168
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:102
int64 exint
Definition: SYS_Types.h:115
PatchTable::PatchHandle Handle
Definition: GT_OSD3.h:284
const GT_AttributeListHandle & attribList() const
Raw access to the attributes.
Definition: GT_OSD3.h:453
OpenSubdiv::Far::PatchTableFactory::Options FactoryOptions
Definition: GT_OSD3.h:122
bool operator!=(const GT_OSDOptions &s) const
Definition: GT_OSD3.h:68
const VertexStorage & coarseStorage() const
Definition: GT_OSD3.h:566
GLintptr offset
Definition: glcorearb.h:664
bool shareEndCapPatchPoints() const
Definition: GT_OSD3.h:145
exint levelCount() const
Number of levels in refinement (note this is the max level + 1)
Definition: GT_OSD3.h:226
bool enableCreaseOverride() const
Definition: GT_OSD3.h:89
void setScheme(GT_Scheme t)
Definition: GT_OSD3.h:78
const int * getPtexMap() const
Definition: GT_OSD3.h:321
GT_Size coarsePointCount() const
Definition: GT_OSD3.h:246
int findAttrib(const char *name) const
Definition: GT_OSD3.h:421
void computeLocalFVPoints(T *src, T *dest) const
Definition: GT_OSD3.h:305
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1601
GLboolean * data
Definition: glcorearb.h:130
GLuint const GLchar * name
Definition: glcorearb.h:785
int level() const
Definition: GT_OSD3.h:80
const T * getData(int attrib, int index) const
Definition: GT_OSD3.h:578
bool generateAllLevels() const
Definition: GT_OSD3.h:137
int int32
Definition: SYS_Types.h:34
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1221
void setTriangulateQuads(bool v)
Definition: GT_OSD3.h:158
bool generateFVarTables() const
Definition: GT_OSD3.h:147
OpenSubdiv::Far::TopologyLevel LevelInfo
Definition: GT_OSD3.h:181
GT_Size coarseFaceCount() const
Definition: GT_OSD3.h:244
const TopologyRefiner * refiner() const
Access to the refiner.
Definition: GT_OSD3.h:254
int fineFVOffset() const
Definition: GT_OSD3.h:607
OpenSubdiv::Far::PatchMap PatchMap
Definition: GT_OSD3.h:633
OpenSubdiv::Far::TopologyRefiner TopologyRefiner
Definition: GT_OSD3.h:180
OpenSubdiv::Far::PtexIndices PtexIndices
Definition: GT_OSD3.h:631
GLsizei const GLfloat * value
Definition: glcorearb.h:823
double fpreal
Definition: SYS_Types.h:269
PatchTable * getTable() const
Definition: GT_OSD3.h:324
const GT_DataArrayHandle & attribArray(int attrib) const
Access a specific data array in the attributes.
Definition: GT_OSD3.h:456
bool removeHoles() const
Definition: GT_OSD3.h:86
OpenSubdiv::Far::PatchTable PatchTable
Definition: GT_OSD3.h:632
OpenSubdiv::Far::PatchTable PatchTable
Definition: GT_OSD3.h:277
SdcOptions & operator*()
Definition: GT_OSD3.h:74
const VertexStorage & fineStorage() const
Definition: GT_OSD3.h:567
const UT_Array< Vertex > & vertexArray() const
Definition: GT_OSD3.h:541
GLuint index
Definition: glcorearb.h:785
png_infop png_bytep png_size_t buffer_size
Definition: png.h:2124
void setGenerateFVarTables(bool v)
Definition: GT_OSD3.h:166
const LevelInfo & levelInfo(int level) const
Definition: GT_OSD3.h:236
GT_OSDOptions(GT_Scheme scheme=GT_CATMULL_CLARK, int level=2, bool adaptive=false, fpreal crease_override=-1, bool remove_holes=true)
Definition: GT_OSD3.h:44
const VertexStorage & coarseVertex() const
Definition: GT_OSD3.h:536
OpenSubdiv::Far::PatchParam PatchParam
Definition: GT_OSD3.h:281
void setShareEndCapPatchPoints(bool v)
Definition: GT_OSD3.h:164
void setLevel(int l)
Definition: GT_OSD3.h:81
getOption("OpenEXR.storage") storage
Definition: HDK_Image.dox:276
void setAdaptive(bool b)
Definition: GT_OSD3.h:84
#define GETSET(TYPE, GET)
Definition: GT_OSD3.h:93
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
bool initialized() const
Definition: GT_OSD3.h:325
OpenSubdiv::Far::TopologyRefiner TopologyRefiner
Definition: GT_OSD3.h:276
Topology definition for opensubdiv classes.
Definition: GT_OSD3.h:177
int64 GT_Size
Definition: GT_Types.h:109
bool triangulateQuads() const
Definition: GT_OSD3.h:139
float fpreal32
Definition: SYS_Types.h:190
bool operator==(const GT_OSDOptions &s) const
Definition: GT_OSD3.h:66
GT_Scheme scheme() const
Definition: GT_OSD3.h:77
SdcOptions::TriangleSubdivision TriangleSubdivision
Definition: GT_OSD3.h:42
const T * getDataFV(int attrib, int index) const
Same idea as with getData, but with face varying data.
Definition: GT_OSD3.h:593
const SdcOptions & operator->() const
Definition: GT_OSD3.h:73
const UT_Array< Vertex > & facevaryingArray() const
Definition: GT_OSD3.h:544
void setUseSingleCreasePatch(bool v)
Definition: GT_OSD3.h:160
bool adaptive() const
Test whether this has been built for adaptive refinement.
Definition: GT_OSD3.h:257
const VertexStorage * storage() const
Methods required for OpenSubdiv.
Definition: GT_OSD3.h:513
Interface to perform limit surface evaluation.
Definition: GT_OSD3.h:627
const VertexStorage & coarseFaceVarying() const
Definition: GT_OSD3.h:538
GLenum src
Definition: glcorearb.h:1792
Options for topology and refinement.
Definition: GT_OSD3.h:35