Loading...
Searching...
No Matches
HdMeshUtil Class Reference

A collection of utility algorithms for generating triangulation and quadrangulation of an input topology. More...

#include <meshUtil.h>

Public Member Functions

 HdMeshUtil (HdMeshTopology const *topology, SdfPath const &id)
 
HD_API void EnumerateEdges (std::vector< GfVec2i > *edgeVerticesOut) const
 Return a buffer filled with face vertex index pairs corresponding to the sequence in which edges are visited when iterating through the mesh topology.
 
Triangulation

Produces a mesh where each non-triangle face in the base mesh topology is fan-triangulated such that the resulting mesh consists entirely of triangles.

In order to access per-face signals (face color, face selection etc) we need a mapping from primitiveID to authored face index domain. This is encoded in primitiveParams, and computed along with indices. See PrimitiveParamEncoding.

HD_API void ComputeTriangleIndices (VtVec3iArray *indices, VtIntArray *primitiveParams, VtIntArray *edgeIndices=nullptr) const
 Return a triangulation of the input topology.
 
HD_API bool ComputeTriangulatedFaceVaryingPrimvar (void const *source, int numElements, HdType dataType, VtValue *triangulated) const
 Return a triangulation of a face-varying primvar.
 
Quadrangulation

Produces a mesh where each non-quad face in the base mesh topology is quadrangulated such that the resulting mesh consists entirely of quads.

Additionally, supports splitting each resulting quad face into a pair of triangles. This is different than simply triangulating the base mesh topology and can be useful for maintaining consistency with quad-based subdivision schemes.

In order to access per-face signals (face color, face selection etc) we need a mapping from primitiveID to authored face index domain. This is encoded in primitiveParams, and computed along with indices. See PrimitiveParamEncoding.

HD_API void ComputeQuadInfo (HdQuadInfo *quadInfo) const
 Generate a quadInfo struct for the input topology.
 
HD_API void ComputeQuadIndices (VtIntArray *indices, VtIntArray *primitiveParams, VtVec2iArray *edgeIndices=nullptr) const
 Return quadrangulated indices of the input topology.
 
HD_API void ComputeTriQuadIndices (VtIntArray *indices, VtIntArray *primitiveParams, VtVec2iArray *edgeIndices=nullptr) const
 Return triquad indices (triangulated after quadrangulation) of the input topology.
 
HD_API bool ComputeQuadrangulatedPrimvar (HdQuadInfo const *qi, void const *source, int numElements, HdType dataType, VtValue *quadrangulated) const
 Return a quadrangulation of a per-vertex primvar.
 
HD_API bool ComputeQuadrangulatedFaceVaryingPrimvar (void const *source, int numElements, HdType dataType, VtValue *quadrangulated) const
 Return a quadrangulation of a face-varying primvar.
 

Primitive Param bit encoding

This encoding provides information about each sub-face resulting from the triangulation or quadrangulation of a base topology face.

The encoded faceIndex is the index of the base topology face corresponding to a triangulated or quadrangulated sub-face.

The encoded edge flag identifies where a sub-face occurs in the sequence of sub-faces produced for each base topology face. This edge flag can be used to determine which edges of a sub-face correspond to edges of a base topology face and which are internal edges that were introduced by triangulation or quadrangulation:

  • 0 unaffected triangle or quad base topology face
  • 1 first sub-face produced by triangulation or quadrangulation
  • 2 last sub-face produced by triangulation or quadrangulation
  • 3 intermediate sub-face produced by triangulation or quadrangulation
static int EncodeCoarseFaceParam (int faceIndex, int edgeFlag)
 
static int DecodeFaceIndexFromCoarseFaceParam (int coarseFaceParam)
 
static int DecodeEdgeFlagFromCoarseFaceParam (int coarseFaceParam)
 

Detailed Description

A collection of utility algorithms for generating triangulation and quadrangulation of an input topology.

Definition at line 82 of file meshUtil.h.

Constructor & Destructor Documentation

◆ HdMeshUtil()

