HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GT_UtilOpenSubdiv Class Reference

Class to perform subdivision refinement using OpenSubdivision. More...

#include <GT_UtilOpenSubdiv.h>

Public Types

using SdcOptions = GT_OSDOptions::SdcOptions
 
using VtxBoundaryInterpolation = SdcOptions::VtxBoundaryInterpolation
 
using FVarLinearInterpolation = SdcOptions::FVarLinearInterpolation
 
using AttribId = GT_OSDAttributes::AttribId
 

Public Member Functions

 GT_UtilOpenSubdiv ()
 
 ~GT_UtilOpenSubdiv ()
 
void dump () const
 
void dump (UT_JSONWriter &w) const
 
void clear ()
 Clear any topology, attributes or limit surface info. More...
 
const UT_StringArrayerrors () const
 
GT_PrimitiveHandle subdivide (const GT_PrimitiveHandle &mesh)
 
bool subdivide (GU_Detail &gdp, GA_Range *range=NULL)
 Refine Houdini geometry. More...
 
bool setupLimitEval (const GT_PrimitiveHandle &mesh)
 
GT_Size limitCoarseFaceCount () const
 
GT_Size limitPatchCount () const
 
GT_Size limitFirstPatch (GT_Size face_index) const
 
GT_Size limitPatchSize (GT_Size face_index) const
 
AttribId limitFindAttribute (const char *name) const
 Definition of an attribute id on the topolgy. More...
 
bool limitLookupPatch (GT_Size hou_face, fpreal hou_u, fpreal hou_v, GT_Size &osd_face, fpreal &osd_u, fpreal &osd_v, const AttribId &attrib) const
 
bool limitLookupFace (GT_Size osd_face, fpreal osd_u, fpreal osd_v, GT_Size &hou_prim, fpreal &hou_u, fpreal &hou_v, const AttribId &attrib) const
 
GT_DataArrayHandle limitSurface (const char *attrib, bool vertex_attrib, const GT_DataArrayHandle &faces, const GT_DataArrayHandle &uvs) const
 
GT_DataArrayHandle limitSurface (const char *attrib, bool vertex_attrib, const GT_DataArrayHandle &faces, const GT_DataArrayHandle &u, const GT_DataArrayHandle &v) const
 
GT_DataArrayHandle limitSurface (const char *attrib, bool vertex_attrib, exint npts, const int32 *face_indices, const fpreal32 *u, const fpreal32 *v, int uv_stride=1) const
 
bool createTopology (const GT_PrimitiveHandle &mesh)
 
bool refine (const GT_PrimitiveHandle &mesh, bool force_update=false)
 
GT_PrimitiveHandle extractSubdividedMesh (int level=-1)
 
const GT_OSDOptionsoptions () const
 
void setOptions (const GT_OSDOptions &options)
 
GT_Scheme scheme () const
 
void setScheme (GT_Scheme s)
 
int levels () const
 
void setLevels (int l)
 
bool adaptive () const
 
void setAdaptive (bool v)
 
bool removeHoles () const
 
void setRemoveHoles (bool v)
 
bool doCreaseOverride () const
 
fpreal creaseOverride () const
 
void setCreaseOverride (bool yes, fpreal w)
 
void setCreaseOverride (fpreal w)
 
bool polySoup () const
 
void setPolySoup (bool v)
 
VtxBoundaryInterpolation vtxBoundaryInterpolation () const
 
FVarLinearInterpolation fvarLinearInterpolation () const
 
void setVtxBoundaryInterpolation (VtxBoundaryInterpolation v)
 
void setFVarLinearInterpolation (FVarLinearInterpolation v)
 
void setCreasingMethod (SdcOptions::CreasingMethod v)
 
void setTriangleSubdivision (SdcOptions::TriangleSubdivision v)
 
GT_OSDPatchTableOptionslimitOptions ()
 
const GT_OSDPatchTableOptionslimitOptions () const
 
int limitSurface (GT_DataArrayHandle *result, GT_DataArrayHandle *result_du, GT_DataArrayHandle *result_dv, const AttribId &attrib, exint npts, const int32 *face_indices, const fpreal32 *u, const fpreal32 *v, int uv_stride=1) const
 
