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