Loading...
Searching...
No Matches
patchDescriptor.h
Go to the documentation of this file.
//
// Copyright 2013 Pixar
//
// Licensed under the Apache License, Version 2.0 (the "Apache License")
// with the following modification; you may not use this file except in
// compliance with the Apache License and the following modification to it:
// Section 6. Trademarks. is deleted and replaced with:
//
// 6. Trademarks. This License does not grant permission to use the trade
// names, trademarks, service marks, or product names of the Licensor
// and its affiliates, except as required to comply with Section 4(c) of
// the License and to reproduce the content of the NOTICE file.
//
// You may obtain a copy of the Apache License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the Apache License with the above modification is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the Apache License for the specific
// language governing permissions and limitations under the Apache License.
//
#ifndef OPENSUBDIV3_FAR_PATCH_DESCRIPTOR_H
#define OPENSUBDIV3_FAR_PATCH_DESCRIPTOR_H
#include "../version.h"
#include "../far/types.h"
#include "../sdc/types.h"
#include <vector>
namespace OpenSubdiv {
namespace OPENSUBDIV_VERSION {
namespace Far {
class PatchDescriptor {
public:
enum Type {
NON_PATCH = 0,
POINTS,
LINES,
QUADS,
TRIANGLES,
LOOP,
REGULAR,
GREGORY,
GREGORY_BOUNDARY,
GREGORY_BASIS,
GREGORY_TRIANGLE
};
public:
PatchDescriptor() :
_type(NON_PATCH) { }
PatchDescriptor(int type) :
_type(type) { }
PatchDescriptor( PatchDescriptor const & d ) :
_type(d.GetType()) { }
PatchDescriptor & operator=( PatchDescriptor const & d ) {
_type = d.GetType();
return *this;
}
Type GetType() const {
return (Type)_type;
}
static inline bool IsAdaptive(Type type) {
return type > TRIANGLES;
}
bool IsAdaptive() const {
return IsAdaptive( this->GetType() );
}
static inline short GetNumControlVertices( Type t );
static inline short GetNumFVarControlVertices( Type t );
short GetNumControlVertices() const {
return GetNumControlVertices( this->GetType() );
}
short GetNumFVarControlVertices() const {
return GetNumFVarControlVertices( this->GetType() );
}
static short GetRegularPatchSize() { return 16; }
static short GetGregoryPatchSize() { return 4; }
static short GetGregoryBasisPatchSize() { return 20; }
static Vtr::ConstArray<PatchDescriptor> GetAdaptivePatchDescriptors(Sdc::SchemeType type);
inline bool operator < ( PatchDescriptor const other ) const;
inline bool operator == ( PatchDescriptor const other ) const;
// debug helper
void print() const;
private:
unsigned int _type;
};
typedef Vtr::ConstArray<PatchDescriptor> ConstPatchDescriptorArray;
// Returns the number of control vertices expected for a patch of this type
inline short
PatchDescriptor::GetNumControlVertices( Type type ) {
switch (type) {
case REGULAR : return GetRegularPatchSize();
case LOOP : return 12;
case QUADS : return 4;
case GREGORY :
case GREGORY_BOUNDARY : return GetGregoryPatchSize();
case GREGORY_BASIS : return GetGregoryBasisPatchSize();
case GREGORY_TRIANGLE : return 18;
case TRIANGLES : return 3;
case LINES : return 2;
case POINTS : return 1;
default : return -1;
}
}
// Returns the number of face-varying control vertices expected for a patch of this type
inline short
PatchDescriptor::GetNumFVarControlVertices( Type type ) {
return PatchDescriptor::GetNumControlVertices(type);
}
// Allows ordering of patches by type
inline bool
PatchDescriptor::operator < ( PatchDescriptor const other ) const {
return (_type < other._type);
}
// True if the descriptors are identical
inline bool
PatchDescriptor::operator == ( PatchDescriptor const other ) const {
return _type == other._type;
}
} // end namespace Far
} // end namespace OPENSUBDIV_VERSION
using namespace OPENSUBDIV_VERSION;
} // end namespace OpenSubdiv
#endif /* OPENSUBDIV3_FAR_PATCH_DESCRIPTOR_H */
OpenSubdiv
Definition limits.h:32
OpenSubdiv::OPENSUBDIV_VERSION
Definition limits.h:33
OpenSubdiv::OPENSUBDIV_VERSION::Far
Definition refinerSurfaceFactory.h:36
OpenSubdiv::OPENSUBDIV_VERSION::Far::ConstPatchDescriptorArray
Vtr::ConstArray< PatchDescriptor > ConstPatchDescriptorArray
Definition patchDescriptor.h:146
OpenSubdiv::OPENSUBDIV_VERSION::Sdc::SchemeType
SchemeType
Enumerated type for all subdivision schemes supported by OpenSubdiv.
Definition types.h:37
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::Type
Type
Definition patchDescriptor.h:48
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::LINES
@ LINES
lines (useful for cage drawing)
Definition patchDescriptor.h:52
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::QUADS
@ QUADS
4-sided quadrilateral (bilinear)
Definition patchDescriptor.h:54
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::NON_PATCH
@ NON_PATCH
undefined
Definition patchDescriptor.h:49
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::LOOP
@ LOOP
regular triangular patch for the Loop scheme
Definition patchDescriptor.h:57
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GREGORY_TRIANGLE
@ GREGORY_TRIANGLE
Definition patchDescriptor.h:63
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::TRIANGLES
@ TRIANGLES
3-sided triangle
Definition patchDescriptor.h:55
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GREGORY_BOUNDARY
@ GREGORY_BOUNDARY
Definition patchDescriptor.h:61
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GREGORY_BASIS
@ GREGORY_BASIS
Definition patchDescriptor.h:62
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::POINTS
@ POINTS
points (useful for cage drawing)
Definition patchDescriptor.h:51
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GREGORY
@ GREGORY
Definition patchDescriptor.h:60
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::REGULAR
@ REGULAR
regular B-Spline patch for the Catmark scheme
Definition patchDescriptor.h:59
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::IsAdaptive
bool IsAdaptive() const
Returns true if the type is an adaptive patch.
Definition patchDescriptor.h:97
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GetType
Type GetType() const
Returns the type of the patch.
Definition patchDescriptor.h:87
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GetGregoryBasisPatchSize
static short GetGregoryBasisPatchSize()
Number of control vertices of Gregory patch basis (20).
Definition patchDescriptor.h:126
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GetNumControlVertices
short GetNumControlVertices() const
Returns the number of control vertices expected for a patch of the type described.
Definition patchDescriptor.h:110
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::PatchDescriptor
PatchDescriptor(PatchDescriptor const &d)
Copy Constructor.
Definition patchDescriptor.h:77
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::operator==
bool operator==(PatchDescriptor const other) const
True if the descriptors are identical.
Definition patchDescriptor.h:180
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GetRegularPatchSize
static short GetRegularPatchSize()
Number of control vertices of Regular Patches in table.
Definition patchDescriptor.h:120
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GetNumFVarControlVertices
short GetNumFVarControlVertices() const
Deprecated.
Definition patchDescriptor.h:115
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::PatchDescriptor
PatchDescriptor(int type)
Constructor.
Definition patchDescriptor.h:73
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::operator=
PatchDescriptor & operator=(PatchDescriptor const &d)
Assignment operator.
Definition patchDescriptor.h:81
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::IsAdaptive
static bool IsAdaptive(Type type)
Returns true if the type is an adaptive (non-linear) patch.
Definition patchDescriptor.h:92
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::operator<
bool operator<(PatchDescriptor const other) const
Allows ordering of patches by type.
Definition patchDescriptor.h:174
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GetGregoryPatchSize
static short GetGregoryPatchSize()
Number of control vertices of Gregory (and Gregory Boundary) Patches in table.
Definition patchDescriptor.h:123
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::print
void print() const
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::GetAdaptivePatchDescriptors
static Vtr::ConstArray< PatchDescriptor > GetAdaptivePatchDescriptors(Sdc::SchemeType type)
Returns a vector of all the legal patch descriptors for the given adaptive subdivision scheme.
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor::PatchDescriptor
PatchDescriptor()
Default constructor.
Definition patchDescriptor.h:69
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::ConstArray
Definition array.h:53
types.h
types.h