25 #ifndef OPENSUBDIV3_FAR_STENCILTABLE_H
26 #define OPENSUBDIV3_FAR_STENCILTABLE_H
28 #include "../version.h"
30 #include "../far/types.h"
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,
138 return (
int)
_sizes.size();
197 template <
class T>
void update( T
const *controlValues, T *values,
198 std::vector<float>
const & valueWeights,
Index start,
Index end)
const;
204 void resize(
int nstencils,
int nelems);
248 :
Stencil(size, indices, weights),
249 _duWeights(duWeights),
250 _dvWeights(dvWeights) {
269 _duWeights += stride;
270 _dvWeights += stride;
287 std::vector<int>
const& offsets,
288 std::vector<int>
const& sizes,
289 std::vector<int>
const& sources,
290 std::vector<float>
const& weights,
291 std::vector<float>
const& duWeights,
292 std::vector<float>
const& dvWeights,
293 bool includeCoarseVerts,
327 int start=-1,
int end=-1)
const {
329 update(controlValues, uderivs, _duWeights, start, end);
330 update(controlValues, vderivs, _dvWeights, start, end);
340 void resize(
int nstencils,
int nelems);
343 std::vector<float> _duWeights,
349 template <
class T>
void
351 std::vector<float>
const &valueWeights,
Index start,
Index end)
const {
353 int const * sizes = &
_sizes.at(0);
355 float const * weights = &valueWeights.at(0);
365 if (end<start or end<0) {
369 int nstencils = end - std::max(0, start);
370 for (
int i=0; i<nstencils; ++i, ++sizes) {
376 for (
int j=0; j<*sizes; ++j, ++indices, ++weights) {
377 values[i].AddWithWeight( controlValues[*indices], *weights );
385 int noffsets = (int)
_sizes.size();
387 for (
int i=0; i<(int)
_sizes.size(); ++i ) {
408 const_cast<Index *>(&
_indices[ofs]),
409 const_cast<float *>(&
_weights[ofs]) );
418 LimitStencilTable::resize(
int nstencils,
int nelems) {
420 _duWeights.resize(nelems);
421 _dvWeights.resize(nelems);
428 using namespace OPENSUBDIV_VERSION;
432 #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.
float const * GetDuWeights() const
void Clear()
Clears the stencils from 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.
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.
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.
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.