VTK  9.3.0
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 
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 
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 
217  vtkCell* cell, int useDataBounds, int cellRegion = -1, double* cellBounds = nullptr);
218 
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 
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:
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
abstract class to specify cell behavior
Definition: vtkCell.h:50
a simple class to control print indentation
Definition: vtkIndent.h:29
This class represents a single spatial region in an 3D axis aligned binary spatial partitioning.
Definition: vtkKdNode.h:32
int IntersectsRegion(vtkPlanesIntersection *pi, int useDataBounds)
A vtkPlanesIntersection object represents a convex 3D region bounded by planes, and it is capable of ...
void SetLeft(vtkKdNode *left)
Set/Get a pointer to the left child of this node.
void SetRight(vtkKdNode *right)
Set/Get a pointer to the right child of this node.
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 PrintVerboseNode(int depth)
For debugging purposes, print out this node.
void SetMinBounds(const double *mb)
Set the xmin, ymin and zmin value of the bounds of this region.
double * GetMinBounds()
Get a pointer to the 3 bound minima (xmin, ymin and zmin) or the 3 bound maxima (xmax,...
Definition: vtkKdNode.h:93
void SetBounds(const double b[6])
Set/Get the bounds of the spatial region represented by this node.
Definition: vtkKdNode.h:69
int IntersectsBox(double x1, double x2, double y1, double y2, double z1, double z2, int useDataBounds)
Return 1 if this spatial region intersects the axis-aligned box given by the bounds passed in.
int ContainsBox(double x1, double x2, double y1, double y2, double z1, double z2, int useDataBounds)
Return 1 if this spatial region entirely contains a box specified by it's bounds.
void SetMinDataBounds(const double *mb)
Set the xmin, ymin and zmin value of the bounds of this data within this region.
void SetDataBounds(double x1, double x2, double y1, double y2, double z1, double z2)
Set/Get the bounds of the points contained in this spatial region.
void SetMaxBounds(const double *mb)
Set the xmax, ymax and zmax value of the bounds of this region.
int IntersectsCell(vtkCell *cell, int useDataBounds, int cellRegion=-1, double *cellBounds=nullptr)
Return 1 if the cell specified intersects this region.
void SetMaxDataBounds(const double *mb)
Set the xmax, ymax and zmax value of the bounds of this data within this region.
double GetDistance2ToInnerBoundary(double x, double y, double z)
Calculate the distance from the specified point (which is required to be inside this spatial region) ...
int IntersectsSphere2(double x, double y, double z, double rSquared, int useDataBounds)
Return 1 if this spatial region intersects a sphere described by it's center and the square of it's r...
void AddChildNodes(vtkKdNode *left, vtkKdNode *right)
Add the left and right children.
double * GetMaxDataBounds()
Definition: vtkKdNode.h:111
void SetUp(vtkKdNode *up)
Set/Get a pointer to the parent of this node.
void GetDataBounds(double *b) const
Set/Get the bounds of the points contained in this spatial region.
void SetDataBounds(float *v)
Given a pointer to NumberOfPoints points, set the DataBounds of this node to the bounds of these poin...
double * GetMaxBounds()
Definition: vtkKdNode.h:94
vtkTypeBool ContainsPoint(double x, double y, double z, int useDataBounds)
Return 1 if this spatial region entirely contains the given point.
static vtkKdNode * New()
double GetDistance2ToBoundary(double x, double y, double z, double *boundaryPt, int useDataBounds)
Calculate the distance squared from any point to the boundary of this region.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetBounds(double x1, double x2, double y1, double y2, double z1, double z2)
Set/Get the bounds of the spatial region represented by this node.
void DeleteChildNodes()
Delete the left and right children.
virtual double GetDivisionPosition()
Get the location of the division plane along the axis the region is divided.
void PrintNode(int depth)
For debugging purposes, print out this node.
~vtkKdNode() override
double GetDistance2ToBoundary(double x, double y, double z, int useDataBounds)
Calculate the distance squared from any point to the boundary of this region.
void GetBounds(double *b) const
Set/Get the bounds of the spatial region represented by this node.
abstract base class for most VTK objects
Definition: vtkObject.h:52
A vtkPlanesIntersection object is a vtkPlanes object that can compute whether the arbitrary convex re...
int vtkTypeBool
Definition: vtkABI.h:64
#define VTK_SIZEHINT(...)