1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkShepardKernel.h 5 6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 7 All rights reserved. 8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 9 10 This software is distributed WITHOUT ANY WARRANTY; without even 11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 12 PURPOSE. See the above copyright notice for more information. 13 14 =========================================================================*/ 15 /** 16 * @class vtkShepardKernel 17 * @brief a Shepard method interpolation kernel 18 * 19 * 20 * vtkShepardKernel is an interpolation kernel that uses the method of 21 * Shepard to perform interpolation. The weights are computed as 1/r^p, where 22 * r is the distance to a neighbor point within the kernel radius R; and p 23 * (the power parameter) is a positive exponent (typically p=2). 24 * 25 * @warning 26 * The weights are normalized sp that SUM(Wi) = 1. If a neighbor point p 27 * precisely lies on the point to be interpolated, then the interpolated 28 * point takes on the values associated with p. 29 * 30 * @sa 31 * vtkPointInterpolator vtkPointInterpolator2D vtkInterpolationKernel 32 * vtkGaussianKernel vtkSPHKernel vtkShepardKernel 33 */ 34 35 #ifndef vtkShepardKernel_h 36 #define vtkShepardKernel_h 37 38 #include "vtkFiltersPointsModule.h" // For export macro 39 #include "vtkGeneralizedKernel.h" 40 41 class vtkIdList; 42 class vtkDoubleArray; 43 44 45 class VTKFILTERSPOINTS_EXPORT vtkShepardKernel : public vtkGeneralizedKernel 46 { 47 public: 48 //@{ 49 /** 50 * Standard methods for instantiation, obtaining type information, and printing. 51 */ 52 static vtkShepardKernel *New(); 53 vtkTypeMacro(vtkShepardKernel,vtkGeneralizedKernel); 54 void PrintSelf(ostream& os, vtkIndent indent) override; 55 //@} 56 57 // Re-use any superclass signatures that we don't override. 58 using vtkGeneralizedKernel::ComputeWeights; 59 60 /** 61 * Given a point x, a list of basis points pIds, and a probability 62 * weighting function prob, compute interpolation weights associated with 63 * these basis points. Note that basis points list pIds, the probability 64 * weighting prob, and the weights array are provided by the caller of the 65 * method, and may be dynamically resized as necessary. The method returns 66 * the number of weights (pIds may be resized in some cases). Typically 67 * this method is called after ComputeBasis(), although advanced users can 68 * invoke ComputeWeights() and provide the interpolation basis points pIds 69 * directly. The probably weighting prob are numbers 0<=prob<=1 which are 70 * multiplied against the interpolation weights before normalization. They 71 * are estimates of local confidence of weights. The prob may be nullptr in 72 * which all probabilities are considered =1. 73 */ 74 vtkIdType ComputeWeights(double x[3], vtkIdList *pIds, 75 vtkDoubleArray *prob, vtkDoubleArray *weights) override; 76 77 //@{ 78 /** 79 * Set / Get the power parameter p. By default p=2. Values (which must be 80 * a positive, real value) != 2 may affect performance significantly. 81 */ 82 vtkSetClampMacro(PowerParameter,double,0.001,100); 83 vtkGetMacro(PowerParameter,double); 84 //@} 85 86 protected: 87 vtkShepardKernel(); 88 ~vtkShepardKernel() override; 89 90 // The exponent of the weights, =2 by default (l2 norm) 91 double PowerParameter; 92 93 private: 94 vtkShepardKernel(const vtkShepardKernel&) = delete; 95 void operator=(const vtkShepardKernel&) = delete; 96 }; 97 98 #endif 99