refinerSurfaceFactory.h
Go to the documentation of this file.
//
// Copyright 2021 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_BFR_REFINER_SURFACE_FACTORY_H
#define OPENSUBDIV3_BFR_REFINER_SURFACE_FACTORY_H
#include "../version.h"
#include "../bfr/surfaceFactory.h"
#include "../bfr/surfaceFactoryCache.h"
namespace OpenSubdiv {
namespace OPENSUBDIV_VERSION {
namespace Far {
class TopologyRefiner;
}
namespace Bfr {
class RefinerSurfaceFactoryBase : public SurfaceFactory {
public:
RefinerSurfaceFactoryBase(Far::TopologyRefiner const & mesh,
Options const & options);
~RefinerSurfaceFactoryBase() override = default;
Far::TopologyRefiner const & GetMesh() const { return _mesh; }
int GetNumFaces() const { return _numFaces; }
int GetNumFVarChannels() const { return _numFVarChannels; }
protected:
//
// Virtual overrides to satisfy the SurfaceFactoryMeshAdapter interface:
//
bool isFaceHole( Index faceIndex) const override;
int getFaceSize(Index faceIndex) const override;
int getFaceVertexIndices(Index faceIndex,
Index vertexIndices[]) const override;
int getFaceFVarValueIndices(Index faceIndex,
FVarID fvarID, Index fvarValueIndices[]) const override;
int populateFaceVertexDescriptor(Index faceIndex, int faceVertex,
VertexDescriptor * vertexDescriptor) const override;
int getFaceVertexIncidentFaceVertexIndices(
Index faceIndex, int faceVertex,
Index vertexIndices[]) const override;
int getFaceVertexIncidentFaceFVarValueIndices(
Index faceIndex, int faceVertex,
FVarID fvarID, Index fvarValueIndices[]) const override;
// Optional SurfaceFactoryMeshAdapter overrides for regular patches:
bool getFaceNeighborhoodVertexIndicesIfRegular(
Index faceIndex,
Index vertexIndices[]) const override;
bool getFaceNeighborhoodFVarValueIndicesIfRegular(
Index faceIndex,
FVarID fvarID, Index fvarValueIndices[]) const override;
private:
//
// Internal supporting methods:
//
int getFaceVaryingChannel(FVarID fvarID) const;
int getFaceVertexPointIndices(Index faceIndex, int faceVertex,
Index indices[], int vtxOrFVarChannel) const;
int getFacePatchPointIndices(Index faceIndex,
Index indices[], int vtxOrFVarChannel) const;
private:
// Additional members for the subclass:
Far::TopologyRefiner const & _mesh;
int _numFaces;
int _numFVarChannels;
};
//
template <class CACHE_TYPE = SurfaceFactoryCache>
class RefinerSurfaceFactory : public RefinerSurfaceFactoryBase {
public:
RefinerSurfaceFactory(Far::TopologyRefiner const & mesh,
Options const & options = Options()) :
RefinerSurfaceFactoryBase(mesh, options),
_localCache() {
SurfaceFactory::setInternalCache(&_localCache);
}
~RefinerSurfaceFactory() override = default;
private:
CACHE_TYPE _localCache;
};
} // end namespace Bfr
} // end namespace OPENSUBDIV_VERSION
using namespace OPENSUBDIV_VERSION;
} // end namespace OpenSubdiv
#endif /* OPENSUBDIV3_BFR_REFINER_SURFACE_FACTORY_H */
OpenSubdiv
Definition: limits.h:32
OpenSubdiv::OPENSUBDIV_VERSION::Bfr::RefinerSurfaceFactoryBase
Intermediate subclass of SurfaceFactory with Far::TopologyRefiner as the mesh.
Definition: refinerSurfaceFactory.h:58
OpenSubdiv::OPENSUBDIV_VERSION::Bfr::RefinerSurfaceFactoryBase::GetNumFaces
int GetNumFaces() const
Return the number of faces.
Definition: refinerSurfaceFactory.h:82
OpenSubdiv::OPENSUBDIV_VERSION::Bfr::RefinerSurfaceFactoryBase::GetNumFVarChannels
int GetNumFVarChannels() const
Return the number of face-varying channels.
Definition: refinerSurfaceFactory.h:85
OpenSubdiv::OPENSUBDIV_VERSION::Bfr::RefinerSurfaceFactoryBase::GetMesh
Far::TopologyRefiner const & GetMesh() const
Return the instance of the mesh.
Definition: refinerSurfaceFactory.h:79
OpenSubdiv::OPENSUBDIV_VERSION::Bfr::RefinerSurfaceFactoryBase::~RefinerSurfaceFactoryBase
~RefinerSurfaceFactoryBase() override=default
OpenSubdiv::OPENSUBDIV_VERSION::Bfr::RefinerSurfaceFactoryBase::RefinerSurfaceFactoryBase
RefinerSurfaceFactoryBase(Far::TopologyRefiner const &mesh, Options const &options)
OpenSubdiv::OPENSUBDIV_VERSION::Bfr::RefinerSurfaceFactory
Template for concrete subclasses of RefinerSurfaceFactoryBase.
Definition: refinerSurfaceFactory.h:157
OpenSubdiv::OPENSUBDIV_VERSION::Bfr::RefinerSurfaceFactory::~RefinerSurfaceFactory
~RefinerSurfaceFactory() override=default
OpenSubdiv::OPENSUBDIV_VERSION::Bfr::RefinerSurfaceFactory::RefinerSurfaceFactory
RefinerSurfaceFactory(Far::TopologyRefiner const &mesh, Options const &options=Options())
Definition: refinerSurfaceFactory.h:159
OpenSubdiv::OPENSUBDIV_VERSION::Bfr::SurfaceFactory
Base class providing initialization of a Surface for each face of a mesh.
Definition: surfaceFactory.h:103
OpenSubdiv::OPENSUBDIV_VERSION::Bfr::SurfaceFactory::setInternalCache
void setInternalCache(SurfaceFactoryCache *cache)
Subclass to identify an internal cache for use by base class.
OpenSubdiv::OPENSUBDIV_VERSION::Bfr::SurfaceFactory::Options
Simple set of options assigned to instances of SurfaceFactory.
Definition: surfaceFactory.h:116
OpenSubdiv::OPENSUBDIV_VERSION::Bfr::SurfaceFactoryMeshAdapter::getFaceVertexIncidentFaceFVarValueIndices
virtual int getFaceVertexIncidentFaceFVarValueIndices(Index faceIndex, int faceVertex, FVarID fvarID, Index fvarValueIndices[]) const =0
Gather face-varying indices of incident faces around a face-vertex.
OpenSubdiv::OPENSUBDIV_VERSION::Bfr::SurfaceFactoryMeshAdapter::getFaceVertexIncidentFaceVertexIndices
virtual int getFaceVertexIncidentFaceVertexIndices(Index faceIndex, int faceVertex, Index vertexIndices[]) const =0
Gather vertex indices of incident faces around a face-vertex.
OpenSubdiv::OPENSUBDIV_VERSION::Bfr::SurfaceFactoryMeshAdapter::getFaceSize
virtual int getFaceSize(Index faceIndex) const =0
Returns the size of a face (number of vertices)
OpenSubdiv::OPENSUBDIV_VERSION::Bfr::SurfaceFactoryMeshAdapter::Index
int Index
Integer type representing a mesh index.
Definition: surfaceFactoryMeshAdapter.h:68
OpenSubdiv::OPENSUBDIV_VERSION::Bfr::SurfaceFactoryMeshAdapter::populateFaceVertexDescriptor
virtual int populateFaceVertexDescriptor(Index faceIndex, int faceVertex, VertexDescriptor *vertexDescriptor) const =0
Describe the topology of incident faces around a face-vertex.
OpenSubdiv::OPENSUBDIV_VERSION::Bfr::SurfaceFactoryMeshAdapter::getFaceNeighborhoodVertexIndicesIfRegular
virtual bool getFaceNeighborhoodVertexIndicesIfRegular(Index faceIndex, Index vertexIndices[]) const
Definition: surfaceFactoryMeshAdapter.h:218
OpenSubdiv::OPENSUBDIV_VERSION::Bfr::SurfaceFactoryMeshAdapter::getFaceNeighborhoodFVarValueIndicesIfRegular
virtual bool getFaceNeighborhoodFVarValueIndicesIfRegular(Index faceIndex, FVarID fvarID, Index fvarValueIndices[]) const
Definition: surfaceFactoryMeshAdapter.h:224
OpenSubdiv::OPENSUBDIV_VERSION::Bfr::SurfaceFactoryMeshAdapter::getFaceFVarValueIndices
virtual int getFaceFVarValueIndices(Index faceIndex, FVarID fvarID, Index fvarValueIndices[]) const =0
Gather the face-varying indices of the face's vertices.
OpenSubdiv::OPENSUBDIV_VERSION::Bfr::SurfaceFactoryMeshAdapter::getFaceVertexIndices
virtual int getFaceVertexIndices(Index faceIndex, Index vertexIndices[]) const =0
Gather the indices of the face's vertices.
OpenSubdiv::OPENSUBDIV_VERSION::Bfr::SurfaceFactoryMeshAdapter::isFaceHole
virtual bool isFaceHole(Index faceIndex) const =0
Returns if a face is a hole.
OpenSubdiv::OPENSUBDIV_VERSION::Bfr::SurfaceFactoryMeshAdapter::FVarID
std::intptr_t FVarID
Type used to identify and specify face-varying primvars.
Definition: surfaceFactoryMeshAdapter.h:80
OpenSubdiv::OPENSUBDIV_VERSION::Bfr::VertexDescriptor
Simple class used by subclasses of SurfaceFactory to describe a vertex.
Definition: vertexDescriptor.h:131
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner
Stores topology data for a specified set of refinement options.
Definition: topologyRefiner.h:51