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);
316 template <
class MESH>
322 if (not populateBaseLevel(*refiner, mesh, options)) {
334 template <
class MESH>
352 if (not resizeComponentTopology(refiner, mesh))
return false;
353 if (not prepareComponentTopologySizing(refiner))
return false;
362 void const * userData = &mesh;
364 if (not assignComponentTopology(refiner, mesh))
return false;
365 if (not prepareComponentTopologyAssignment(refiner, validate, callback, userData))
return false;
371 if (not assignComponentTags(refiner, mesh))
return false;
372 if (not prepareComponentTagsAndSharpness(refiner))
return false;
377 if (not assignFaceVaryingTopology(refiner, mesh))
return false;
378 if (not prepareFaceVaryingChannels(refiner))
return false;
383 template <
class MESH>
386 newRefiner._levels[0]->resizeFaces(count);
388 template <
class MESH>
391 newRefiner._levels[0]->resizeEdges(count);
393 template <
class MESH>
396 newRefiner._levels[0]->resizeVertices(count);
399 template <
class MESH>
402 return newRefiner._levels[0]->getNumFaces();
404 template <
class MESH>
407 return newRefiner._levels[0]->getNumEdges();
409 template <
class MESH>
412 return newRefiner._levels[0]->getNumVertices();
415 template <
class MESH>
418 newRefiner._levels[0]->resizeFaceVertices(f, count);
420 template <
class MESH>
423 newRefiner._levels[0]->resizeEdgeFaces(e, count);
425 template <
class MESH>
428 newRefiner._levels[0]->resizeVertexFaces(v, count);
430 template <
class MESH>
433 newRefiner._levels[0]->resizeVertexEdges(v, count);
436 template <
class MESH>
439 return newRefiner._levels[0]->getFaceVertices(f);
441 template <
class MESH>
444 return newRefiner._levels[0]->getFaceEdges(f);
446 template <
class MESH>
449 return newRefiner._levels[0]->getEdgeVertices(e);
451 template <
class MESH>
454 return newRefiner._levels[0]->getEdgeFaces(e);
456 template <
class MESH>
459 return newRefiner._levels[0]->getVertexFaces(v);
461 template <
class MESH>
464 return newRefiner._levels[0]->getVertexEdges(v);
467 template <
class MESH>
470 return newRefiner._levels[0]->getEdgeFaceLocalIndices(e);
472 template <
class MESH>
475 return newRefiner._levels[0]->getVertexFaceLocalIndices(v);
477 template <
class MESH>
480 return newRefiner._levels[0]->getVertexEdgeLocalIndices(v);
483 template <
class MESH>
486 return newRefiner._levels[0]->findEdge(v0, v1);
489 template <
class MESH>
492 newRefiner._levels[0]->populateLocalIndices();
495 template <
class MESH>
498 newRefiner._levels[0]->setEdgeNonManifold(e, b);
500 template <
class MESH>
503 newRefiner._levels[0]->setVertexNonManifold(v, b);
506 template <
class MESH>
509 newRefiner._levels[0]->getEdgeSharpness(e) = s;
511 template <
class MESH>
514 newRefiner._levels[0]->getVertexSharpness(v) = s;
516 template <
class MESH>
519 newRefiner._levels[0]->setFaceHole(f, b);
520 newRefiner._hasHoles |= b;
523 template <
class MESH>
526 return newRefiner._levels[0]->createFVarChannel(numValues, newRefiner._subdivOptions);
528 template <
class MESH>
533 return newRefiner._levels[0]->createFVarChannel(numValues, newOptions);
535 template <
class MESH>
538 return newRefiner._levels[0]->getFaceFVarValues(face, channel);
546 template <
class MESH>
550 Error(
FAR_RUNTIME_ERROR,
"Missing specialization for TopologyRefinerFactory<MESH>::resizeComponentTopology()");
586 template <
class MESH>
590 Error(
FAR_RUNTIME_ERROR,
"Missing specialization for TopologyRefinerFactory<MESH>::assignComponentTopology()");
638 template <
class MESH>
654 template <
class MESH>
671 template <
class MESH>
688 using namespace OPENSUBDIV_VERSION;
static IndexArray getBaseEdgeVertices(TopologyRefiner &newRefiner, Index e)
Assign the vertices incident each edge.
static bool prepareComponentTagsAndSharpness(TopologyRefiner &refiner)
SchemeType
Enumerated type for all subdivisions schemes supported by OpenSubdiv.
void(* ValidationCallback)(TopologyError errCode, char const *msg, void const *clientData)
static bool populateBaseLevel(TopologyRefiner &refiner, MESH const &mesh, Options options)
Vtr::internal::Level::ValidationCallback TopologyCallback
static void setNumBaseEdgeFaces(TopologyRefiner &newRefiner, Index e, int count)
Specify the number of faces incident each edge.
Private base class of Factories for constructing TopologyRefiners.
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 accomodated.
void Error(ErrorType err)
Sends an OSD error.
static void setBaseEdgeNonManifold(TopologyRefiner &newRefiner, Index e, bool b)
Tag an edge as non-manifold.
static int getNumBaseFaces(TopologyRefiner const &newRefiner)
static IndexArray getBaseVertexFaces(TopologyRefiner &newRefiner, Index v)
Assign the faces incident each vertex.
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.
Issue a generic runtime error, but continue execution.
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 bool prepareComponentTopologySizing(TopologyRefiner &refiner)
static void setBaseEdgeSharpness(TopologyRefiner &newRefiner, Index e, float sharpness)
Assign a sharpness value to a given edge.
Factory for constructing TopologyRefiners from specific mesh classes.
static void setBaseFaceHole(TopologyRefiner &newRefiner, Index f, bool isHole)
Tag a face as a hole.
Sdc::Options schemeOptions
static LocalIndexArray getBaseEdgeFaceLocalIndices(TopologyRefiner &newRefiner, Index e)
Assign the local indices of an edge within each of its incident faces.
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 IndexArray getBaseFaceEdges(TopologyRefiner &newRefiner, Index f)
Assign the edges incident each face.
static IndexArray getBaseVertexEdges(TopologyRefiner &newRefiner, Index v)
Assign the edges incident each vertex.
static void setNumBaseFaces(TopologyRefiner &newRefiner, int count)
Specify the number of faces to be accomodated.
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 int getNumBaseVertices(TopologyRefiner const &newRefiner)
static void setBaseVertexNonManifold(TopologyRefiner &newRefiner, Index v, bool b)
Tag a vertex as non-manifold.
void SetFVarLinearInterpolation(FVarLinearInterpolation b)
Set face-varying interpolation rule.
Vtr::internal::Level::TopologyError TopologyError
static void populateBaseLocalIndices(TopologyRefiner &newRefiner)
Determine all local indices by inspection (only for pure manifold meshes)
static bool prepareComponentTopologyAssignment(TopologyRefiner &refiner, bool fullValidation, TopologyCallback callback, void const *callbackData)
static bool resizeComponentTopology(TopologyRefiner &newRefiner, MESH const &mesh)
Specify the number of vertices, faces, face-vertices, etc.
static int getNumBaseEdges(TopologyRefiner const &newRefiner)
static bool prepareFaceVaryingChannels(TopologyRefiner &refiner)
static void setNumBaseVertexEdges(TopologyRefiner &newRefiner, Index v, int count)
Specify the number of edges incident each vertex.
static TopologyRefiner * Create(MESH const &mesh, Options options=Options())
Instantiates a TopologyRefiner from client-provided topological representation.
Stores topology data for a specified set of refinement options.
static void setBaseVertexSharpness(TopologyRefiner &newRefiner, Index v, float sharpness)
Assign a sharpness value to a given vertex.
static int createBaseFVarChannel(TopologyRefiner &newRefiner, int numValues)
Create a new face-varying channel with the given number of values.
Options related to the construction of each TopologyRefiner.
Options(Sdc::SchemeType sdcType=Sdc::SCHEME_CATMARK, Sdc::Options sdcOptions=Sdc::Options())
Sdc::SchemeType schemeType
The subdivision scheme type identifier.
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 getBaseFaceVertices(TopologyRefiner &newRefiner, Index f)
Assign the vertices incident each face.
static LocalIndexArray getBaseVertexEdgeLocalIndices(TopologyRefiner &newRefiner, Index v)
Assign the local indices of a vertex within each of its incident edges.
unsigned int validateFullTopology
static void setNumBaseEdges(TopologyRefiner &newRefiner, int count)
Specify the number of edges to be accomodated.
static bool assignFaceVaryingTopology(TopologyRefiner &newRefiner, MESH const &mesh)
(Optional) Specify face-varying data per face
static IndexArray getBaseFaceFVarValues(TopologyRefiner &newRefiner, Index face, int channel=0)
Assign the face-varying values for the corners of each face.