pysdic.PointCloud.to_vtk#

PointCloud.to_vtk(filepath, binary=False, only_finite=False, save_properties=True)[source]#

Save the point cloud to a VTK file (only for \(E=3\) point clouds).

The points are saved using meshio library.

The VTK file will contain vertex definitions.

See also

Warning

VTK cannot handle NaN or infinite values. If the point cloud contains such values, consider using the only_finite parameter to filter them out before saving.

Warning

This method only works for 3-dimensional point clouds, as VTK format is primarily used for 3D data.

Parameters:
  • filepath (str) – The path to the output VTK file.

  • binary (bool, optional) – If True, the VTK file will be saved in binary format. Default is False.

  • only_finite (bool, optional) – If True, only finite points (excluding NaN and infinite values) will be saved. Default is False.

  • save_properties (bool, optional) – If True, the point data properties from the point cloud will be saved to the VTK file. Default is True.

Raises:

ValueError – If the binary parameter is not a boolean value. If the only_finite parameter is not a boolean value. If only_finite is True and there are no finite points to save.

Return type:

None

Examples

Saving a PointCloud object to a VTK file.

1from pysdic import PointCloud
2import numpy as np
3
4# Create a random point cloud with 100 points
5random_points = np.random.rand(100, 3)  # shape (100, 3)
6point_cloud = PointCloud.from_array(random_points)
7
8# Save the point cloud to a VTK file
9point_cloud.to_vtk('path/to/output_point_cloud.vtk')

This will save the points of the point cloud to the specified VTK file.