The definition of the "FindClosestPoint" function is the following:
def FindClosestPoint(self, p_float=None, p_float=None_1, p_float=None_2, *args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__
"""
V.FindClosestPoint([float, float, float], [float, float, float],
vtkGenericCell, int, int, float)
C++: void FindClosestPoint(double x[3], double closestPoint[3],
vtkGenericCell *cell, vtkIdType &cellId, int &subId,
double &dist2) override;
V.FindClosestPoint([float, float, float], [float, float, float],
int, int, float)
C++: virtual void FindClosestPoint(double x[3],
double closestPoint[3], vtkIdType &cellId, int &subId,
double &dist2)
Return the closest point and the cell which is closest to the
point x. The closest point is somewhere on a cell, it need not be
one of the vertices of the cell. This version takes in a
vtkGenericCell to avoid allocating and deallocating the cell.
This is much faster than the version which does not take a *cell,
especially when this function is called many times in a row such
as by a for loop, where the allocation and deallocation can be
done only once outside the for loop. If a cell is found, "cell"
contains the points and ptIds for the cell "cellId" upon exit.
"""
pass
In my code I use the function like this:
my_cell_locator = vtk.vtkCellLocator()
my_cell_locator.SetDataSet(reverse.GetOutput()) # reverse.GetOutput() --> vtkPolyData
cellId = 0
c = [0.0, 0.0, 0.0]
subId = 0
d = 0.0
my_cell_locator.FindClosestPoint([-23.7, -48.4, -1096.4], c, cellId, subId, d)
And this leads to the following error:
Process finished with exit code -1073741819 (0xC0000005)
I don't know how to use this function correctly. What is wrong? What would be the correct usage?
I had to change the code to the following:
reverse.Update()
my_cell_locator = vtk.vtkCellLocator()
my_cell_locator.SetDataSet(reverse.GetOutput()) # reverse.GetOutput() --> vtkPolyData
my_cell_locator.BuildLocator()
cellId = vtk.reference(0)
c = [0.0, 0.0, 0.0]
subId = vtk.reference(0)
d = vtk.reference(0.0)
my_cell_locator.FindClosestPoint([-23.7, -48.4, -906.4], c, cellId, subId, d)
I added the lines:
reverse.Update()
and
my_cell_locator.BuildLocator()
Then I changed the following lines:
cellId = 0
subId = 0
d = 0.0
To...
cellId = vtk.reference(0)
subId = vtk.reference(0)
d = vtk.reference(0.0)
For vtk version 8 had to change vtk.reference to vtk.mutable
User contributions licensed under CC BY-SA 3.0