| OpenSubdiv

Loading...
Searching...
No Matches
surfaceFactoryMeshAdapter.h
Go to the documentation of this file.
1//
2// Copyright 2021 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://opensubdiv.org/license.
6//
7
8#ifndef OPENSUBDIV3_BFR_SURFACE_FACTORY_ADAPTER_H
9#define OPENSUBDIV3_BFR_SURFACE_FACTORY_ADAPTER_H
10
11#include "../version.h"
12
13#include <cstdint>
14
15 namespace OpenSubdiv {
16 namespace OPENSUBDIV_VERSION {
17
18 namespace Bfr {
19
20 class VertexDescriptor;
21
26// SurfaceFactoryMeshAdapter is an abstract class that defines the interface
27// through which subclasses of SurfaceFactory adapt to a connected mesh
28// representation. The interface defines methods that describe the mesh
29// topology and control indices in the neighborhood of a mesh -- from
30// which the SurfaceFactory to identifies an appropriate limit surface.
31//
32// SurfaceFactoryMeshAdapter methods require a subclass to provide a complete
33// description of the topology around a base face, as well as indices
34// associated with it (both vertex and face-varying). The intent here is
35// to keep the number of methods required to a minimum, and also to minimize
36// the number of invocations required by the factory.
37//
38// With the need to support both linear and non-linear cases (for which
39// linear is trivial by comparison) and the limit surface for both vertex
40// and face-varying topologies, the result is a small set of methods
41// covering this matrix of functionality.
42//
43// Since face-varying data may differ in topology from the vertex data --
44// with each set of face-varying data potentially having its own unique
45// topology -- sets of face-varying data are uniquely distinguished by an
46// associated integer (a face-varying ID).
47//
48 class SurfaceFactoryMeshAdapter {
49 public:
51 typedef int Index;
52
63 typedef std::intptr_t FVarID;
64
65 protected:
67 SurfaceFactoryMeshAdapter() { }
68 virtual ~SurfaceFactoryMeshAdapter() { }
70
71 protected:
73
77
79 virtual bool isFaceHole(Index faceIndex) const = 0;
80
82 virtual int getFaceSize(Index faceIndex) const = 0;
84
86
94
96 virtual int getFaceVertexIndices(Index faceIndex,
97 Index vertexIndices[]) const = 0;
98
100 virtual int getFaceFVarValueIndices(Index faceIndex,
101 FVarID fvarID, Index fvarValueIndices[]) const = 0;
103
104 protected:
106
142
144 virtual int populateFaceVertexDescriptor(
145 Index faceIndex, int faceVertex,
146 VertexDescriptor * vertexDescriptor) const = 0;
147
149 virtual int getFaceVertexIncidentFaceVertexIndices(
150 Index faceIndex, int faceVertex,
151 Index vertexIndices[]) const = 0;
152
155 virtual int getFaceVertexIncidentFaceFVarValueIndices(
156 Index faceIndex, int faceVertex,
157 FVarID fvarID, Index fvarValueIndices[]) const = 0;
159
160 protected:
162
186 virtual bool getFaceNeighborhoodVertexIndicesIfRegular(
187 Index faceIndex, Index vertexIndices[]) const;
188
189 virtual bool getFaceNeighborhoodFVarValueIndicesIfRegular(
190 Index faceIndex, FVarID fvarID, Index fvarValueIndices[]) const;
192
193 private:
194 // No private members
195};
196
197//
198// Inline defaults for optional methods:
199//
200 inline bool
201 SurfaceFactoryMeshAdapter::getFaceNeighborhoodVertexIndicesIfRegular(
202 Index, Index[]) const {
203 return false;
204}
205
206 inline bool
207 SurfaceFactoryMeshAdapter::getFaceNeighborhoodFVarValueIndicesIfRegular(
208 Index, FVarID, Index[]) const {
209 return false;
210}
211
212} // end namespace Bfr
213
214} // end namespace OPENSUBDIV_VERSION
215 using namespace OPENSUBDIV_VERSION;
216
217} // end namespace OpenSubdiv
218
219#endif /* OPENSUBDIV3_BFR_SURFACE_FACTORY_ADAPTER_H */
OpenSubdiv
Definition limits.h:15
OpenSubdiv::OPENSUBDIV_VERSION
Definition limits.h:16
OpenSubdiv::OPENSUBDIV_VERSION::Bfr
Definition limits.h:18
OpenSubdiv::OPENSUBDIV_VERSION::Bfr::SurfaceFactoryMeshAdapter
Abstract interface adapting SurfaceFactory to a connected mesh representation.
Definition surfaceFactoryMeshAdapter.h:48
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:51
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:201
OpenSubdiv::OPENSUBDIV_VERSION::Bfr::SurfaceFactoryMeshAdapter::getFaceNeighborhoodFVarValueIndicesIfRegular
virtual bool getFaceNeighborhoodFVarValueIndicesIfRegular(Index faceIndex, FVarID fvarID, Index fvarValueIndices[]) const
Definition surfaceFactoryMeshAdapter.h:207
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:63
OpenSubdiv::OPENSUBDIV_VERSION::Bfr::VertexDescriptor
Simple class used by subclasses of SurfaceFactory to describe a vertex.
Definition vertexDescriptor.h:114