stencilTableFactory.h
Go to the documentation of this file.
//
// Copyright 2013 Pixar
//
// Licensed under the Apache License, Version 2.0 (the "Apache License")
// with the following modification; you may not use this file except in
// compliance with the Apache License and the following modification to it:
// Section 6. Trademarks. is deleted and replaced with:
//
// 6. Trademarks. This License does not grant permission to use the trade
// names, trademarks, service marks, or product names of the Licensor
// and its affiliates, except as required to comply with Section 4(c) of
// the License and to reproduce the content of the NOTICE file.
//
// You may obtain a copy of the Apache License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the Apache License with the above modification is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the Apache License for the specific
// language governing permissions and limitations under the Apache License.
//
#ifndef OPENSUBDIV3_FAR_STENCILTABLE_FACTORY_H
#define OPENSUBDIV3_FAR_STENCILTABLE_FACTORY_H
#include "../version.h"
#include "../far/patchTable.h"
#include <vector>
namespace OpenSubdiv {
namespace OPENSUBDIV_VERSION {
namespace Far {
class TopologyRefiner;
template <typename REAL> class StencilReal;
template <typename REAL> class StencilTableReal;
template <typename REAL> class LimitStencilReal;
template <typename REAL> class LimitStencilTableReal;
template <typename REAL>
class StencilTableFactoryReal {
public:
enum Mode {
INTERPOLATE_VERTEX=0,
INTERPOLATE_VARYING,
INTERPOLATE_FACE_VARYING
};
struct Options {
Options() : interpolationMode(INTERPOLATE_VERTEX),
generateOffsets(false),
generateControlVerts(false),
generateIntermediateLevels(true),
factorizeIntermediateLevels(true),
maxLevel(10),
fvarChannel(0) { }
unsigned int interpolationMode : 2,
generateOffsets : 1,
generateControlVerts : 1,
generateIntermediateLevels : 1,
factorizeIntermediateLevels : 1,
maxLevel : 4;
unsigned int fvarChannel;
};
static StencilTableReal<REAL> const * Create(
TopologyRefiner const & refiner, Options options = Options());
static StencilTableReal<REAL> const * Create(
int numTables, StencilTableReal<REAL> const ** tables);
static StencilTableReal<REAL> const * AppendLocalPointStencilTable(
TopologyRefiner const &refiner,
StencilTableReal<REAL> const *baseStencilTable,
StencilTableReal<REAL> const *localPointStencilTable,
bool factorize = true);
static StencilTableReal<REAL> const * AppendLocalPointStencilTableVarying(
TopologyRefiner const &refiner,
StencilTableReal<REAL> const *baseStencilTable,
StencilTableReal<REAL> const *localPointStencilTable,
bool factorize = true) {
return AppendLocalPointStencilTable(
refiner, baseStencilTable, localPointStencilTable, factorize);
}
static StencilTableReal<REAL> const * AppendLocalPointStencilTableFaceVarying(
TopologyRefiner const &refiner,
StencilTableReal<REAL> const *baseStencilTable,
StencilTableReal<REAL> const *localPointStencilTable,
int channel = 0,
bool factorize = true);
private:
// Generate stencils for the coarse control-vertices (single weight = 1.0f)
static void generateControlVertStencils(
int numControlVerts,
StencilReal<REAL> & dst);
// Internal method to splice local point stencils
static StencilTableReal<REAL> const * appendLocalPointStencilTable(
TopologyRefiner const &refiner,
StencilTableReal<REAL> const * baseStencilTable,
StencilTableReal<REAL> const * localPointStencilTable,
int channel,
bool factorize);
};
template <typename REAL>
class LimitStencilTableFactoryReal {
public:
enum Mode {
INTERPOLATE_VERTEX=0,
INTERPOLATE_VARYING,
INTERPOLATE_FACE_VARYING
};
struct Options {
Options() : interpolationMode(INTERPOLATE_VERTEX),
generate1stDerivatives(true),
generate2ndDerivatives(false),
fvarChannel(0) { }
unsigned int interpolationMode : 2,
generate1stDerivatives : 1,
generate2ndDerivatives : 1;
unsigned int fvarChannel;
};
struct LocationArray {
LocationArray() : ptexIdx(-1), numLocations(0), s(0), t(0) { }
int ptexIdx,
numLocations;
REAL const * s,
* t;
};
typedef std::vector<LocationArray> LocationArrayVec;
static LimitStencilTableReal<REAL> const * Create(
TopologyRefiner const & refiner,
LocationArrayVec const & locationArrays,
StencilTableReal<REAL> const * cvStencils = 0,
PatchTable const * patchTable = 0,
Options options = Options());
};
//
// Public wrapper classes for the templates
//
class Stencil;
class StencilTable;
class StencilTableFactory : public StencilTableFactoryReal<float> {
private:
typedef StencilTableFactoryReal<float> BaseFactory;
typedef StencilTableReal<float> BaseTable;
public:
static StencilTable const * Create(
TopologyRefiner const & refiner, Options options = Options()) {
return static_cast<StencilTable const *>(
BaseFactory::Create(refiner, options));
}
static StencilTable const * Create(
int numTables, StencilTable const ** tables) {
return static_cast<StencilTable const *>(
BaseFactory::Create(numTables,
reinterpret_cast<BaseTable const **>(tables)));
}
static StencilTable const * AppendLocalPointStencilTable(
TopologyRefiner const &refiner,
StencilTable const *baseStencilTable,
StencilTable const *localPointStencilTable,
bool factorize = true) {
return static_cast<StencilTable const *>(
BaseFactory::AppendLocalPointStencilTable(refiner,
static_cast<BaseTable const *>(baseStencilTable),
static_cast<BaseTable const *>(localPointStencilTable),
factorize));
}
static StencilTable const * AppendLocalPointStencilTableVarying(
TopologyRefiner const &refiner,
StencilTable const *baseStencilTable,
StencilTable const *localPointStencilTable,
bool factorize = true) {
return static_cast<StencilTable const *>(
BaseFactory::AppendLocalPointStencilTableVarying(refiner,
static_cast<BaseTable const *>(baseStencilTable),
static_cast<BaseTable const *>(localPointStencilTable),
factorize));
}
static StencilTable const * AppendLocalPointStencilTableFaceVarying(
TopologyRefiner const &refiner,
StencilTable const *baseStencilTable,
StencilTable const *localPointStencilTable,
int channel = 0,
bool factorize = true) {
return static_cast<StencilTable const *>(
BaseFactory::AppendLocalPointStencilTableFaceVarying(refiner,
static_cast<BaseTable const *>(baseStencilTable),
static_cast<BaseTable const *>(localPointStencilTable),
channel, factorize));
}
};
class LimitStencil;
class LimitStencilTable;
class LimitStencilTableFactory : public LimitStencilTableFactoryReal<float> {
private:
typedef LimitStencilTableFactoryReal<float> BaseFactory;
typedef StencilTableReal<float> BaseTable;
public:
static LimitStencilTable const * Create(
TopologyRefiner const & refiner,
LocationArrayVec const & locationArrays,
StencilTable const * cvStencils = 0,
PatchTable const * patchTable = 0,
Options options = Options()) {
return static_cast<LimitStencilTable const *>(
BaseFactory::Create(
refiner,
locationArrays,
static_cast<BaseTable const *>(cvStencils),
patchTable,
options));
}
};
} // end namespace Far
} // end namespace OPENSUBDIV_VERSION
using namespace OPENSUBDIV_VERSION;
} // end namespace OpenSubdiv
#endif // OPENSUBDIV3_FAR_STENCILTABLE_FACTORY_H
OpenSubdiv
Definition: limits.h:32
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTable
Container for arrays of parametric patches.
Definition: patchTable.h:55
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal
A specialized factory for StencilTable.
Definition: stencilTableFactory.h:51
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Create
static StencilTableReal< REAL > const * Create(TopologyRefiner const &refiner, Options options=Options())
Instantiates StencilTable from TopologyRefiner that have been refined uniformly or adaptively.
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::AppendLocalPointStencilTableFaceVarying
static StencilTableReal< REAL > const * AppendLocalPointStencilTableFaceVarying(TopologyRefiner const &refiner, StencilTableReal< REAL > const *baseStencilTable, StencilTableReal< REAL > const *localPointStencilTable, int channel=0, bool factorize=true)
Utility function for stencil splicing for local point face-varying stencils.
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Mode
Mode
Definition: stencilTableFactory.h:55
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::INTERPOLATE_FACE_VARYING
@ INTERPOLATE_FACE_VARYING
face-varying primvar stencils
Definition: stencilTableFactory.h:58
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::INTERPOLATE_VARYING
@ INTERPOLATE_VARYING
varying primvar stencils
Definition: stencilTableFactory.h:57
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::INTERPOLATE_VERTEX
@ INTERPOLATE_VERTEX
vertex primvar stencils
Definition: stencilTableFactory.h:56
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::AppendLocalPointStencilTableVarying
static StencilTableReal< REAL > const * AppendLocalPointStencilTableVarying(TopologyRefiner const &refiner, StencilTableReal< REAL > const *baseStencilTable, StencilTableReal< REAL > const *localPointStencilTable, bool factorize=true)
Utility function for stencil splicing for local point varying stencils.
Definition: stencilTableFactory.h:148
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::AppendLocalPointStencilTable
static StencilTableReal< REAL > const * AppendLocalPointStencilTable(TopologyRefiner const &refiner, StencilTableReal< REAL > const *baseStencilTable, StencilTableReal< REAL > const *localPointStencilTable, bool factorize=true)
Utility function for stencil splicing for local point stencils.
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Create
static StencilTableReal< REAL > const * Create(int numTables, StencilTableReal< REAL > const **tables)
Instantiates StencilTable by concatenating an array of existing stencil tables.
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal
A specialized factory for LimitStencilTable.
Definition: stencilTableFactory.h:209
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::Mode
Mode
Definition: stencilTableFactory.h:213
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::INTERPOLATE_FACE_VARYING
@ INTERPOLATE_FACE_VARYING
face-varying primvar stencils
Definition: stencilTableFactory.h:216
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::INTERPOLATE_VARYING
@ INTERPOLATE_VARYING
varying primvar stencils
Definition: stencilTableFactory.h:215
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::INTERPOLATE_VERTEX
@ INTERPOLATE_VERTEX
vertex primvar stencils
Definition: stencilTableFactory.h:214
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::LocationArrayVec
std::vector< LocationArray > LocationArrayVec
Definition: stencilTableFactory.h:244
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::Create
static LimitStencilTableReal< REAL > const * Create(TopologyRefiner const &refiner, LocationArrayVec const &locationArrays, StencilTableReal< REAL > const *cvStencils=0, PatchTable const *patchTable=0, Options options=Options())
Instantiates LimitStencilTable from a TopologyRefiner that has been refined either uniformly or adapt...
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilReal
Vertex stencil descriptor.
Definition: stencilTable.h:53
OpenSubdiv::OPENSUBDIV_VERSION::Far::Stencil
Vertex stencil class wrapping the template for compatibility.
Definition: stencilTable.h:116
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableReal
Table of subdivision stencils.
Definition: stencilTable.h:141
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTable
Stencil table class wrapping the template for compatibility.
Definition: stencilTable.h:273
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableReal
Table of limit subdivision stencils.
Definition: stencilTable.h:409
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTable
Limit stencil table class wrapping the template for compatibility.
Definition: stencilTable.h:583
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Options
Definition: stencilTableFactory.h:61
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Options::factorizeIntermediateLevels
unsigned int factorizeIntermediateLevels
Definition: stencilTableFactory.h:77
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Options::maxLevel
unsigned int maxLevel
generate stencils up to 'maxLevel'
Definition: stencilTableFactory.h:78
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Options::Options
Options()
Definition: stencilTableFactory.h:63
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Options::generateIntermediateLevels
unsigned int generateIntermediateLevels
vertices at all levels or highest only
Definition: stencilTableFactory.h:74
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Options::generateControlVerts
unsigned int generateControlVerts
generate stencils for control-vertices
Definition: stencilTableFactory.h:73
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Options::generateOffsets
unsigned int generateOffsets
populate optional "_offsets" field
Definition: stencilTableFactory.h:72
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Options::fvarChannel
unsigned int fvarChannel
Definition: stencilTableFactory.h:79
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Options::interpolationMode
unsigned int interpolationMode
interpolation mode
Definition: stencilTableFactory.h:71
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::Options
Definition: stencilTableFactory.h:219
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::Options::Options
Options()
Definition: stencilTableFactory.h:221
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::Options::fvarChannel
unsigned int fvarChannel
face-varying channel to use
Definition: stencilTableFactory.h:229
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::Options::interpolationMode
unsigned int interpolationMode
interpolation mode
Definition: stencilTableFactory.h:226
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::Options::generate2ndDerivatives
unsigned int generate2ndDerivatives
Generate weights for 2nd derivatives.
Definition: stencilTableFactory.h:228
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::Options::generate1stDerivatives
unsigned int generate1stDerivatives
Generate weights for 1st derivatives.
Definition: stencilTableFactory.h:227
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::LocationArray
Descriptor for limit surface locations.
Definition: stencilTableFactory.h:233
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::LocationArray::t
REAL const * t
array of v coordinates
Definition: stencilTableFactory.h:241
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::LocationArray::s
REAL const * s
array of u coordinates
Definition: stencilTableFactory.h:240
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::LocationArray::LocationArray
LocationArray()
Definition: stencilTableFactory.h:235
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::LocationArray::numLocations
int numLocations
number of (u,v) coordinates in the array
Definition: stencilTableFactory.h:238
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::LocationArray::ptexIdx
int ptexIdx
ptex face index
Definition: stencilTableFactory.h:237
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory
Stencil table factory class wrapping the template for compatibility.
Definition: stencilTableFactory.h:287
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::AppendLocalPointStencilTableVarying
static StencilTable const * AppendLocalPointStencilTableVarying(TopologyRefiner const &refiner, StencilTable const *baseStencilTable, StencilTable const *localPointStencilTable, bool factorize=true)
Definition: stencilTableFactory.h:321
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::Create
static StencilTable const * Create(TopologyRefiner const &refiner, Options options=Options())
Definition: stencilTableFactory.h:293
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::AppendLocalPointStencilTableFaceVarying
static StencilTable const * AppendLocalPointStencilTableFaceVarying(TopologyRefiner const &refiner, StencilTable const *baseStencilTable, StencilTable const *localPointStencilTable, int channel=0, bool factorize=true)
Definition: stencilTableFactory.h:334
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::AppendLocalPointStencilTable
static StencilTable const * AppendLocalPointStencilTable(TopologyRefiner const &refiner, StencilTable const *baseStencilTable, StencilTable const *localPointStencilTable, bool factorize=true)
Definition: stencilTableFactory.h:308
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::Create
static StencilTable const * Create(int numTables, StencilTable const **tables)
Definition: stencilTableFactory.h:300
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactory
Stencil table factory class wrapping the template for compatibility.
Definition: stencilTableFactory.h:354
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactory::Create
static LimitStencilTable const * Create(TopologyRefiner const &refiner, LocationArrayVec const &locationArrays, StencilTable const *cvStencils=0, PatchTable const *patchTable=0, Options options=Options())
Definition: stencilTableFactory.h:360
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner
Stores topology data for a specified set of refinement options.
Definition: topologyRefiner.h:51