25 #ifndef OPENSUBDIV3_FAR_PATCH_MAP_H
26 #define OPENSUBDIV3_FAR_PATCH_MAP_H
28 #include "../version.h"
30 #include "../far/patchTable.h"
35 namespace OPENSUBDIV_VERSION {
73 Handle
const *
FindPatch(
int faceid,
float u,
float v )
const;
77 inline void initialize(
PatchTable const & patchTable );
88 void SetChild(
int patchIdx);
91 void SetChild(
unsigned char quadrant,
int child,
bool isLeaf=
true);
96 typedef std::vector<QuadNode> QuadTree;
99 static QuadNode * addChild( QuadTree & quadtree, QuadNode * parent,
int quadrant );
116 template <
class T>
static int resolveQuadrant(T & median, T & u, T & v);
118 std::vector<Handle> _handles;
119 std::vector<QuadNode> _quadtree;
124 template <
class T>
int
125 PatchMap::resolveQuadrant(T & median, T & u, T & v) {
151 if (faceid>=(
int)_quadtree.size())
154 assert( (u>=0.0f) and (u<=1.0f) and (v>=0.0f) and (v<=1.0f) );
156 QuadNode
const * node = &_quadtree[faceid];
161 for (
int depth=0; depth<0xFF; ++depth) {
163 float delta = half * 0.5f;
165 int quadrant = resolveQuadrant( half, u, v );
169 if (not node->children[quadrant].isSet)
172 if (node->children[quadrant].isLeaf) {
173 return &_handles[node->children[quadrant].idx];
175 node = &_quadtree[node->children[quadrant].idx];
188 using namespace OPENSUBDIV_VERSION;
PatchTable::PatchHandle Handle
PatchMap(PatchTable const &patchTable)
Constructor.
Handle const * FindPatch(int faceid, float u, float v) const
Returns a handle to the sub-patch of the face at the given (u,v). Note : the faceid corresponds to qu...
An quadtree-based map connecting coarse faces to their sub-patches.
Container for arrays of parametric patches.
Handle that can be used as unique patch identifier within PatchTable.