OpenSubdiv
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 
59 public:
61 
67  Options const & options);
68 
69  ~RefinerSurfaceFactoryBase() override = default;
71 
73 
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 
105  Index faceIndex, int faceVertex,
106  Index vertexIndices[]) const override;
108  Index faceIndex, int faceVertex,
109  FVarID fvarID, Index fvarValueIndices[]) const override;
110 
111  // Optional SurfaceFactoryMeshAdapter overrides for regular patches:
113  Index faceIndex,
114  Index vertexIndices[]) const override;
115 
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>
158 public:
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 */
Far::TopologyRefiner const & GetMesh() const
Return the instance of the mesh.
RefinerSurfaceFactoryBase(Far::TopologyRefiner const &mesh, Options const &options)
void setInternalCache(SurfaceFactoryCache *cache)
Subclass to identify an internal cache for use by base class.
virtual int getFaceVertexIndices(Index faceIndex, Index vertexIndices[]) const =0
Gather the indices of the face's vertices.
virtual int getFaceVertexIncidentFaceVertexIndices(Index faceIndex, int faceVertex, Index vertexIndices[]) const =0
Gather vertex indices of incident faces around a face-vertex.
virtual bool getFaceNeighborhoodFVarValueIndicesIfRegular(Index faceIndex, FVarID fvarID, Index fvarValueIndices[]) const
virtual int getFaceVertexIncidentFaceFVarValueIndices(Index faceIndex, int faceVertex, FVarID fvarID, Index fvarValueIndices[]) const =0
Gather face-varying indices of incident faces around a face-vertex.
Base class providing initialization of a Surface for each face of a mesh.
virtual int getFaceSize(Index faceIndex) const =0
Returns the size of a face (number of vertices)
Template for concrete subclasses of RefinerSurfaceFactoryBase.
std::intptr_t FVarID
Type used to identify and specify face-varying primvars.
int GetNumFVarChannels() const
Return the number of face-varying channels.
Intermediate subclass of SurfaceFactory with Far::TopologyRefiner as the mesh.
virtual bool isFaceHole(Index faceIndex) const =0
Returns if a face is a hole.
virtual bool getFaceNeighborhoodVertexIndicesIfRegular(Index faceIndex, Index vertexIndices[]) const
RefinerSurfaceFactory(Far::TopologyRefiner const &mesh, Options const &options=Options())
virtual int getFaceFVarValueIndices(Index faceIndex, FVarID fvarID, Index fvarValueIndices[]) const =0
Gather the face-varying indices of the face's vertices.
Simple class used by subclasses of SurfaceFactory to describe a vertex.
Simple set of options assigned to instances of SurfaceFactory.
virtual int populateFaceVertexDescriptor(Index faceIndex, int faceVertex, VertexDescriptor *vertexDescriptor) const =0
Describe the topology of incident faces around a face-vertex.
Stores topology data for a specified set of refinement options.