Volume Mesh Operations
Volume Mesh Operations Tutorial.
This tutorial demonstrates operations on tetrahedral volume meshes including import/export, transformations, and conversion to surfaces.
Prerequisites
- Volvicon application must be running
- Volume meshes are typically created by converting surfaces using
Listing Volume Meshes​
all_volume_meshes = app.get_all_volume_mesh_names()
all_volumes = app.get_all_volume_names()
print(f"Available volume meshes: {all_volume_meshes}")
print(f"Available volumes: {all_volumes}")
Importing and Exporting Volume Meshes​
# Supported formats: vtu, vtk
# Import a single volume mesh file
# mesh_name = VolumeMeshOperations.import_volume_mesh_from_disk(r'C:\data\mesh.vtu')
# Import multiple volume mesh files
# mesh_names = VolumeMeshOperations.import_volume_meshes_from_disk([
# r'C:\data\mesh1.vtu',
# r'C:\data\mesh2.vtk'
# ])
# Export a single volume mesh to file
# VolumeMeshOperations.export_volume_mesh_to_disk('volume_mesh (1)', r'C:\output\mesh.vtu', False) # isASCII=False (bool)
# Export multiple volume meshes to a directory
# VolumeMeshOperations.export_volume_meshes_to_disk(['volume_mesh (1)', 'volume_mesh (2)'], r'C:\output', 'vtu', False) # isASCII=False
Geometric Transformations​
# if all_volume_meshes:
# # Rotate around axis
# VolumeMeshOperations.rotate(
# [all_volume_meshes[0]], # volumeMeshNames (list)
# 45.0, # angleDegrees (float)
# [0.0, 0.0, 1.0], # axis [x, y, z]
# [0.0, 0.0, 0.0], # center [x, y, z] (ignored if aroundObjectCentroid=True)
# True # aroundObjectCentroid (bool)
# )
#
# # Translate
# VolumeMeshOperations.translate(
# [all_volume_meshes[0]], # volumeMeshNames (list)
# [10.0, 5.0, 0.0] # translation [x, y, z] in mm
# )
#
# # Scale
# VolumeMeshOperations.scale(
# [all_volume_meshes[0]], # volumeMeshNames (list)
# [1.5, 1.5, 1.5] # scaleFactors [x, y, z]
# )
#
# # Mirror across axes
# VolumeMeshOperations.mirror(
# [all_volume_meshes[0]], # volumeMeshNames (list)
# True, # mirrorX (bool)
# False, # mirrorY (bool)
# False # mirrorZ (bool)
# )
#
# # Apply 4x4 transformation matrix
# # matrix = [1,0,0,0, 0,1,0,0, 0,0,1,0, 10,20,30,1] # Translation example
# # VolumeMeshOperations.transform([all_volume_meshes[0]], matrix)
#
# # Move to center of active volume
# VolumeMeshOperations.move_to_active_volume_center([all_volume_meshes[0]])
Convert Volume Mesh to Surfaces​
# if all_volume_meshes:
# surface_names = VolumeMeshOperations.convert_to_surfaces([all_volume_meshes[0]])
# print(f"Created surfaces: {surface_names}")
Render Properties​
# VolumeMeshRenderPropertiesOperations = VolumeMeshOperations.get_render_properties_operations()
# if all_volume_meshes:
# # Set representation mode
# VolumeMeshRenderPropertiesOperations.set_representation([all_volume_meshes[0]], api.VolumeMeshRepresentation.Solid) # Points, Wireframe, Solid, SolidEdges
#
# # Set color (RGB values 0.0-1.0)
# VolumeMeshRenderPropertiesOperations.set_color([all_volume_meshes[0]], [0.2, 0.6, 0.8]) # Blue
#
# # Set random color
# VolumeMeshRenderPropertiesOperations.set_random_color([all_volume_meshes[0]])
#
# # Set opacity (0.0-1.0)
# VolumeMeshRenderPropertiesOperations.set_opacity([all_volume_meshes[0]], 0.8)
print("Volume mesh operations tutorial completed successfully.")
Related Resources​
- API Reference - API documentation
- Quick Reference - Common methods at a glance