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 #include <opensubdiv/bfr/surface.h>
50 bool adaptive =
false,
51 fpreal crease_override = -1,
52 bool remove_holes =
true)
55 , myCreaseOverride(crease_override)
57 , myAdaptive(adaptive)
58 , myRemoveHoles(remove_holes)
61 setVtxBoundaryInterpolation(SdcOptions::VTX_BOUNDARY_EDGE_AND_CORNER);
62 setFVarLinearInterpolation(SdcOptions::FVAR_LINEAR_BOUNDARIES);
71 {
return isEqual(s); }
73 {
return !isEqual(s); }
84 int level()
const {
return myLevel; }
97 #define GETSET(TYPE, GET) \
98 TYPE GET() const { return myOptions.Get##TYPE(); } \
99 void set##TYPE(TYPE v) { myOptions.Set##TYPE(v); }
103 GETSET(VtxBoundaryInterpolation, vtxBoundaryInterpolation);
104 GETSET(FVarLinearInterpolation, fvarLinearInterpolation);
105 GETSET(CreasingMethod, creasingMethod);
106 GETSET(TriangleSubdivision, triangleSubdivision);
114 SdcOptions myOptions;
135 {
return isEqual(o); }
137 {
return !isEqual(o); }
147 {
return myOptions.generateAllLevels; }
149 {
return myOptions.triangulateQuads; }
151 {
return myOptions.useSingleCreasePatch; }
153 {
return myOptions.maxIsolationLevel; }
155 {
return myOptions.shareEndCapPatchPoints; }
157 {
return myOptions.generateFVarTables; }
159 {
return myOptions.numFVarChannels; }
161 {
return myOptions.fvarChannelIndices; }
166 { myOptions.generateAllLevels =
v; }
168 { myOptions.triangulateQuads =
v; }
170 { myOptions.useSingleCreasePatch =
v; }
172 { myOptions.maxIsolationLevel =
v; }
174 { myOptions.shareEndCapPatchPoints =
v; }
176 { myOptions.generateFVarTables =
v; }
178 { myOptions.numFVarChannels =
n; }
180 { myOptions.fvarChannelIndices =
indices; }
182 { myOptions.generateFVarLegacyLinearPatches =
b; }
184 FactoryOptions myOptions;
219 {
return myRefiner->GetNumLevels(); }
229 {
return myRefiner->GetLevel(level); }
231 {
return levelInfo(myRefiner->GetNumLevels()-1); }
237 {
return levelInfo(0).GetNumFaces(); }
239 {
return levelInfo(0).GetNumVertices(); }
241 {
return levelInfo(0).GetNumFaceVertices(); }
259 TopologyRefiner *myRefiner;
281 bool createPtexMap=
false,
282 bool legacy_linear=
true,
287 {
return isEqual(o); }
292 int arrayCount()
const;
293 int arrayPatchCount(
int arr)
const;
294 int numLocalPoints()
const;
295 int numLocalPointsVarying()
const;
296 ConstIndexArray vertexArray(
int arr)
const;
297 ConstIndexArray varyingVertexArray(
int arr)
const;
298 PatchDescriptor arrayPatchDesc(
int arr)
const;
303 myTable->ComputeLocalPointValues(src, dest);
309 myTable->ComputeLocalPointValuesFaceVarying(src, dest);
313 PatchParam patchParam(
int arr,
int pat)
const;
314 ConstIndexArray patchVertices(
const Handle &patch)
const;
315 ConstIndexArray patchFVValues(
const Handle &patch)
const;
316 void evaluateBasis(
const Handle &patch,
float u,
float v,
317 float *
w,
float *du,
float *dv)
const;
318 void evaluateBasisFV(
const Handle &patch,
float u,
float v,
319 float *
w,
float *du,
float *dv)
const;
322 int numPtexFaces()
const;
350 exint getMemoryUsage()
const;
358 bool skip_equality_check =
false);
385 int level_index)
const;
390 int level_index)
const;
395 AttribId findAttribute(
const char *
name,
bool vertex_attrib)
const;
399 int tupleSize(
const AttribId &attrib)
const;
402 bool coarseValues(
const AttribId &attrib,
416 , myPointers(nullptr)
426 exint getMemoryUsage()
const;
430 return myAttribs ? myAttribs->getIndex(name) : -1;
435 bool skip_equality_check =
false);
442 delete [] myPointers;
446 myPointers =
nullptr;
464 {
return myAttribs->get(attrib); }
470 {
return myPointers[attrib] !=
nullptr; }
472 {
return myStorage[attrib]; }
474 {
return myType[attrib]; }
477 template <
typename T>
480 UT_ASSERT(myPointers[attrib + mySize * seg]);
484 auto data = (
T *)myPointers[attrib + mySize * seg];
485 return data + index*mySizes[attrib];
487 template <
typename T>
490 UT_ASSERT(myPointers[attrib + mySize * seg]);
491 auto data = (
const T *)myPointers[attrib + mySize * seg];
492 return data + index*mySizes[attrib];
502 const void **myPointers;
528 template <
typename T>
532 return static_cast<const VertexStorage *
>(myStorage)->attribData<T>(
533 attrib, myIndex, seg);
541 void AddWithWeight(
const Vertex &
src,
float weight);
551 {
return myCoarseStorage; }
553 {
return myCoarseFVStorage; }
556 {
return myVertices; }
559 {
return myFVertices; }
571 const AttribId &attrib)
const;
577 const AttribId &attrib)
const;
591 template <
typename T>
594 if (index < myFineOffset)
596 return myCoarseStorage.attribData<
T>(attrib,
index, seg);
600 int offset = index - myFineOffset;
601 return myFineStorage.attribData<
T>(attrib,
offset, seg);
606 template <
typename T>
609 if (index < myFineFVOffset)
611 return myCoarseFVStorage.attribData<
T>(attrib,
index, seg);
615 int offset = index - myFineFVOffset;
616 return myFineFVStorage.attribData<
T>(attrib,
offset, seg);
630 VertexStorage myCoarseStorage;
631 VertexStorage myFineStorage;
632 VertexStorage myCoarseFVStorage;
633 VertexStorage myFineFVStorage;
637 exint myFineFVOffset;
644 using Surface = OpenSubdiv::Bfr::Surface<fpreal32>;
650 exint getMemoryUsage()
const;
661 return doPreparePatchPoints<false>(attrdata);
667 return doPreparePatchPoints<true>(attrdata);
676 template <
typename T>
678 int ptexid,
float u,
float v,
681 doEvaluate<T, false>(
result, du, dv, ptexid, u,
v, patchpoints);
684 template <
typename T>
686 int ptexid,
float u,
float v,
689 doEvaluate<T, true>(
result, du, dv, ptexid, u,
v, patchpoints);
694 const int *
getPtexMap()
const {
return myPtexToFaceMap.array(); };
698 void decodePtex(
int &faceid,
int &subface,
int ptexid)
const;
701 exint totalPatchPointsCount()
const;
707 template <
typename T,
bool FVAR>
709 int ptexid,
float u,
float v,
742 int ptexFaceCount()
const;
745 int ptexFromFace(
GT_Size face_index)
const;
752 {
return numPtexPatches(*top.
refiner(), face_index); }
785 const AttribId &attrib,
799 const AttribId &attrib,
const UT_Array< int > & getPtexArray() const
SIM_API const UT_StringHolder vertex
OpenSubdiv::Far::ConstIndexArray ConstIndexArray
OpenSubdiv::Far::TopologyRefiner TopologyRefiner
OpenSubdiv::Far::PatchTableFactory PatchTableFactory
const int * fvarChannelIndices() const
FactoryOptions & operator*()
GLsizei GLenum const void * indices
OpenSubdiv::Sdc::Options SdcOptions
GT_Storage attribStorage(int attrib) const
GT_DataArrayHandle preparePatchPoints(const GT_DataArrayHandle &attrdata) const
OpenSubdiv::Far::PtexIndices PtexIndices
void computeLocalPoints(const T *src, T *dest) const
int numPtexPatches(const GT_OSDTopology &top, GT_Size face_index) const
GT_DataArrayHandle preparePatchPointsFV(const GT_DataArrayHandle &attrdata) const
OpenSubdiv::Far::PatchDescriptor::Type PatchType
void evaluate(T *result, T *du, T *dv, int ptexid, float u, float v, const GT_DataArrayHandle &patchpoints) const
const LevelInfo & lastLevel() const
void computeLocalFVPoints(const T *src, T *dest) const
bool operator!=(const GT_OSDPatchTableOptions &o) const
SdcOptions & operator->()
GT_OSDAttributes::AttribId AttribId
getFileOption("OpenEXR:storage") storage
const SdcOptions & operator*() const
void setRemoveHoles(bool v)
void evaluateFV(T *result, T *du, T *dv, int ptexid, float u, float v, const GT_DataArrayHandle &patchpoints) const
GLsizei const GLfloat * value
std::pair< int, bool > AttribId
const VertexStorage & coarseFVStorage() const
OpenSubdiv::Far::PatchDescriptor PatchDescriptor
bool operator==(const GT_OSDPatchTableOptions &o) const
void setMaxIsolationLevel(int v)
GLboolean GLboolean GLboolean GLboolean a
const VertexStorage & fineFVStorage() const
std::size_t SYS_HashType
Define the type for hash values.
Storage arrays for vertex data for opensubdiv classes.
int maxIsolationLevel() const
void setCreaseOverride(fpreal value=-1)
SdcOptions::VtxBoundaryInterpolation VtxBoundaryInterpolation
Class which writes ASCII or binary JSON streams.
const T * attribData(int attrib, GT_Size index, int seg) const
**But if you need a result
void init(VertexStorage &storage, GT_Size index)
OpenSubdiv::Far::PatchTableFactory PatchTableFactory
void setFVarChannelIndices(const int *indices)
void setGenerateAllLevels(bool v)
SdcOptions::FVarLinearInterpolation FVarLinearInterpolation
Options for setting up limit surface evaluation.
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
bool useSingleCreasePatch() const
fpreal creaseOverride() const
FactoryOptions::EndCapType endCapType() const
SdcOptions::CreasingMethod CreasingMethod
OIIO_FORCEINLINE bool extract(const vbool4 &a)
void setEndCapType(FactoryOptions::EndCapType t)
void setOptions(const SdcOptions &o)
const FactoryOptions & operator*() const
GT_Size attribSize(int attrib) const
int numFVarChannels() const
const T * getDataFV(int attrib, int index, int seg) const
Same idea as with getData, but with face varying data.
GT_Size coarseVertexCount() const
bool attribValid(int attrib) const
GT_Type attribType(int attrib) const
const SdcOptions & options() const
GT_Scheme
Subdivision schemes.
void setNumFVarChannels(int n)
void setLegacyLinearPatches(bool b)
bool operator==(const GT_OSDTopology &o) const
PatchTable::PatchHandle Handle
const GT_AttributeListHandle & attribList() const
Raw access to the attributes.
OpenSubdiv::Far::PatchTableFactory::Options FactoryOptions
GT_API const UT_StringHolder topology
bool operator!=(const GT_OSDOptions &s) const
const VertexStorage & coarseStorage() const
bool shareEndCapPatchPoints() const
exint levelCount() const
Number of levels in refinement (note this is the max level + 1)
bool enableCreaseOverride() const
void setScheme(GT_Scheme t)
const int * getPtexMap() const
GT_Size coarsePointCount() const
int findAttrib(const char *name) const
const T * getData(int attrib, int index, int seg) const
GT_OSDPatchTableOptions()
T * attribData(int attrib, GT_Size index, int seg)
GLuint const GLchar * name
bool generateAllLevels() const
GLboolean GLboolean GLboolean b
GT_ElementSetMapPtr GT_FaceSetMapPtr
Aliases for backwards compatibility. In the past, only face sets were supported.
void setTriangulateQuads(bool v)
GLenum GLenum GLsizei void * table
bool generateFVarTables() const
OpenSubdiv::Far::TopologyLevel LevelInfo
GT_Size coarseFaceCount() const
const TopologyRefiner * refiner() const
Access to the refiner.
OpenSubdiv::Far::PatchMap PatchMap
Minimal interface to Bfr (base-face representation)
OpenSubdiv::Far::TopologyRefiner TopologyRefiner
OpenSubdiv::Far::PtexIndices PtexIndices
const T * attribData(int attrib, int seg) const
bool operator==(const GT_OSDPatchTable &o) const
PatchTable * getTable() const
const GT_DataArrayHandle & attribArray(int attrib) const
Access a specific data array in the attributes.
OpenSubdiv::Far::PatchTable PatchTable
OpenSubdiv::Far::PatchTable PatchTable
GLenum GLsizei GLsizei GLint * values
const VertexStorage & fineStorage() const
const int * getPtexMap() const
Get Ptex to base face mapping.
const UT_Array< Vertex > & vertexArray() const
void setGenerateFVarTables(bool v)
const LevelInfo & levelInfo(int level) const
GT_OSDOptions(GT_Scheme scheme=GT_CATMULL_CLARK, int level=2, bool adaptive=false, fpreal crease_override=-1, bool remove_holes=true)
const VertexStorage & coarseVertex() const
OpenSubdiv::Far::PatchParam PatchParam
void setShareEndCapPatchPoints(bool v)
GLdouble GLdouble GLdouble top
#define GETSET(TYPE, GET)
GLubyte GLubyte GLubyte GLubyte w
OpenSubdiv::Far::TopologyRefiner TopologyRefiner
Topology definition for opensubdiv classes.
OpenSubdiv::Bfr::Surface< fpreal32 > Surface
int motionSegments() const
bool triangulateQuads() const
bool operator==(const GT_OSDOptions &s) const
SdcOptions::TriangleSubdivision TriangleSubdivision
const SdcOptions & operator->() const
const UT_Array< Vertex > & facevaryingArray() const
void setUseSingleCreasePatch(bool v)
bool adaptive() const
Test whether this has been built for adaptive refinement.
const VertexStorage * storage() const
Methods required for OpenSubdiv.
Interface to perform limit surface evaluation.
const VertexStorage & coarseFaceVarying() const
Options for topology and refinement.