24 #ifndef OPENSUBDIV3_VTR_LEVEL_H
25 #define OPENSUBDIV3_VTR_LEVEL_H
27 #include "../version.h"
29 #include "../sdc/types.h"
30 #include "../sdc/crease.h"
31 #include "../sdc/options.h"
32 #include "../vtr/types.h"
40 namespace OpenSubdiv {
41 namespace OPENSUBDIV_VERSION {
344 int fvarChannel = -1)
const;
347 int fvarChannel = -1)
const;
349 int fvarChannel = -1)
const;
351 int fvarChannel = -1)
const;
354 int fvarChannel = -1)
const;
356 int fvarChannel = -1)
const;
514 std::vector<Index> _faceVertCountsAndOffsets;
515 std::vector<Index> _faceVertIndices;
516 std::vector<Index> _faceEdgeIndices;
517 std::vector<FTag> _faceTags;
520 std::vector<Index> _edgeVertIndices;
521 std::vector<Index> _edgeFaceCountsAndOffsets;
522 std::vector<Index> _edgeFaceIndices;
523 std::vector<LocalIndex> _edgeFaceLocalIndices;
525 std::vector<float> _edgeSharpness;
526 std::vector<ETag> _edgeTags;
529 std::vector<Index> _vertFaceCountsAndOffsets;
530 std::vector<Index> _vertFaceIndices;
531 std::vector<LocalIndex> _vertFaceLocalIndices;
533 std::vector<Index> _vertEdgeCountsAndOffsets;
534 std::vector<Index> _vertEdgeIndices;
535 std::vector<LocalIndex> _vertEdgeLocalIndices;
537 std::vector<float> _vertSharpness;
538 std::vector<VTag> _vertTags;
541 std::vector<FVarLevel*> _fvarChannels;
549 return ConstIndexArray(&_faceVertIndices[_faceVertCountsAndOffsets[faceIndex*2+1]],
550 _faceVertCountsAndOffsets[faceIndex*2]);
554 return IndexArray(&_faceVertIndices[_faceVertCountsAndOffsets[faceIndex*2+1]],
555 _faceVertCountsAndOffsets[faceIndex*2]);
561 int* countOffsetPair = &_faceVertCountsAndOffsets[faceIndex*2];
563 countOffsetPair[0] = count;
564 countOffsetPair[1] = (faceIndex == 0) ? 0 : (countOffsetPair[-2] + countOffsetPair[-1]);
566 _maxValence = std::max(_maxValence, count);
571 return ConstIndexArray(&_faceVertIndices[0], (
int)_faceVertIndices.size());
579 return ConstIndexArray(&_faceEdgeIndices[_faceVertCountsAndOffsets[faceIndex*2+1]],
580 _faceVertCountsAndOffsets[faceIndex*2]);
584 return IndexArray(&_faceEdgeIndices[_faceVertCountsAndOffsets[faceIndex*2+1]],
585 _faceVertCountsAndOffsets[faceIndex*2]);
593 return ConstIndexArray( (&_vertFaceIndices[0]) + _vertFaceCountsAndOffsets[vertIndex*2+1],
594 _vertFaceCountsAndOffsets[vertIndex*2]);
598 return IndexArray( (&_vertFaceIndices[0]) + _vertFaceCountsAndOffsets[vertIndex*2+1],
599 _vertFaceCountsAndOffsets[vertIndex*2]);
604 return ConstLocalIndexArray( (&_vertFaceLocalIndices[0]) + _vertFaceCountsAndOffsets[vertIndex*2+1],
605 _vertFaceCountsAndOffsets[vertIndex*2]);
609 return LocalIndexArray( (&_vertFaceLocalIndices[0]) + _vertFaceCountsAndOffsets[vertIndex*2+1],
610 _vertFaceCountsAndOffsets[vertIndex*2]);
615 int* countOffsetPair = &_vertFaceCountsAndOffsets[vertIndex*2];
617 countOffsetPair[0] = count;
618 countOffsetPair[1] = (vertIndex == 0) ? 0 : (countOffsetPair[-2] + countOffsetPair[-1]);
622 _vertFaceCountsAndOffsets[vertIndex*2] = count;
630 return ConstIndexArray( (&_vertEdgeIndices[0]) +_vertEdgeCountsAndOffsets[vertIndex*2+1],
631 _vertEdgeCountsAndOffsets[vertIndex*2]);
635 return IndexArray( (&_vertEdgeIndices[0]) +_vertEdgeCountsAndOffsets[vertIndex*2+1],
636 _vertEdgeCountsAndOffsets[vertIndex*2]);
641 return ConstLocalIndexArray( (&_vertEdgeLocalIndices[0]) + _vertEdgeCountsAndOffsets[vertIndex*2+1],
642 _vertEdgeCountsAndOffsets[vertIndex*2]);
646 return LocalIndexArray( (&_vertEdgeLocalIndices[0]) + _vertEdgeCountsAndOffsets[vertIndex*2+1],
647 _vertEdgeCountsAndOffsets[vertIndex*2]);
652 int* countOffsetPair = &_vertEdgeCountsAndOffsets[vertIndex*2];
654 countOffsetPair[0] = count;
655 countOffsetPair[1] = (vertIndex == 0) ? 0 : (countOffsetPair[-2] + countOffsetPair[-1]);
657 _maxValence = std::max(_maxValence, count);
661 _vertEdgeCountsAndOffsets[vertIndex*2] = count;
666 _maxValence = valence;
678 return IndexArray(&_edgeVertIndices[edgeIndex*2], 2);
687 _edgeFaceCountsAndOffsets[edgeIndex*2+1],
688 _edgeFaceCountsAndOffsets[edgeIndex*2]);
693 _edgeFaceCountsAndOffsets[edgeIndex*2+1],
694 _edgeFaceCountsAndOffsets[edgeIndex*2]);
700 _edgeFaceCountsAndOffsets[edgeIndex*2+1],
701 _edgeFaceCountsAndOffsets[edgeIndex*2]);
706 _edgeFaceCountsAndOffsets[edgeIndex*2+1],
707 _edgeFaceCountsAndOffsets[edgeIndex*2]);
712 int* countOffsetPair = &_edgeFaceCountsAndOffsets[edgeIndex*2];
714 countOffsetPair[0] = count;
715 countOffsetPair[1] = (edgeIndex == 0) ? 0 : (countOffsetPair[-2] + countOffsetPair[-1]);
717 _maxEdgeFaces = std::max(_maxEdgeFaces, count);
721 _edgeFaceCountsAndOffsets[edgeIndex*2] = count;
729 return _edgeSharpness[edgeIndex];
733 return _edgeSharpness[edgeIndex];
738 return _vertSharpness[vertIndex];
742 return _vertSharpness[vertIndex];
755 _faceTags[faceIndex]._hole = b;
759 return _faceTags[faceIndex]._hole;
767 _edgeTags[edgeIndex]._nonManifold = b;
771 return _edgeTags[edgeIndex]._nonManifold;
776 _vertTags[vertIndex]._nonManifold = b;
780 return _vertTags[vertIndex]._nonManifold;
788 _faceCount = faceCount;
789 _faceVertCountsAndOffsets.resize(2 * faceCount);
791 _faceTags.resize(faceCount);
792 std::memset(&_faceTags[0], 0, _faceCount *
sizeof(
FTag));
796 _faceVertIndices.resize(totalFaceVertCount);
800 _faceEdgeIndices.resize(totalFaceEdgeCount);
806 _edgeCount = edgeCount;
807 _edgeFaceCountsAndOffsets.resize(2 * edgeCount);
809 _edgeSharpness.resize(edgeCount);
810 _edgeTags.resize(edgeCount);
813 std::memset(&_edgeTags[0], 0, _edgeCount *
sizeof(
ETag));
819 _edgeVertIndices.resize(2 * _edgeCount);
824 _edgeFaceIndices.resize(totalEdgeFaceCount);
825 _edgeFaceLocalIndices.resize(totalEdgeFaceCount);
831 _vertCount = vertCount;
832 _vertFaceCountsAndOffsets.resize(2 * vertCount);
833 _vertEdgeCountsAndOffsets.resize(2 * vertCount);
835 _vertSharpness.resize(vertCount);
836 _vertTags.resize(vertCount);
837 std::memset(&_vertTags[0], 0, _vertCount *
sizeof(
VTag));
842 _vertFaceIndices.resize(totalVertFaceCount);
843 _vertFaceLocalIndices.resize(totalVertFaceCount);
848 _vertEdgeIndices.resize(totalVertEdgeCount);
849 _vertEdgeLocalIndices.resize(totalVertEdgeCount);
856 return IndexArray(const_cast<Index *>(&_faceVertCountsAndOffsets[0]),
857 (
int)_faceVertCountsAndOffsets.size());
864 using namespace OPENSUBDIV_VERSION;
IndexArray shareFaceVertCountsAndOffsets() const
void resizeEdgeFaces(int numEdgeFacesTotal)
bool validateTopology(ValidationCallback callback=0, void const *clientData=0) const
ConstArray< LocalIndex > ConstLocalIndexArray
int getNumVertices() const
FTag const & getFaceTag(Index faceIndex) const
Array< LocalIndex > LocalIndexArray
int getNumEdgeVerticesTotal() const
void resizeVertexFaces(int numVertexFacesTotal)
Sdc::Crease::Rule getVertexRule(Index vertIndex) const
void orientIncidentComponents()
void resizeVertexEdges(int numVertexEdgesTotal)
ConstArray< Index > ConstIndexArray
int getNumVertexEdges(Index vertIndex) const
int gatherQuadRegularPartialRingAroundVertex(Index vIndex, VSpan const &span, Index ringPoints[], int fvarChannel=-1) const
void destroyFVarChannel(int channel)
void resizeVertices(int numVertices)
ConstIndexArray getFaceFVarValues(Index faceIndex, int channel) const
int getNumFVarValues(int channel) const
void resizeEdgeVertices()
int gatherTriRegularCornerVertexPatchPoints(Index fIndex, Index patchVerts[], int cornerVertInFace) const
int gatherTriRegularBoundaryVertexPatchPoints(Index fIndex, Index patchVerts[], int boundaryVertInFace) const
int getOffsetOfEdgeFaces(Index edgeIndex) const
FTag & getFaceTag(Index faceIndex)
int createFVarChannel(int fvarValueCount, Sdc::Options const &options)
int getNumVertexEdgesTotal() const
ConstLocalIndexArray getEdgeFaceLocalIndices(Index edgeIndex) const
ConstLocalIndexArray getVertexFaceLocalIndices(Index vertIndex) const
void populateLocalIndices()
int gatherTriRegularBoundaryEdgePatchPoints(Index fIndex, Index patchVerts[], int boundaryEdgeInFace) const
float getEdgeSharpness(Index edgeIndex) const
void setVertexNonManifold(Index vertIndex, bool b)
FVarLevel const & getFVarLevel(int channel) const
bool isFaceHole(Index faceIndex) const
bool doesEdgeFVarTopologyMatch(Index eIndex, int fvarChannel) const
bool isEdgeNonManifold(Index edgeIndex) const
FVarLevel & getFVarLevel(int channel)
int gatherQuadLinearPatchPoints(Index fIndex, Index patchPoints[], int rotation=0, int fvarChannel=-1) const
int getNumFVarChannels() const
int getNumEdgeFacesTotal() const
ConstIndexArray getVertexFaces(Index vertIndex) const
void(* ValidationCallback)(TopologyError errCode, char const *msg, void const *clientData)
int getNumFaceVerticesTotal() const
VTag getVertexCompositeFVarVTag(Index vIndex, int fvarChannel) const
ConstIndexArray getFaceVertices() const
void setFaceHole(Index faceIndex, bool b)
int getNumVertexFacesTotal() const
bool isSingleCreasePatch(Index face, float *sharpnessOut=NULL, int *rotationOut=NULL) const
ETag const & getEdgeTag(Index edgeIndex) const
void trimVertexFaces(Index vertIndex, int count)
int gatherTriRegularCornerEdgePatchPoints(Index fIndex, Index patchVerts[], int cornerEdgeInFace) const
ETag & getEdgeTag(Index edgeIndex)
Index findEdge(Index v0Index, Index v1Index) const
VTag const & getVertexTag(Index vertIndex) const
int gatherQuadRegularCornerPatchPoints(Index fIndex, Index patchPoints[], int cornerVertInFace, int fvarChannel=-1) const
int getOffsetOfVertexEdges(Index vertIndex) const
bool doesVertexFVarTopologyMatch(Index vIndex, int fvarChannel) const
void getFaceETags(Index fIndex, ETag eTags[], int fvarChannel=-1) const
void resizeEdges(int numEdges)
VTag getFaceCompositeVTag(Index fIndex, int fvarChannel=-1) const
int getNumVertexFaces(Index vertIndex) const
friend class TriRefinement
All supported options applying to subdivision scheme.
int getOffsetOfEdgeVertices(Index edgeIndex) const
Sdc::Options getFVarOptions(int channel) const
void print(const Refinement *parentRefinement=0) const
static ETag BitwiseOr(ETag const eTags[], int size=4)
int getNumFaceVertices(Index faceIndex) const
int getMaxEdgeFaces() const
ConstIndexArray getEdgeFaces(Index edgeIndex) const
int gatherQuadRegularRingAroundVertex(Index vIndex, Index ringPoints[], int fvarChannel=-1) const
int gatherQuadRegularInteriorPatchPoints(Index fIndex, Index patchPoints[], int rotation=0, int fvarChannel=-1) const
void trimEdgeFaces(Index edgeIndex, int count)
int getNumEdgeVertices(Index) const
ConstIndexArray getVertexEdges(Index vertIndex) const
ConstLocalIndexArray getVertexEdgeLocalIndices(Index vertIndex) const
int getOffsetOfVertexFaces(Index vertIndex) const
void setEdgeNonManifold(Index edgeIndex, bool b)
friend class QuadRefinement
Array< Index > IndexArray
unsigned short LocalIndex
int getOffsetOfFaceVertices(Index faceIndex) const
void getFaceVTags(Index fIndex, VTag vTags[], int fvarChannel=-1) const
float getVertexSharpness(Index vertIndex) const
VTag & getVertexTag(Index vertIndex)
int gatherQuadRegularBoundaryPatchPoints(Index fIndex, Index patchPoints[], int boundaryEdgeInFace, int fvarChannel=-1) const
ConstIndexArray getFaceEdges(Index faceIndex) const
bool completeTopologyFromFaceVertices()
bool orderVertexFacesAndEdges(Index vIndex, Index *vFaces, Index *vEdges) const
void resizeFaces(int numFaces)
int getNumFaceEdges(Index faceIndex) const
void resizeFaceEdges(int numFaceEdgesTotal)
static char const * getTopologyErrorString(TopologyError errCode)
int getNumEdgeFaces(Index edgeIndex) const
bool doesFaceFVarTopologyMatch(Index fIndex, int fvarChannel) const
void trimVertexEdges(Index vertIndex, int count)
bool isVertexNonManifold(Index vertIndex) const
void resizeFaceVertices(int numFaceVertsTotal)
void completeFVarChannelTopology(int channel, int regBoundaryValence)
int getMaxValence() const
void setMaxValence(int maxValence)
ConstIndexArray getEdgeVertices(Index edgeIndex) const
static VTag BitwiseOr(VTag const vTags[], int size=4)
int gatherTriRegularInteriorPatchPoints(Index fIndex, Index patchVerts[], int rotation=0) const
int getOffsetOfFaceEdges(Index faceIndex) const
int getNumFaceEdgesTotal() const