ShapeWorks
ShapeWorks copied to clipboard
Writing mesh distance scalar fields
Currently, if you want to compute the distance between two meshes and save it as a scalar field (so you can visualize it as a heat map), using the Python API this is what you must call:
import shapeworks as sw
import numpy as np
# Load meshes
mesh_1 = sw.Mesh([path_to_mesh1])
mesh_2 = sw.Mesh([path_to_mesh2])
# Compute distance
distance_values, cell_ids = mesh_1.distance(mesh_2, method=sw.Mesh.DistanceMethod.PointToCell)
# Write mesh with distance scalar field
mesh_1.setField(name='distance', array=distance_values, type=sw.Mesh.FieldType.Point).write([path_to_output_mesh])
This is not very intuitive. I think we should set the field automatically when distance is called so that we can just call:
mesh_1.distance(mesh_2).write(path_to_output_mesh])
At the very least, we should set a default parameter for the setFiled()
type
option. And also add documentation for how to do this because, as far as I know, there currently isn't any.