25#ifndef OPENSUBDIV3_BFR_SURFACE_FACTORY_H
26#define OPENSUBDIV3_BFR_SURFACE_FACTORY_H
28#include "../version.h"
30#include "../bfr/surface.h"
31#include "../bfr/surfaceFactoryMeshAdapter.h"
32#include "../sdc/options.h"
33#include "../sdc/types.h"
38namespace OPENSUBDIV_VERSION {
45class SurfaceFactoryCache;
118 Options() : _dfltFVarID(-1), _externCache(0), _enableCache(true),
119 _approxLevelSmooth(2), _approxLevelSharp(6) { }
155 unsigned char _enableCache : 1;
156 unsigned char _approxLevelSmooth;
157 unsigned char _approxLevelSharp;
241 template <
typename REAL>
251 template <
typename REAL>
266 template <
typename REAL>
278 template <
typename REAL>
307 template <
typename REAL>
310 FVarID const fvarIDs[] = 0,
324 template <
typename REAL=
float>
328 template <
typename REAL=
float>
332 template <
typename REAL=
float>
336 template <
typename REAL=
float>
372 void setFactoryOptions(
Options const & factoryOptions);
374 bool faceHasLimitSimple(
Index faceIndex,
int faceSize)
const;
376 bool faceHasLimitNeighborhood(
Index faceIndex)
const;
377 bool faceHasLimitNeighborhood(FaceTopology
const & faceTopology)
const;
381 bool populateAllSurfaces(
Index faceIndex, SurfaceSet * sSetPtr)
const;
382 bool populateLinearSurfaces(
Index faceIndex, SurfaceSet * sSetPtr)
const;
383 bool populateNonLinearSurfaces(
Index faceIndex, SurfaceSet * sSetPtr)
const;
385 bool initSurfaces(
Index faceIndex, internal::SurfaceData * vtxSurface,
386 internal::SurfaceData * varSurface,
387 internal::SurfaceData * fvarSurfaces,
389 FVarID const fvarIDs[])
const;
392 bool isFaceNeighborhoodRegular(
Index faceIndex,
393 FVarID const * fvarPtrOrVtx,
394 Index indices[])
const;
396 bool initFaceNeighborhoodTopology(
Index faceIndex,
397 FaceTopology * topology)
const;
399 bool gatherFaceNeighborhoodTopology(
Index faceIndex,
400 FaceTopology * topology)
const;
402 int gatherFaceNeighborhoodIndices(
Index faceIndex,
403 FaceTopology
const & topology,
404 FVarID const * fvarPtrOrVtx,
405 Index indices[])
const;
408 typedef internal::SurfaceData SurfaceType;
410 void assignLinearSurface(SurfaceType * surfacePtr,
412 FVarID const * fvarPtrOrVtx)
const;
414 void assignRegularSurface(SurfaceType * surfacePtr,
415 Index const surfacePatchPoints[])
const;
417 void assignRegularSurface(SurfaceType * surfacePtr,
418 FaceSurface
const & surfaceDescription)
const;
420 void assignIrregularSurface(SurfaceType * surfacePtr,
421 FaceSurface
const & surfaceDescription)
const;
423 void copyNonLinearSurface(SurfaceType * surfacePtr,
424 SurfaceType
const & surfaceSource,
425 FaceSurface
const & surfaceDescription)
const;
435 unsigned int _linearScheme : 1;
436 unsigned int _linearFVarInterp : 1;
438 unsigned int _testNeighborhoodForLimit : 1;
439 unsigned int _rejectSmoothBoundariesForLimit : 1;
440 unsigned int _rejectIrregularFacesForLimit : 1;
468 _approxLevelSmooth = (
unsigned char) level;
473 _approxLevelSharp = (
unsigned char) level;
480template <
typename REAL>
484 return initSurfaces(face, &s->getSurfaceData(), 0, 0, 0, 0);
486template <
typename REAL>
490 return initSurfaces(face, 0, &s->getSurfaceData(), 0, 0, 0);
492template <
typename REAL>
496 return initSurfaces(face, 0, 0, &s->getSurfaceData(), 1, &fvarID);
498template <
typename REAL>
502 return initSurfaces(face, 0, 0, &s->getSurfaceData(), 1, &dfltID);
505template <
typename REAL>
511 bool useDfltFVarID = fvarSurfaces && (fvarIDs == 0) && (fvarCount == 0);
514 return initSurfaces(faceIndex,
515 vtxSurface ? &vtxSurface->getSurfaceData() : 0,
516 varSurface ? &varSurface->getSurfaceData() : 0,
517 fvarSurfaces ? &fvarSurfaces->getSurfaceData() : 0,
518 fvarCount ? fvarCount : (fvarSurfaces != 0),
519 useDfltFVarID ? &dfltFVarID : fvarIDs);
525template <
typename REAL>
529 if (InitVertexSurface<REAL>(faceIndex, s))
return s;
533template <
typename REAL>
537 if (InitVaryingSurface<REAL>(faceIndex, s))
return s;
541template <
typename REAL>
545 if (InitFaceVaryingSurface<REAL>(faceIndex, s, fvarID))
return s;
549template <
typename REAL>
553 return CreateFaceVaryingSurface<REAL>(face, dfltID);
559using 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.