HdMeshUtil ( HdMeshTopology const *  topology,
SdfPath const &  id 
)
inline

Definition at line 85 of file meshUtil.h.

◆ ~HdMeshUtil()

virtual ~HdMeshUtil ( )
inlinevirtual

Definition at line 87 of file meshUtil.h.

Member Function Documentation

◆ ComputeQuadIndices()

HD_API void ComputeQuadIndices ( VtIntArray *  indices,
VtIntArray *  primitiveParams,
VtVec2iArray *  edgeIndices = nullptr 
) const

Return quadrangulated indices of the input topology.

indices and primitiveParams are output parameters.

◆ ComputeQuadInfo()

HD_API void ComputeQuadInfo ( HdQuadInfo quadInfo) const

Generate a quadInfo struct for the input topology.

◆ ComputeQuadrangulatedFaceVaryingPrimvar()

HD_API bool ComputeQuadrangulatedFaceVaryingPrimvar ( void const *  source,
int  numElements,
HdType  dataType,
VtValue quadrangulated 
) const

Return a quadrangulation of a face-varying primvar.

source is a buffer of size numElements and type corresponding to dataType (e.g. HdTypeFloatVec3); the result is a VtArray<T> of the correct type written to the variable "quadrangulated". This function returns false if it can't resolve dataType.

◆ ComputeQuadrangulatedPrimvar()

HD_API bool ComputeQuadrangulatedPrimvar ( HdQuadInfo const *  qi,
void const *  source,
int  numElements,
HdType  dataType,
VtValue quadrangulated 
) const

Return a quadrangulation of a per-vertex primvar.

source is a buffer of size numElements and type corresponding to dataType (e.g. HdTypeFloatVec3); the result is a VtArray<T> of the correct type written to the variable "quadrangulated". This function returns false if it can't resolve dataType.

◆ ComputeTriangleIndices()

HD_API void ComputeTriangleIndices ( VtVec3iArray *  indices,
VtIntArray *  primitiveParams,
VtIntArray *  edgeIndices = nullptr 
) const

Return a triangulation of the input topology.

indices and primitiveParams are output parameters.

◆ ComputeTriangulatedFaceVaryingPrimvar()

HD_API bool ComputeTriangulatedFaceVaryingPrimvar ( void const *  source,
int  numElements,
HdType  dataType,
VtValue triangulated 
) const

Return a triangulation of a face-varying primvar.

source is a buffer of size numElements and type corresponding to dataType (e.g. HdTypeFloatVec3); the result is a VtArray<T> of the correct type written to the variable "triangulated". This function returns false if it can't resolve dataType.

◆ ComputeTriQuadIndices()

HD_API void ComputeTriQuadIndices ( VtIntArray *  indices,
VtIntArray *  primitiveParams,
VtVec2iArray *  edgeIndices = nullptr 
) const

Return triquad indices (triangulated after quadrangulation) of the input topology.

indices and primitiveParams are output parameters.

◆ DecodeEdgeFlagFromCoarseFaceParam()

static int DecodeEdgeFlagFromCoarseFaceParam ( int  coarseFaceParam)
inlinestatic

Definition at line 242 of file meshUtil.h.

◆ DecodeFaceIndexFromCoarseFaceParam()

static int DecodeFaceIndexFromCoarseFaceParam ( int  coarseFaceParam)
inlinestatic

Definition at line 239 of file meshUtil.h.

◆ EncodeCoarseFaceParam()

static int EncodeCoarseFaceParam ( int  faceIndex,
int  edgeFlag 
)
inlinestatic

Definition at line 236 of file meshUtil.h.

◆ EnumerateEdges()

HD_API void EnumerateEdges ( std::vector< GfVec2i > *  edgeVerticesOut) const

Return a buffer filled with face vertex index pairs corresponding to the sequence in which edges are visited when iterating through the mesh topology.

The edges of degenerate and hole faces are included so that this sequence will correspond with either base face triangulation or quadrangulation (which typically skips over hole faces) as well as for refined surfaces which take into account faces tagged as holes as well as other non-manifold faces.


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