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