VTKConverter#

class ansys.tools.usdviewer.vtk_converter.VTKConverter#

Convert VTK files to USD format for visualization.

Overview#

load_asset

Load a VTK asset into a given stage.

convert_vtk_file_to_usd

Convert a VTK file to a USD file.

convert_vtk_to_usd

Convert a VTK file to a USD stage.

get_vtk_reader

Get the appropriate VTK reader based on the file extension.

convert_polydata_to_usd_mesh

Convert VTK polydata to USD mesh geometry.

convert_usd_to_vtk

Convert a USD mesh to VTK polydata.

Import detail#

from ansys.tools.usdviewer.vtk_converter import VTKConverter

Method detail#

static VTKConverter.convert_vtk_file_to_usd(vtk_file_path: str | pathlib.Path, stage: pxr.Usd.Stage = None) None#

Convert a VTK file to a USD file.

Parameters#

vtk_file_pathUnion[str, Path]

Path to the VTK file to convert.

stageUsd.Stage

Stage to add the converted USD data to.

static VTKConverter.convert_vtk_to_usd(data: vtk.vtkDataSet, stage: pxr.Usd.Stage = None, mesh_name: str = 'VTKMesh') pxr.Usd.Stage#

Convert a VTK file to a USD stage.

Parameters#

vtk_file_pathUnion[str, Path]

Path to the VTK file to convert.

stageUsd.Stage

Stage to add the VTK data to.

Returns#

Usd.Stage

Stage containing the VTK data.

static VTKConverter.get_vtk_reader(file_path: pathlib.Path) vtk.vtkAlgorithm#

Get the appropriate VTK reader based on the file extension.

Parameters#

file_pathPath

Path to the VTK file.

static VTKConverter.convert_polydata_to_usd_mesh(polydata: vtk.vtkPolyData, stage: pxr.Usd.Stage = None, mesh_name: str = 'VTKMesh') None#

Convert VTK polydata to USD mesh geometry.

Parameters#

polydatavtk.vtkPolyData

VTK polydata to convert.

stageUsd.Stage

USD stage to add the mesh to.

mesh_namestr, default: "VTKMesh"

Name of the mesh in USD.

static VTKConverter.convert_usd_to_vtk(stage: pxr.Usd.Stage, mesh_path: str | None = None) vtk.vtkPolyData | None#

Convert a USD mesh to VTK polydata.

Parameters#

stageUsd.Stage

USD stage containing the mesh.

mesh_pathstr, default: None

Path to the mesh in USD. If None, the first mesh in the stage is used.

Returns#

Optional[vtk.vtkPolyData]

Converted VTK polydata or None if conversion failed.

VTKConverter.load_asset(asset_path: str, stage: pxr.Usd.Stage) pxr.Usd.Stage | None#

Load a VTK asset into a given stage.

Parameters#

asset_pathstr

Path to the asset file.

stageUsd.Stage

Stage to add the asset to.

Returns#

Optional[Usd.Stage]

Stage with the loaded asset or None if loading failed.