VTK  9.2.6
vtkIncrementalOctreeNode.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkIncrementalOctreeNode.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=========================================================================*/
62#ifndef vtkIncrementalOctreeNode_h
63#define vtkIncrementalOctreeNode_h
64
65#include "vtkCommonDataModelModule.h" // For export macro
66#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_1_0
67#include "vtkObject.h"
68
69class vtkPoints;
70class vtkIdList;
71
72class VTKCOMMONDATAMODEL_EXPORT vtkIncrementalOctreeNode : public vtkObject
73{
74public:
76 void PrintSelf(ostream& os, vtkIndent indent) override;
77
79
81
84 vtkGetMacro(NumberOfPoints, int);
86
88
91 vtkGetObjectMacro(PointIdSet, vtkIdList);
93
98
103 void SetBounds(double x1, double x2, double y1, double y2, double z1, double z2);
104
109 void GetBounds(double bounds[6]) const;
110
112
115 vtkGetVector3Macro(MinBounds, double);
117
119
122 vtkGetVector3Macro(MaxBounds, double);
124
130 {
131 return this->NumberOfPoints ? this->MinDataBounds : this->MinBounds;
132 }
133
139 {
140 return this->NumberOfPoints ? this->MaxDataBounds : this->MaxBounds;
141 }
142
146 int IsLeaf() { return (this->Children == nullptr) ? 1 : 0; }
147
153 int GetChildIndex(const double point[3]);
154
159 vtkIncrementalOctreeNode* GetChild(int i) { return this->Children[i]; }
160
165 vtkTypeBool ContainsPoint(const double pnt[3]);
166
171 vtkTypeBool ContainsPointByData(const double pnt[3]);
172
174
191 VTK_DEPRECATED_IN_9_1_0("Use the version with numberOfNodes parameter instead.")
192 int InsertPoint(
193 vtkPoints* points, const double newPnt[3], int maxPts, vtkIdType* pntId, int ptMode);
194 int InsertPoint(vtkPoints* points, const double newPnt[3], int maxPts, vtkIdType* pntId,
195 int ptMode, int& numberOfNodes);
197
203 double GetDistance2ToInnerBoundary(const double point[3], vtkIncrementalOctreeNode* rootNode);
204
210 double GetDistance2ToBoundary(
211 const double point[3], vtkIncrementalOctreeNode* rootNode, int checkData);
212
218 double GetDistance2ToBoundary(
219 const double point[3], double closest[3], vtkIncrementalOctreeNode* rootNode, int checkData);
220
225 void ExportAllPointIdsByInsertion(vtkIdList* idList);
226
233 void ExportAllPointIdsByDirectSet(vtkIdType* pntIdx, vtkIdList* idList);
235
240 int GetNumberOfLevels() const;
246 int GetID() const { return this->ID; }
247 vtkIdList* GetPointIds() const { return this->PointIdSet; }
248
249protected:
252
253private:
257 int NumberOfPoints;
258
262 double MinBounds[3];
263
267 double MaxBounds[3];
268
274 double MinDataBounds[3];
275
281 double MaxDataBounds[3];
282
287 vtkIdList* PointIdSet;
288
294 int ID;
295
300
304 vtkIncrementalOctreeNode** Children;
305
309 virtual void SetParent(vtkIncrementalOctreeNode*);
310
314 virtual void SetPointIdSet(vtkIdList*);
315
334 int CreateChildNodes(vtkPoints* points, vtkIdList* pntIds, const double newPnt[3],
335 vtkIdType* pntIdx, int maxPts, int ptMode, int& numberOfNodes);
336
341 void CreatePointIdSet(int initSize, int growSize);
342
346 void DeletePointIdSet();
347
353 void UpdateCounterAndDataBounds(const double point[3]);
354
364 int UpdateCounterAndDataBounds(const double point[3], int nHits, int updateData);
365
376 int UpdateCounterAndDataBoundsRecursively(
377 const double point[3], int nHits, int updateData, vtkIncrementalOctreeNode* endNode);
378
385 int ContainsDuplicatePointsOnly(const double pnt[3]);
386
400 void SeperateExactlyDuplicatePointsFromNewInsertion(vtkPoints* points, vtkIdList* pntIds,
401 const double newPnt[3], vtkIdType* pntIdx, int maxPts, int ptMode);
402
410 double GetDistance2ToBoundary(const double point[3], double closest[3], int innerOnly,
411 vtkIncrementalOctreeNode* rootNode, int checkData = 0);
412
414 void operator=(const vtkIncrementalOctreeNode&) = delete;
415};
416
417// In-lined for performance
418inline int vtkIncrementalOctreeNode::GetChildIndex(const double point[3])
419{
420 // Children[0]->MaxBounds[] is exactly the center point of this node.
421 return int(point[0] > this->Children[0]->MaxBounds[0]) +
422 ((int(point[1] > this->Children[0]->MaxBounds[1])) << 1) +
423 ((int(point[2] > this->Children[0]->MaxBounds[2])) << 2);
424}
425
426// In-lined for performance
428{
429 return (
430 (this->MinBounds[0] < pnt[0] && pnt[0] <= this->MaxBounds[0] && this->MinBounds[1] < pnt[1] &&
431 pnt[1] <= this->MaxBounds[1] && this->MinBounds[2] < pnt[2] && pnt[2] <= this->MaxBounds[2])
432 ? 1
433 : 0);
434}
435
436// In-lined for performance
438{
439 return ((this->MinDataBounds[0] <= pnt[0] && pnt[0] <= this->MaxDataBounds[0] &&
440 this->MinDataBounds[1] <= pnt[1] && pnt[1] <= this->MaxDataBounds[1] &&
441 this->MinDataBounds[2] <= pnt[2] && pnt[2] <= this->MaxDataBounds[2])
442 ? 1
443 : 0);
444}
445
446// In-lined for performance
447inline int vtkIncrementalOctreeNode::ContainsDuplicatePointsOnly(const double pnt[3])
448{
449 return ((this->MinDataBounds[0] == pnt[0] && pnt[0] == this->MaxDataBounds[0] &&
450 this->MinDataBounds[1] == pnt[1] && pnt[1] == this->MaxDataBounds[1] &&
451 this->MinDataBounds[2] == pnt[2] && pnt[2] == this->MaxDataBounds[2])
452 ? 1
453 : 0);
454}
455
456// In-lined for performance
457inline void vtkIncrementalOctreeNode::UpdateCounterAndDataBounds(const double point[3])
458{
459 this->NumberOfPoints++;
460
461 this->MinDataBounds[0] = (point[0] < this->MinDataBounds[0]) ? point[0] : this->MinDataBounds[0];
462 this->MinDataBounds[1] = (point[1] < this->MinDataBounds[1]) ? point[1] : this->MinDataBounds[1];
463 this->MinDataBounds[2] = (point[2] < this->MinDataBounds[2]) ? point[2] : this->MinDataBounds[2];
464 this->MaxDataBounds[0] = (point[0] > this->MaxDataBounds[0]) ? point[0] : this->MaxDataBounds[0];
465 this->MaxDataBounds[1] = (point[1] > this->MaxDataBounds[1]) ? point[1] : this->MaxDataBounds[1];
466 this->MaxDataBounds[2] = (point[2] > this->MaxDataBounds[2]) ? point[2] : this->MaxDataBounds[2];
467}
468
469// In-lined for performance
470inline int vtkIncrementalOctreeNode::UpdateCounterAndDataBoundsRecursively(
471 const double point[3], int nHits, int updateData, vtkIncrementalOctreeNode* endNode)
472{
473 int updated = this->UpdateCounterAndDataBounds(point, nHits, updateData);
474
475 return ((this->Parent == endNode)
476 ? updated
477 : this->Parent->UpdateCounterAndDataBoundsRecursively(point, nHits, updated, endNode));
478}
479#endif
list of point or cell ids
Definition: vtkIdList.h:34
Octree node constituting incremental octree (in support of both point location and point insertion)
void GetBounds(double bounds[6]) const
Get the spatial bounding box of the node.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
double * GetMaxDataBounds()
Get access to MaxDataBounds.
vtkIncrementalOctreeNode * GetChild(int i)
Get quick access to a child of this node.
void DeleteChildNodes()
Delete the eight child nodes.
void SetBounds(double x1, double x2, double y1, double y2, double z1, double z2)
Set the spatial bounding box of the node.
~vtkIncrementalOctreeNode() override
double * GetMinDataBounds()
Get access to MinDataBounds.
vtkTypeBool ContainsPointByData(const double pnt[3])
A point is in a node, in terms of data, if and only if MinDataBounds[i] <= p[i] <= MaxDataBounds[i].
int GetChildIndex(const double point[3])
Determine which specific child / octant contains a given point.
int IsLeaf()
Determine whether or not this node is a leaf.
static vtkIncrementalOctreeNode * New()
vtkTypeBool ContainsPoint(const double pnt[3])
A point is in a node if and only if MinBounds[i] < p[i] <= MaxBounds[i], which allows a node to be di...
a simple class to control print indentation
Definition: vtkIndent.h:40
abstract base class for most VTK objects
Definition: vtkObject.h:63
represent and manipulate 3D points
Definition: vtkPoints.h:40
@ point
Definition: vtkX3D.h:242
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_DEPRECATED_IN_9_1_0(reason)
int vtkIdType
Definition: vtkType.h:332