24#ifndef OPENSUBDIV3_FAR_TOPOLOGY_REFINER_FACTORY_H
25#define OPENSUBDIV3_FAR_TOPOLOGY_REFINER_FACTORY_H
27#include "../version.h"
29#include "../far/topologyRefiner.h"
30#include "../far/error.h"
35namespace OPENSUBDIV_VERSION {
335 static void reportInvalidTopologyAdapter(TopologyError errCode,
char const * msg, MESH
const * mesh) {
350 if (! populateBaseLevel(*refiner, mesh, options)) {
387 if (! resizeComponentTopology(refiner, mesh))
return false;
388 if (! prepareComponentTopologySizing(refiner))
return false;
397 void const * userData = &mesh;
399 if (! assignComponentTopology(refiner, mesh))
return false;
400 if (! prepareComponentTopologyAssignment(refiner, validate, callback, userData))
return false;
406 if (! assignComponentTags(refiner, mesh))
return false;
407 if (! prepareComponentTagsAndSharpness(refiner))
return false;
412 if (! assignFaceVaryingTopology(refiner, mesh))
return false;
413 if (! prepareFaceVaryingChannels(refiner))
return false;
421 newRefiner._levels[0]->resizeFaces(count);
426 newRefiner._levels[0]->resizeEdges(count);
431 newRefiner._levels[0]->resizeVertices(count);
437 return newRefiner._levels[0]->getNumFaces();
442 return newRefiner._levels[0]->getNumEdges();
447 return newRefiner._levels[0]->getNumVertices();
453 newRefiner._levels[0]->resizeFaceVertices(f, count);
454 newRefiner._hasIrregFaces = newRefiner._hasIrregFaces || (count != newRefiner._regFaceSize);
459 newRefiner._levels[0]->resizeEdgeFaces(e, count);
464 newRefiner._levels[0]->resizeVertexFaces(v, count);
469 newRefiner._levels[0]->resizeVertexEdges(v, count);
475 return newRefiner._levels[0]->getFaceVertices(f);
480 return newRefiner._levels[0]->getFaceEdges(f);
485 return newRefiner._levels[0]->getEdgeVertices(e);
490 return newRefiner._levels[0]->getEdgeFaces(e);
495 return newRefiner._levels[0]->getVertexFaces(v);
500 return newRefiner._levels[0]->getVertexEdges(v);
506 return newRefiner._levels[0]->getEdgeFaceLocalIndices(e);
511 return newRefiner._levels[0]->getVertexFaceLocalIndices(v);
516 return newRefiner._levels[0]->getVertexEdgeLocalIndices(v);
522 return newRefiner._levels[0]->findEdge(v0, v1);
528 newRefiner._levels[0]->populateLocalIndices();
534 newRefiner._levels[0]->setEdgeNonManifold(e, b);
539 newRefiner._levels[0]->setVertexNonManifold(v, b);
545 newRefiner._levels[0]->getEdgeSharpness(e) = s;
550 newRefiner._levels[0]->getVertexSharpness(v) = s;
555 newRefiner._levels[0]->setFaceHole(f, b);
556 newRefiner._hasHoles = newRefiner._hasHoles || b;
562 return newRefiner._levels[0]->createFVarChannel(numValues, newRefiner._subdivOptions);
569 return newRefiner._levels[0]->createFVarChannel(numValues, newOptions);
574 return newRefiner._levels[0]->getFaceFVarValues(face, channel);
583 "Failure in TopologyRefinerFactory<>::resizeComponentTopology() -- no specialization provided.");
624 "Failure in TopologyRefinerFactory<>::assignComponentTopology() -- no specialization provided.");
708 TopologyError ,
char const * , MESH
const& ) {
720using namespace OPENSUBDIV_VERSION;
void Error(ErrorType err, const char *format,...)
Sends an OSD error with a message (internal use only)
@ FAR_RUNTIME_ERROR
Issue a generic runtime error, but continue execution.
SchemeType
Enumerated type for all subdivision schemes supported by OpenSubdiv.
Factory for constructing TopologyRefiners from specific mesh classes.
static int getNumBaseFaces(TopologyRefiner const &newRefiner)
static bool assignComponentTopology(TopologyRefiner &newRefiner, MESH const &mesh)
Specify the relationships between vertices, faces, etc. ie the face-vertices, vertex-faces,...
static void reportInvalidTopology(TopologyError errCode, char const *msg, MESH const &mesh)
(Optional) Control run-time topology validation and error reporting
static LocalIndexArray getBaseVertexFaceLocalIndices(TopologyRefiner &newRefiner, Index v)
Assign the local indices of a vertex within each of its incident faces.
static int getNumBaseVertices(TopologyRefiner const &newRefiner)
static void setNumBaseEdgeFaces(TopologyRefiner &newRefiner, Index e, int count)
Specify the number of faces incident each edge.
static IndexArray getBaseFaceVertices(TopologyRefiner &newRefiner, Index f)
Assign the vertices incident each face.
static LocalIndexArray getBaseEdgeFaceLocalIndices(TopologyRefiner &newRefiner, Index e)
Assign the local indices of an edge within each of its incident faces.
static bool populateBaseLevel(TopologyRefiner &refiner, MESH const &mesh, Options options)
static void populateBaseLocalIndices(TopologyRefiner &newRefiner)
Determine all local indices by inspection (only for pure manifold meshes)
static bool assignComponentTags(TopologyRefiner &newRefiner, MESH const &mesh)
(Optional) Specify edge or vertex sharpness or face holes
static bool resizeComponentTopology(TopologyRefiner &newRefiner, MESH const &mesh)
Specify the number of vertices, faces, face-vertices, etc.
static void setNumBaseVertexEdges(TopologyRefiner &newRefiner, Index v, int count)
Specify the number of edges incident each vertex.
Vtr::internal::Level::TopologyError TopologyError
static IndexArray getBaseFaceFVarValues(TopologyRefiner &newRefiner, Index face, int channel=0)
Assign the face-varying values for the corners of each face.
static IndexArray getBaseEdgeFaces(TopologyRefiner &newRefiner, Index e)
Assign the faces incident each edge.
static void setNumBaseVertexFaces(TopologyRefiner &newRefiner, Index v, int count)
Specify the number of faces incident each vertex.
static bool assignFaceVaryingTopology(TopologyRefiner &newRefiner, MESH const &mesh)
(Optional) Specify face-varying data per face
static void setBaseVertexSharpness(TopologyRefiner &newRefiner, Index v, float sharpness)
Assign a sharpness value to a given vertex.
static LocalIndexArray getBaseVertexEdgeLocalIndices(TopologyRefiner &newRefiner, Index v)
Assign the local indices of a vertex within each of its incident edges.
static IndexArray getBaseEdgeVertices(TopologyRefiner &newRefiner, Index e)
Assign the vertices incident each edge.
static IndexArray getBaseVertexFaces(TopologyRefiner &newRefiner, Index v)
Assign the faces incident each vertex.
static void setBaseVertexNonManifold(TopologyRefiner &newRefiner, Index v, bool b)
Tag a vertex as non-manifold.
static void setNumBaseFaces(TopologyRefiner &newRefiner, int count)
Specify the number of faces to be accommodated.
static IndexArray getBaseFaceEdges(TopologyRefiner &newRefiner, Index f)
Assign the edges incident each face.
static void setNumBaseFaceVertices(TopologyRefiner &newRefiner, Index f, int count)
Specify the number of vertices incident each face.
static void setBaseEdgeSharpness(TopologyRefiner &newRefiner, Index e, float sharpness)
Assign a sharpness value to a given edge.
static void setBaseEdgeNonManifold(TopologyRefiner &newRefiner, Index e, bool b)
Tag an edge as non-manifold.
static void setNumBaseEdges(TopologyRefiner &newRefiner, int count)
Specify the number of edges to be accommodated.
static TopologyRefiner * Create(MESH const &mesh, Options options=Options())
Instantiates a TopologyRefiner from client-provided topological representation.
static Index findBaseEdge(TopologyRefiner const &newRefiner, Index v0, Index v1)
Identify an edge to be assigned a sharpness value given a vertex pair.
static IndexArray getBaseVertexEdges(TopologyRefiner &newRefiner, Index v)
Assign the edges incident each vertex.
static int createBaseFVarChannel(TopologyRefiner &newRefiner, int numValues)
Create a new face-varying channel with the given number of values.
static int getNumBaseEdges(TopologyRefiner const &newRefiner)
static void setNumBaseVertices(TopologyRefiner &newRefiner, int count)
Specify the number of vertices to be accommodated.
static void setBaseFaceHole(TopologyRefiner &newRefiner, Index f, bool isHole)
Tag a face as a hole.
Stores topology data for a specified set of refinement options.
Private base class of Factories for constructing TopologyRefiners.
static bool prepareComponentTopologyAssignment(TopologyRefiner &refiner, bool fullValidation, TopologyCallback callback, void const *callbackData)
Vtr::internal::Level::ValidationCallback TopologyCallback
static bool prepareComponentTagsAndSharpness(TopologyRefiner &refiner)
static bool prepareComponentTopologySizing(TopologyRefiner &refiner)
static bool prepareFaceVaryingChannels(TopologyRefiner &refiner)
Options related to the construction of each TopologyRefiner.
Options(Sdc::SchemeType sdcType=Sdc::SCHEME_CATMARK, Sdc::Options sdcOptions=Sdc::Options())
Sdc::Options schemeOptions
Sdc::SchemeType schemeType
The subdivision scheme type identifier.
unsigned int validateFullTopology
All supported options applying to subdivision scheme.
void SetFVarLinearInterpolation(FVarLinearInterpolation b)
Set face-varying interpolation rule.
FVarLinearInterpolation GetFVarLinearInterpolation() const
Get face-varying interpolation rule.