VTK  9.3.1
vtkKdNode.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
3 // SPDX-License-Identifier: BSD-3-Clause
4 
21 #ifndef vtkKdNode_h
22 #define vtkKdNode_h
23 
24 #include "vtkCommonDataModelModule.h" // For export macro
25 #include "vtkObject.h"
26 
27 VTK_ABI_NAMESPACE_BEGIN
28 class vtkCell;
30 
31 class VTKCOMMONDATAMODEL_EXPORT vtkKdNode : public vtkObject
32 {
33 public:
34  vtkTypeMacro(vtkKdNode, vtkObject);
35  void PrintSelf(ostream& os, vtkIndent indent) override;
36 
37  static vtkKdNode* New();
38 
40 
44  vtkSetMacro(Dim, int);
45  vtkGetMacro(Dim, int);
47 
53  virtual double GetDivisionPosition();
54 
56 
59  vtkSetMacro(NumberOfPoints, int);
60  vtkGetMacro(NumberOfPoints, int);
62 
64 
68  void SetBounds(double x1, double x2, double y1, double y2, double z1, double z2);
69  void SetBounds(const double b[6]) { this->SetBounds(b[0], b[1], b[2], b[3], b[4], b[5]); }
70  void GetBounds(double* b) const;
72 
74 
79  void SetDataBounds(double x1, double x2, double y1, double y2, double z1, double z2);
80  void GetDataBounds(double* b) const;
82 
87  void SetDataBounds(float* v);
88 
93  double* GetMinBounds() VTK_SIZEHINT(3) { return this->Min; }
94  double* GetMaxBounds() VTK_SIZEHINT(3) { return this->Max; }
95 
99  void SetMinBounds(const double* mb);
100 
104  void SetMaxBounds(const double* mb);
105 
110  double* GetMinDataBounds() VTK_SIZEHINT(3) { return this->MinVal; }
111  double* GetMaxDataBounds() VTK_SIZEHINT(3) { return this->MaxVal; }
112 
117  void SetMinDataBounds(const double* mb);
118 
123  void SetMaxDataBounds(const double* mb);
124 
126 
130  vtkSetMacro(ID, int);
131  vtkGetMacro(ID, int);
133 
135 
142  vtkGetMacro(MinID, int);
143  vtkGetMacro(MaxID, int);
144  vtkSetMacro(MinID, int);
145  vtkSetMacro(MaxID, int);
147 
151  void AddChildNodes(vtkKdNode* left, vtkKdNode* right);
152 
156  void DeleteChildNodes();
157 
159 
162  vtkGetObjectMacro(Left, vtkKdNode);
163  void SetLeft(vtkKdNode* left);
165 
167 
170  vtkGetObjectMacro(Right, vtkKdNode);
171  void SetRight(vtkKdNode* right);
173 
175 
178  vtkGetObjectMacro(Up, vtkKdNode);
179  void SetUp(vtkKdNode* up);
181 
187  int IntersectsBox(
188  double x1, double x2, double y1, double y2, double z1, double z2, int useDataBounds);
189 
195  int IntersectsSphere2(double x, double y, double z, double rSquared, int useDataBounds);
196 
205  int IntersectsRegion(vtkPlanesIntersection* pi, int useDataBounds);
206 
216  int IntersectsCell(
217  vtkCell* cell, int useDataBounds, int cellRegion = -1, double* cellBounds = nullptr);
218 
224  int ContainsBox(
225  double x1, double x2, double y1, double y2, double z1, double z2, int useDataBounds);
226 
232  vtkTypeBool ContainsPoint(double x, double y, double z, int useDataBounds);
233 
239  double GetDistance2ToBoundary(double x, double y, double z, int useDataBounds);
240 
246  double GetDistance2ToBoundary(
247  double x, double y, double z, double* boundaryPt, int useDataBounds);
248 
255  double GetDistance2ToInnerBoundary(double x, double y, double z);
256 
258 
261  void PrintNode(int depth);
262  void PrintVerboseNode(int depth);
264 
265 protected:
266  vtkKdNode();
267  ~vtkKdNode() override;
268 
269 private:
270  double GetDistance2ToBoundaryPrivate(
271  double x, double y, double z, double* boundaryPt, int innerBoundaryOnly, int useDataBounds);
272 
273  double Min[3]; // spatial bounds of node
274  double Max[3]; // spatial bounds of node
275  double MinVal[3]; // spatial bounds of data within node
276  double MaxVal[3]; // spatial bounds of data within node
277  int NumberOfPoints;
278 
279  vtkKdNode* Up;
280 
281  vtkKdNode* Left;
282  vtkKdNode* Right;
283 
284  int Dim;
285 
286  int ID; // region id
287 
288  int MinID;
289  int MaxID;
290 
291  vtkKdNode(const vtkKdNode&) = delete;
292  void operator=(const vtkKdNode&) = delete;
293 };
294 
295 VTK_ABI_NAMESPACE_END
296 #endif
double * GetMinDataBounds()
Get a pointer to the 3 data bound minima (xmin, ymin and zmin) or the 3 data bound maxima (xmax...
Definition: vtkKdNode.h:110
void GetBounds(T a, double bds[6])
double * GetMinBounds()
Get a pointer to the 3 bound minima (xmin, ymin and zmin) or the 3 bound maxima (xmax, ymax, zmax).
Definition: vtkKdNode.h:93
This class represents a single spatial region in an 3D axis aligned binary spatial partitioning...
Definition: vtkKdNode.h:31
abstract base class for most VTK objects
Definition: vtkObject.h:51
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
A vtkPlanesIntersection object is a vtkPlanes object that can compute whether the arbitrary convex re...
double * GetMaxDataBounds()
Definition: vtkKdNode.h:111
int vtkTypeBool
Definition: vtkABI.h:64
double * GetMaxBounds()
Definition: vtkKdNode.h:94
abstract class to specify cell behavior
Definition: vtkCell.h:49
a simple class to control print indentation
Definition: vtkIndent.h:28
#define VTK_SIZEHINT(...)
void SetBounds(const double b[6])
Set/Get the bounds of the spatial region represented by this node.
Definition: vtkKdNode.h:69
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...