| OpenSubdiv

Loading...
Searching...
No Matches
refinerSurfaceFactory.h
Go to the documentation of this file.
1//
2// Copyright 2021 Pixar
3//
4// Licensed under the Apache License, Version 2.0 (the "Apache License")
5// with the following modification; you may not use this file except in
6// compliance with the Apache License and the following modification to it:
7// Section 6. Trademarks. is deleted and replaced with:
8//
9// 6. Trademarks. This License does not grant permission to use the trade
10// names, trademarks, service marks, or product names of the Licensor
11// and its affiliates, except as required to comply with Section 4(c) of
12// the License and to reproduce the content of the NOTICE file.
13//
14// You may obtain a copy of the Apache License at
15//
16// http://www.apache.org/licenses/LICENSE-2.0
17//
18// Unless required by applicable law or agreed to in writing, software
19// distributed under the Apache License with the above modification is
20// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21// KIND, either express or implied. See the Apache License for the specific
22// language governing permissions and limitations under the Apache License.
23//
24
25#ifndef OPENSUBDIV3_BFR_REFINER_SURFACE_FACTORY_H
26#define OPENSUBDIV3_BFR_REFINER_SURFACE_FACTORY_H
27
28#include "../version.h"
29
30#include "../bfr/surfaceFactory.h"
31#include "../bfr/surfaceFactoryCache.h"
32
33 namespace OpenSubdiv {
34 namespace OPENSUBDIV_VERSION {
35
36 namespace Far {
37 class TopologyRefiner;
38}
39
40 namespace Bfr {
41
58 class RefinerSurfaceFactoryBase : public SurfaceFactory {
59 public:
61
65
66 RefinerSurfaceFactoryBase(Far::TopologyRefiner const & mesh,
67 Options const & options);
68
69 ~RefinerSurfaceFactoryBase() override = default;
71
73
77
79 Far::TopologyRefiner const & GetMesh() const { return _mesh; }
80
82 int GetNumFaces() const { return _numFaces; }
83
85 int GetNumFVarChannels() const { return _numFVarChannels; }
87
88 protected:
90 //
91 // Virtual overrides to satisfy the SurfaceFactoryMeshAdapter interface:
92 //
93 bool isFaceHole( Index faceIndex) const override;
94 int getFaceSize(Index faceIndex) const override;
95
96 int getFaceVertexIndices(Index faceIndex,
97 Index vertexIndices[]) const override;
98 int getFaceFVarValueIndices(Index faceIndex,
99 FVarID fvarID, Index fvarValueIndices[]) const override;
100
101 int populateFaceVertexDescriptor(Index faceIndex, int faceVertex,
102 VertexDescriptor * vertexDescriptor) const override;
103
104 int getFaceVertexIncidentFaceVertexIndices(
105 Index faceIndex, int faceVertex,
106 Index vertexIndices[]) const override;
107 int getFaceVertexIncidentFaceFVarValueIndices(
108 Index faceIndex, int faceVertex,
109 FVarID fvarID, Index fvarValueIndices[]) const override;
110
111 // Optional SurfaceFactoryMeshAdapter overrides for regular patches:
112 bool getFaceNeighborhoodVertexIndicesIfRegular(
113 Index faceIndex,
114 Index vertexIndices[]) const override;
115
116 bool getFaceNeighborhoodFVarValueIndicesIfRegular(
117 Index faceIndex,
118 FVarID fvarID, Index fvarValueIndices[]) const override;
120
121 private:
122 //
123 // Internal supporting methods:
124 //
125 int getFaceVaryingChannel(FVarID fvarID) const;
126
127 int getFaceVertexPointIndices(Index faceIndex, int faceVertex,
128 Index indices[], int vtxOrFVarChannel) const;
129
130 int getFacePatchPointIndices(Index faceIndex,
131 Index indices[], int vtxOrFVarChannel) const;
132
133 private:
134 // Additional members for the subclass:
135 Far::TopologyRefiner const & _mesh;
136
137 int _numFaces;
138 int _numFVarChannels;
139};
140
141
142//
156 template <class CACHE_TYPE = SurfaceFactoryCache>
157 class RefinerSurfaceFactory : public RefinerSurfaceFactoryBase {
158 public:
159 RefinerSurfaceFactory(Far::TopologyRefiner const & mesh,
160 Options const & options = Options()) :
161 RefinerSurfaceFactoryBase(mesh, options),
162 _localCache() {
163
164 SurfaceFactory::setInternalCache(&_localCache);
165 }
166 ~RefinerSurfaceFactory() override = default;
167
168 private:
169 CACHE_TYPE _localCache;
170};
171
172} // end namespace Bfr
173
174} // end namespace OPENSUBDIV_VERSION
175 using namespace OPENSUBDIV_VERSION;
176
177} // end namespace OpenSubdiv
178
179#endif /* OPENSUBDIV3_BFR_REFINER_SURFACE_FACTORY_H */
surfaceFactory.h
surfaceFactoryCache.h
OpenSubdiv
Definition limits.h:32
OpenSubdiv::OPENSUBDIV_VERSION
Definition limits.h:33
OpenSubdiv::OPENSUBDIV_VERSION::Bfr
Definition limits.h:35
OpenSubdiv::OPENSUBDIV_VERSION::Far
Definition refinerSurfaceFactory.h:36
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::~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::setInternalCache
void setInternalCache(SurfaceFactoryCache *cache)
Subclass to identify an internal cache for use by base class.
OpenSubdiv::OPENSUBDIV_VERSION::Bfr::SurfaceFactory::SurfaceFactory
SurfaceFactory(Sdc::SchemeType schemeType, Sdc::Options const &schemeOptions, Options const &limitOptions)
Constructor to be used by subclasses.
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