欢迎大家加入社区,雪易VTK社区-CSDN社区云
前言:目前在做模型的ReMesh,在研究这个接口,希望能有所帮助。
vtkPointInterpolator
描述:
变量:
Strategy:MASK_POINTS, NULL_VALUE, CLOSEST_POINT
指定插补过程中遇到“空”点时使用的策略。当局部邻域(要进行插值的相邻点的邻域)为空时,就会出现空点。若策略设置为MaskPoints,则创建一个输出数组,将点标记为有效或无效。若策略设置为NullValue(默认值),则输出数据值设置为NullPoint值(在输出点数据中指定)。若策略为ClosePoint,则简单地使用最近的点来执行插值。
目录
vtkInterpolationKernel
vtkGeneralizedKernel
vtkEllipsoidalGaussianKernel
vtkGaussianKernel
vtkLinearKernel
vtkProbabilisticVoronoiKernel
vtkShepardKernel
vtkSPHKernel
vtkInterpolationKernel
vtkGeneralizedKernel
描述:vtkGeneralizedKernel是一个抽象类,具有重要的属性:权值是归一化的;基础的占用空间是可配置的;概率加权函数可用于偏爱某些权重。
权值是归一化的
归一化权值即Sum(w_i) = 1;这确保了插值具有良好的质量。
基础的占用空间是可配置的
插值footprint是用于执行插值过程的点集。例如可以选择基于半径的内核和基于N个邻域点的内核。内核的性能和数学属性会根据选择的内核类型而有很大的不同。例如基于半径的内核,如果半径过大,则算法将以n^3执行。
在高级用法中,可以将概率函数应用于计算插值权重。概率函数是对某点的数据准确的置信度估计。一个典型的应用是当激光扫描用于获取点测量时,它返回法线,表示与直接的、接近正交的命中相比的掠射返回。
常用方法:
ComputeBasis
/*** Based on the kernel style, invoke the appropriate locator method to* obtain the points making up the basis. Given a point x (and optional* associated point id), determine the points around x which form an* interpolation basis. The user must provide the vtkIdList pIds, which* will be dynamically resized as necessary. The method returns the number* of points in the basis. Typically this method is called before* ComputeWeights(). Note that ptId is optional in most cases, although in* some kernels it is used to facilitate basis computation.*///基于内核样式,调用适当的定位器方法来获得组成Basis的点。给定一个点x(和可选的关联点id),确定在//在x周围形成插值Basis的点。用户必须提供pIds,它将根据需要动态调整大小。//该方法返回Basis中的点数,通常在ComputeWeights()之前调用该方法。vtkIdType ComputeBasis(double x[3], vtkIdList* pIds, vtkIdType ptId = 0) override;
ComputeWeights
/*** Given a point x, a list of basis points pIds, and a probability* weighting function prob, compute interpolation weights associated with* these basis points. Note that basis points list pIds, the probability* weighting prob, and the weights array are provided by the caller of the* method, and may be dynamically resized as necessary. The method returns* the number of weights (pIds may be resized in some cases). Typically* this method is called after ComputeBasis(), although advanced users can* invoke ComputeWeights() and provide the interpolation basis points pIds* directly. The probably weighting prob are numbers 0<=prob<=1 which are* multiplied against the interpolation weights before normalization. They* are estimates of local confidence of weights. The prob may be nullptr in* which all probabilities are considered =1.*/
//给定一个点x,一组几点pIds和一个概率加权函数probb,计算这些基点相关的插值权重。
//该方法返回权重的数量(在某些情况下可以调整pIds的大小),通常在ComputeBasis()之后调用。
//加权概率prob是数字0<= probb <=1,在归一化之前乘以插值权重。它们是加权局部置信度的估计。
//prob可能是nullptr,其中所有概率都被认为是=1。
virtual vtkIdType ComputeWeights(double x[3], vtkIdList* pIds, vtkDoubleArray* prob, vtkDoubleArray* weights) = 0;
KernelStyle:RADIUS, N_CLOSEST
/*** Specify the interpolation basis style. By default, a Radius style is* used (i.e., the basis is defined from all points within a specified* radius). However, it is also possible to select the N closest points* (NClosest). Note that in most formulations the Radius style is assumed* as it provides better mathematical properties. However, for convenience* some bases are easier to use when the N closest points are taken.*/
//指定插值基样式。默认情况下,使用半径样式(即,从指定半径内的所有点定义基础)。但是,也可以选择N个
//最近的点(nnearest)。
//请注意,在大多数公式中采用半径样式,因为它提供了更好的数学属性。
//然而,为了方便起见,当取N个最近的点时,一些基底更容易使用。
vtkSetMacro(KernelFootprint, int);
vtkGetMacro(KernelFootprint, int);
void SetKernelFootprintToRadius() { this->SetKernelFootprint(RADIUS); }
void SetKernelFootprintToNClosest() { this->SetKernelFootprint(N_CLOSEST); }
NormalizeWeights权重归一化
/*** Indicate whether the interpolation weights should be normalized after they* are computed. Generally this is left on as it results in more reasonable* behavior.*/
//插值权重计算后是否应归一化。通常情况下,这是保留的,因为它会导致更合理的行为。
vtkSetMacro(NormalizeWeights, bool);
vtkEllipsoidalGaussianKernel
描述:vtkEllipsoidalaussianKernel是一个插值核,返回由半径R定义的椭球中所有点的权重(结合法线或者标量数据)。“pancake”权重(与最小椭球轴平行的局部法线);“needle”权重(与最大椭球轴平面的局部法线)。vtkGaussianKernel可以更有效的计算球形高斯权重。
vtkGaussianKernel
描述:vtkGaussianKernel是一个插值核,它简单地返回由半径R定义的球中所有点的权重。权重计算为:exp(-(s*r/ R)^2),其中r是从要插值的点到r内邻近点的距离。锐度s只是影响高斯函数的下降速率。(更通用的高斯内核可以从vtkEllipsoidalGaussianKernel中获得。)
vtkIdType vtkGaussianKernel::ComputeWeights(double x[3], vtkIdList* pIds, vtkDoubleArray* prob, vtkDoubleArray* weights)
{vtkIdType numPts = pIds->GetNumberOfIds();double d2, y[3], sum = 0.0;weights->SetNumberOfTuples(numPts);double* p = (prob ? prob->GetPointer(0) : nullptr);double* w = weights->GetPointer(0);double f2 = this->F2;for (vtkIdType i = 0; i < numPts; ++i){vtkIdType id = pIds->GetId(i);this->DataSet->GetPoint(id, y);d2 = vtkMath::Distance2BetweenPoints(x, y);if (vtkMathUtilities::FuzzyCompare(d2, 0.0, std::numeric_limits<double>::epsilon() * 256.0)) // precise hit on existing point{pIds->SetNumberOfIds(1);pIds->SetId(0, id);weights->SetNumberOfTuples(1);weights->SetValue(0, 1.0);return 1;}else{w[i] = (p ? p[i] * exp(-f2 * d2) : exp(-f2 * d2));sum += w[i];}} // over all points// Normalizeif (this->NormalizeWeights && sum != 0.0){for (vtkIdType i = 0; i < numPts; ++i){w[i] /= sum;}}return numPts;
}
vtkLinearKernel
描述:vtkLinearKernel是一个插值核,它为Basis中所有点的均值。
vtkIdType vtkLinearKernel::ComputeWeights(double*, vtkIdList* pIds, vtkDoubleArray* prob, vtkDoubleArray* weights)
{vtkIdType numPts = pIds->GetNumberOfIds();double* p = (prob ? prob->GetPointer(0) : nullptr);weights->SetNumberOfTuples(numPts);double* w = weights->GetPointer(0);double weight = 1.0 / static_cast<double>(numPts);if (!prob) // standard linear interpolation{for (vtkIdType i = 0; i < numPts; ++i){w[i] = weight;}}else // weight by probability{double sum = 0.0;for (vtkIdType i = 0; i < numPts; ++i){w[i] = weight * p[i];sum += w[i];}// Now normalizeif (this->NormalizeWeights && sum != 0.0){for (vtkIdType i = 0; i < numPts; ++i){w[i] /= sum;}}}return numPts;
}
vtkProbabilisticVoronoiKernel
描述:vtkProbabilisticVoronoiKernel是一个插值核,它从点的邻域中最近的加权点进行插值。权重指的是可以提供给ComputeWeights()方法的概率权重。
如果没有定义概率权重,则内核提供与vtkVoronoiKernel相同的结果,只是效率较低。
vtkIdType vtkProbabilisticVoronoiKernel::ComputeWeights(double x[3], vtkIdList* pIds, vtkDoubleArray* prob, vtkDoubleArray* weights)
{vtkIdType numPts = pIds->GetNumberOfIds();double* p = (prob ? prob->GetPointer(0) : nullptr);double highestProbability = VTK_FLOAT_MIN;vtkIdType id, mostProbableId = 0;if (p) // return the point in the neighborhood with the highest probability{for (vtkIdType i = 0; i < numPts; ++i){if (p[i] > highestProbability){mostProbableId = pIds->GetId(i);highestProbability = p[i];}}}else // return the closest point in the footprint provided{double y[3], d, minD = VTK_FLOAT_MAX;for (vtkIdType i = 0; i < numPts; ++i){id = pIds->GetId(i);this->DataSet->GetPoint(id, y);d = vtkMath::Distance2BetweenPoints(x, y);if (vtkMathUtilities::FuzzyCompare(d, 0.0,std::numeric_limits<double>::epsilon() * 256.0)) // precise hit on existing point{mostProbableId = id;break;}else if (d <= minD){mostProbableId = id;minD = d;}} // over all points}// Okay let's get outpIds->SetNumberOfIds(1);pIds->SetId(0, mostProbableId);weights->SetNumberOfTuples(1);weights->SetValue(0, 1.0);return 1;
}
vtkShepardKernel
描述:vtkShepardKernel是一个使用Shepard方法进行插值的插值内核。权值计算为1/r^p,其中r是到核半径r内邻居点的距离;p(幂参数)是一个正指数(通常p=2)。
如果相邻点p恰好位于要插值的点上,则被插值点取与p相关的值。
vtkVoronoiKernel
描述:vtkVoronoiKernel是一个插值内核,它只返回与要插值的点最近的点。返回值为1.0的单个权重。
vtkIdType vtkVoronoiKernel::ComputeBasis(double x[3], vtkIdList* pIds, vtkIdType)
{pIds->SetNumberOfIds(1);vtkIdType pId = this->Locator->FindClosestPoint(x);pIds->SetId(0, pId);return 1;
}vtkIdType vtkVoronoiKernel::ComputeWeights(double*, vtkIdList*, vtkDoubleArray* weights)
{weights->SetNumberOfTuples(1);weights->SetValue(0, 1.0);return 1;
}
vtkSPHKernel
描述:vtkSPHKernel是D.J. Price描述的光滑粒子流体动力学插值内核的抽象超类。
内核在采样点的半径所定义的空间上运行。核隐含地假设组成输入数据的粒子满足质量守恒等物理性质。因此,这个内核的子类通常不适用于插值过程,因此与vthSPHInterpolator类一起操作。
默认情况下,内核从空间步长^3计算局部粒子体积。
但是,如果同时提供可选的质量和密度数组,则使用它们来计算局部体积。
同样是默认的,插值点周围的局部邻域被计算为CutoffFactor * SpatialStep。(注意CutoffFactor对于每种类型的SPH内核是不同的。)但是,用户可以指定一个CutoffArray,使每个点的截断距离可变。
包含三个子类:vtkSPHCubicKernel、vtkSPHQuarticKernel、vtkSPHQuinticKernel。