8#ifndef OPENSUBDIV3_BFR_SURFACE_FACTORY_H
9#define OPENSUBDIV3_BFR_SURFACE_FACTORY_H
11#include "../version.h"
21namespace OPENSUBDIV_VERSION {
28class SurfaceFactoryCache;
101 Options() : _dfltFVarID(-1), _externCache(0), _enableCache(true),
102 _approxLevelSmooth(2), _approxLevelSharp(6) { }
138 unsigned char _enableCache : 1;
139 unsigned char _approxLevelSmooth;
140 unsigned char _approxLevelSharp;
224 template <
typename REAL>
234 template <
typename REAL>
249 template <
typename REAL>
261 template <
typename REAL>
290 template <
typename REAL>
293 FVarID const fvarIDs[] = 0,
307 template <
typename REAL=
float>
311 template <
typename REAL=
float>
315 template <
typename REAL=
float>
319 template <
typename REAL=
float>
355 void setFactoryOptions(
Options const & factoryOptions);
357 bool faceHasLimitSimple(
Index faceIndex,
int faceSize)
const;
359 bool faceHasLimitNeighborhood(
Index faceIndex)
const;
360 bool faceHasLimitNeighborhood(FaceTopology
const & faceTopology)
const;
364 bool populateAllSurfaces(
Index faceIndex, SurfaceSet * sSetPtr)
const;
365 bool populateLinearSurfaces(
Index faceIndex, SurfaceSet * sSetPtr)
const;
366 bool populateNonLinearSurfaces(
Index faceIndex, SurfaceSet * sSetPtr)
const;
368 bool initSurfaces(
Index faceIndex, internal::SurfaceData * vtxSurface,
369 internal::SurfaceData * varSurface,
370 internal::SurfaceData * fvarSurfaces,
372 FVarID const fvarIDs[])
const;
375 bool isFaceNeighborhoodRegular(
Index faceIndex,
376 FVarID const * fvarPtrOrVtx,
377 Index indices[])
const;
379 bool initFaceNeighborhoodTopology(
Index faceIndex,
380 FaceTopology * topology)
const;
382 bool gatherFaceNeighborhoodTopology(
Index faceIndex,
383 FaceTopology * topology)
const;
385 int gatherFaceNeighborhoodIndices(
Index faceIndex,
386 FaceTopology
const & topology,
387 FVarID const * fvarPtrOrVtx,
388 Index indices[])
const;
391 typedef internal::SurfaceData SurfaceType;
393 void assignLinearSurface(SurfaceType * surfacePtr,
395 FVarID const * fvarPtrOrVtx)
const;
397 void assignRegularSurface(SurfaceType * surfacePtr,
398 Index const surfacePatchPoints[])
const;
400 void assignRegularSurface(SurfaceType * surfacePtr,
401 FaceSurface
const & surfaceDescription)
const;
403 void assignIrregularSurface(SurfaceType * surfacePtr,
404 FaceSurface
const & surfaceDescription)
const;
406 void copyNonLinearSurface(SurfaceType * surfacePtr,
407 SurfaceType
const & surfaceSource,
408 FaceSurface
const & surfaceDescription)
const;
418 unsigned int _linearScheme : 1;
419 unsigned int _linearFVarInterp : 1;
421 unsigned int _testNeighborhoodForLimit : 1;
422 unsigned int _rejectSmoothBoundariesForLimit : 1;
423 unsigned int _rejectIrregularFacesForLimit : 1;
451 _approxLevelSmooth = (
unsigned char) level;
456 _approxLevelSharp = (
unsigned char) level;
463template <
typename REAL>
467 return initSurfaces(face, &s->getSurfaceData(), 0, 0, 0, 0);
469template <
typename REAL>
473 return initSurfaces(face, 0, &s->getSurfaceData(), 0, 0, 0);
475template <
typename REAL>
479 return initSurfaces(face, 0, 0, &s->getSurfaceData(), 1, &fvarID);
481template <
typename REAL>
485 return initSurfaces(face, 0, 0, &s->getSurfaceData(), 1, &dfltID);
488template <
typename REAL>
494 bool useDfltFVarID = fvarSurfaces && (fvarIDs == 0) && (fvarCount == 0);
497 return initSurfaces(faceIndex,
498 vtxSurface ? &vtxSurface->getSurfaceData() : 0,
499 varSurface ? &varSurface->getSurfaceData() : 0,
500 fvarSurfaces ? &fvarSurfaces->getSurfaceData() : 0,
501 fvarCount ? fvarCount : (fvarSurfaces != 0),
502 useDfltFVarID ? &dfltFVarID : fvarIDs);
508template <
typename REAL>
516template <
typename REAL>
524template <
typename REAL>
532template <
typename REAL>
542using namespace OPENSUBDIV_VERSION;
SchemeType
Enumerated type for all subdivision schemes supported by OpenSubdiv.
Simple class defining the 2D parameterization of a face.
Encapsulates the limit surface for a face of a mesh.
Base class providing initialization of a Surface for each face of a mesh.
void setInternalCache(SurfaceFactoryCache *cache)
Subclass to identify an internal cache for use by base class.
~SurfaceFactory() override
bool InitFaceVaryingSurface(Index faceIndex, Surface< REAL > *surface) const
Initialize a Surface for the default face-varying data.
Sdc::Options GetSchemeOptions() const
Return the set of subdivision options.
Parameterization GetFaceParameterization(Index faceIndex) const
Return the Parameterization of a face with a limit surface.
SurfaceFactory(SurfaceFactory const &)=delete
bool FaceHasLimitSurface(Index faceIndex) const
Return if a specified face has a limit surface.
SurfaceFactory & operator=(SurfaceFactory const &)=delete
Surface< REAL > * CreateVertexSurface(Index faceIndex) const
Construct a Surface for vertex data.
Surface< REAL > * CreateFaceVaryingSurface(Index faceIndex) const
Construct a Surface for the default face-varying data.
bool InitSurfaces(Index faceIndex, Surface< REAL > *vtxSurface, Surface< REAL > *fvarSurfaces, FVarID const fvarIDs[]=0, int fvarCount=0, Surface< REAL > *varSurface=0) const
Initialize multiple Surfaces at once.
Sdc::SchemeType GetSchemeType() const
Return the subdivision scheme.
Surface< REAL > * CreateVaryingSurface(Index faceIndex) const
Construct a Surface for varying data.
bool InitVertexSurface(Index faceIndex, Surface< REAL > *surface) const
Initialize a Surface for vertex data.
bool InitVaryingSurface(Index faceIndex, Surface< REAL > *surface) const
Initialize a Surface for varying data.
SurfaceFactory(Sdc::SchemeType schemeType, Sdc::Options const &schemeOptions, Options const &limitOptions)
Constructor to be used by subclasses.
Simple set of options assigned to instances of SurfaceFactory.
Options & SetExternalCache(SurfaceFactoryCache *c)
Assign an external cache to override the internal.
Options & EnableCaching(bool on)
Enable or disable caching (default is true):
Options & SetApproxLevelSmooth(int level)
Assign maximum refinement level for smooth features.
int GetApproxLevelSmooth() const
Return maximum refinement level for smooth features.
bool IsCachingEnabled() const
Return if caching is enable.
Options & SetDefaultFVarID(FVarID id)
Assign the default face-varying ID (none assigned by default)
Options & SetApproxLevelSharp(int level)
Assign maximum refinement level for sharp features.
FVarID GetDefaultFVarID() const
Return the default face-varying ID.
int GetApproxLevelSharp() const
Return maximum refinement level for sharp features.
SurfaceFactoryCache * GetExternalCache() const
Return any assigned external cache.
Container used internally by SurfaceFactory to store reusable information.
Abstract interface adapting SurfaceFactory to a connected mesh representation.
int Index
Integer type representing a mesh index.
std::intptr_t FVarID
Type used to identify and specify face-varying primvars.
All supported options applying to subdivision scheme.