VTK  9.1.0
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=========================================================================*/
59#ifndef vtkIncrementalOctreeNode_h
60#define vtkIncrementalOctreeNode_h
61
62#include "vtkCommonDataModelModule.h" // For export macro
63#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_1_0
64#include "vtkObject.h"
65
66class vtkPoints;
67class vtkIdList;
68
69class VTKCOMMONDATAMODEL_EXPORT vtkIncrementalOctreeNode : public vtkObject
70{
71public:
73 void PrintSelf(ostream& os, vtkIndent indent) override;
74
76
78
81 vtkGetMacro(NumberOfPoints, int);
83
85
88 vtkGetObjectMacro(PointIdSet, vtkIdList);
90
95
100 void SetBounds(double x1, double x2, double y1, double y2, double z1, double z2);
101
106 void GetBounds(double bounds[6]) const;
107
109
112 vtkGetVector3Macro(MinBounds, double);
114
116
119 vtkGetVector3Macro(MaxBounds, double);
121
127 {
128 return this->NumberOfPoints ? this->MinDataBounds : this->MinBounds;
129 }
130
136 {
137 return this->NumberOfPoints ? this->MaxDataBounds : this->MaxBounds;
138 }
139
143 int IsLeaf() { return (this->Children == nullptr) ? 1 : 0; }
144
150 int GetChildIndex(const double point[3]);
151
156 vtkIncrementalOctreeNode* GetChild(int i) { return this->Children[i]; }
157
162 vtkTypeBool ContainsPoint(const double pnt[3]);
163
168 vtkTypeBool ContainsPointByData(const double pnt[3]);
169
171
188 VTK_DEPRECATED_IN_9_1_0("Use the version with numberOfNodes parameter instead.")
189 int InsertPoint(
190 vtkPoints* points, const double newPnt[3], int maxPts, vtkIdType* pntId, int ptMode);
191 int InsertPoint(vtkPoints* points, const double newPnt[3], int maxPts, vtkIdType* pntId,
192 int ptMode, int& numberOfNodes);
194
200 double GetDistance2ToInnerBoundary(const double point[3], vtkIncrementalOctreeNode* rootNode);
201
207 double GetDistance2ToBoundary(
208 const double point[3], vtkIncrementalOctreeNode* rootNode, int checkData);
209
215 double GetDistance2ToBoundary(
216 const double point[3], double closest[3], vtkIncrementalOctreeNode* rootNode, int checkData);
217
222 void ExportAllPointIdsByInsertion(vtkIdList* idList);
223
230 void ExportAllPointIdsByDirectSet(vtkIdType* pntIdx, vtkIdList* idList);
232
237 int GetNumberOfLevels() const;
243 int GetID() const { return this->ID; }
244 vtkIdList* GetPointIds() const { return this->PointIdSet; }
245
246protected:
249
250private:
254 int NumberOfPoints;
255
259 double MinBounds[3];
260
264 double MaxBounds[3];
265
271 double MinDataBounds[3];
272
278 double MaxDataBounds[3];
279
284 vtkIdList* PointIdSet;
285
291 int ID;
292
297
301 vtkIncrementalOctreeNode** Children;
302
306 virtual void SetParent(vtkIncrementalOctreeNode*);
307
311 virtual void SetPointIdSet(vtkIdList*);
312
331 int CreateChildNodes(vtkPoints* points, vtkIdList* pntIds, const double newPnt[3],
332 vtkIdType* pntIdx, int maxPts, int ptMode, int& numberOfNodes);
333
338 void CreatePointIdSet(int initSize, int growSize);
339
343 void DeletePointIdSet();
344
350 void UpdateCounterAndDataBounds(const double point[3]);
351
361 int UpdateCounterAndDataBounds(const double point[3], int nHits, int updateData);
362
373 int UpdateCounterAndDataBoundsRecursively(
374 const double point[3], int nHits, int updateData, vtkIncrementalOctreeNode* endNode);
375
382 int ContainsDuplicatePointsOnly(const double pnt[3]);
383
397 void SeperateExactlyDuplicatePointsFromNewInsertion(vtkPoints* points, vtkIdList* pntIds,
398 const double newPnt[3], vtkIdType* pntIdx, int maxPts, int ptMode);
399
407 double GetDistance2ToBoundary(const double point[3], double closest[3], int innerOnly,
408 vtkIncrementalOctreeNode* rootNode, int checkData = 0);
409
411 void operator=(const vtkIncrementalOctreeNode&) = delete;
412};
413
414// In-lined for performance
416{
417 // Children[0]->MaxBounds[] is exactly the center point of this node.
418 return int(point[0] > this->Children[0]->MaxBounds[0]) +
419 ((int(point[1] > this->Children[0]->MaxBounds[1])) << 1) +
420 ((int(point[2] > this->Children[0]->MaxBounds[2])) << 2);
421}
422
423// In-lined for performance
425{
426 return (
427 (this->MinBounds[0] < pnt[0] && pnt[0] <= this->MaxBounds[0] && this->MinBounds[1] < pnt[1] &&
428 pnt[1] <= this->MaxBounds[1] && this->MinBounds[2] < pnt[2] && pnt[2] <= this->MaxBounds[2])
429 ? 1
430 : 0);
431}
432
433// In-lined for performance
435{
436 return ((this->MinDataBounds[0] <= pnt[0] && pnt[0] <= this->MaxDataBounds[0] &&
437 this->MinDataBounds[1] <= pnt[1] && pnt[1] <= this->MaxDataBounds[1] &&
438 this->MinDataBounds[2] <= pnt[2] && pnt[2] <= this->MaxDataBounds[2])
439 ? 1
440 : 0);
441}
442
443// In-lined for performance
444inline int vtkIncrementalOctreeNode::ContainsDuplicatePointsOnly(const double pnt[3])
445{
446 return ((this->MinDataBounds[0] == pnt[0] && pnt[0] == this->MaxDataBounds[0] &&
447 this->MinDataBounds[1] == pnt[1] && pnt[1] == this->MaxDataBounds[1] &&
448 this->MinDataBounds[2] == pnt[2] && pnt[2] == this->MaxDataBounds[2])
449 ? 1
450 : 0);
451}
452
453// In-lined for performance
454inline void vtkIncrementalOctreeNode::UpdateCounterAndDataBounds(const double point[3])
455{
456 this->NumberOfPoints++;
457
458 this->MinDataBounds[0] = (point[0] < this->MinDataBounds[0]) ? point[0] : this->MinDataBounds[0];
459 this->MinDataBounds[1] = (point[1] < this->MinDataBounds[1]) ? point[1] : this->MinDataBounds[1];
460 this->MinDataBounds[2] = (point[2] < this->MinDataBounds[2]) ? point[2] : this->MinDataBounds[2];
461 this->MaxDataBounds[0] = (point[0] > this->MaxDataBounds[0]) ? point[0] : this->MaxDataBounds[0];
462 this->MaxDataBounds[1] = (point[1] > this->MaxDataBounds[1]) ? point[1] : this->MaxDataBounds[1];
463 this->MaxDataBounds[2] = (point[2] > this->MaxDataBounds[2]) ? point[2] : this->MaxDataBounds[2];
464}
465
466// In-lined for performance
467inline int vtkIncrementalOctreeNode::UpdateCounterAndDataBoundsRecursively(
468 const double point[3], int nHits, int updateData, vtkIncrementalOctreeNode* endNode)
469{
470 int updated = this->UpdateCounterAndDataBounds(point, nHits, updateData);
471
472 return ((this->Parent == endNode)
473 ? updated
474 : this->Parent->UpdateCounterAndDataBoundsRecursively(point, nHits, updated, endNode));
475}
476#endif
list of point or cell ids
Definition: vtkIdList.h:140
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:113
abstract base class for most VTK objects
Definition: vtkObject.h:73
represent and manipulate 3D points
Definition: vtkPoints.h:143
@ point
Definition: vtkX3D.h:242
@ points
Definition: vtkX3D.h:452
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_DEPRECATED_IN_9_1_0(reason)
int vtkIdType
Definition: vtkType.h:332