1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkVoronoiKernel.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   vtkVoronoiKernel
17  * @brief   a Voronoi interpolation kernel
18  *
19  *
20  * vtkVoronoiKernel is an interpolation kernel that simply returns the
21  * closest point to a point to be interpolated. A single weight is returned
22  * with value=1.0.
23  *
24  * @warning
25  * In degenerate cases (where a point x is equidistance from more than one
26  * point) the kernel basis arbitrarily chooses one of the equidistant points.
27  *
28  * @sa
29  * vtkInterpolationKernel vtkGeneralizedKernel vtkProbabilisticVoronoiKernel
30 */
31 
32 #ifndef vtkVoronoiKernel_h
33 #define vtkVoronoiKernel_h
34 
35 #include "vtkFiltersPointsModule.h" // For export macro
36 #include "vtkInterpolationKernel.h"
37 
38 class vtkIdList;
39 class vtkDoubleArray;
40 
41 
42 class VTKFILTERSPOINTS_EXPORT vtkVoronoiKernel : public vtkInterpolationKernel
43 {
44 public:
45   //@{
46   /**
47    * Standard methods for instantiation, obtaining type information, and printing.
48    */
49   static vtkVoronoiKernel *New();
50   vtkTypeMacro(vtkVoronoiKernel,vtkInterpolationKernel);
51   void PrintSelf(ostream& os, vtkIndent indent) override;
52   //@}
53 
54   /**
55    * Given a point x (and optional associated ptId), determine the points
56    * around x which form an interpolation basis. The user must provide the
57    * vtkIdList pIds, which will be dynamically resized as necessary. The
58    * method returns the number of points in the basis. Typically this method
59    * is called before ComputeWeights().
60    */
61   vtkIdType ComputeBasis(double x[3], vtkIdList *pIds, vtkIdType ptId=0) override;
62 
63   /**
64    * Given a point x, and a list of basis points pIds, compute interpolation
65    * weights associated with these basis points.  Note that both the nearby
66    * basis points list pIds and the weights array are provided by the caller
67    * of the method, and may be dynamically resized as necessary. Typically
68    * this method is called after ComputeBasis(), although advanced users can
69    * invoke ComputeWeights() and provide the interpolation basis points pIds
70    * directly.
71    */
72   vtkIdType ComputeWeights(double x[3], vtkIdList *pIds,
73                                    vtkDoubleArray *weights) override;
74 
75 protected:
76   vtkVoronoiKernel();
77   ~vtkVoronoiKernel() override;
78 
79 private:
80   vtkVoronoiKernel(const vtkVoronoiKernel&) = delete;
81   void operator=(const vtkVoronoiKernel&) = delete;
82 };
83 
84 #endif
85