25 #ifndef FAR_STENCILTABLES_H
26 #define FAR_STENCILTABLES_H
28 #include "../version.h"
33 namespace OpenSubdiv {
34 namespace OPENSUBDIV_VERSION {
120 return (
int)_sizes.size();
124 return _numControlVertices;
131 std::vector<unsigned char>
const &
GetSizes()
const {
165 void UpdateValues(T
const *controlValues, T *values,
int start=-1,
int end=-1)
const {
167 _Update(controlValues, values, _weights, start, end);
173 template <
class T>
void _Update( T
const *controlValues, T *values,
174 std::vector<float>
const & valueWeights,
int start,
int end)
const;
180 int _numControlVertices;
182 std::vector<unsigned char> _sizes;
183 std::vector<int> _offsets,
185 std::vector<float> _weights;
212 :
Stencil(size, indices, weights),
213 _duWeights(duWeights),
214 _dvWeights(dvWeights) {
233 _duWeights += stride;
234 _dvWeights += stride;
278 int start=-1,
int end=-1)
const {
280 _Update(controlValues, uderivs, _duWeights, start, end);
281 _Update(controlValues, vderivs, _dvWeights, start, end);
286 std::vector<float> _duWeights,
292 template <
class T>
void
293 StencilTables::_Update(T
const *controlValues, T *values,
294 std::vector<float>
const &valueWeights,
int start,
int end)
const {
296 int const * indices = &_indices.at(0);
297 float const * weights = &valueWeights.at(0);
300 assert(start<(
int)_offsets.size());
301 indices += _offsets[start];
302 weights += _offsets[start];
306 if (end<start or end<0) {
310 int nstencils = end - std::max(0, start);
311 for (
int i=0; i<nstencils; ++i) {
317 for (
int j=0; j<_sizes[i]; ++j, ++indices, ++weights) {
318 values[i].AddWithWeight( controlValues[*indices], *weights );
327 int ofs = _offsets[i];
329 return Stencil( const_cast<unsigned char *>(&_sizes[i]),
330 const_cast<int *>(&_indices[ofs]),
331 const_cast<float *>(&_weights[ofs]) );
337 using namespace OPENSUBDIV_VERSION;
341 #endif // FAR_STENCILTABLES_H
A specialized factory for StencilTables.
std::vector< unsigned char > const & GetSizes() const
Returns the number of control vertices of each stencil in the table.
Vertex stencil descriptor.
LimitStencil(unsigned char *size, int *indices, float *weights, float *duWeights, float *dvWeights)
Constructor.
Stencil()
Default constructor.
Table of subdivision stencils.
std::vector< float > const & GetWeights() const
Returns the stencil interpolation weights.
int const * GetVertexIndices() const
Returns the control vertices indices.
std::vector< int > const & GetOffsets() const
Returns the offset to a given stencil (factory may leave empty)
void Next()
Advance to the next stencil in the table.
int GetNumControlVertices() const
std::vector< int > const & GetControlIndices() const
Returns the indices of the control vertices.
std::vector< float > const & GetDvWeights() const
Returns the 'v' derivative stencil interpolation weights.
Table of limit subdivision stencils.
void UpdateValues(T const *controlValues, T *values, int start=-1, int end=-1) const
Updates point values based on the control values.
int GetNumStencils() const
Returns the number of stencils in the table.
float const * GetDuWeights() const
float const * GetWeights() const
Returns the interpolation weights.
Stencil GetStencil(int i) const
Returns a Stencil at index i in the tables.
void Next()
Advance to the next stencil in the table.
float const * GetDvWeights() 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.
Limit point stencil descriptor.
Stencil(Stencil const &other)
Copy constructor.
std::vector< float > const & GetDuWeights() const
Returns the 'u' derivative stencil interpolation weights.
Stencil(unsigned char *size, int *indices, float *weights)
Constructor.