7#ifndef OPENSUBDIV3_VTR_COMPONENT_INTERFACES_H
8#define OPENSUBDIV3_VTR_COMPONENT_INTERFACES_H
10#include "../version.h"
21namespace OPENSUBDIV_VERSION {
42 FaceInterface(
int vertCount) : _vertCount(vertCount) { }
46 int GetNumVertices()
const {
return _vertCount; }
59 EdgeInterface(Level
const& level) : _level(&level) { }
62 void SetIndex(
int edgeIndex) { _eIndex = edgeIndex; }
65 int GetNumFaces()
const {
return _level->getEdgeFaces(_eIndex).size(); }
66 float GetSharpness()
const {
return _level->getEdgeSharpness(_eIndex); }
68 void GetChildSharpnesses(Sdc::Crease
const&,
float s[2])
const {
70 s[0] = s[1] = GetSharpness() - 1.0f;
73 void GetNumVerticesPerFace(
int vertsPerFace[])
const {
75 for (
int i = 0; i < eFaces.size(); ++i) {
76 vertsPerFace[i] = _level->getFaceVertices(eFaces[i]).size();
90class VertexInterface {
93 VertexInterface(Level
const& parent, Level
const& child) : _parent(&parent), _child(&child) { }
94 ~VertexInterface() { }
96 void SetIndex(
int parentIndex,
int childIndex) {
97 _pIndex = parentIndex;
99 _eCount = _parent->getVertexEdges(_pIndex).size();
100 _fCount = _parent->getVertexFaces(_pIndex).size();
104 int GetNumEdges()
const {
return _eCount; }
105 int GetNumFaces()
const {
return _fCount; }
107 float GetSharpness()
const {
return _parent->getVertexSharpness(_pIndex); }
108 float* GetSharpnessPerEdge(
float pSharpness[])
const {
110 for (
int i = 0; i < _eCount; ++i) {
111 pSharpness[i] = _parent->getEdgeSharpness(pEdges[i]);
116 float GetChildSharpness(Sdc::Crease
const&)
const {
return _child->getVertexSharpness(_cIndex); }
117 float* GetChildSharpnessPerEdge(Sdc::Crease
const& crease,
float cSharpness[])
const {
118 internal::StackBuffer<float,16> pSharpness(_eCount);
119 GetSharpnessPerEdge(pSharpness);
120 crease.SubdivideEdgeSharpnessesAroundVertex(_eCount, pSharpness, cSharpness);
125 const Level* _parent;
138using namespace OPENSUBDIV_VERSION;
ConstArray< Index > ConstIndexArray