8#ifndef OPENSUBDIV3_FAR_PATCH_TABLE_H
9#define OPENSUBDIV3_FAR_PATCH_TABLE_H
11#include "../version.h"
22namespace OPENSUBDIV_VERSION {
68 return (
int)_patchVerts.size();
150 template <
typename REAL>
169 template <
class T>
void
180 template <
typename REAL>
199 template <
class T>
void
210 template <
typename REAL>
231 template <
class T>
void
251 return _vertexValenceTable;
376 return _quadOffsetsTable;
411 template <
typename REAL>
413 REAL wP[], REAL wDu[] = 0, REAL wDv[] = 0,
414 REAL wDuu[] = 0, REAL wDuv[] = 0, REAL wDvv[] = 0)
const;
419 float wP[],
float wDu[] = 0,
float wDv[] = 0,
420 float wDuu[] = 0,
float wDuv[] = 0,
float wDvv[] = 0)
const;
425 double wP[],
double wDu[] = 0,
double wDv[] = 0,
426 double wDuu[] = 0,
double wDuv[] = 0,
double wDvv[] = 0)
const;
450 template <
typename REAL>
452 REAL wP[], REAL wDu[] = 0, REAL wDv[] = 0,
453 REAL wDuu[] = 0, REAL wDuv[] = 0, REAL wDvv[] = 0)
const;
458 float wP[],
float wDu[] = 0,
float wDv[] = 0,
459 float wDuu[] = 0,
float wDuv[] = 0,
float wDvv[] = 0)
const;
464 double wP[],
double wDu[] = 0,
double wDv[] = 0,
465 double wDuu[] = 0,
double wDuv[] = 0,
double wDvv[] = 0)
const;
491 template <
typename REAL>
493 REAL wP[], REAL wDu[] = 0, REAL wDv[] = 0,
494 REAL wDuu[] = 0, REAL wDuv[] = 0, REAL wDvv[] = 0,
495 int channel = 0)
const;
500 float wP[],
float wDu[] = 0,
float wDv[] = 0,
501 float wDuu[] = 0,
float wDuv[] = 0,
float wDvv[] = 0,
502 int channel = 0)
const;
507 double wP[],
double wDu[] = 0,
double wDv[] = 0,
508 double wDuu[] = 0,
double wDuv[] = 0,
double wDvv[] = 0,
509 int channel = 0)
const;
533 desc(d), numPatches(np), vertIndex(v),
534 patchIndex(p), quadOffsetIndex (qo) { }
547 typedef std::vector<PatchArray> PatchArrayVector;
549 PatchArray & getPatchArray(
Index arrayIndex);
550 PatchArray
const & getPatchArray(
Index arrayIndex)
const;
552 void reservePatchArrays(
int numPatchArrays);
553 void pushPatchArray(PatchDescriptor desc,
int npatches,
556 IndexArray getPatchArrayVertices(
int arrayIndex);
558 Index findPatchArray(PatchDescriptor desc);
564 IndexArray getPatchArrayVaryingVertices(
int arrayIndex);
566 void allocateVaryingVertices(
567 PatchDescriptor desc,
int numPatches);
568 void populateVaryingVertices();
598 struct FVarPatchChannel {
601 PatchDescriptor regDesc;
602 PatchDescriptor irregDesc;
606 std::vector<Index> patchValues;
607 std::vector<PatchParam> patchParam;
609 typedef std::vector<FVarPatchChannel> FVarPatchChannelVector;
611 FVarPatchChannel & getFVarPatchChannel(
int channel);
612 FVarPatchChannel
const & getFVarPatchChannel(
int channel)
const;
614 void allocateFVarPatchChannels(
int numChannels);
615 void allocateFVarPatchChannelValues(
616 PatchDescriptor regDesc, PatchDescriptor irregDesc,
617 int numPatches,
int channel);
620 void setFVarPatchChannelLinearInterpolation(
627 PatchParam getPatchFVarPatchParam(
int patch,
int channel)
const;
637 class StencilTablePtr {
639 typedef StencilTableReal<float> float_type;
640 typedef StencilTableReal<double> double_type;
648 StencilTablePtr() { _fPtr = 0; }
649 StencilTablePtr(float_type * ptr) { _fPtr = ptr; }
650 StencilTablePtr(double_type * ptr) { _dPtr = ptr; }
652 operator bool()
const {
return _fPtr != 0; }
654 void Set() { _fPtr = 0; }
655 void Set(float_type * ptr) { _fPtr = ptr; }
656 void Set(double_type * ptr) { _dPtr = ptr; }
658 template <
typename REAL> StencilTableReal<REAL> * Get()
const;
672 std::vector<Index> _patchVerts;
685 StencilTablePtr _localPointStencils;
686 StencilTablePtr _localPointVaryingStencils;
691 PatchDescriptor _varyingDesc;
693 std::vector<Index> _varyingVerts;
698 FVarPatchChannelVector _fvarChannels;
700 std::vector<StencilTablePtr> _localPointFaceVaryingStencils;
705 std::vector<Index> _sharpnessIndices;
706 std::vector<float> _sharpnessValues;
711 unsigned int _isUniformLinear : 1;
716 unsigned int _vertexPrecisionIsDouble : 1;
717 unsigned int _varyingPrecisionIsDouble : 1;
718 unsigned int _faceVaryingPrecisionIsDouble : 1;
725template <>
inline StencilTableReal<float> *
726PatchTable::StencilTablePtr::Get<float>()
const {
return _fPtr; }
728template <>
inline StencilTableReal<double> *
729PatchTable::StencilTablePtr::Get<double>()
const {
return _dPtr; }
731template <>
inline bool
733 return !_vertexPrecisionIsDouble;
735template <>
inline bool
737 return !_varyingPrecisionIsDouble;
739template <>
inline bool
741 return !_faceVaryingPrecisionIsDouble;
744template <>
inline bool
746 return _vertexPrecisionIsDouble;
748template <>
inline bool
750 return _varyingPrecisionIsDouble;
752template <>
inline bool
754 return _faceVaryingPrecisionIsDouble;
763 return reinterpret_cast<StencilTable const *
>(_localPointStencils.Get<
float>());
769 _localPointVaryingStencils.Get<
float>());
774 if (channel >= 0 && channel < (
int)_localPointFaceVaryingStencils.size()) {
776 _localPointFaceVaryingStencils[channel].Get<
float>());
781template <
typename REAL>
785 return _localPointStencils.Get<REAL>();
787template <
typename REAL>
791 return _localPointVaryingStencils.Get<REAL>();
793template <
typename REAL>
797 if (channel >= 0 && channel < (
int)_localPointFaceVaryingStencils.size()) {
798 return _localPointFaceVaryingStencils[channel].Get<REAL>();
811 if (_localPointStencils) {
812 _localPointStencils.Get<
float>()->UpdateValues(src, dst);
820 if (_localPointVaryingStencils) {
821 _localPointVaryingStencils.Get<
float>()->UpdateValues(src, dst);
829 if (channel >= 0 && channel < (
int)_localPointFaceVaryingStencils.size()) {
830 if (_localPointFaceVaryingStencils[channel]) {
831 _localPointFaceVaryingStencils[channel].Get<
float>()->UpdateValues(src, dst);
842 float wP[],
float wDu[],
float wDv[],
843 float wDuu[],
float wDuv[],
float wDvv[])
const {
849 double wP[],
double wDu[],
double wDv[],
850 double wDuu[],
double wDuv[],
double wDvv[])
const {
857 float wP[],
float wDu[],
float wDv[],
858 float wDuu[],
float wDuv[],
float wDvv[])
const {
864 double wP[],
double wDu[],
double wDv[],
865 double wDuu[],
double wDuv[],
double wDvv[])
const {
872 float wP[],
float wDu[],
float wDv[],
873 float wDuu[],
float wDuv[],
float wDvv[],
int channel)
const {
879 double wP[],
double wDu[],
double wDv[],
880 double wDuu[],
double wDuv[],
double wDvv[],
int channel)
const {
888using namespace OPENSUBDIV_VERSION;
Vtr::ConstIndexArray ConstIndexArray
std::vector< PatchParam > PatchParamTable
Vtr::IndexArray IndexArray
Vtr::Array< PatchParam > PatchParamArray
std::vector< PatchArray > PatchArrayVector
Describes the type of a patch.
An quadtree-based map connecting coarse faces to their sub-patches.
Container for arrays of parametric patches.
ConstIndexArray GetPatchArrayVaryingVertices(int array) const
Returns the varying vertex indices for the patches in array.
float * getSharpnessValues(Index arrayIndex)
PatchVertsTable const & GetPatchControlVerticesTable() const
Get the table of patch control vertices.
void ComputeLocalPointValuesFaceVarying(T const *src, T *dst, int channel=0) const
Updates local point face-varying values.
ConstIndexArray GetVaryingVertices() const
Returns an array of varying vertex indices for the patches.
void ComputeLocalPointValuesVarying(T const *src, T *dst) const
Updates local point varying values.
ConstIndexArray GetPatchVaryingVertices(PatchHandle const &handle) const
Returns the varying vertex indices for a given patch.
bool IsFeatureAdaptive() const
True if the patches are of feature adaptive types.
int GetMaxValence() const
Returns max vertex valence.
StencilTableReal< REAL > const * GetLocalPointStencilTable() const
Returns the stencil table to compute local point vertex values.
StencilTable const * GetLocalPointStencilTable() const
Returns the stencil table to compute local point vertex values.
PatchParamArray getPatchParams(int arrayIndex)
std::vector< unsigned int > QuadOffsetsTable
ConstIndexArray GetPatchArrayFVarValues(int array, int channel=0) const
Returns the value indices for the patches in array in channel.
std::vector< float > const & GetSharpnessValues() const
Returns sharpness values table.
PatchParam GetPatchFVarPatchParam(int array, int patch, int channel=0) const
Returns the face-varying params for a given patch channel.
ConstIndexArray GetPatchVaryingVertices(int array, int patch) const
Returns the varying vertex indices for a given patch.
PatchTable(PatchTable const &src)
Copy constructor.
int GetNumPatchArrays() const
Returns the number of patch arrays in the table.
ConstIndexArray GetPatchVertices(PatchHandle const &handle) const
Returns the control vertex indices for the patch identified by handle.
PatchTable(int maxvalence)
bool LocalPointFaceVaryingStencilPrecisionMatchesType() const
Tests if the precision of the stencil table to compute local point face-varying values matches the gi...
PatchParamTable const & GetPatchParamTable() const
Returns the PatchParamTable (PatchParams order matches patch array sorting)
VertexValenceTable const & GetVertexValenceTable() const
Returns the 'VertexValences' table (vertex neighborhoods table)
StencilTable const * GetLocalPointFaceVaryingStencilTable(int channel=0) const
Returns the stencil table to compute local point face-varying values.
int GetNumControlVertices(int array) const
Returns the number of control vertices in array.
void EvaluateBasisFaceVarying(PatchHandle const &handle, REAL u, REAL v, REAL wP[], REAL wDu[]=0, REAL wDv[]=0, REAL wDuu[]=0, REAL wDuv[]=0, REAL wDvv[]=0, int channel=0) const
Evaluate basis functions for a face-varying value and derivatives at a given (u,v) parametric locatio...
ConstQuadOffsetsArray GetPatchQuadOffsets(PatchHandle const &handle) const
Returns the 'QuadOffsets' for the Gregory patch identified by handle.
std::vector< Index > VertexValenceTable
PatchDescriptor GetFVarPatchDescriptorIrregular(int channel=0) const
Returns the irregular patch descriptor for channel.
float GetSingleCreasePatchSharpnessValue(int array, int patch) const
Returns the crease sharpness for the patch in array if it is a single-crease patch,...
Vtr::ConstArray< unsigned int > ConstQuadOffsetsArray
Accessors for the gregory patch evaluation buffers. These methods will be deprecated.
Index * getSharpnessIndices(Index arrayIndex)
void ComputeLocalPointValues(T const *src, T *dst) const
Updates local point vertex values.
float GetSingleCreasePatchSharpnessValue(PatchHandle const &handle) const
Returns the crease sharpness for the patch identified by handle if it is a single-crease patch,...
PatchParam GetPatchParam(int array, int patch) const
Returns the PatchParam for patch in array.
ConstIndexArray GetPatchFVarValues(int array, int patch, int channel=0) const
Returns the value indices for a given patch in channel.
PatchDescriptor GetFVarPatchDescriptorRegular(int channel=0) const
Returns the regular patch descriptor for channel.
PatchDescriptor GetPatchDescriptor(PatchHandle const &handle) const
Returns the PatchDescriptor for the patch identified by handle.
QuadOffsetsTable const & GetQuadOffsetsTable() const
Returns the quad-offsets table.
int GetNumPatches(int array) const
Returns the number of patches in array.
PatchDescriptor GetVaryingPatchDescriptor() const
Returns the varying patch descriptor.
ConstIndexArray GetPatchFVarValues(PatchHandle const &handle, int channel=0) const
Returns the value indices for a given patch in channel.
ConstPatchParamArray const GetPatchParams(int array) const
Returns the PatchParams for the patches in array.
int GetNumControlVerticesTotal() const
Returns the total number of control vertex indices in the table.
int GetNumFVarChannels() const
Returns the number of face-varying channels.
ConstPatchParamArray GetPatchArrayFVarPatchParams(int array, int channel=0) const
Returns the face-varying for a given patch in array in channel.
Index getPatchIndex(int array, int patch) const
int GetNumLocalPoints() const
Returns the number of local vertex points.
bool LocalPointVaryingStencilPrecisionMatchesType() const
Tests if the precision of the stencil table to compute local point varying values matches the given f...
ConstIndexArray GetPatchArrayVertices(int array) const
Returns the control vertex indices for the patches in array.
int GetNumPtexFaces() const
Returns the total number of ptex faces in the mesh.
ConstIndexArray GetFVarValues(int channel=0) const
Returns an array of value indices for the patches in channel.
void EvaluateBasis(PatchHandle const &handle, REAL u, REAL v, REAL wP[], REAL wDu[]=0, REAL wDv[]=0, REAL wDuu[]=0, REAL wDuv[]=0, REAL wDvv[]=0) const
Evaluate basis functions for position and derivatives at a given (u,v) parametric location of a patch...
StencilTableReal< REAL > const * GetLocalPointFaceVaryingStencilTable(int channel=0) const
Returns the stencil table to compute local point face-varying values.
int GetNumPatchesTotal() const
Returns the total number of patches stored in the table.
PatchParam GetPatchParam(PatchHandle const &handle) const
Returns a PatchParam for the patch identified by handle.
void print() const
debug helper
Sdc::Options::FVarLinearInterpolation GetFVarChannelLinearInterpolation(int channel=0) const
Deprecated.
std::vector< Index > const & GetSharpnessIndexTable() const
Returns a sharpness index table for each patch (if exists)
PatchDescriptor GetPatchArrayDescriptor(int array) const
Returns the PatchDescriptor for the patches in array.
friend class PatchTableBuilder
void EvaluateBasisVarying(PatchHandle const &handle, REAL u, REAL v, REAL wP[], REAL wDu[]=0, REAL wDv[]=0, REAL wDuu[]=0, REAL wDuv[]=0, REAL wDvv[]=0) const
Evaluate basis functions for a varying value and derivatives at a given (u,v) parametric location of ...
StencilTable const * GetLocalPointVaryingStencilTable() const
Returns the stencil table to compute local point varying values.
ConstIndexArray GetPatchVertices(int array, int patch) const
Returns the control vertex indices for patch in array.
PatchParam GetPatchFVarPatchParam(PatchHandle const &handle, int channel=0) const
Returns the value indices for a given patch in channel.
int GetFVarValueStride(int channel=0) const
Returns the stride between patches in the value index array of channel.
ConstPatchParamArray GetFVarPatchParams(int channel=0) const
Returns an array of face-varying patch param for channel.
PatchDescriptor GetFVarPatchDescriptor(int channel=0) const
Returns the default/irregular patch descriptor for channel.
int GetNumLocalPointsVarying() const
Returns the number of local varying points.
bool LocalPointStencilPrecisionMatchesType() const
Tests if the precision of the stencil table to compute local point vertex values matches the given fl...
std::vector< Index > PatchVertsTable
StencilTableReal< REAL > const * GetLocalPointVaryingStencilTable() const
Returns the stencil table to compute local point varying values.
int GetNumLocalPointsFaceVarying(int channel=0) const
Returns the number of local face-varying points for channel.
Handle that can be used as unique patch identifier within PatchTable.
Table of subdivision stencils.
Stencil table class wrapping the template for compatibility.