All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
PatchParam Struct Reference

Patch parameterization. More...

#include <patchParam.h>

Inheritance diagram for PatchParam:
PatchParam

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. More...
 
void Clear ()
 Resets everything to 0. More...
 
Index GetFaceId () const
 Returns the faceid. More...
 
unsigned short GetU () const
 Returns the log2 value of the u parameter at the first corner of the patch. More...
 
unsigned short GetV () const
 Returns the log2 value of the v parameter at the first corner of the patch. More...
 
unsigned short GetTransition () const
 Returns the transition edge encoding for the patch. More...
 
unsigned short GetBoundary () const
 Returns the boundary edge encoding for the patch. More...
 
bool NonQuadRoot () const
 True if the parent base face is a non-quad. More...
 
unsigned short GetDepth () const
 Returns the level of subdivision of the patch. More...
 
float GetParamFraction () const
 Returns the fraction of unit parametric space covered by this face. More...
 
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. More...
 
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. More...
 
template<typename REAL >
void UnnormalizeTriangle (REAL &u, REAL &v) const
 
bool IsTriangleRotated () const
 Returns if a triangular patch is parametrically rotated 180 degrees. More...
 
bool IsRegular () const
 Returns whether the patch is regular. More...
 

Public Attributes

unsigned int field0:32
 
unsigned int field1:32
 

Detailed Description

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 quad-tree organization of the faces produced by subdivision. We encode the U,V origin of the patch using two 10-bit integer values and the refinement level as a 4-bit 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 quad-tree 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 non-quad 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 bit-fields and endian-ness.

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.

Member Function Documentation

void Clear ( )
inline

Resets everything to 0.

Definition at line 174 of file patchParam.h.

unsigned short GetBoundary ( ) const
inline

Returns the boundary edge encoding for the patch.

Definition at line 191 of file patchParam.h.

unsigned short GetDepth ( ) const
inline

Returns the level of subdivision of the patch.

Definition at line 197 of file patchParam.h.

Index GetFaceId ( ) const
inline

Returns the faceid.

Definition at line 177 of file patchParam.h.

float GetParamFraction ( ) const
inline

Returns the fraction of unit parametric space covered by this face.

Definition at line 265 of file patchParam.h.

unsigned short GetTransition ( ) const
inline

Returns the transition edge encoding for the patch.

Definition at line 188 of file patchParam.h.

unsigned short GetU ( ) const
inline

Returns the log2 value of the u parameter at the first corner of the patch.

Definition at line 181 of file patchParam.h.

unsigned short GetV ( ) const
inline

Returns the log2 value of the v parameter at the first corner of the patch.

Definition at line 185 of file patchParam.h.

bool IsRegular ( ) const
inline

Returns whether the patch is regular.

Definition at line 228 of file patchParam.h.

bool IsTriangleRotated ( ) const
inline

Returns if a triangular patch is parametrically rotated 180 degrees.

Definition at line 290 of file patchParam.h.

bool NonQuadRoot ( ) const
inline

True if the parent base face is a non-quad.

Definition at line 194 of file patchParam.h.

void Normalize ( REAL &  u,
REAL &  v 
) const
inline

A (u,v) pair in the fraction of parametric space covered by this face is mapped into a normalized parametric space.

Parameters
uu parameter
vv parameter

Definition at line 271 of file patchParam.h.

void NormalizeTriangle ( REAL &  u,
REAL &  v 
) const
inline

Definition at line 297 of file patchParam.h.

void Set ( Index  faceid,
short  u,
short  v,
unsigned short  depth,
bool  nonquad,
unsigned short  boundary,
unsigned short  transition,
bool  regular = false 
)
inline

Sets the values of the bit fields.

Parameters
faceidface index
uvalue of the u parameter for the first corner of the face
vvalue of the v parameter for the first corner of the face
depthsubdivision level of the patch
nonquadtrue if the root face is not a quad
boundary5-bits identifying boundary edges (and verts for tris)
transition4-bits identifying transition edges
regularwhether the patch is regular

Definition at line 249 of file patchParam.h.

void Unnormalize ( REAL &  u,
REAL &  v 
) const
inline

A (u,v) pair in a normalized parametric space is mapped back into the fraction of parametric space covered by this face.

Parameters
uu parameter
vv parameter

Definition at line 281 of file patchParam.h.

void UnnormalizeTriangle ( REAL &  u,
REAL &  v 
) const
inline

Definition at line 312 of file patchParam.h.

Member Data Documentation

unsigned int field0

Definition at line 230 of file patchParam.h.

unsigned int field1

Definition at line 231 of file patchParam.h.


The documentation for this struct was generated from the following file: