VTK  9.7.1
vtkStaticPointLocator2D.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
54 #ifndef vtkStaticPointLocator2D_h
55 #define vtkStaticPointLocator2D_h
56 
58 #include "vtkCommonDataModelModule.h" // For export macro
59 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_7_0
60 
61 VTK_ABI_NAMESPACE_BEGIN
62 class vtkDoubleArray;
63 class vtkIdList;
64 struct vtkBucketList2D;
65 struct vtkDist2TupleArray;
66 
67 class VTKCOMMONDATAMODEL_EXPORT vtkStaticPointLocator2D : public vtkAbstractPointLocator
68 {
69 public:
74  static vtkStaticPointLocator2D* New();
75 
77 
81  void PrintSelf(ostream& os, vtkIndent indent) override;
83 
85 
90  vtkSetClampMacro(NumberOfPointsPerBucket, int, 1, VTK_INT_MAX);
91  vtkGetMacro(NumberOfPointsPerBucket, int);
93 
95 
101  vtkSetVector2Macro(Divisions, int);
102  vtkGetVectorMacro(Divisions, int, 2);
104 
105  // Reuse any superclass signatures that we don't override.
110 
118  vtkIdType FindClosestPoint(const double x[3]) override;
119 
121 
129  vtkIdType FindClosestPointWithinRadius(double radius, const double x[3], double& dist2) override;
131  double radius, const double x[3], double inputDataLength, double& dist2);
133 
142  void FindClosestNPoints(int N, const double x[3], vtkIdList* result) override;
143 
161  double FindNPointsInAnnulus(int N, const double x[3], vtkDist2TupleArray& results,
162  double minDist2 = (-0.1), bool sort = true, vtkDoubleArray* petals = nullptr);
163 
170  void FindPointsWithinRadius(double R, const double x[3], vtkIdList* result) override;
171 
181  int IntersectWithLine(double a0[3], double a1[3], double tol, double& t, double lineX[3],
182  double ptX[3], vtkIdType& ptId);
183 
185 
192  double FindCloseNBoundedPoints(int N, const double x[3], vtkIdList* result);
194 
202  void MergePoints(double tol, vtkIdType* mergeMap);
203 
205 
209  void Initialize() override;
210  void FreeSearchStructure() override;
211  void BuildLocator() override;
212  void ForceBuildLocator() override;
214 
221  vtkIdType GetNumberOfPointsInBucket(vtkIdType bNum);
222 
228  void GetBucketIds(vtkIdType bNum, vtkIdList* bList);
229 
231 
245  vtkSetClampMacro(MaxNumberOfBuckets, vtkIdType, 1000, VTK_ID_MAX);
246  vtkGetMacro(MaxNumberOfBuckets, vtkIdType);
248 
256  bool GetLargeIds() { return this->LargeIds; }
257 
259 
262  void GetBounds(double* bounds) override
263  {
264  bounds[0] = this->Bounds[0];
265  bounds[1] = this->Bounds[1];
266  bounds[2] = this->Bounds[2];
267  bounds[3] = this->Bounds[3];
268  }
270 
272 
276  virtual double* GetSpacing() { return this->H; }
277  virtual void GetSpacing(double spacing[3])
278  {
279  spacing[0] = this->H[0];
280  spacing[1] = this->H[1];
281  spacing[2] = 0.0;
282  }
284 
286 
291  void GetBucketIndices(const double* x, int ij[2]) const;
292  vtkIdType GetBucketIndex(const double* x) const;
294 
296 
302  VTK_DEPRECATED_IN_9_7_0("Use UseExistingSearchStructureOn instead.")
303  void StaticOn() { this->Static = true; }
304  VTK_DEPRECATED_IN_9_7_0("Use UseExistingSearchStructureOff instead.")
305  void StaticOff() { this->Static = false; }
306  VTK_DEPRECATED_IN_9_7_0("Use GetUseExistingSearchStructure instead.")
307  vtkGetMacro(Static, vtkTypeBool);
309 
313  vtkBucketList2D* GetBuckets() { return this->Buckets; }
314 
320  void GenerateRepresentation(int level, vtkPolyData* pd) override;
321 
322 protected:
324  ~vtkStaticPointLocator2D() override;
325 
326  void BuildLocatorInternal() override;
327 
328  int NumberOfPointsPerBucket; // Used with AutomaticOn to control subdivide
329  int Divisions[2]; // Number of sub-divisions in x-y directions
330  double H[2]; // Width of each bucket in x-y directions
331  vtkBucketList2D* Buckets; // Lists of point ids in each bucket
332  vtkIdType MaxNumberOfBuckets; // Maximum number of buckets in locator
333  bool LargeIds; // indicate whether integer ids are small or large
334  vtkTypeBool Static; // Control whether to repeatedly check modified time
335 
336 private:
338  void operator=(const vtkStaticPointLocator2D&) = delete;
339 };
340 
341 VTK_ABI_NAMESPACE_END
342 #endif
virtual void BuildLocator()=0
Build the locator from the input dataset.
virtual void GetSpacing(double spacing[3])
Provide an accessor to the bucket spacing.
virtual vtkIdType FindClosestPointWithinRadius(double radius, const double x[3], double &dist2)=0
Given a position x and a radius r, return the id of the point closest to the point in that radius...
#define VTK_INT_MAX
Definition: vtkType.h:192
virtual double * GetBounds()
Provide an accessor to the bounds.
virtual double * GetSpacing()
Provide an accessor to the bucket spacing.
int vtkIdType
Definition: vtkType.h:363
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
virtual void FreeSearchStructure()=0
Free the memory required for the spatial data structure.
dynamic, self-adjusting array of double
int vtkTypeBool
Definition: vtkABI.h:64
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual void BuildLocatorInternal()
This function is not pure virtual to maintain backwards compatibility.
Definition: vtkLocator.h:199
void PrintSelf(ostream &os, vtkIndent indent) override
Standard type and print methods.
abstract class to quickly locate points in 3-space
list of point or cell ids
Definition: vtkIdList.h:25
virtual void FindPointsWithinRadius(double R, const double x[3], vtkIdList *result)=0
Find all points within a specified radius R of position x.
void GetBounds(double *bounds) override
Provide an accessor to the bounds.
Private declarations for 2D binned spatial locator.
virtual void FindClosestNPoints(int N, const double x[3], vtkIdList *result)=0
Find the closest N points to a position.
#define VTK_ID_MAX
Definition: vtkType.h:367
Represent an array of vtkDist2Tuples.
virtual vtkIdType FindClosestPoint(const double x[3])=0
Given a position x, return the id of the point closest to it.
virtual void Initialize()
Initialize locator.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
bool GetLargeIds()
Inform the user as to whether large ids are being used.
#define VTK_DEPRECATED_IN_9_7_0(reason)
virtual void GenerateRepresentation(int level, vtkPolyData *pd)=0
Method to build a representation at a particular level.
virtual void ForceBuildLocator()
Build the locator from the input dataset (even if UseExistingSearchStructure is on).
Definition: vtkLocator.h:163
quickly locate points in 2-space