int limitSurface (GT_DataArrayHandle *result, GT_DataArrayHandle *result_du, GT_DataArrayHandle *result_dv, const char *attrib, bool vertex_attrib, exint npts, const int32 *face_indices, const fpreal32 *u, const fpreal32 *v, int uv_stride=1) const
 
void addError (const char *msg)
 
void clearErrors ()
 

Detailed Description

Class to perform subdivision refinement using OpenSubdivision.

Definition at line 103 of file GT_UtilOpenSubdiv.h.

Member Typedef Documentation

using GT_UtilOpenSubdiv::FVarLinearInterpolation = SdcOptions::FVarLinearInterpolation

Definition at line 111 of file GT_UtilOpenSubdiv.h.

using GT_UtilOpenSubdiv::VtxBoundaryInterpolation = SdcOptions::VtxBoundaryInterpolation

Definition at line 110 of file GT_UtilOpenSubdiv.h.

Constructor & Destructor Documentation

GT_UtilOpenSubdiv::GT_UtilOpenSubdiv ( )
GT_UtilOpenSubdiv::~GT_UtilOpenSubdiv ( )

Member Function Documentation

bool GT_UtilOpenSubdiv::adaptive ( ) const
inline

Option accessors

Definition at line 139 of file GT_UtilOpenSubdiv.h.

void GT_UtilOpenSubdiv::addError ( const char *  msg)
inline

Error handling (used internally)

Definition at line 368 of file GT_UtilOpenSubdiv.h.

void GT_UtilOpenSubdiv::clear ( )

Clear any topology, attributes or limit surface info.

void GT_UtilOpenSubdiv::clearErrors ( )
inline

Error handling (used internally)

Definition at line 369 of file GT_UtilOpenSubdiv.h.

fpreal GT_UtilOpenSubdiv::creaseOverride ( ) const
inline

Option accessors

Definition at line 154 of file GT_UtilOpenSubdiv.h.

bool GT_UtilOpenSubdiv::createTopology ( const GT_PrimitiveHandle mesh)

Create the OSD data structures to represent a particular subdivision mesh. The suppolied handle must refer to a GT_PrimSubdivisionMesh or the functions will fail. This function can be called once followed by ay number of calls to refine and/or extractSubdivisionMesh.

bool GT_UtilOpenSubdiv::doCreaseOverride ( ) const
inline

Option accessors

Definition at line 152 of file GT_UtilOpenSubdiv.h.

void GT_UtilOpenSubdiv::dump ( ) const
void GT_UtilOpenSubdiv::dump ( UT_JSONWriter w) const
const UT_StringArray& GT_UtilOpenSubdiv::errors ( ) const
inline

Definition at line 204 of file GT_UtilOpenSubdiv.h.

GT_PrimitiveHandle GT_UtilOpenSubdiv::extractSubdividedMesh ( int  level = -1)

Returns a GT_PrimPolygonMesh that is the result of subdividing the mesh passed to the refine function above.

FVarLinearInterpolation GT_UtilOpenSubdiv::fvarLinearInterpolation ( ) const
inline

Option accessors

Definition at line 169 of file GT_UtilOpenSubdiv.h.

int GT_UtilOpenSubdiv::levels ( ) const
inline

Option accessors

Definition at line 133 of file GT_UtilOpenSubdiv.h.

GT_Size GT_UtilOpenSubdiv::limitCoarseFaceCount ( ) const

Return the number of input faces. A cube would have 6 faces, a tetrahedron would have 4 faces.

AttribId GT_UtilOpenSubdiv::limitFindAttribute ( const char *  name) const

Definition of an attribute id on the topolgy.

GT_Size GT_UtilOpenSubdiv::limitFirstPatch ( GT_Size  face_index) const

Return the ptexture id for a given input face. For example, if the input mesh is a tetrahedron, limitFirstPatch(2) would return 6. This is also equivalent to the ptexture index of the first patch for a given face.

bool GT_UtilOpenSubdiv::limitLookupFace ( GT_Size  osd_face,
fpreal  osd_u,
fpreal  osd_v,
GT_Size hou_prim,
fpreal hou_u,
fpreal hou_v,
const AttribId attrib 
) const

Given a patch on the subdivision mesh and a uv interpolant on the patch, return the face on the coarse mesh and possibly the uv attributes. If the topology attribute id is invalid, then the u/v returned will be the uv interpolants on the patch, with the patch offset added to the uv.

