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);
269 float * duuWeights=0,
270 float * duvWeights=0,
271 float * dvvWeights=0)
272 :
Stencil(size, indices, weights),
273 _duWeights(duWeights),
274 _dvWeights(dvWeights),
275 _duuWeights(duuWeights),
276 _duvWeights(duvWeights),
277 _dvvWeights(dvvWeights) {
311 if (_duWeights) _duWeights += stride;
312 if (_dvWeights) _dvWeights += stride;
313 if (_duuWeights) _duuWeights += stride;
314 if (_duvWeights) _duvWeights += stride;
315 if (_dvvWeights) _dvvWeights += stride;
335 std::vector<int>
const& offsets,
336 std::vector<int>
const& sizes,
337 std::vector<int>
const& sources,
338 std::vector<float>
const& weights,
339 std::vector<float>
const& duWeights,
340 std::vector<float>
const& dvWeights,
341 std::vector<float>
const& duuWeights,
342 std::vector<float>
const& duvWeights,
343 std::vector<float>
const& dvvWeights,
344 bool includeCoarseVerts,
399 int start=-1,
int end=-1)
const {
401 update(controlValues, uderivs, _duWeights, start, end);
402 update(controlValues, vderivs, _dvWeights, start, end);
427 int start=-1,
int end=-1)
const {
429 update(controlValues, uuderivs, _duuWeights, start, end);
430 update(controlValues, uvderivs, _duvWeights, start, end);
431 update(controlValues, vvderivs, _dvvWeights, start, end);
441 void resize(
int nstencils,
int nelems);
444 std::vector<float> _duWeights,
453 template <
class T>
void 455 std::vector<float>
const &valueWeights,
Index start,
Index end)
const {
457 int const * sizes = &
_sizes.at(0);
459 float const * weights = &valueWeights.at(0);
469 if (end<start || end<0) {
473 int nstencils = end - std::max(0, start);
474 for (
int i=0; i<nstencils; ++i, ++sizes) {
480 for (
int j=0; j<*sizes; ++j, ++indices, ++weights) {
481 values[i].AddWithWeight( controlValues[*indices], *weights );
489 int noffsets = (int)
_sizes.size();
491 for (
int i=0; i<(int)
_sizes.size(); ++i ) {
506 _sizes.reserve(nstencils);
532 const_cast<Index *>(&
_indices[ofs]),
533 const_cast<float *>(&
_weights[ofs]) );
542 LimitStencilTable::resize(
int nstencils,
int nelems) {
544 _duWeights.resize(nelems);
545 _dvWeights.resize(nelems);
555 if (!_duWeights.empty() && !_dvWeights.empty() &&
556 !_duuWeights.empty() && !_duvWeights.empty() && !_dvvWeights.empty()) {
565 }
else if (!_duWeights.empty() && !_dvWeights.empty()) {
587 using namespace OPENSUBDIV_VERSION;
591 #endif // OPENSUBDIV3_FAR_STENCILTABLE_H Stencil(Stencil const &other)
Copy constructor.
friend class GregoryBasis
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.
friend class EndCapGregoryBasisPatchFactory
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.
Factory for constructing a PatchTable from a TopologyRefiner.
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.
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
friend class EndCapBSplineBasisPatchFactory