luc*_*hli 2 python vtk python-3.x
“FindClosestPoint”函数的定义如下:
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
Run Code Online (Sandbox Code Playgroud)
在我的代码中,我使用这样的函数:
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)
Run Code Online (Sandbox Code Playgroud)
这会导致以下错误:
进程完成,退出代码 -1073741819 (0xC0000005)
我不知道如何正确使用此功能。怎么了?正确的用法是什么?
我不得不将代码更改为以下内容:
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)
Run Code Online (Sandbox Code Playgroud)
我添加了以下几行:
reverse.Update()
Run Code Online (Sandbox Code Playgroud)
和
my_cell_locator.BuildLocator()
Run Code Online (Sandbox Code Playgroud)
然后我更改了以下几行:
cellId = 0
subId = 0
d = 0.0
Run Code Online (Sandbox Code Playgroud)
到...
cellId = vtk.reference(0)
subId = vtk.reference(0)
d = vtk.reference(0.0)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1314 次 |
| 最近记录: |