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