gpt4 book ai didi

vtk - 如何在 vtk 中使用 IntersectWithLine 函数?

转载 作者:行者123 更新时间:2023-12-04 17:54:09 24 4
gpt4 key购买 nike

所以我有一个点,并在 z 轴上创建一条线以查看与某个网格的交点(将网格上的点投影到 z 轴上)。

所以我创建了一个 vtkCellLocator,但是函数的每个参数是什么?文档中根本没有描述它:

int vtkCellLocator::IntersectWithLine(double a0[3], double a1[3], double tol,
double& t, double x[3], double pcoords[3],
int &subId, vtkIdType &cellId,
vtkGenericCell *cell);

我测试了一下,好像a0和a1是我们直线的端点,x是找到的交点值,cellid是交点的cellid。

剩下的是什么意思?如果我有多个交点会怎样?它如何从所有交点中选择“最佳”交点单元格?

最佳答案

IntersectWithLine 的参数派生自 vtkCell 类。有点埋没看详细说明here对于参数。 vtkCellLocator 中的实现使用对 vtkCell::IntersectWithLine 的调用来定义参数。

virtual int vtkCell::IntersectWithLine ( const double p1[3],const double p2[3], double tol, double & t, doublex[3], double pcoords[3], int & subId )

Intersect with a ray.

Return parametric coordinates (both line and cell) and globalintersection coordinates, given ray definition p1[3], p2[3] andtolerance tol. The method returns non-zero value if intersectionoccurs. A parametric distance t between 0 and 1 along the rayrepresenting the intersection point, the point coordinates x[3] indata coordinates and also pcoords[3] in parametric coordinates. subIdis the index within the cell if a composed cell like a triangle strip.

返回的 cellId 基于到相交单元格的参数化距离。所以返回的cellId就是最小化成员函数vtkCell::GetParametricDistance

的cell

virtual double vtkCell::GetParametricDistance ( const double pcoords[3] )

Return the distance of the parametric coordinate provided to thecell.

If inside the cell, a distance of zero is returned. This is usedduring picking to get the correct cell picked. (The tolerance willoccasionally allow cells to be picked who are not really intersected"inside" the cell.)

因此它应该是在公差范围内与最接近 p1

的线相交的单元格

关于vtk - 如何在 vtk 中使用 IntersectWithLine 函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41832596/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com