OpenSubdiv: opensubdiv/bfr/surfaceFactoryMeshAdapter.h Source File

| OpenSubdiv

Loading...
Searching...
No Matches
surfaceFactoryMeshAdapter.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_SURFACE_FACTORY_ADAPTER_H
26#define OPENSUBDIV3_BFR_SURFACE_FACTORY_ADAPTER_H
27
28#include "../version.h"
29
30#include <cstdint>
31
32namespace OpenSubdiv {
33namespace OPENSUBDIV_VERSION {
34
35namespace Bfr {
36
37class VertexDescriptor;
38
43// SurfaceFactoryMeshAdapter is an abstract class that defines the interface
44// through which subclasses of SurfaceFactory adapt to a connected mesh
45// representation. The interface defines methods that describe the mesh
46// topology and control indices in the neighborhood of a mesh -- from
47// which the SurfaceFactory to identifies an appropriate limit surface.
48//
49// SurfaceFactoryMeshAdapter methods require a subclass to provide a complete
50// description of the topology around a base face, as well as indices
51// associated with it (both vertex and face-varying). The intent here is
52// to keep the number of methods required to a minimum, and also to minimize
53// the number of invocations required by the factory.
54//
55// With the need to support both linear and non-linear cases (for which
56// linear is trivial by comparison) and the limit surface for both vertex
57// and face-varying topologies, the result is a small set of methods
58// covering this matrix of functionality.
59//
60// Since face-varying data may differ in topology from the vertex data --
61// with each set of face-varying data potentially having its own unique
62// topology -- sets of face-varying data are uniquely distinguished by an
63// associated integer (a face-varying ID).
64//
65 class SurfaceFactoryMeshAdapter {
66public:
68 typedef int Index;
69
80 typedef std::intptr_t FVarID;
81
82protected:
84 SurfaceFactoryMeshAdapter() { }
85 virtual ~SurfaceFactoryMeshAdapter() { }
87
88protected:
90
94
96 virtual bool isFaceHole(Index faceIndex) const = 0;
97
99 virtual int getFaceSize(Index faceIndex) const = 0;
101
103
111
113 virtual int getFaceVertexIndices(Index faceIndex,
114 Index vertexIndices[]) const = 0;
115
117 virtual int getFaceFVarValueIndices(Index faceIndex,
118 FVarID fvarID, Index fvarValueIndices[]) const = 0;
120
121protected:
123
159
161 virtual int populateFaceVertexDescriptor(
162 Index faceIndex, int faceVertex,
163 VertexDescriptor * vertexDescriptor) const = 0;
164
166 virtual int getFaceVertexIncidentFaceVertexIndices(
167 Index faceIndex, int faceVertex,
168 Index vertexIndices[]) const = 0;
169
172 virtual int getFaceVertexIncidentFaceFVarValueIndices(
173 Index faceIndex, int faceVertex,
174 FVarID fvarID, Index fvarValueIndices[]) const = 0;
176
177protected:
179
203 virtual bool getFaceNeighborhoodVertexIndicesIfRegular(
204 Index faceIndex, Index vertexIndices[]) const;
205
206 virtual bool getFaceNeighborhoodFVarValueIndicesIfRegular(
207 Index faceIndex, FVarID fvarID, Index fvarValueIndices[]) const;
209
210private:
211 // No private members
212};
213
214//
215// Inline defaults for optional methods:
216//
217inline bool
218SurfaceFactoryMeshAdapter::getFaceNeighborhoodVertexIndicesIfRegular(
219 Index, Index[]) const {
220 return false;
221}
222
223inline bool
224SurfaceFactoryMeshAdapter::getFaceNeighborhoodFVarValueIndicesIfRegular(
225 Index, FVarID, Index[]) const {
226 return false;
227}
228
229} // end namespace Bfr
230
231} // end namespace OPENSUBDIV_VERSION
232using namespace OPENSUBDIV_VERSION;
233
234} // end namespace OpenSubdiv
235
236#endif /* OPENSUBDIV3_BFR_SURFACE_FACTORY_ADAPTER_H */
OpenSubdiv
Definition limits.h:32
OpenSubdiv::OPENSUBDIV_VERSION
Definition limits.h:33
OpenSubdiv::OPENSUBDIV_VERSION::Bfr
Definition limits.h:35
OpenSubdiv::OPENSUBDIV_VERSION::Bfr::SurfaceFactoryMeshAdapter
Abstract interface adapting SurfaceFactory to a connected mesh representation.
Definition surfaceFactoryMeshAdapter.h:65
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