25 #ifndef OPENSUBDIV3_FAR_STENCILTABLE_H
26 #define OPENSUBDIV3_FAR_STENCILTABLE_H
28 #include "../version.h"
30 #include "../far/types.h"
37 namespace OpenSubdiv {
38 namespace OPENSUBDIV_VERSION {
127 std::vector<int>
const& offsets,
128 std::vector<int>
const& sizes,
129 std::vector<int>
const& sources,
130 std::vector<float>
const& weights,
131 bool includeCoarseVerts,
140 return (
int)
_sizes.size();
199 template <
class T>
void update( T
const *controlValues, T *values,
200 std::vector<float>
const & valueWeights,
Index start,
Index end)
const;
206 void resize(
int nstencils,
int nelems);
209 void reserve(
int nstencils,
int nelems);
263 :
Stencil(size, indices, weights),
264 _duWeights(duWeights),
265 _dvWeights(dvWeights) {
284 _duWeights += stride;
285 _dvWeights += stride;
302 std::vector<int>
const& offsets,
303 std::vector<int>
const& sizes,
304 std::vector<int>
const& sources,
305 std::vector<float>
const& weights,
306 std::vector<float>
const& duWeights,
307 std::vector<float>
const& dvWeights,
308 bool includeCoarseVerts,
348 int start=-1,
int end=-1)
const {
350 update(controlValues, uderivs, _duWeights, start, end);
351 update(controlValues, vderivs, _dvWeights, start, end);
361 void resize(
int nstencils,
int nelems);
364 std::vector<float> _duWeights,
370 template <
class T>
void
372 std::vector<float>
const &valueWeights,
Index start,
Index end)
const {
374 int const * sizes = &
_sizes.at(0);
376 float const * weights = &valueWeights.at(0);
386 if (end<start or end<0) {
390 int nstencils = end - std::max(0, start);
391 for (
int i=0; i<nstencils; ++i, ++sizes) {
397 for (
int j=0; j<*sizes; ++j, ++indices, ++weights) {
398 values[i].AddWithWeight( controlValues[*indices], *weights );
406 int noffsets = (int)
_sizes.size();
408 for (
int i=0; i<(int)
_sizes.size(); ++i ) {
423 _sizes.reserve(nstencils);
449 const_cast<Index *>(&
_indices[ofs]),
450 const_cast<float *>(&
_weights[ofs]) );
459 LimitStencilTable::resize(
int nstencils,
int nelems) {
461 _duWeights.resize(nelems);
462 _dvWeights.resize(nelems);
488 using namespace OPENSUBDIV_VERSION;
492 #endif // OPENSUBDIV3_FAR_STENCILTABLE_H
float const * GetDvWeights() const
LimitStencil(int *size, Index *indices, float *weights, float *duWeights, float *dvWeights)
Constructor.
void Next()
Advance to the next stencil in the table.
std::vector< Index > const & GetControlIndices() const
Returns the indices of the control vertices.
void reserve(int nstencils, int nelems)
float const * GetDuWeights() const
void Clear()
Clears the stencils from the table.
LimitStencil GetLimitStencil(Index i) const
Returns a LimitStencil at index i in the table.
StencilTable(int numControlVerts)
std::vector< Index > _indices
void UpdateDerivs(T const *controlValues, T *uderivs, T *vderivs, int start=-1, int end=-1) const
Updates derivative values based on the control values.
Limit point stencil descriptor.
void UpdateValues(T const *controlValues, T *values, Index start=-1, Index end=-1) const
Updates point values based on the control values.
LimitStencil operator[](Index index) const
Returns the limit stencil at index i in the table.
Stencil(int *size, Index *indices, float *weights)
Constructor.
A specialized factory for StencilTable.
int GetNumControlVertices() const
Returns the number of control vertices indexed in the table.
std::vector< float > const & GetWeights() const
Returns the stencil interpolation weights.
Stencil()
Default constructor.
friend class GregoryBasis
Stencil operator[](Index index) const
Returns the stencil at index i in the table.
std::vector< Index > _offsets
void resize(int nstencils, int nelems)
Index const * GetVertexIndices() const
Returns the control vertices indices.
Stencil GetStencil(Index i) const
Returns a Stencil at index i in the table.
Table of subdivision stencils.
void update(T const *controlValues, T *values, std::vector< float > const &valueWeights, Index start, Index end) const
void Next()
Advance to the next stencil in the table.
std::vector< float > const & GetDuWeights() const
Returns the 'u' derivative stencil interpolation weights.
friend class EndCapBSplineBasisPatchFactory
A specialized factory for LimitStencilTable.
Stencil(Stencil const &other)
Copy constructor.
std::vector< Index > const & GetOffsets() const
Returns the offset to a given stencil (factory may leave empty)
std::vector< float > _weights
std::vector< float > const & GetDvWeights() const
Returns the 'v' derivative stencil interpolation weights.
int * GetSizePtr() const
Returns the size of the stencil as a pointer.
friend class EndCapGregoryBasisPatchFactory
void Clear()
Clears the stencils from the table.
int GetNumStencils() const
Returns the number of stencils in the table.
Vertex stencil descriptor.
std::vector< int > const & GetSizes() const
Returns the number of control vertices of each stencil in the table.
std::vector< int > _sizes
float const * GetWeights() const
Returns the interpolation weights.
int GetSize() const
Returns the size of the stencil.
Table of limit subdivision stencils.