2013-09-11 23:05:14 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// Copyright 2013 Pixar
|
2013-09-11 23:05:14 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// 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:
|
2013-09-11 23:05:14 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// 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.
|
2013-09-11 23:05:14 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// You may obtain a copy of the Apache License at
|
2013-09-11 23:05:14 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2013-09-11 23:05:14 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// 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.
|
2013-09-11 23:05:14 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef FAR_STENCILTABLE_FACTORY_H
|
|
|
|
#define FAR_STENCILTABLE_FACTORY_H
|
|
|
|
|
|
|
|
#include "../version.h"
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
#include "../far/kernelBatch.h"
|
2014-09-12 23:59:16 +00:00
|
|
|
#include "../far/patchTables.h"
|
|
|
|
|
|
|
|
#include <vector>
|
2013-09-11 23:05:14 +00:00
|
|
|
|
|
|
|
namespace OpenSubdiv {
|
|
|
|
namespace OPENSUBDIV_VERSION {
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
namespace Far {
|
2013-09-11 23:05:14 +00:00
|
|
|
|
2014-09-12 23:59:16 +00:00
|
|
|
class TopologyRefiner;
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
class Stencil;
|
|
|
|
class StencilTables;
|
2014-09-12 23:59:16 +00:00
|
|
|
class LimitStencil;
|
|
|
|
class LimitStencilTables;
|
2013-09-11 23:05:14 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
/// \brief A specialized factory for StencilTables
|
2013-09-11 23:05:14 +00:00
|
|
|
///
|
2014-09-05 22:07:46 +00:00
|
|
|
class StencilTablesFactory {
|
2013-09-11 23:05:14 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
enum Mode {
|
|
|
|
INTERPOLATE_VERTEX=0,
|
2014-09-12 23:59:16 +00:00
|
|
|
INTERPOLATE_VARYING,
|
2014-09-05 22:07:46 +00:00
|
|
|
};
|
2013-09-11 23:05:14 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
struct Options {
|
2014-09-12 23:59:16 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
Options() : interpolationMode(INTERPOLATE_VERTEX),
|
2014-09-12 23:59:16 +00:00
|
|
|
generateOffsets(false),
|
2014-09-19 00:48:34 +00:00
|
|
|
generateControlVerts(false),
|
2014-10-21 23:36:26 +00:00
|
|
|
generateIntermediateLevels(true),
|
|
|
|
factorizeIntermediateLevels(true),
|
|
|
|
maxLevel(10) { }
|
|
|
|
|
|
|
|
unsigned int interpolationMode : 2, ///< interpolation mode
|
|
|
|
generateOffsets : 1, ///< populate optional "_offsets" field
|
|
|
|
generateControlVerts : 1, ///< generate stencils for control-vertices
|
|
|
|
generateIntermediateLevels : 1, ///< vertices at all levels or highest only
|
|
|
|
factorizeIntermediateLevels : 1, ///< accumulate stencil weights from control
|
|
|
|
/// vertices or from the stencils of the
|
|
|
|
/// previous level
|
|
|
|
maxLevel : 4; ///< generate stencils up to 'maxLevel'
|
2014-09-05 22:07:46 +00:00
|
|
|
};
|
2013-09-11 23:05:14 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
/// \brief Instantiates StencilTables from TopologyRefiner that have been
|
|
|
|
/// refined uniformly or adaptively.
|
2013-09-11 23:05:14 +00:00
|
|
|
///
|
2014-09-05 22:07:46 +00:00
|
|
|
/// \note The factory only creates stencils for vertices that have already
|
|
|
|
/// been refined in the TopologyRefiner. Use RefineUniform() or
|
|
|
|
/// RefineAdaptive() before constructing the stencils.
|
2013-09-11 23:05:14 +00:00
|
|
|
///
|
2014-10-02 23:09:17 +00:00
|
|
|
/// @param refiner The TopologyRefiner containing the topology
|
2013-09-11 23:05:14 +00:00
|
|
|
///
|
2014-09-05 22:07:46 +00:00
|
|
|
/// @param options Options controlling the creation of the tables
|
2013-09-11 23:05:14 +00:00
|
|
|
///
|
2014-09-05 22:07:46 +00:00
|
|
|
static StencilTables const * Create(TopologyRefiner const & refiner,
|
|
|
|
Options options = Options());
|
2013-09-11 23:05:14 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
/// \brief Returns a KernelBatch applying all the stencil in the tables
|
|
|
|
/// to primvar data.
|
2013-09-11 23:05:14 +00:00
|
|
|
///
|
2014-09-05 22:07:46 +00:00
|
|
|
/// @param stencilTables The stencil tables to batch
|
2014-05-15 20:34:32 +00:00
|
|
|
///
|
2014-09-05 22:07:46 +00:00
|
|
|
static KernelBatch Create(StencilTables const &stencilTables);
|
2013-09-11 23:05:14 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2014-10-21 23:36:26 +00:00
|
|
|
// Generate stencils for the coarse control-vertices (single weight = 1.0f)
|
2014-09-19 00:48:34 +00:00
|
|
|
static void generateControlVertStencils(int numControlVerts, Stencil & dst);
|
2013-09-11 23:05:14 +00:00
|
|
|
};
|
|
|
|
|
2014-09-12 23:59:16 +00:00
|
|
|
/// \brief A specialized factory for LimitStencilTables
|
|
|
|
///
|
2014-09-19 00:48:34 +00:00
|
|
|
/// The LimitStencilTablesFactory creates tables of limit stencils. Limit
|
2014-10-02 23:09:17 +00:00
|
|
|
/// stencils can interpolate any arbitrary location on the limit surface.
|
|
|
|
/// The stencils will be bilinear if the surface is refined uniformly, and
|
|
|
|
/// bicubic if feature adaptive isolation is used instead.
|
2014-09-19 00:48:34 +00:00
|
|
|
///
|
2014-10-02 23:09:17 +00:00
|
|
|
/// Surface locations are expressed as a combination of ptex face index and
|
|
|
|
/// normalized (s,t) patch coordinates. The factory exposes the LocationArray
|
|
|
|
/// struct as a container for these location descriptors.
|
2014-09-19 00:48:34 +00:00
|
|
|
///
|
2014-09-12 23:59:16 +00:00
|
|
|
class LimitStencilTablesFactory {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2014-09-19 00:48:34 +00:00
|
|
|
/// \brief Descriptor for limit surface locations
|
2014-09-12 23:59:16 +00:00
|
|
|
struct LocationArray {
|
|
|
|
|
2014-09-19 00:48:34 +00:00
|
|
|
LocationArray() : ptexIdx(-1), numLocations(0), s(0), t(0) { }
|
2014-09-12 23:59:16 +00:00
|
|
|
|
2014-09-19 00:48:34 +00:00
|
|
|
int ptexIdx, ///< ptex face index
|
|
|
|
numLocations; ///< number of (u,v) coordinates in the array
|
2014-09-12 23:59:16 +00:00
|
|
|
|
2014-09-19 00:48:34 +00:00
|
|
|
float const * s, ///< array of u coordinates
|
|
|
|
* t; ///< array of v coordinates
|
2014-09-12 23:59:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<LocationArray> LocationArrayVec;
|
|
|
|
|
2014-10-02 23:09:17 +00:00
|
|
|
/// \brief Instantiates LimitStencilTables from a TopologyRefiner that has
|
|
|
|
/// been refined either uniformly or adaptively.
|
|
|
|
///
|
|
|
|
/// @param refiner The TopologyRefiner containing the topology
|
|
|
|
///
|
|
|
|
/// @param locationArrays An array of surface location descriptors
|
|
|
|
/// (see LocationArray)
|
|
|
|
///
|
|
|
|
/// @param cvStencils A set of StencilTables generated from the
|
|
|
|
/// TopologyRefiner (optional: prevents redundant
|
|
|
|
/// instanciation of the tables if available)
|
|
|
|
///
|
|
|
|
/// @param patchTables A set of PatchTables generated from the
|
|
|
|
/// TopologyRefiner (optional: prevents redundant
|
|
|
|
/// instanciation of the tables if available)
|
|
|
|
///
|
2014-09-12 23:59:16 +00:00
|
|
|
static LimitStencilTables const * Create(TopologyRefiner const & refiner,
|
2014-10-02 23:09:17 +00:00
|
|
|
LocationArrayVec const & locationArrays,
|
|
|
|
StencilTables const * cvStencils=0,
|
|
|
|
PatchTables const * patchTables=0);
|
2014-09-12 23:59:16 +00:00
|
|
|
};
|
|
|
|
|
2013-12-20 19:01:58 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
} // end namespace Far
|
2013-12-20 19:01:58 +00:00
|
|
|
|
2013-09-11 23:05:14 +00:00
|
|
|
} // end namespace OPENSUBDIV_VERSION
|
|
|
|
using namespace OPENSUBDIV_VERSION;
|
|
|
|
|
|
|
|
} // end namespace OpenSubdiv
|
|
|
|
|
|
|
|
#endif // FAR_STENCILTABLE_FACTORY_H
|