bool GT_UtilOpenSubdiv::limitLookupPatch ( GT_Size  hou_face,
fpreal  hou_u,
fpreal  hou_v,
GT_Size osd_face,
fpreal osd_u,
fpreal osd_v,
const AttribId attrib 
) const

Given a face on the coarse mesh and a u,v coordinate from an attribute, look up the corresponding patch and interpolant. If the attribute is invalid, then the uv's will be assumed to be the patch interpolants, with the patch offset added to the u coordinate.

GT_OSDPatchTableOptions& GT_UtilOpenSubdiv::limitOptions ( )
inline

Accessors for the limit surface evaluation options

Definition at line 195 of file GT_UtilOpenSubdiv.h.

const GT_OSDPatchTableOptions& GT_UtilOpenSubdiv::limitOptions ( ) const
inline

Accessors for the limit surface evaluation options

Definition at line 197 of file GT_UtilOpenSubdiv.h.

GT_Size GT_UtilOpenSubdiv::limitPatchCount ( ) const

Return the number of individual patches (ptex face ids). So, a cube would have 6 patches, while a tetrahedron would have 12 patches (each triangle generates 3 patches).

GT_Size GT_UtilOpenSubdiv::limitPatchSize ( GT_Size  face_index) const

Return the number of subdivision patches for a given input face. For example, if the input mesh is a tetrahedron, limitPTextureId(2) would return 3.

GT_DataArrayHandle GT_UtilOpenSubdiv::limitSurface ( const char *  attrib,
bool  vertex_attrib,
const GT_DataArrayHandle faces,
const GT_DataArrayHandle uvs 
) const

Evaluate the limit surface for a given point/vertex attribute at the coordinates specified.

GT_DataArrayHandle GT_UtilOpenSubdiv::limitSurface ( const char *  attrib,
bool  vertex_attrib,
const GT_DataArrayHandle faces,
const GT_DataArrayHandle u,
const GT_DataArrayHandle v 
) const
GT_DataArrayHandle GT_UtilOpenSubdiv::limitSurface ( const char *  attrib,
bool  vertex_attrib,
exint  npts,
const int32 face_indices,
const fpreal32 u,
const fpreal32 v,
int  uv_stride = 1 
) const

Evaluate the limit surface for a given point/vertex attribute at the coordinates specified. The face_indices array should have npts entries. The uvs array should have uv_stride*npts entries. Only the first 2 coordinates will be used (and represent the s/t coordinates of the face).

int GT_UtilOpenSubdiv::limitSurface ( GT_DataArrayHandle result,
GT_DataArrayHandle result_du,
GT_DataArrayHandle result_dv,
const AttribId attrib,
exint  npts,
const int32 face_indices,
const fpreal32 u,
const fpreal32 v,
int  uv_stride = 1 
) const

Evaluate the limit surface for a given point/vertex attribute at the coordinates specified. The face_indices array should have npts entries. The uvs array should have uv_stride*npts entries. Only the first 2 coordinates will be used (and represent the s/t coordinates of the face). The data handles determine which properties are returned: result - Attribute result_du - Derivative of attribute in 'u' result_dv - Derivative of attribute in 'v' Passing 'NULL' for a handle disables evaluation of that property. The size of the evaluated attribute is returned.

int GT_UtilOpenSubdiv::limitSurface ( GT_DataArrayHandle result,
GT_DataArrayHandle result_du,
GT_DataArrayHandle result_dv,
const char *  attrib,
bool  vertex_attrib,
exint  npts,
const int32 face_indices,
const fpreal32 u,
const fpreal32 v,
int  uv_stride = 1 
) const

Evaluate the limit surface for a given point/vertex attribute at the coordinates specified. The face_indices array should have npts entries. The uvs array should have uv_stride*npts entries. Only the first 2 coordinates will be used (and represent the s/t coordinates of the face). The data handles determine which properties are returned: result - Attribute result_du - Derivative of attribute in 'u' result_dv - Derivative of attribute in 'v' Passing 'NULL' for a handle disables evaluation of that property. The size of the evaluated attribute is returned.

const GT_OSDOptions& GT_UtilOpenSubdiv::options ( ) const
inline

Option accessors

Definition at line 119 of file GT_UtilOpenSubdiv.h.

bool GT_UtilOpenSubdiv::polySoup ( ) const
inline

Option accessors

Definition at line 164 of file GT_UtilOpenSubdiv.h.

