OpenSubdiv

Patch parameterization. More...
#include <patchParam.h>
Public Member Functions  
void  Set (Index faceid, short u, short v, unsigned short depth, bool nonquad, unsigned short boundary, unsigned short transition, bool regular=false) 
Sets the values of the bit fields.  
void  Clear () 
Resets everything to 0.  
Index  GetFaceId () const 
Returns the faceid.  
unsigned short  GetU () const 
Returns the log2 value of the u parameter at the first corner of the patch.  
unsigned short  GetV () const 
Returns the log2 value of the v parameter at the first corner of the patch.  
unsigned short  GetTransition () const 
Returns the transition edge encoding for the patch.  
unsigned short  GetBoundary () const 
Returns the boundary edge encoding for the patch.  
bool  NonQuadRoot () const 
True if the parent base face is a nonquad.  
unsigned short  GetDepth () const 
Returns the level of subdivision of the patch.  
float  GetParamFraction () const 
Returns the fraction of unit parametric space covered by this face.  
template<typename REAL >  
void  Normalize (REAL &u, REAL &v) const 
A (u,v) pair in the fraction of parametric space covered by this face is mapped into a normalized parametric space.  
template<typename REAL >  
void  NormalizeTriangle (REAL &u, REAL &v) const 
template<typename REAL >  
void  Unnormalize (REAL &u, REAL &v) const 
A (u,v) pair in a normalized parametric space is mapped back into the fraction of parametric space covered by this face.  
template<typename REAL >  
void  UnnormalizeTriangle (REAL &u, REAL &v) const 
bool  IsTriangleRotated () const 
Returns if a triangular patch is parametrically rotated 180 degrees.  
bool  IsRegular () const 
Returns whether the patch is regular.  
Public Attributes  
unsigned int  field0:32 
unsigned int  field1:32 
Patch parameterization.
Topological refinement splits coarse mesh faces into refined faces.
This patch parameterzation describes the relationship between one of these refined faces and its corresponding coarse face. It is used both for refined faces that are represented as full limit surface parametric patches as well as for refined faces represented as simple triangles or quads. This parameterization is needed to interpolate primvar data across a refined face.
The U,V and refinement level parameters describe the scale and offset needed to map a location on the patch between levels of refinement. The encoding of these values exploits the quadtree organization of the faces produced by subdivision. We encode the U,V origin of the patch using two 10bit integer values and the refinement level as a 4bit integer. This is sufficient to represent up through 10 levels of refinement.
Special consideration must be given to the refined faces resulting from irregular coarse faces. We adopt a convention similar to Ptex texture mapping and define the parameterization for these faces in terms of the regular faces resulting from the first topological splitting of the irregular coarse face.
When computing the basis functions needed to evaluate the limit surface parametric patch representing a refined face, we also need to know which edges of the patch are interpolated boundaries. These edges are encoded as a boundary bitmask identifying the boundary edges of the patch in sequential order starting from the first vertex of the refined face.
A sparse topological refinement (like feature adaptive refinement) can produce refined faces that are adjacent to faces at the next level of subdivision. We identify these transitional edges with a transition bitmask using the same encoding as the boundary bitmask.
For triangular subdivision schemes we specify the parameterization using a similar method. Alternate triangles at a given level of refinement are parameterized from their opposite corners and encoded as occupying the opposite diagonal of the quadtree hierarchy. The third barycentric coordinate is dependent on and can be derived from the other two coordinates. This encoding also takes inspiration from the Ptex texture mapping specification.
Bitfield layout :
Field0  Bits  Content 

faceId  28  the faceId of the patch 
transition  4  transition edge mask encoding 
Field1  Bits  Content 

level  4  the subdivision level of the patch 
nonquad  1  whether patch is refined from a nonquad face 
regular  1  whether patch is regular 
unused  1  unused 
boundary  5  boundary edge mask encoding 
v  10  log2 value of u parameter at first patch corner 
u  10  log2 value of v parameter at first patch corner 
Note : the bitfield is not expanded in the struct due to differences in how GPU & CPU compilers pack bitfields and endianness.
Quad Patch Parameterization (0,1) (1,1) ++++      L2  L2   0,3 1,3   +++ L1       L2  L2   0,2 1,2 1,1  ++++           L1  L1        0,0 1,0  +++ (0,0) (1,0)
Triangle Patch Parameterization (0,1) (1,1) (0,1,0) ++++ +  \  \  \   \ L2 \ L2 \  \   \ 0,3 \ 1,3 \  \   L2 \ +++ \  ++  \  \  L1 \   \ L2  \ L2 \ L2 \  \   \  \ 0,2 \ 1,2 \ 1,1 \   L2 \  L2 \ ++++ +++  \  \   \  \  \  \   \  \  \  \   \ L1  \  \  \   \  \  L1 \  L1 \   L1 \  L1 \  \  \   \  \ 0,0 \ 1,0 \   \  \ +++ +++ (0,0) (1,0) (0,0,1) (1,0,0)
Definition at line 152 of file patchParam.h.

inline 
Resets everything to 0.
Definition at line 174 of file patchParam.h.

inline 
Returns the boundary edge encoding for the patch.
Definition at line 191 of file patchParam.h.

inline 
Returns the level of subdivision of the patch.
Definition at line 197 of file patchParam.h.

inline 
Returns the faceid.
Definition at line 177 of file patchParam.h.

inline 
Returns the fraction of unit parametric space covered by this face.
Definition at line 265 of file patchParam.h.

inline 
Returns the transition edge encoding for the patch.
Definition at line 188 of file patchParam.h.

inline 
Returns the log2 value of the u parameter at the first corner of the patch.
Definition at line 181 of file patchParam.h.

inline 
Returns the log2 value of the v parameter at the first corner of the patch.
Definition at line 185 of file patchParam.h.

inline 
Returns whether the patch is regular.
Definition at line 228 of file patchParam.h.

inline 
Returns if a triangular patch is parametrically rotated 180 degrees.
Definition at line 290 of file patchParam.h.

inline 
True if the parent base face is a nonquad.
Definition at line 194 of file patchParam.h.

inline 
A (u,v) pair in the fraction of parametric space covered by this face is mapped into a normalized parametric space.
u  u parameter 
v  v parameter 
Definition at line 271 of file patchParam.h.

inline 
Definition at line 297 of file patchParam.h.

inline 
Sets the values of the bit fields.
faceid  face index 
u  value of the u parameter for the first corner of the face 
v  value of the v parameter for the first corner of the face 
depth  subdivision level of the patch 
nonquad  true if the root face is not a quad 
boundary  5bits identifying boundary edges (and verts for tris) 
transition  4bits identifying transition edges 
regular  whether the patch is regular 
Definition at line 249 of file patchParam.h.

inline 
A (u,v) pair in a normalized parametric space is mapped back into the fraction of parametric space covered by this face.
u  u parameter 
v  v parameter 
Definition at line 281 of file patchParam.h.

inline 
Definition at line 312 of file patchParam.h.
unsigned int field0 
Definition at line 230 of file patchParam.h.
unsigned int field1 
Definition at line 231 of file patchParam.h.