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();
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);
264 float * duuWeights=0,
265 float * duvWeights=0,
266 float * dvvWeights=0)
267 :
Stencil(size, indices, weights),
268 _duWeights(duWeights),
269 _dvWeights(dvWeights),
270 _duuWeights(duuWeights),
271 _duvWeights(duvWeights),
272 _dvvWeights(dvvWeights) {
306 if (_duWeights) _duWeights += stride;
307 if (_dvWeights) _dvWeights += stride;
308 if (_duuWeights) _duuWeights += stride;
309 if (_duvWeights) _duvWeights += stride;
310 if (_dvvWeights) _dvvWeights += stride;
330 std::vector<int>
const& offsets,
331 std::vector<int>
const& sizes,
332 std::vector<int>
const& sources,
333 std::vector<float>
const& weights,
334 std::vector<float>
const& duWeights,
335 std::vector<float>
const& dvWeights,
336 std::vector<float>
const& duuWeights,
337 std::vector<float>
const& duvWeights,
338 std::vector<float>
const& dvvWeights,
339 bool includeCoarseVerts,
394 int start=-1,
int end=-1)
const {
396 update(controlValues, uderivs, _duWeights, start, end);
397 update(controlValues, vderivs, _dvWeights, start, end);
422 int start=-1,
int end=-1)
const {
424 update(controlValues, uuderivs, _duuWeights, start, end);
425 update(controlValues, uvderivs, _duvWeights, start, end);
426 update(controlValues, vvderivs, _dvvWeights, start, end);
436 void resize(
int nstencils,
int nelems);
439 std::vector<float> _duWeights,
448 template <
class T>
void 450 std::vector<float>
const &valueWeights,
Index start,
Index end)
const {
452 int const * sizes = &
_sizes.at(0);
454 float const * weights = &valueWeights.at(0);
464 if (end<start || end<0) {
468 int nstencils = end - std::max(0, start);
469 for (
int i=0; i<nstencils; ++i, ++sizes) {
475 for (
int j=0; j<*sizes; ++j, ++indices, ++weights) {
476 values[i].AddWithWeight( controlValues[*indices], *weights );
484 int noffsets = (int)
_sizes.size();
486 for (
int i=0; i<(int)
_sizes.size(); ++i ) {
501 _sizes.reserve(nstencils);
527 const_cast<Index *>(&
_indices[ofs]),
528 const_cast<float *>(&
_weights[ofs]) );
537 LimitStencilTable::resize(
int nstencils,
int nelems) {
539 _duWeights.resize(nelems);
540 _dvWeights.resize(nelems);
550 if (!_duWeights.empty() && !_dvWeights.empty() &&
551 !_duuWeights.empty() && !_duvWeights.empty() && !_dvvWeights.empty()) {
560 }
else if (!_duWeights.empty() && !_dvWeights.empty()) {
582 using namespace OPENSUBDIV_VERSION;
586 #endif // OPENSUBDIV3_FAR_STENCILTABLE_H Stencil(Stencil const &other)
Copy constructor.
std::vector< float > const & GetDvWeights() const
Returns the 'v' derivative stencil interpolation weights.
void Update2ndDerivs(T const *controlValues, T *uuderivs, T *uvderivs, T *vvderivs, int start=-1, int end=-1) const
Updates 2nd derivative values based on the control values.
int * GetSizePtr() const
Returns the size of the stencil as a pointer.
std::vector< Index > _indices
int GetNumControlVertices() const
Returns the number of control vertices indexed in the table.
int GetNumStencils() const
Returns the number of stencils in the table.
std::vector< Index > _offsets
void reserve(int nstencils, int nelems)
float const * GetDvvWeights() const
Returns the vv derivative weights.
float const * GetWeights() const
Returns the interpolation weights.
std::vector< float > const & GetDuuWeights() const
Returns the 'uu' derivative stencil interpolation weights.
void UpdateDerivs(T const *controlValues, T *uderivs, T *vderivs, int start=-1, int end=-1) const
Updates derivative values based on the control values.
std::vector< float > _weights
void Clear()
Clears the stencils from the table.
Vertex stencil descriptor.
StencilTable(int numControlVerts)
int GetSize() const
Returns the size of the stencil.
void resize(int nstencils, int nelems)
void Next()
Advance to the next stencil in the table.
float const * GetDvWeights() const
Returns the v derivative weights.
Limit point stencil descriptor.
float const * GetDuuWeights() const
Returns the uu derivative weights.
std::vector< Index > const & GetOffsets() const
Returns the offset to a given stencil (factory may leave empty)
std::vector< float > const & GetDvvWeights() const
Returns the 'vv' derivative stencil interpolation weights.
void Clear()
Clears the stencils from the table.
void Next()
Advance to the next stencil in the table.
std::vector< int > const & GetSizes() const
Returns the number of control vertices of each stencil in the table.
std::vector< float > const & GetWeights() const
Returns the stencil interpolation weights.
std::vector< float > const & GetDuWeights() const
Returns the 'u' derivative stencil interpolation weights.
friend class PatchTableBuilder
std::vector< float > const & GetDuvWeights() const
Returns the 'uv' derivative stencil interpolation weights.
Stencil GetStencil(Index i) const
Returns a Stencil at index i in the table.
Index const * GetVertexIndices() const
Returns the control vertices' indices.
std::vector< Index > const & GetControlIndices() const
Returns the indices of the control vertices.
A specialized factory for StencilTable.
Table of subdivision stencils.
std::vector< int > _sizes
LimitStencil GetLimitStencil(Index i) const
Returns a LimitStencil 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.
LimitStencil operator[](Index index) const
Returns the limit stencil at index i in the table.
A specialized factory for LimitStencilTable.
float const * GetDuvWeights() const
Returns the uv derivative weights.
Table of limit subdivision stencils.
Stencil()
Default constructor.
Stencil operator[](Index index) const
Returns the stencil at index i in the table.
float const * GetDuWeights() const
Returns the u derivative weights.
Stencil(int *size, Index *indices, float *weights)
Constructor.
LimitStencil(int *size, Index *indices, float *weights, float *duWeights=0, float *dvWeights=0, float *duuWeights=0, float *duvWeights=0, float *dvvWeights=0)
Constructor.
void update(T const *controlValues, T *values, std::vector< float > const &valueWeights, Index start, Index end) const