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
meshiolibrary.The VTK file will contain vertex definitions.
See also
from_vtk()method for creating aPointCloudobject from a VTK file.
Warning
VTK cannot handle NaN or infinite values. If the point cloud contains such values, consider using the
only_finiteparameter 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) – IfTrue, the VTK file will be saved in binary format. Default isFalse.only_finite (
bool, optional) – IfTrue, only finite points (excluding NaN and infinite values) will be saved. Default isFalse.save_properties (
bool, optional) – IfTrue, the point data properties from the point cloud will be saved to the VTK file. Default isTrue.
- Raises:
ValueError – If the
binaryparameter is not a boolean value. If theonly_finiteparameter is not a boolean value. Ifonly_finiteis True and there are no finite points to save.- Return type:
None
Examples
Saving a
PointCloudobject 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.