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/ptexIndices.h>
27 #include <opensubdiv/far/primvarRefiner.h>
28 #include <opensubdiv/far/patchTableFactory.h>
29 #include <opensubdiv/far/patchMap.h>
30 
31 class UT_JSONWriter;
32 
33 /// @file
34 /// This file contains code to support OpenSubdiv 3.x for the GT library
35 /// The code in here is primarily used in GT_UtilOpenSubdiv
36 
37 /// Options for topology and refinement
39 {
40 public:
41  using SdcOptions = OpenSubdiv::Sdc::Options;
42  using VtxBoundaryInterpolation = SdcOptions::VtxBoundaryInterpolation;
43  using FVarLinearInterpolation = SdcOptions::FVarLinearInterpolation;
44  using CreasingMethod = SdcOptions::CreasingMethod;
45  using TriangleSubdivision = SdcOptions::TriangleSubdivision;
46 
48  int level = 2,
49  bool adaptive = false,
50  fpreal crease_override = -1,
51  bool remove_holes = true)
52  : myOptions()
53  , myScheme(scheme)
54  , myCreaseOverride(crease_override)
55  , myLevel(level)
56  , myAdaptive(adaptive)
57  , myRemoveHoles(remove_holes)
58  {
59  // Set default behaviour
60  setVtxBoundaryInterpolation(SdcOptions::VTX_BOUNDARY_EDGE_AND_CORNER);
61  setFVarLinearInterpolation(SdcOptions::FVAR_LINEAR_BOUNDARIES);
62  }
63 
64  const SdcOptions &options() const { return myOptions; }
65  void setOptions(const SdcOptions &o) { myOptions = o; }
66 
67  SYS_HashType hash() const;
68  bool isEqual(const GT_OSDOptions &opts) const;
69  bool operator==(const GT_OSDOptions &s) const
70  { return isEqual(s); }
71  bool operator!=(const GT_OSDOptions &s) const
72  { return !isEqual(s); }
73 
74  // Access this object as it were an OpenSubdiv::Sdc::Options
75  SdcOptions &operator->() { return myOptions; }
76  const SdcOptions &operator->() const { return myOptions; }
77  SdcOptions &operator*() { return myOptions; }
78  const SdcOptions &operator*() const { return myOptions; }
79 
80  GT_Scheme scheme() const { return myScheme; }
81  void setScheme(GT_Scheme t) { myScheme = t; }
82 
83  int level() const { return myLevel; }
84  void setLevel(int l) { myLevel = l; }
85 
86  bool adaptive() const { return myAdaptive; }
87  void setAdaptive(bool b) { myAdaptive = b; }
88 
89  bool removeHoles() const { return myRemoveHoles; }
90  void setRemoveHoles(bool v) { myRemoveHoles = v; }
91 
92  bool enableCreaseOverride() const { return myCreaseOverride >= 0; }
93  fpreal creaseOverride() const { return myCreaseOverride; }
94  void setCreaseOverride(fpreal value=-1) { myCreaseOverride = value; }
95 
96 #define GETSET(TYPE, GET) \
97  TYPE GET() const { return myOptions.Get##TYPE(); } \
98  void set##TYPE(TYPE v) { myOptions.Set##TYPE(v); }
99 
100  /// @{
101  /// Simple wrappers on the SdcOptions
102  GETSET(VtxBoundaryInterpolation, vtxBoundaryInterpolation);
103  GETSET(FVarLinearInterpolation, fvarLinearInterpolation);
104  GETSET(CreasingMethod, creasingMethod);
105  GETSET(TriangleSubdivision, triangleSubdivision);
106  /// @}
107 #undef GETSET
108 
109  void dump() const;
110  void dump(UT_JSONWriter &w) const;
111 
112 private:
113  SdcOptions myOptions;
114  GT_Scheme myScheme;
115  fpreal myCreaseOverride;
116  int myLevel;
117  bool myAdaptive;
118  bool myRemoveHoles;
119 };
120 
121 /// Options for setting up limit surface evaluation.
123 {
124 public:
125  using FactoryOptions = OpenSubdiv::Far::PatchTableFactory::Options;
126 
128  : myOptions()
129  {
130  }
131 
132  bool isEqual(const GT_OSDPatchTableOptions &o) const;
133  bool operator==(const GT_OSDPatchTableOptions &o) const
134  { return isEqual(o); }
135  bool operator!=(const GT_OSDPatchTableOptions &o) const
136  { return !isEqual(o); }
137  void dump() const;
138  void dump(UT_JSONWriter &w) const;
139 
140  FactoryOptions &operator*() { return myOptions; }
141  const FactoryOptions &operator*() const { return myOptions; }
142 
144  { return (FactoryOptions::EndCapType)myOptions.endCapType; }
145  bool generateAllLevels() const
146  { return myOptions.generateAllLevels; }
147  bool triangulateQuads() const
148  { return myOptions.triangulateQuads; }
149  bool useSingleCreasePatch() const
150  { return myOptions.useSingleCreasePatch; }
151  int maxIsolationLevel() const
152  { return myOptions.maxIsolationLevel; }
154  { return myOptions.shareEndCapPatchPoints; }
155  bool generateFVarTables() const
156  { return myOptions.generateFVarTables; }
157  int numFVarChannels() const
158  { return myOptions.numFVarChannels; }
159  const int *fvarChannelIndices() const
160  { return myOptions.fvarChannelIndices; }
161 
163  { myOptions.endCapType = (FactoryOptions::EndCapType)t; }
165  { myOptions.generateAllLevels = v; }
167  { myOptions.triangulateQuads = v; }
169  { myOptions.useSingleCreasePatch = v; }
171  { myOptions.maxIsolationLevel = v; }
173  { myOptions.shareEndCapPatchPoints = v; }
175  { myOptions.generateFVarTables = v; }
177  { myOptions.numFVarChannels = n; }
179  { myOptions.fvarChannelIndices = indices; }
181  { myOptions.generateFVarLegacyLinearPatches = b; }
182 private:
183  FactoryOptions myOptions;
184 };
185 
186 /// Topology definition for opensubdiv classes
188 {
189 public:
190  using TopologyRefiner = OpenSubdiv::Far::TopologyRefiner;
191  using LevelInfo = OpenSubdiv::Far::TopologyLevel;
192 
193  GT_OSDTopology();
194  ~GT_OSDTopology();
195 
196  /// @{
197  /// Debug - dump the topology out
198  void dump() const;
199  void dump(UT_JSONWriter &w) const;
200  /// @}
201 
202  bool isEqual(const GT_OSDTopology &src) const;
203  bool operator==(const GT_OSDTopology &o) const { return isEqual(o); }
204 
205  static SYS_HashType hash(const GT_PrimPolygonMesh &mesh,
206  const GT_OSDOptions &options);
207  static SYS_HashType areEqual(const GT_PrimPolygonMesh &a,
208  const GT_PrimPolygonMesh &b);
209 
210  /// Create the topology for the given polygonal hull and options. Note
211  /// that if the mesh is a GT_PrimSubdivisionMesh, crease weights will be
212  /// picked up from the tags on the primitive.
213  bool create(const GT_PrimPolygonMesh &mesh,
214  const GT_OSDOptions &options);
215 
216  /// Number of levels in refinement (note this is the max level + 1)
218  { return myRefiner->GetNumLevels(); }
219 
220  /// Access to the level information for a given refinement level
221  /// This returns the number of vertices, face-varying vertices, faces, etc.
222  /// for each level. Level 0 is the "coarse" mesh.
223  /// - GetNumVertices() - Number of shared points (i.e. Houdini points)
224  /// - GetNumFaces() - Number of faces
225  /// - GetNumEdges() - Number of edges
226  /// - GetNumFaceVertices() - Number of face varying (i.e. Houdini vertices)
227  const LevelInfo &levelInfo(int level) const
228  { return myRefiner->GetLevel(level); }
229  const LevelInfo &lastLevel() const
230  { return levelInfo(myRefiner->GetNumLevels()-1); }
231 
232 
233  /// @{
234  /// Return specific information about the coarse mesh (i.e. level 0)
236  { return levelInfo(0).GetNumFaces(); }
238  { return levelInfo(0).GetNumVertices(); }
240  { return levelInfo(0).GetNumFaceVertices(); }
241  GT_Size coarseVertexCount(GT_Size face_index) const;
242  /// @}
243 
244  /// Access to the refiner
245  const TopologyRefiner *refiner() const { return myRefiner; }
246 
247  /// Test whether this has been built for adaptive refinement
248  bool adaptive() const { return myAdaptive; }
249 
250  /// Create a polygon mesh for a given level
251  GT_PrimitiveHandle createMesh(int level,
252  const GT_AttributeListHandle &point,
253  const GT_AttributeListHandle &vertex,
254  const GT_AttributeListHandle &uniform,
255  const GT_AttributeListHandle &detail,
256  const GT_FaceSetMapPtr &fsets=GT_FaceSetMapPtr()) const;
257 private:
258  TopologyRefiner *myRefiner;
259  bool myAdaptive;
260  bool myRemoveHoles;
261 };
262 
263 // Interface to create and look through a patch table
265 {
266 public:
267  using TopologyRefiner = OpenSubdiv::Far::TopologyRefiner;
268  using PatchTable = OpenSubdiv::Far::PatchTable;
269  using PatchTableFactory = OpenSubdiv::Far::PatchTableFactory;
270  using PatchDescriptor = OpenSubdiv::Far::PatchDescriptor;
271  using ConstIndexArray = OpenSubdiv::Far::ConstIndexArray;
272  using PatchParam = OpenSubdiv::Far::PatchParam;
274  using PtexIndices = OpenSubdiv::Far::PtexIndices;
275  using Handle = PatchTable::PatchHandle;
276 
278 
279  bool create(const GT_OSDTopology &top,
280  bool createPtexMap=false,
281  bool legacy_linear=true,
282  ConstIndexArray selectedfaces=ConstIndexArray());
283 
284  bool isEqual(const GT_OSDPatchTable &p) const;
285  bool operator==(const GT_OSDPatchTable &o) const
286  { return isEqual(o); }
287  void dump() const;
288  void dump(UT_JSONWriter &w )const;
289 
290  // Array level queries
291  int arrayCount() const;
292  int arrayPatchCount(int arr) const;
293  int numLocalPoints() const;
294  int numLocalPointsVarying() const;
295  ConstIndexArray vertexArray(int arr) const;
296  ConstIndexArray varyingVertexArray(int arr) const;
297  PatchDescriptor arrayPatchDesc(int arr) const;
298  template<typename T>
299  void computeLocalPoints(const T *src, T *dest) const
300  {
301  if (myTable)
302  myTable->ComputeLocalPointValues(src, dest);
303  }
304  template<typename T>
305  void computeLocalFVPoints(const T *src, T *dest) const
306  {
307  if (myTable)
308  myTable->ComputeLocalPointValuesFaceVarying(src, dest);
309  }
310 
311  // Patch level queries
312  PatchParam patchParam(int arr, int pat) const;
313  ConstIndexArray patchVertices(const Handle &patch) const;
314  ConstIndexArray patchFVValues(const Handle &patch) const;
315  void evaluateBasis(const Handle &patch, float u, float v,
316  float *w, float *du, float *dv) const;
317  void evaluateBasisFV(const Handle &patch, float u, float v,
318  float *w, float *du, float *dv) const;
319 
320  // For ptex queries
321  int numPtexFaces() const;
322  const int *getPtexMap() const { return myPtexMap.array(); };
323  const UT_Array<int> &getPtexArray() const { return myPtexMap; };
324 
325  PatchTable *getTable() const { return myTable.get(); };
326  bool initialized() const { return myTable != nullptr; };
327 
328 private:
329  UT_UniquePtr<PatchTable> myTable;
330  GT_OSDPatchTableOptions myOptions;
331  UT_Array<int> myPtexMap;
332 };
333 
334 /// Storage arrays for vertex data for opensubdiv classes
336 {
337 public:
338  /// Identifier for an attribute. The first item is the index in the
339  /// attribute list, the second is whether it's a vertex or a point
340  /// attribute.
341  using AttribId = std::pair<int, bool>;
342 
344  ~GT_OSDAttributes();
345 
346  void dump() const;
347  void dump(UT_JSONWriter &w )const;
348 
349  exint getMemoryUsage() const;
350 
351  bool create(const GT_OSDTopology &topology,
352  const GT_PrimPolygonMesh &mesh,
353  const GT_OSDPatchTable *table=nullptr);
354 
355  bool update(const GT_OSDTopology &topology,
356  const GT_PrimPolygonMesh &mesh,
357  bool skip_equality_check = false);
358 
359  /// Extract a subdivided mesh for the given topology level
360  GT_PrimitiveHandle extractMesh(const GT_OSDTopology &topology,
361  bool harden,
362  int level = -1);
363 
364  /// Extract the shared/point attributes for a mesh at the given refinement
365  /// level. If @c harden is @c false, the attributes lists will point to
366  /// the temporary buffers (which are over-sized). Passing @c true to @c
367  /// harden will copy out the temporary data into compact arrays.
368  GT_AttributeListHandle extractShared(const GT_OSDTopology &top,
369  int level_index,
370  bool harden) const;
371  /// Extract the vertex/face-varying attributes for a mesh at the given
372  /// refinement level. See @c extractShared for help on @c harden
373  GT_AttributeListHandle extractVertex(const GT_OSDTopology &top,
374  int level_index,
375  bool harden) const;
376  /// Extract the primitive/face attributes for a mesh at the given
377  /// refinement level.
378  GT_AttributeListHandle extractUniform(const GT_OSDTopology &top,
379  int level_index,
380  bool harden) const;
381 
382  /// Extract a face map set for a mesh at the given refinement level
383  GT_FaceSetMapPtr extractFaceSets(const GT_OSDTopology &top,
384  int level_index) const;
385 
386  /// Extract a mapping from fine faces at a given refinement level to
387  /// its corresponding coarse face
388  GT_DataArrayHandle extractFaceMap(const GT_OSDTopology &top,
389  int level_index) const;
390 
391  /// @{
392  /// Find an attribute
393  AttribId findAttribute(const char *name) const;
394  AttribId findAttribute(const char *name, bool vertex_attrib) const;
395  /// @}
396 
397  /// Return the size of a given attribute
398  int tupleSize(const AttribId &attrib) const;
399 
400  /// Extract attributes on the coarse mesh
401  bool coarseValues(const AttribId &attrib,
402  const GT_Size *vertices,
403  GT_Size nvtx,
405  int seg) const;
406 
408  {
409  public:
411  : myAttribs(nullptr)
412  , myArrays(nullptr)
413  , mySizes(nullptr)
414  , myStorage(nullptr)
415  , myPointers(nullptr)
416  , mySize(0)
417  , myReadOnly(true)
418  {
419  }
421  {
422  clear();
423  }
424 
425  exint getMemoryUsage() const;
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 
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_OSDPatchTableOptions &options,
654  const GT_OSDPatchTable &patchTable,
655  const GT_PrimPolygonMesh &mesh);
657 
658  void dump() const;
659  void dump(UT_JSONWriter &w) const;
660 
661  /// Return the number of patches
662  int ptexFaceCount() const;
663 
664  /// Return the first ptex patch associated with the given coarse face
665  int ptexFromFace(GT_Size face_index) const;
666  /// @{
667  /// Return the number of ptex patches for the given coarse face
668  int numPtexPatches(const TopologyRefiner &refiner,
669  GT_Size face_index) const;
671  GT_Size face_index) const
672  { return numPtexPatches(*top.refiner(), face_index); }
673  /// @}
674 
675  /// Return the coarse face associated with the given ptex id
676  GT_Size faceFromPtex(int ptex_id, int &offset) const;
677 
678  /// @{
679  /// Query the points/vertices for a face in the coarse mesh
680  bool coarsePoints(const GT_OSDTopology &topology,
681  GT_Size coarse_face_index,
682  GT_Size *vertices,
683  GT_Size buffer_size) const;
684  bool coarseVertices(const GT_OSDTopology &topology,
685  GT_Size coarse_face_index,
686  GT_Size *vertices,
687  GT_Size buffer_size) const;
688  /// @}
689 
690  /// Evaluate the limit surface (and derivatives) at a given coordinates.
691  /// The @c faces array should have @c npts entries. The @c u and @c v
692  /// arrays should have also have @c npts entries. Each @c u and @c v
693  /// coordinate will be offset by @c uv_stride entries. So, if you have
694  /// uv's that are interleaved (i.e. [u0 v0 u1 v1 u2 v2 ...]), you can
695  /// offset the @c v pointer and set the stride to 2.
696  ///
697  /// Passing a @c nullptr for any of the results will disable evaluation of
698  /// that property.
699  ///
700  /// The method returns the tuple size of the attribute evaluated.
701  int limitSurface(GT_DataArrayHandle *result,
702  GT_DataArrayHandle *result_du,
703  GT_DataArrayHandle *result_dv,
704  const GT_OSDAttributes &alist,
705  const AttribId &attrib,
706  int npts,
707  const int32 *faces,
708  const fpreal32 *u,
709  const fpreal32 *v,
710  int uv_stride = 1,
711  int seg = 0) const;
712 
713  /// Evaluation of face-varying attributes on the limit surface
714  int limitSurfaceFVar(const GT_OSDTopology &topology,
716  GT_DataArrayHandle *result_du,
717  GT_DataArrayHandle *result_dv,
718  const GT_OSDAttributes &alist,
719  const AttribId &attrib,
720  int npts,
721  const int32 *faces,
722  const fpreal32 *u,
723  const fpreal32 *v,
724  int uv_stride = 1,
725  int seg = 0) const;
726 
727 private:
728  // Maps coarse face -> ptex
729  UT_UniquePtr<PtexIndices> myPtexIndices;
730  // Holds all patches and also a map for ptex -> face
731  const GT_OSDPatchTable &myPatches;
732  // Maps (coarse face + (u,v)) -> sub patch
733  UT_UniquePtr<PatchMap> myPatchMap;
734  //VertexStorage myStorage;
735  GT_CountArray myFaceOffsets;
736 };
737 
738 #endif
const UT_Array< int > & getPtexArray() const
Definition: GT_OSD3.h:323
OpenSubdiv::Far::ConstIndexArray ConstIndexArray
Definition: GT_OSD3.h:271
GLfloat GLfloat GLfloat top
Definition: glew.h:15525
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:18
OpenSubdiv::Far::PatchTableFactory PatchTableFactory
Definition: GT_OSD3.h:269
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
const int * fvarChannelIndices() const
Definition: GT_OSD3.h:159
FactoryOptions & operator*()
Definition: GT_OSD3.h:140
OpenSubdiv::Sdc::Options SdcOptions
Definition: GT_OSD3.h:41
int int32
Definition: SYS_Types.h:39
GT_Storage attribStorage(int attrib) const
Definition: GT_OSD3.h:470
OpenSubdiv::Far::PtexIndices PtexIndices
Definition: GT_OSD3.h:274
void computeLocalPoints(const T *src, T *dest) const
Definition: GT_OSD3.h:299
int numPtexPatches(const GT_OSDTopology &top, GT_Size face_index) const
Definition: GT_OSD3.h:670
OpenSubdiv::Far::PatchDescriptor::Type PatchType
Definition: GT_OSD3.h:273
A mesh of polygons.
const LevelInfo & lastLevel() const
Definition: GT_OSD3.h:229
void computeLocalFVPoints(const T *src, T *dest) const
Definition: GT_OSD3.h:305
bool operator!=(const GT_OSDPatchTableOptions &o) const
Definition: GT_OSD3.h:135
SdcOptions & operator->()
Definition: GT_OSD3.h:75
GT_OSDAttributes::AttribId AttribId
Definition: GT_OSD3.h:648
const SdcOptions & operator*() const
Definition: GT_OSD3.h:78
void setRemoveHoles(bool v)
Definition: GT_OSD3.h:90
int fineOffset() const
Definition: GT_OSD3.h:619
std::pair< int, bool > AttribId
Definition: GT_OSD3.h:341
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:86
OpenSubdiv::Far::PatchDescriptor PatchDescriptor
Definition: GT_OSD3.h:270
#define GT_API
Definition: GT_API.h:11
int64 exint
Definition: SYS_Types.h:125
bool operator==(const GT_OSDPatchTableOptions &o) const
Definition: GT_OSD3.h:133
GLint level
Definition: glcorearb.h:108
GT_Type
Definition: GT_Types.h:34
void setMaxIsolationLevel(int v)
Definition: GT_OSD3.h:170
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:335
int maxIsolationLevel() const
Definition: GT_OSD3.h:151
void setCreaseOverride(fpreal value=-1)
Definition: GT_OSD3.h:94
SdcOptions::VtxBoundaryInterpolation VtxBoundaryInterpolation
Definition: GT_OSD3.h:42
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:35
const T * attribData(int attrib, GT_Size index, int seg) const
Definition: GT_OSD3.h:487
GLuint const GLchar * name
Definition: glcorearb.h:786
void init(VertexStorage &storage, GT_Size index)
Definition: GT_OSD3.h:516
GLenum src
Definition: glcorearb.h:1793
OpenSubdiv::Far::PatchTableFactory PatchTableFactory
Definition: GT_OSD3.h:647
void setFVarChannelIndices(const int *indices)
Definition: GT_OSD3.h:178
float fpreal32
Definition: SYS_Types.h:200
GLdouble GLdouble t
Definition: glew.h:1403
void setGenerateAllLevels(bool v)
Definition: GT_OSD3.h:164
SdcOptions::FVarLinearInterpolation FVarLinearInterpolation
Definition: GT_OSD3.h:43
Options for setting up limit surface evaluation.
Definition: GT_OSD3.h:122
GLuint GLuint GLfloat weight
Definition: glew.h:13892
GLdouble l
Definition: glew.h:9164
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1602
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
bool useSingleCreasePatch() const
Definition: GT_OSD3.h:149
GLsizeiptr size
Definition: glcorearb.h:664
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
fpreal creaseOverride() const
Definition: GT_OSD3.h:93
FactoryOptions::EndCapType endCapType() const
Definition: GT_OSD3.h:143
SdcOptions::CreasingMethod CreasingMethod
Definition: GT_OSD3.h:44
OIIO_FORCEINLINE bool extract(const vbool4 &a)
Definition: simd.h:3426
void setEndCapType(FactoryOptions::EndCapType t)
Definition: GT_OSD3.h:162
void setOptions(const SdcOptions &o)
Definition: GT_OSD3.h:65
const FactoryOptions & operator*() const
Definition: GT_OSD3.h:141
GT_Size attribSize(int attrib) const
Definition: GT_OSD3.h:467
int numFVarChannels() const
Definition: GT_OSD3.h:157
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
GLuint64EXT * result
Definition: glew.h:14311
GT_Size coarseVertexCount() const
Definition: GT_OSD3.h:239
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:64
GT_Scheme
Subdivision schemes.
Definition: GT_Types.h:79
void setNumFVarChannels(int n)
Definition: GT_OSD3.h:176
void setLegacyLinearPatches(bool b)
Definition: GT_OSD3.h:180
bool operator==(const GT_OSDTopology &o) const
Definition: GT_OSD3.h:203
PatchTable::PatchHandle Handle
Definition: GT_OSD3.h:275
const GT_AttributeListHandle & attribList() const
Raw access to the attributes.
Definition: GT_OSD3.h:459
OpenSubdiv::Far::PatchTableFactory::Options FactoryOptions
Definition: GT_OSD3.h:125
GT_API const UT_StringHolder topology
const GLdouble * v
Definition: glcorearb.h:837
bool operator!=(const GT_OSDOptions &s) const
Definition: GT_OSD3.h:71
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
GLsizei GLenum const void * indices
Definition: glcorearb.h:406
const VertexStorage & coarseStorage() const
Definition: GT_OSD3.h:579
bool shareEndCapPatchPoints() const
Definition: GT_OSD3.h:153
exint levelCount() const
Number of levels in refinement (note this is the max level + 1)
Definition: GT_OSD3.h:217
bool enableCreaseOverride() const
Definition: GT_OSD3.h:92
void setScheme(GT_Scheme t)
Definition: GT_OSD3.h:81
const int * getPtexMap() const
Definition: GT_OSD3.h:322
GT_Size coarsePointCount() const
Definition: GT_OSD3.h:237
int findAttrib(const char *name) const
Definition: GT_OSD3.h:427
GLfloat GLfloat p
Definition: glew.h:16656
const T * getData(int attrib, int index, int seg) const
Definition: GT_OSD3.h:591
T * attribData(int attrib, GT_Size index, int seg)
Definition: GT_OSD3.h:477
int level() const
Definition: GT_OSD3.h:83
bool generateAllLevels() const
Definition: GT_OSD3.h:145
void setTriangulateQuads(bool v)
Definition: GT_OSD3.h:166
bool generateFVarTables() const
Definition: GT_OSD3.h:155
OpenSubdiv::Far::TopologyLevel LevelInfo
Definition: GT_OSD3.h:191
GT_Size coarseFaceCount() const
Definition: GT_OSD3.h:235
const TopologyRefiner * refiner() const
Access to the refiner.
Definition: GT_OSD3.h:245
int fineFVOffset() const
Definition: GT_OSD3.h:620
GLdouble n
Definition: glcorearb.h:2008
OpenSubdiv::Far::PatchMap PatchMap
Definition: GT_OSD3.h:646
OpenSubdiv::Far::TopologyRefiner TopologyRefiner
Definition: GT_OSD3.h:190
OpenSubdiv::Far::PtexIndices PtexIndices
Definition: GT_OSD3.h:644
int64 GT_Size
Definition: GT_Types.h:123
const T * attribData(int attrib, int seg) const
Definition: GT_OSD3.h:528
bool operator==(const GT_OSDPatchTable &o) const
Definition: GT_OSD3.h:285
PatchTable * getTable() const
Definition: GT_OSD3.h:325
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:89
OpenSubdiv::Far::PatchTable PatchTable
Definition: GT_OSD3.h:645
OpenSubdiv::Far::PatchTable PatchTable
Definition: GT_OSD3.h:268
SdcOptions & operator*()
Definition: GT_OSD3.h:77
const VertexStorage & fineStorage() const
Definition: GT_OSD3.h:580
fpreal64 fpreal
Definition: SYS_Types.h:277
const UT_Array< Vertex > & vertexArray() const
Definition: GT_OSD3.h:554
GLuint index
Definition: glcorearb.h:786
void setGenerateFVarTables(bool v)
Definition: GT_OSD3.h:174
const LevelInfo & levelInfo(int level) const
Definition: GT_OSD3.h:227
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:47
const VertexStorage & coarseVertex() const
Definition: GT_OSD3.h:549
OpenSubdiv::Far::PatchParam PatchParam
Definition: GT_OSD3.h:272
GLsizei const GLfloat * value
Definition: glcorearb.h:824
void setShareEndCapPatchPoints(bool v)
Definition: GT_OSD3.h:172
void setLevel(int l)
Definition: GT_OSD3.h:84
getOption("OpenEXR.storage") storage
Definition: HDK_Image.dox:276
void setAdaptive(bool b)
Definition: GT_OSD3.h:87
#define GETSET(TYPE, GET)
Definition: GT_OSD3.h:96
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:153
Definition: core.h:1131
bool initialized() const
Definition: GT_OSD3.h:326
GLintptr offset
Definition: glcorearb.h:665
OpenSubdiv::Far::TopologyRefiner TopologyRefiner
Definition: GT_OSD3.h:267
Topology definition for opensubdiv classes.
Definition: GT_OSD3.h:187
bool triangulateQuads() const
Definition: GT_OSD3.h:147
GLdouble s
Definition: glew.h:1395
bool operator==(const GT_OSDOptions &s) const
Definition: GT_OSD3.h:69
GT_Scheme scheme() const
Definition: GT_OSD3.h:80
SdcOptions::TriangleSubdivision TriangleSubdivision
Definition: GT_OSD3.h:45
const SdcOptions & operator->() const
Definition: GT_OSD3.h:76
GLenum GLsizei GLenum GLenum const void * table
Definition: glew.h:4970
const UT_Array< Vertex > & facevaryingArray() const
Definition: GT_OSD3.h:557
void setUseSingleCreasePatch(bool v)
Definition: GT_OSD3.h:168
Definition: format.h:895
bool adaptive() const
Test whether this has been built for adaptive refinement.
Definition: GT_OSD3.h:248
const VertexStorage * storage() const
Methods required for OpenSubdiv.
Definition: GT_OSD3.h:524
Interface to perform limit surface evaluation.
Definition: GT_OSD3.h:640
void * Handle
Definition: plugin.h:27
const VertexStorage & coarseFaceVarying() const
Definition: GT_OSD3.h:551
Options for topology and refinement.
Definition: GT_OSD3.h:38