25 #ifndef FAR_PATCH_TABLES_H
26 #define FAR_PATCH_TABLES_H
28 #include "../version.h"
30 #include "../far/patchParam.h"
31 #include "../far/types.h"
39 namespace OpenSubdiv {
40 namespace OPENSUBDIV_VERSION {
52 typedef std::vector<unsigned int>
PTable;
111 _type(type), _pattern(pattern), _rotation(rotation) { }
129 return (
unsigned char)_rotation;
208 unsigned int _type:4;
209 unsigned int _pattern:3;
210 unsigned int _rotation:2;
236 PatchArray(
Descriptor desc,
unsigned int vertIndex,
unsigned int patchIndex,
unsigned int npatches,
unsigned int quadOffsetIndex ) :
237 _desc(desc), _range(vertIndex, patchIndex, npatches, quadOffsetIndex) { }
260 ArrayRange(
unsigned int ivertIndex,
unsigned int ipatchIndex,
unsigned int inpatches,
unsigned int iquadOffsetIndex ) :
311 return const_cast<PatchTables *
>(
this)->findPatchArray( desc );
410 return (
int)_channels.size();
418 return _channels[channel].patchVertIndices;
427 std::vector<unsigned int> patchVertIndices;
430 std::vector<Channel> _channels;
457 FVarPatchTables
const * fvarPatchTables,
471 PatchTables(
int maxvalence ) : _fvarPatchTables(0), _maxValence(maxvalence) { }
483 FVarPatchTables
const * _fvarPatchTables;
509 return (_pos==other._pos);
514 return not (*
this==other);
537 std::vector<Descriptor>
const & descs =
540 for (
int i=0; i<(int)descs.size(); ++i) {
541 if (descs[i] == desc) {
559 PatchTables::Descriptor::iterator::getValue()
const {
563 std::vector<Descriptor>
const & descs =
566 if (_pos>=0 and _pos<(
int)descs.size()) {
573 inline std::vector<PatchTables::Descriptor>
const &
576 static std::vector<Descriptor> _descriptors;
578 if (_descriptors.empty()) {
579 _descriptors.reserve(55);
597 for (
int j=0; j<4; ++j) {
601 for (
int j=0; j<4; ++j) {
638 _patchArrays(patchArrays),
640 _fvarPatchTables(fvarPatchTables),
641 _maxValence(maxValence),
646 _vertexValenceTable = *vertexValences;
648 _quadOffsetTable = *quadOffsets;
650 _paramTable = *patchParams;
658 if (not _vertexValenceTable.empty())
664 for (
int i=0; i<(int)parrays.size(); ++i) {
666 if (parrays[i].GetDescriptor().GetType() >=
REGULAR and
679 case QUADS :
return 4;
685 case LINES :
return 2;
696 for (
int i=0; i<(int)_patchArrays.size(); ++i) {
697 result += _patchArrays[i].GetDescriptor().GetNumControlVertices() *
698 _patchArrays[i].GetNumPatches();
715 case LINES :
return 2;
734 return &(*parrays.rbegin());
735 }
else if ((level-1) < (int)parrays.size() ) {
736 return &parrays[level-1];
743 inline unsigned int const *
769 return _pattern < other._pattern or ((_pattern == other._pattern) and
770 (_type < other._type or ((_type == other._type) and
771 (_rotation < other._rotation))));
777 return _pattern == other._pattern and
778 _type == other._type and
779 _rotation == other._rotation;
786 for (
int i=0; i<(int)_patchArrays.size(); ++i) {
787 if (_patchArrays[i].GetDescriptor()==desc)
788 return &_patchArrays[i];
803 using namespace OPENSUBDIV_VERSION;
unsigned char GetRotation() const
Returns the rotation of the patch (4 rotations)
TransitionPattern GetPattern() const
Returns the transition pattern of the patch if any (5 types)
Descriptor()
Default constructor.
PatchArray const * GetPatchArray(Descriptor desc) const
Returns a pointer to the array of patches matching the descriptor.
Container for patch vertex indices tables.
Describes the range of patches in a PatchArray.
std::vector< PatchParam > PatchParamTable
ArrayRange const & GetArrayRange() const
Returns a array range struct.
int GetNumFaces(int level=0) const
Returns the number of faces in a uniformly subdivided mesh at a given level.
lines (useful for cage drawing)
PatchParamTable const & GetPatchParamTable() const
Returns a PatchParamTable for each type of patch.
bool IsFeatureAdaptive() const
True if the patches are of feature adaptive types.
Describes the type of a patch.
static short GetRegularPatchRingsize()
Ringsize of Regular Patches in table.
bilinear quads-only patches
unsigned int GetVertIndex() const
Returns the index of the first control vertex of the first patch of this array in the global PTable...
Descriptor(Descriptor const &d)
Copy Constructor.
Face-varying patch vertex indices tables.
std::vector< unsigned int > const & GetPatchVertices(int channel) const
Returns the face-varying patches vertex indices.
int GetNumPatches() const
Returns the total number of patches stored in the tables.
Descriptor const * operator->() const
Dereferencing operator.
static iterator begin(PrimType type)
Returns a patch type iterator.
PatchArray(Descriptor desc, unsigned int vertIndex, unsigned int patchIndex, unsigned int npatches, unsigned int quadOffsetIndex)
Constructor.
unsigned int const * GetFaceVertices(int level=0) const
Returns a pointer to the vertex indices of uniformly subdivided faces.
Descriptor(int type, int pattern, unsigned char rotation)
Constructor.
feature-adaptive bicubic patches
unsigned int quadOffsetIndex
ArrayRange(unsigned int ivertIndex, unsigned int ipatchIndex, unsigned int inpatches, unsigned int iquadOffsetIndex)
Constructor.
int GetNumChannels() const
Returns the number of face-varying primvar channels.
Descriptor iterator class.
short GetNumFVarControlVertices() const
Returns the number of control vertices expected for a patch of the type described.
static short GetCornerPatchRingsize()
Ringsize of Boundary Patches in table.
iterator & operator++()
Iteration increment operator.
bool operator==(Descriptor const other) const
True if the descriptors are identical.
std::vector< unsigned int > QuadOffsetTable
static std::vector< Descriptor > const & GetAllValidDescriptors()
Returns a vector of all the legal patch descriptors.
bool operator==(iterator const &other) const
True of the two descriptors are identical.
Descriptor GetDescriptor() const
Returns a patch descriptor defining the type of patches in the array.
int GetNumPtexFaces() const
Returns the total number of vertices in the mesh across across all depths.
unsigned int GetPatchIndex() const
Returns the global index of the first patch in this array (Used to access param / fvar table data) ...
bool operator<(Descriptor const other) const
Allows ordering of patches by type.
std::vector< unsigned int > PTable
unsigned int GetNumPatches() const
Returns the number of patches in the array.
bool operator!=(iterator const &other) const
True if the two descriptors are different.
PatchArrayVector const & GetPatchArrayVector() const
Returns all arrays of patches.
unsigned int GetQuadOffsetIndex() const
Returns the index to the first entry in the QuadOffsetTable.
Describes an array of patches of the same type.
PatchTables(PatchArrayVector const &patchArrays, PTable const &patches, VertexValenceTable const *vertexValences, QuadOffsetTable const *quadOffsets, PatchParamTable const *patchParams, FVarPatchTables const *fvarPatchTables, int maxValence)
Public constructor.
~PatchTables()
Destructor.
std::vector< PatchArray > PatchArrayVector
PTable const & GetPatchTable() const
Get the table of patch control vertices.
VertexValenceTable const & GetVertexValenceTable() const
Returns a vertex valence table used by Gregory patches.
QuadOffsetTable const & GetQuadOffsetTable() const
Returns a quad offsets table used by Gregory patches.
static short GetBoundaryPatchRingsize()
Ringsize of Boundary Patches in table.
int GetMaxValence() const
Returns max vertex valence.
FVarPatchTables const * GetFVarPatchTables() const
Returns the face-varying patches.
std::vector< int > VertexValenceTable
static short GetGregoryPatchRingsize()
Ringsize of Gregory (and Gregory Boundary) Patches in table.
A specialized factory for feature adaptive PatchTables.
bilinear triangles-only mesh
Descriptor const & operator*() const
Dereferencing operator.
Type GetType() const
Returns the type of the patch.
short GetNumControlVertices() const
Returns the number of control vertices expected for a patch of the type described.
points (useful for cage drawing)
int GetNumControlVertices() const
Returns the total number of control vertex indices in the tables.
static iterator end()
Returns an iterator to the end of the list of patch types (NON_PATCH)