bool GT_UtilOpenSubdiv::refine ( const GT_PrimitiveHandle mesh,
bool  force_update = false 
)

Copies attribute data from the supplied mesh into the OSD data structure, and performs the refinement. The topology of the supplied mesh must match that of the mesh passed to the createTopology function, which must be called before this one.

bool GT_UtilOpenSubdiv::removeHoles ( ) const
inline

Option accessors

Definition at line 145 of file GT_UtilOpenSubdiv.h.

GT_Scheme GT_UtilOpenSubdiv::scheme ( ) const
inline

Option accessors

Definition at line 126 of file GT_UtilOpenSubdiv.h.

void GT_UtilOpenSubdiv::setAdaptive ( bool  v)
inline

Option accessors

Definition at line 140 of file GT_UtilOpenSubdiv.h.

void GT_UtilOpenSubdiv::setCreaseOverride ( bool  yes,
fpreal  w 
)
inline

Option accessors

Definition at line 156 of file GT_UtilOpenSubdiv.h.

void GT_UtilOpenSubdiv::setCreaseOverride ( fpreal  w)
inline

Option accessors

Definition at line 158 of file GT_UtilOpenSubdiv.h.

void GT_UtilOpenSubdiv::setCreasingMethod ( SdcOptions::CreasingMethod  v)
inline

Option accessors

Definition at line 181 of file GT_UtilOpenSubdiv.h.

void GT_UtilOpenSubdiv::setFVarLinearInterpolation ( FVarLinearInterpolation  v)
inline

Option accessors

Definition at line 176 of file GT_UtilOpenSubdiv.h.

void GT_UtilOpenSubdiv::setLevels ( int  l)
inline

Option accessors

Definition at line 134 of file GT_UtilOpenSubdiv.h.

void GT_UtilOpenSubdiv::setOptions ( const GT_OSDOptions options)
inline

Option accessors

Definition at line 120 of file GT_UtilOpenSubdiv.h.

void GT_UtilOpenSubdiv::setPolySoup ( bool  v)
inline

Option accessors

Definition at line 165 of file GT_UtilOpenSubdiv.h.

void GT_UtilOpenSubdiv::setRemoveHoles ( bool  v)
inline

Option accessors

Definition at line 146 of file GT_UtilOpenSubdiv.h.

void GT_UtilOpenSubdiv::setScheme ( GT_Scheme  s)
inline

Option accessors

Definition at line 127 of file GT_UtilOpenSubdiv.h.

void GT_UtilOpenSubdiv::setTriangleSubdivision ( SdcOptions::TriangleSubdivision  v)
inline

Option accessors

Definition at line 186 of file GT_UtilOpenSubdiv.h.

bool GT_UtilOpenSubdiv::setupLimitEval ( const GT_PrimitiveHandle mesh)

Set up mesh for limit surface evaluation. If successful, a subdivision surface will be set up for evaluation. You can then do something like

for (int i = 0; i < osd.limitCoarseFaceCount(); ++i)
{
int first = osd.limitFirstPatch(i);
int size = osd.limitPatchSize(i);
UT_ASSERT(first + size <= limit.patchCount());
for (int j = 0; j < size; ++j)
{
int patch_index = first + j;
float coord = .5;
// It's considerably more efficient to evaluate these in batch
osd.limitSurface("P", false, 1, &patch_index, &coord, &coord);
}
}
void GT_UtilOpenSubdiv::setVtxBoundaryInterpolation ( VtxBoundaryInterpolation  v)
inline

Option accessors

Definition at line 171 of file GT_UtilOpenSubdiv.h.

GT_PrimitiveHandle GT_UtilOpenSubdiv::subdivide ( const GT_PrimitiveHandle mesh)

Refine the mesh to the given number of levels using a given subdivision scheme. If the primitive is a subdivision mesh, the crease tags will be used in refinement. If the supplied prim is not a subdivision mesh, any required refinements will be performed automatically.

If the method fails, a null pointer will be returned.

bool GT_UtilOpenSubdiv::subdivide ( GU_Detail gdp,
GA_Range range = NULL 
)

Refine Houdini geometry.

VtxBoundaryInterpolation GT_UtilOpenSubdiv::vtxBoundaryInterpolation ( ) const
inline

Option accessors

Definition at line 167 of file GT_UtilOpenSubdiv.h.


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