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,
140 return (
int)_sizes.size();
145 return _numControlVertices;
190 update(controlValues, values,
_weights, start, end);
199 template <
class T>
void update( T
const *controlValues, T *values,
200 std::vector<float>
const & valueWeights,
Index start,
Index end)
const;
203 void generateOffsets();
206 void resize(
int nstencils,
int nelems);
211 : _numControlVertices(numControlVerts)
216 friend class GregoryBasis;
250 :
Stencil(size, indices, weights),
251 _duWeights(duWeights),
252 _dvWeights(dvWeights) {
271 _duWeights += stride;
272 _dvWeights += stride;
289 std::vector<int>
const& offsets,
290 std::vector<int>
const& sizes,
291 std::vector<int>
const& sources,
292 std::vector<float>
const& weights,
293 std::vector<float>
const& duWeights,
294 std::vector<float>
const& dvWeights,
295 bool includeCoarseVerts,
329 int start=-1,
int end=-1)
const {
331 update(controlValues, uderivs, _duWeights, start, end);
332 update(controlValues, vderivs, _dvWeights, start, end);
342 void resize(
int nstencils,
int nelems);
345 std::vector<float> _duWeights,
351 template <
class T>
void 353 std::vector<float>
const &valueWeights,
Index start,
Index end)
const {
355 int const * sizes = &_sizes.at(0);
357 float const * weights = &valueWeights.at(0);
360 assert(start<(
Index)_offsets.size());
362 indices += _offsets[start];
363 weights += _offsets[start];
367 if (end<start or end<0) {
368 end = GetNumStencils();
371 int nstencils = end - std::max(0, start);
372 for (
int i=0; i<nstencils; ++i, ++sizes) {
378 for (
int j=0; j<*sizes; ++j, ++indices, ++weights) {
379 values[i].AddWithWeight( controlValues[*indices], *weights );
387 int noffsets = (int)_sizes.size();
388 _offsets.resize(noffsets);
389 for (
int i=0; i<(int)_sizes.size(); ++i ) {
397 _sizes.resize(nstencils);
405 assert((not _offsets.empty()) and i<(
int)_offsets.size());
407 Index ofs = _offsets[i];
409 return Stencil( const_cast<int*>(&_sizes[i]),
410 const_cast<Index *>(&
_indices[ofs]),
411 const_cast<float *>(&
_weights[ofs]) );
416 return GetStencil(index);
420 LimitStencilTable::resize(
int nstencils,
int nelems) {
422 _duWeights.resize(nelems);
423 _dvWeights.resize(nelems);
430 using namespace OPENSUBDIV_VERSION;
434 #endif // OPENSUBDIV3_FAR_STENCILTABLE_H
std::vector< float > const & GetDvWeights() const
Returns the 'v' derivative stencil interpolation weights.
float const * GetWeights() const
Returns the interpolation weights.
Stencil(Stencil const &other)
Copy constructor.
void Next()
Advance to the next stencil in the table.
Stencil(int *size, Index *indices, float *weights)
Constructor.
std::vector< float > _weights
LimitStencil(int *size, Index *indices, float *weights, float *duWeights, float *dvWeights)
Constructor.
int GetNumStencils() const
Returns the number of stencils in the table.
Table of subdivision stencils.
StencilTable(int numControlVerts)
Index const * GetVertexIndices() const
Returns the control vertices indices.
std::vector< Index > _offsets
int * GetSizePtr() const
Returns the size of the stencil as a pointer.
float const * GetDuWeights() const
void UpdateDerivs(T const *controlValues, T *uderivs, T *vderivs, int start=-1, int end=-1) const
Updates derivative values based on the control values.
Stencil()
Default constructor.
int GetSize() const
Returns the size of the stencil.
void resize(int nstencils, int nelems)
Limit point stencil descriptor.
std::vector< Index > const & GetControlIndices() const
Returns the indices of the control vertices.
int GetNumControlVertices() const
Returns the number of control vertices indexed in the table.
Stencil operator[](Index index) const
Returns the stencil at index i in the table.
void UpdateValues(T const *controlValues, T *values, Index start=-1, Index end=-1) const
Updates point values based on the control values.
std::vector< float > const & GetDuWeights() const
Returns the 'u' derivative stencil interpolation weights.
std::vector< float > const & GetWeights() const
Returns the stencil interpolation weights.
void Next()
Advance to the next stencil in the table.
std::vector< Index > const & GetOffsets() const
Returns the offset to a given stencil (factory may leave empty)
Stencil GetStencil(Index i) const
Returns a Stencil at index i in the table.
float const * GetDvWeights() const
A specialized factory for StencilTable.
Vertex stencil descriptor.
std::vector< int > const & GetSizes() const
Returns the number of control vertices of each stencil in the table.
A specialized factory for LimitStencilTable.
Table of limit subdivision stencils.
std::vector< int > _sizes
void update(T const *controlValues, T *values, std::vector< float > const &valueWeights, Index start, Index end) const