Hi!
Im using vtk.vtkImplicitPolyDataDistance
and have found that the amount of time it takes for vtk to calculate the signed distance is related to the distance the sampled points are from the surface. Further points take longer. This behaviour seemed strange to me, so I wanted to check and see if this also seems odd to others or if there could be something done to ameliorate the issue.
Below is the code I am using. Sorry, I am using a custom library for reading vtk meshes and turning the point coords to an array. If you want to see that library it is here (GitHub - gattia/pymskt: Python Musculoskeletal Tools), but its not doing anything other than helping load data.
In the below, if
noise_amplitude = 1, then it solves in <4s,
noise_amplitude = 5 its ~12 s,
noise_amplitude = 10 its ~ 20 s.
The range from min to max of the mesh points is 60-80 in each dimension ~[80, 60, 60]. So, the max noise is on the range of 16% of the size of the mesh.
Thanks!
import pymskt as mskt
import vtk
from vtk.util.numpy_support import numpy_to_vtk, vtk_to_numpy
import time
import numpy as np
mesh = mskt.mesh.Mesh('/dataNAS/people/aagatti/projects/OAI_Segmentation/oai_predictions_april_2023/2d_models/00_month/meshes_July_5_2023/9569243/RIGHT_femur__fixed_July_5_2023.vtk')
pts = mesh.point_coords
pts = np.concatenate([pts, pts, pts, pts], axis=0)
noise_amplitude = 5
noise = (np.random.rand(pts.shape[0], pts.shape[1]) - 0.5) * noise_amplitude
pts += noise
pts = pts.astype(np.float64)
print(pts.shape)
print(pts.dtype)
tic = time.time()
mesh = mesh.mesh
implicit_distance = vtk.vtkImplicitPolyDataDistance()
implicit_distance.SetInput(mesh)
toc = time.time()
print(toc-tic)