VTK  9.1.0
vtkKdTree.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkKdTree.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 =========================================================================*/
15 /*----------------------------------------------------------------------------
16  Copyright (c) Sandia Corporation
17  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
18 ----------------------------------------------------------------------------*/
19 
121 #ifndef vtkKdTree_h
122 #define vtkKdTree_h
123 
124 #include "vtkCommonDataModelModule.h" // For export macro
125 #include "vtkLocator.h"
126 
127 class vtkTimerLog;
128 class vtkIdList;
129 class vtkIdTypeArray;
130 class vtkIntArray;
131 class vtkPointSet;
132 class vtkPoints;
133 class vtkCellArray;
134 class vtkCell;
135 class vtkKdNode;
136 class vtkBSPCuts;
137 class vtkBSPIntersections;
139 
140 class VTKCOMMONDATAMODEL_EXPORT vtkKdTree : public vtkLocator
141 {
142 public:
143  vtkTypeMacro(vtkKdTree, vtkLocator);
144  void PrintSelf(ostream& os, vtkIndent indent) override;
145 
146  static vtkKdTree* New();
147 
149 
152  vtkBooleanMacro(Timing, vtkTypeBool);
153  vtkSetMacro(Timing, vtkTypeBool);
154  vtkGetMacro(Timing, vtkTypeBool);
156 
158 
161  vtkSetMacro(MinCells, int);
162  vtkGetMacro(MinCells, int);
164 
172  vtkGetMacro(NumberOfRegionsOrLess, int);
173  vtkSetMacro(NumberOfRegionsOrLess, int);
174 
182  vtkGetMacro(NumberOfRegionsOrMore, int);
183  vtkSetMacro(NumberOfRegionsOrMore, int);
184 
192  vtkGetMacro(FudgeFactor, double);
193  vtkSetMacro(FudgeFactor, double);
194 
200  vtkGetObjectMacro(Cuts, vtkBSPCuts);
201 
208  void SetCuts(vtkBSPCuts* cuts);
209 
214 
219 
224 
229 
234 
239 
244 
259  void SetDataSet(vtkDataSet* set) override;
260 
265  virtual void AddDataSet(vtkDataSet* set);
266 
268 
271  virtual void RemoveDataSet(int index);
272  virtual void RemoveDataSet(vtkDataSet* set);
273  virtual void RemoveAllDataSets();
275 
280 
291 
296  vtkDataSet* GetDataSet() override { return this->GetDataSet(0); }
297 
299 
302  vtkGetObjectMacro(DataSets, vtkDataSetCollection);
304 
310 
315  void GetBounds(double* bounds);
316 
325  void SetNewBounds(double* bounds);
326 
328 
331  vtkGetMacro(NumberOfRegions, int);
333 
337  void GetRegionBounds(int regionID, double bounds[6]);
338 
342  void GetRegionDataBounds(int regionID, double bounds[6]);
343 
345 
348  void PrintTree();
351 
355  void PrintRegion(int id);
356 
369  void CreateCellLists(int dataSetIndex, int* regionReqList, int reqListSize);
370  void CreateCellLists(vtkDataSet* set, int* regionReqList, int reqListSize);
371  void CreateCellLists(int* regionReqList, int listSize);
373 
375 
382  vtkSetMacro(IncludeRegionBoundaryCells, vtkTypeBool);
383  vtkGetMacro(IncludeRegionBoundaryCells, vtkTypeBool);
384  vtkBooleanMacro(IncludeRegionBoundaryCells, vtkTypeBool);
386 
391 
396  vtkIdList* GetCellList(int regionID);
397 
409 
411 
432  vtkIntArray* regions, int set, vtkIdList* inRegionCells, vtkIdList* onBoundaryCells);
434  vtkIntArray* regions, vtkDataSet* set, vtkIdList* inRegionCells, vtkIdList* onBoundaryCells);
436  vtkIntArray* regions, vtkIdList* inRegionCells, vtkIdList* onBoundaryCells);
438 
440 
447  int GetRegionContainingCell(int set, vtkIdType cellID);
450 
460 
464  int GetRegionContainingPoint(double x, double y, double z);
465 
471  void BuildLocator() override;
472 
487  int MinimalNumberOfConvexSubRegions(vtkIntArray* regionIdList, double** convexRegionBounds);
488 
497  const double directionOfProjection[3], vtkIntArray* orderedList);
498 
507  vtkIntArray* regionIds, const double directionOfProjection[3], vtkIntArray* orderedList);
508 
517  const double directionOfProjection[3], vtkIntArray* orderedList);
518 
527  vtkIntArray* regionIds, const double directionOfProjection[3], vtkIntArray* orderedList);
528 
530 
545  void BuildLocatorFromPoints(vtkPoints** ptArray, int numPtArrays);
547 
563 
565 
570  vtkIdType FindPoint(double* x);
571  vtkIdType FindPoint(double x, double y, double z);
573 
575 
580  vtkIdType FindClosestPoint(double* x, double& dist2);
581  vtkIdType FindClosestPoint(double x, double y, double z, double& dist2);
583 
589  vtkIdType FindClosestPointWithinRadius(double radius, const double x[3], double& dist2);
590 
592 
597  vtkIdType FindClosestPointInRegion(int regionId, double* x, double& dist2);
598  vtkIdType FindClosestPointInRegion(int regionId, double x, double y, double z, double& dist2);
600 
607  void FindPointsWithinRadius(double R, const double x[3], vtkIdList* result);
608 
617  void FindClosestNPoints(int N, const double x[3], vtkIdList* result);
618 
624 
629  void FreeSearchStructure() override;
630 
636  void GenerateRepresentation(int level, vtkPolyData* pd) override;
637 
642  void GenerateRepresentation(int* regionList, int len, vtkPolyData* pd);
643 
645 
651  vtkBooleanMacro(GenerateRepresentationUsingDataBounds, vtkTypeBool);
652  vtkSetMacro(GenerateRepresentationUsingDataBounds, vtkTypeBool);
653  vtkGetMacro(GenerateRepresentationUsingDataBounds, vtkTypeBool);
655 
659  virtual void PrintTiming(ostream& os, vtkIndent indent);
660 
665  virtual int NewGeometry();
666 
672  virtual int NewGeometry(vtkDataSet** sets, int numDataSets);
673 
679  virtual void InvalidateGeometry();
680 
687 
694  void FindPointsInArea(double* area, vtkIdTypeArray* ids, bool clearArray = true);
695 
696 protected:
698  ~vtkKdTree() override;
699 
702 
704 
705  int ProcessUserDefinedCuts(double* bounds);
706 
707  void SetCuts(vtkBSPCuts* cuts, int userDefined);
708 
715 
723  int DivideTest(int numberOfPoints, int level);
724 
725  enum
726  {
727  XDIM = 0, // don't change these values
728  YDIM = 1,
729  ZDIM = 2
730  };
731 
733 
735  vtkKdNode** RegionList; // indexed by region ID
736 
738 
739  static void DeleteAllDescendants(vtkKdNode* nd);
740 
742  virtual int SelectCutDirection(vtkKdNode* kd);
743  void SetActualLevel() { this->Level = vtkKdTree::ComputeLevel(this->Top); }
744 
750  void GetRegionsAtLevel(int level, vtkKdNode** nodes);
751 
757  static void GetLeafNodeIds(vtkKdNode* node, vtkIntArray* ids);
758 
764 
770  int GetDataSetsNumberOfCells(int set1, int set2);
771 
778  void ComputeCellCenter(vtkDataSet* set, int cellId, float* center);
779  void ComputeCellCenter(vtkDataSet* set, int cellId, double* center);
780 
791  float* ComputeCellCenters(int set);
793 
795 
801  void UpdateProgress(double amount);
802 
804 
807  vtkSetClampMacro(Progress, double, 0.0, 1.0);
808  vtkGetMacro(Progress, double);
810 
811 protected:
812  // So that each suboperation can report progress
813  // in [0,1], yet we will be able to report a global
814  // progress. Sub-operations must use UpdateSubOperationProgress()
815  // for this to work.
818 
819  // Update progress for a sub-operation. \c amount goes from 0.0 to 1.0.
820  // Actual progress is given by
821  // (this->ProgressOffset + this->ProgressScale* amount).
822  void UpdateSubOperationProgress(double amount);
823 
824  static void _SetNewBounds(vtkKdNode* kd, double* b, int* fixDim);
825  static void CopyChildNodes(vtkKdNode* to, vtkKdNode* from);
826  static void CopyKdNode(vtkKdNode* to, vtkKdNode* from);
828  static void ZeroNumberOfPoints(vtkKdNode* kd);
829 
830  // Recursive helper for public FindPointsWithinRadius
831  void FindPointsWithinRadius(vtkKdNode* node, double R2, const double x[3], vtkIdList* ids);
832 
833  // Recursive helper for public FindPointsWithinRadius
835 
836  // Recursive helper for public FindPointsInArea
837  void FindPointsInArea(vtkKdNode* node, double* area, vtkIdTypeArray* ids);
838 
839  // Recursive helper for public FindPointsInArea
841 
842  int DivideRegion(vtkKdNode* kd, float* c1, int* ids, int nlevels);
843 
844  void DoMedianFind(vtkKdNode* kd, float* c1, int* ids, int d1, int d2, int d3);
845 
847 
848  struct _cellList
849  {
850  vtkDataSet* dataSet; // cell lists for which data set
851  int* regionIds; // nullptr if listing all regions
852  int nRegions;
856  };
857 
859  vtkIdList* GetList(int regionId, vtkIdList** which);
860 
861  void ComputeCellCenter(vtkCell* cell, double* center, double* weights);
862 
865  vtkKdNode* kd, vtkPoints* pts, vtkCellArray* polys, int level);
866 
869  vtkKdNode* kd, vtkPoints* pts, vtkCellArray* polys, int level);
870 
871  void AddPolys(vtkKdNode* kd, vtkPoints* pts, vtkCellArray* polys);
872 
873  void _printTree(int verbose);
874 
876  int regionId, float* point, int** pointsSoFar, int* len, float tolerance, float tolerance2);
877 
878  int SearchRegionForDuplicate(float* point, int* pointsSoFar, int len, float tolerance2);
879 
880  int _FindClosestPointInRegion(int regionId, double x, double y, double z, double& dist2);
881 
883  double x, double y, double z, double radius, int skipRegion, double& dist2);
884 
886  vtkIntArray* IdsOfInterest, const double dop[3], vtkIntArray* orderedList);
887 
889  vtkIntArray* IdsOfInterest, const double dir[3], int nextId);
890 
892  vtkIntArray* IdsOfInterest, const double pos[3], vtkIntArray* orderedList);
893 
895  vtkIntArray* IdsOfInterest, const double pos[3], int nextId);
896 
897  static int __ConvexSubRegions(int* ids, int len, vtkKdNode* tree, vtkKdNode** nodes);
898  static int FoundId(vtkIntArray* idArray, int id);
899 
900  void SetInputDataInfo(int i, int dims[3], double origin[3], double spacing[3]);
901  int CheckInputDataInfo(int i, int dims[3], double origin[3], double spacing[3]);
903 
904  static void __printTree(vtkKdNode* kd, int depth, int verbose);
905 
906  static int MidValue(int dim, float* c1, int nvals, double& coord);
907 
908  static int Select(int dim, float* c1, int* ids, int nvals, double& coord);
909  static float FindMaxLeftHalf(int dim, float* c1, int K);
910  static void _Select(int dim, float* X, int* ids, int L, int R, int K);
911 
912  static int ComputeLevel(vtkKdNode* kd);
913  static int SelfOrder(int id, vtkKdNode* kd);
914  static int findRegion(vtkKdNode* node, float x, float y, float z);
915  static int findRegion(vtkKdNode* node, double x, double y, double z);
916 
917  static vtkKdNode** _GetRegionsAtLevel(int level, vtkKdNode** nodes, vtkKdNode* kd);
918 
919  static void AddNewRegions(vtkKdNode* kd, float* c1, int midpt, int dim, double coord);
920 
921  void NewPartitioningRequest(int req);
922 
925 
927  double CellBoundsCache[6]; // to optimize IntersectsCell()
928 
930 
931  struct _cellList CellList;
932 
933  // Region Ids, by data set by cell id - this list is large (one
934  // int per cell) but accelerates creation of cell lists
935 
937 
938  int MinCells;
939  int NumberOfRegions; // number of leaf nodes
940 
942  double FudgeFactor; // a very small distance, relative to the dataset's size
943 
944  // These instance variables are used by the special locator created
945  // to find duplicate points. (BuildLocatorFromPoints)
946 
951 
952  float MaxWidth;
953 
954  // These Last* values are here to save state so we can
955  // determine later if k-d tree must be rebuilt.
956 
960  unsigned long* LastDataSetObserverTags;
963  double* LastBounds;
966 
968  double Progress;
969 
970  vtkKdTree(const vtkKdTree&) = delete;
971  void operator=(const vtkKdTree&) = delete;
972 };
973 #endif
vtkKdTree::CopyChildNodes
static void CopyChildNodes(vtkKdNode *to, vtkKdNode *from)
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:143
vtkKdTree::GetBounds
void GetBounds(double *bounds)
Get the spatial bounds of the entire k-d tree space.
vtkKdTree::CreateCellLists
void CreateCellLists(vtkDataSet *set, int *regionReqList, int reqListSize)
vtkKdTree::TimerLog
vtkTimerLog * TimerLog
Definition: vtkKdTree.h:737
vtkKdNode
This class represents a single spatial region in an 3D axis aligned binary spatial partitioning.
Definition: vtkKdNode.h:43
vtkKdTree::GetList
vtkIdList * GetList(int regionId, vtkIdList **which)
vtkKdTree::OmitYPartitioning
void OmitYPartitioning()
Omit partitions along the Y axis, yielding shafts in the Y direction.
vtkKdTree::GetCellLists
vtkIdType GetCellLists(vtkIntArray *regions, int set, vtkIdList *inRegionCells, vtkIdList *onBoundaryCells)
For a list of regions, get two cell lists.
vtkKdTree::AddPolys
void AddPolys(vtkKdNode *kd, vtkPoints *pts, vtkCellArray *polys)
vtkKdTree::GetNumberOfCells
int GetNumberOfCells()
Returns the total number of cells in all the data sets.
vtkKdTree::RemoveAllDataSets
virtual void RemoveAllDataSets()
Remove the given data set.
vtkKdTree::PrintTiming
virtual void PrintTiming(ostream &os, vtkIndent indent)
Print timing of k-d tree build.
vtkKdTree::OmitZXPartitioning
void OmitZXPartitioning()
Omit partitions along the Z and X axes, yielding slabs along Y.
vtkKdTree::OmitXPartitioning
void OmitXPartitioning()
Omit partitions along the X axis, yielding shafts in the X direction.
vtkKdTree::_cellList::nRegions
int nRegions
Definition: vtkKdTree.h:852
vtkKdTree::NewPartitioningRequest
void NewPartitioningRequest(int req)
vtkKdTree::FudgeFactor
double FudgeFactor
Definition: vtkKdTree.h:942
vtkKdTree::_generateRepresentationWholeSpace
void _generateRepresentationWholeSpace(vtkKdNode *kd, vtkPoints *pts, vtkCellArray *polys, int level)
vtkKdTree::LocatorIds
int * LocatorIds
Definition: vtkKdTree.h:949
vtkKdTree::GetDataSetIndex
int GetDataSetIndex(vtkDataSet *set)
Return the index of the given data set.
vtkKdTree::AddDataSet
virtual void AddDataSet(vtkDataSet *set)
This class can compute a spatial decomposition based on the cells in a list of one or more input data...
vtkKdTree::_cellList::emptyList
vtkIdList * emptyList
Definition: vtkKdTree.h:855
vtkKdTree::ComputeCellCenter
void ComputeCellCenter(vtkDataSet *set, int cellId, float *center)
Get or compute the center of one cell.
vtkKdTree::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkKdTree::FindPointsWithinRadius
void FindPointsWithinRadius(double R, const double x[3], vtkIdList *result)
Find all points within a specified radius R of position x.
vtkKdTree::GetRegionContainingCell
int GetRegionContainingCell(vtkDataSet *set, vtkIdType cellID)
Get the id of the region containing the cell centroid.
vtkIdType
int vtkIdType
Definition: vtkType.h:332
vtkKdTree::FindPoint
vtkIdType FindPoint(double *x)
Find the Id of the point that was previously supplied to BuildLocatorFromPoints().
vtkKdTree::BuildMapForDuplicatePoints
vtkIdTypeArray * BuildMapForDuplicatePoints(float tolerance)
This call returns a mapping from the original point IDs supplied to BuildLocatorFromPoints to a subse...
vtkKdTree::_SetNewBounds
static void _SetNewBounds(vtkKdNode *kd, double *b, int *fixDim)
vtkKdTree::InvalidateGeometry
virtual void InvalidateGeometry()
Forget about the last geometry used.
vtkKdTree::_cellList::dataSet
vtkDataSet * dataSet
Definition: vtkKdTree.h:850
vtkKdTree::SetDataSet
void SetDataSet(vtkDataSet *set) override
This class can compute a spatial decomposition based on the cells in a list of one or more input data...
vtkKdTree::SetActualLevel
void SetActualLevel()
Definition: vtkKdTree.h:743
vtkKdTree::_cellList::cells
vtkIdList ** cells
Definition: vtkKdTree.h:853
vtkKdTree::FindPointsInArea
void FindPointsInArea(vtkKdNode *node, double *area, vtkIdTypeArray *ids)
vtkLocator.h
vtkKdTree::ViewOrderAllRegionsInDirection
int ViewOrderAllRegionsInDirection(const double directionOfProjection[3], vtkIntArray *orderedList)
Given a direction of projection (typically obtained with vtkCamera::GetDirectionOfProjection()),...
vtkKdTree::FoundId
static int FoundId(vtkIntArray *idArray, int id)
vtkKdTree::ViewOrderAllRegionsFromPosition
int ViewOrderAllRegionsFromPosition(const double directionOfProjection[3], vtkIntArray *orderedList)
Given a camera position (typically obtained with vtkCamera::GetPosition()), this method,...
vtkKdTree::__printTree
static void __printTree(vtkKdNode *kd, int depth, int verbose)
vtkX3D::dir
@ dir
Definition: vtkX3D.h:330
vtkKdTree::AddNewRegions
static void AddNewRegions(vtkKdNode *kd, float *c1, int midpt, int dim, double coord)
vtkKdTree::FindClosestPointInSphere
int FindClosestPointInSphere(double x, double y, double z, double radius, int skipRegion, double &dist2)
vtkKdTree::LastInputDataInfo
double * LastInputDataInfo
Definition: vtkKdTree.h:962
vtkKdTree::PrintTree
void PrintTree()
Print out nodes of kd tree.
vtkKdTree::Select
static int Select(int dim, float *c1, int *ids, int nvals, double &coord)
vtkKdTree::LastNumPoints
vtkIdType * LastNumPoints
Definition: vtkKdTree.h:964
vtkX3D::center
@ center
Definition: vtkX3D.h:236
vtkKdTree::SearchNeighborsForDuplicate
int SearchNeighborsForDuplicate(int regionId, float *point, int **pointsSoFar, int *len, float tolerance, float tolerance2)
vtkKdTree::CellRegionList
int * CellRegionList
Definition: vtkKdTree.h:936
vtkKdTree::findRegion
static int findRegion(vtkKdNode *node, float x, float y, float z)
vtkKdTree::GenerateRepresentation
void GenerateRepresentation(int *regionList, int len, vtkPolyData *pd)
Generate a polygonal representation of a list of regions.
vtkKdTree::__ViewOrderRegionsFromPosition
static int __ViewOrderRegionsFromPosition(vtkKdNode *node, vtkIntArray *list, vtkIntArray *IdsOfInterest, const double pos[3], int nextId)
vtkKdTree::GetDataSet
vtkDataSet * GetDataSet(int n)
Get the nth defined data set in the spatial partitioning.
vtkKdTree::LastBounds
double * LastBounds
Definition: vtkKdTree.h:963
vtkKdTree::FindClosestPoint
vtkIdType FindClosestPoint(double x, double y, double z, double &dist2)
Find the Id of the point that was previously supplied to BuildLocatorFromPoints() which is closest to...
vtkKdTree::RemoveDataSet
virtual void RemoveDataSet(int index)
Remove the given data set.
vtkKdTree::FindPoint
vtkIdType FindPoint(double x, double y, double z)
Find the Id of the point that was previously supplied to BuildLocatorFromPoints().
vtkKdTree::DivideTest
int DivideTest(int numberOfPoints, int level)
Prior to dividing a region at level "level", of size "numberOfPoints", apply the tests implied by Min...
vtkKdTree::ProgressOffset
double ProgressOffset
Definition: vtkKdTree.h:817
vtkKdTree::ClearLastBuildCache
void ClearLastBuildCache()
vtkKdTree::_ViewOrderRegionsFromPosition
int _ViewOrderRegionsFromPosition(vtkIntArray *IdsOfInterest, const double pos[3], vtkIntArray *orderedList)
vtkKdTree::GetRegionsAtLevel
void GetRegionsAtLevel(int level, vtkKdNode **nodes)
Get back a list of the nodes at a specified level, nodes must be preallocated to hold 2^^(level) node...
vtkKdTree::ComputeCellCenter
void ComputeCellCenter(vtkCell *cell, double *center, double *weights)
vtkKdTree::_cellList::regionIds
int * regionIds
Definition: vtkKdTree.h:851
vtkKdTree::FreeSearchStructure
void FreeSearchStructure() override
Delete the k-d tree data structure.
vtkKdTree::New
static vtkKdTree * New()
vtkKdTree::vtkKdTree
vtkKdTree()
vtkKdTree::AllGetRegionContainingCell
int * AllGetRegionContainingCell()
Get a list (in order by data set by cell id) of the region IDs of the region containing the centroid ...
vtkKdTree::_GetRegionsAtLevel
static vtkKdNode ** _GetRegionsAtLevel(int level, vtkKdNode **nodes, vtkKdNode *kd)
vtkKdTree::GetRegionDataBounds
void GetRegionDataBounds(int regionID, double bounds[6])
Get the bounds of the data within the k-d tree region.
vtkLocator
abstract base class for objects that accelerate spatial searches
Definition: vtkLocator.h:89
vtkKdTree::GenerateRepresentation
void GenerateRepresentation(int level, vtkPolyData *pd) override
Create a polydata representation of the boundaries of the k-d tree regions.
vtkKdTree::FindPointsInArea
void FindPointsInArea(double *area, vtkIdTypeArray *ids, bool clearArray=true)
Fill ids with points found in area.
vtkX3D::level
@ level
Definition: vtkX3D.h:401
vtkKdTree::CreateCellLists
void CreateCellLists(int dataSetIndex, int *regionReqList, int reqListSize)
Create a list for each of the requested regions, listing the IDs of all cells whose centroid falls in...
vtkKdTree::GetCellLists
vtkIdType GetCellLists(vtkIntArray *regions, vtkDataSet *set, vtkIdList *inRegionCells, vtkIdList *onBoundaryCells)
For a list of regions, get two cell lists.
vtkKdTree::BuildLocator
void BuildLocator() override
Create the k-d tree decomposition of the cells of the data set or data sets.
vtkX3D::point
@ point
Definition: vtkX3D.h:242
vtkBSPIntersections
Perform calculations (mostly intersection calculations) on regions of a 3D binary spatial partitionin...
Definition: vtkBSPIntersections.h:46
vtkKdTree::SelectCutDirection
virtual int SelectCutDirection(vtkKdNode *kd)
vtkKdTree::ComputeCellCenters
float * ComputeCellCenters()
Compute and return a pointer to a list of all cell centers, in order by data set by cell Id.
vtkKdTree::FindMaxLeftHalf
static float FindMaxLeftHalf(int dim, float *c1, int K)
vtkKdTree::NumberOfRegionsOrMore
int NumberOfRegionsOrMore
Definition: vtkKdTree.h:924
vtkKdTree::Top
vtkKdNode * Top
Definition: vtkKdTree.h:734
vtkKdTree::SetInputDataInfo
void SetInputDataInfo(int i, int dims[3], double origin[3], double spacing[3])
vtkKdTree::BuildLocatorFromPoints
void BuildLocatorFromPoints(vtkPoints **ptArray, int numPtArrays)
This is a special purpose locator that builds a k-d tree to find duplicate and near-by points.
vtkKdTree::FindClosestPointWithinRadius
vtkIdType FindClosestPointWithinRadius(double radius, const double x[3], double &dist2)
Given a position x and a radius r, return the id of the point closest to the point in that radius.
vtkKdTree::CreateCellLists
void CreateCellLists(int *regionReqList, int listSize)
vtkKdTree::InitializeCellLists
void InitializeCellLists()
vtkKdTree::ProcessUserDefinedCuts
int ProcessUserDefinedCuts(double *bounds)
vtkKdTree::GetRegionContainingCell
int GetRegionContainingCell(int set, vtkIdType cellID)
Get the id of the region containing the cell centroid.
vtkKdTree::vtkKdTree
vtkKdTree(const vtkKdTree &)=delete
vtkKdTree::GetCellList
vtkIdList * GetCellList(int regionID)
Get the cell list for a region.
vtkKdTree::LocatorPoints
float * LocatorPoints
Definition: vtkKdTree.h:948
vtkKdTree::_FindClosestPointInRegion
int _FindClosestPointInRegion(int regionId, double x, double y, double z, double &dist2)
vtkKdTree::_cellList::boundaryCells
vtkIdList ** boundaryCells
Definition: vtkKdTree.h:854
vtkKdTree::Timing
vtkTypeBool Timing
Definition: vtkKdTree.h:941
vtkKdTree::DoMedianFind
void DoMedianFind(vtkKdNode *kd, float *c1, int *ids, int d1, int d2, int d3)
vtkKdTree::BSPCalculator
vtkBSPIntersections * BSPCalculator
Definition: vtkKdTree.h:700
vtkCell
abstract class to specify cell behavior
Definition: vtkCell.h:147
vtkKdTree::SelfOrder
static int SelfOrder(int id, vtkKdNode *kd)
vtkKdTree::CopyTree
static vtkKdNode * CopyTree(vtkKdNode *kd)
Create a copy of the binary tree representation of the k-d tree spatial partitioning provided.
vtkKdTree::ValidDirections
int ValidDirections
Definition: vtkKdTree.h:732
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkKdTree::ComputeLevel
static int ComputeLevel(vtkKdNode *kd)
vtkCellArray
object to represent cell connectivity
Definition: vtkCellArray.h:290
vtkKdTree::SelfRegister
void SelfRegister(vtkKdNode *kd)
vtkIntArray
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:149
vtkKdTree::LastDataSetObserverTags
unsigned long * LastDataSetObserverTags
Definition: vtkKdTree.h:960
vtkKdTree::SetDataBoundsToSpatialBounds
static void SetDataBoundsToSpatialBounds(vtkKdNode *kd)
vtkKdTree::DivideRegion
int DivideRegion(vtkKdNode *kd, float *c1, int *ids, int nlevels)
vtkKdTree::UpdateProgress
void UpdateProgress(double amount)
Modelled on vtkAlgorithm::UpdateProgress().
vtkKdTree::MinCells
int MinCells
Definition: vtkKdTree.h:938
vtkKdTree::NumberOfRegions
int NumberOfRegions
Definition: vtkKdTree.h:939
vtkKdTree::GenerateRepresentationUsingDataBounds
vtkTypeBool GenerateRepresentationUsingDataBounds
Definition: vtkKdTree.h:929
vtkBSPCuts
This class represents an axis-aligned Binary Spatial Partitioning of a 3D space.
Definition: vtkBSPCuts.h:45
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:140
vtkKdTree::UpdateBuildTime
void UpdateBuildTime()
Save enough state so NewGeometry() can work, and update the BuildTime time stamp.
vtkKdTree::BuildLocatorFromPoints
void BuildLocatorFromPoints(vtkPoints *ptArray)
This is a special purpose locator that builds a k-d tree to find duplicate and near-by points.
vtkKdTree::Progress
double Progress
Definition: vtkKdTree.h:968
vtkKdTree::_cellList
Definition: vtkKdTree.h:849
vtkKdTree::~vtkKdTree
~vtkKdTree() override
vtkKdTree::OmitXYPartitioning
void OmitXYPartitioning()
Omit partitions along the X and Y axes, yielding slabs along Z.
vtkKdTree::GetDataSet
vtkDataSet * GetDataSet() override
Return the 0'th data set.
Definition: vtkKdTree.h:296
vtkKdTree::SearchRegionForDuplicate
int SearchRegionForDuplicate(float *point, int *pointsSoFar, int len, float tolerance2)
vtkKdTree::GenerateRepresentationDataBounds
void GenerateRepresentationDataBounds(int level, vtkPolyData *pd)
vtkKdTree::BuildLocatorFromPoints
void BuildLocatorFromPoints(vtkPointSet *pointset)
This is a special purpose locator that builds a k-d tree to find duplicate and near-by points.
vtkKdTree::FindClosestNPoints
void FindClosestNPoints(int N, const double x[3], vtkIdList *result)
Find the closest N points to a position.
vtkKdTree::LastInputDataSets
vtkDataSet ** LastInputDataSets
Definition: vtkKdTree.h:959
vtkKdTree::OmitZPartitioning
void OmitZPartitioning()
Omit partitions along the Z axis, yielding shafts in the Z direction.
vtkKdTree::CopyKdNode
static void CopyKdNode(vtkKdNode *to, vtkKdNode *from)
vtkKdTree::LocatorRegionLocation
int * LocatorRegionLocation
Definition: vtkKdTree.h:950
vtkKdTree::LastNumDataSets
int LastNumDataSets
Definition: vtkKdTree.h:957
vtkKdTree::GetBoundaryCellList
vtkIdList * GetBoundaryCellList(int regionID)
The cell list obtained with GetCellList is the list of all cells such that their centroid is containe...
vtkKdTree::OmitNoPartitioning
void OmitNoPartitioning()
Partition along all three axes - this is the default.
vtkKdTree::RemoveDataSet
virtual void RemoveDataSet(vtkDataSet *set)
Remove the given data set.
vtkKdTree::ProgressScale
double ProgressScale
Definition: vtkKdTree.h:808
vtkKdTree::GetCellLists
vtkIdType GetCellLists(vtkIntArray *regions, vtkIdList *inRegionCells, vtkIdList *onBoundaryCells)
For a list of regions, get two cell lists.
vtkKdTree::DataSets
vtkDataSetCollection * DataSets
Definition: vtkKdTree.h:794
vtkKdTree::SetCuts
void SetCuts(vtkBSPCuts *cuts)
Normally the k-d tree is computed from the dataset(s) provided in SetDataSet.
vtkX3D::spacing
@ spacing
Definition: vtkX3D.h:487
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:166
vtkKdTree::MaxWidth
float MaxWidth
Definition: vtkKdTree.h:952
vtkKdTree::NewGeometry
virtual int NewGeometry(vtkDataSet **sets, int numDataSets)
Return 1 if the geometry of these data sets differs for the geometry of the last data sets used to bu...
vtkKdTree::LastDataSetType
int * LastDataSetType
Definition: vtkKdTree.h:961
vtkKdTree::UpdateSubOperationProgress
void UpdateSubOperationProgress(double amount)
vtkTimerLog
Timer support and logging.
Definition: vtkTimerLog.h:199
vtkKdTree::PrintRegion
void PrintRegion(int id)
Print out leaf node data for given id.
vtkIdTypeArray
dynamic, self-adjusting array of vtkIdType
Definition: vtkIdTypeArray.h:145
vtkKdTree::LastNumCells
vtkIdType * LastNumCells
Definition: vtkKdTree.h:965
vtkKdTree::GetDataSetsNumberOfCells
int GetDataSetsNumberOfCells(int set1, int set2)
Returns the total number of cells in data set 1 through data set 2.
vtkKdTree::IncludeRegionBoundaryCells
vtkTypeBool IncludeRegionBoundaryCells
Definition: vtkKdTree.h:926
vtkKdTree::FindPointsWithinRadius
void FindPointsWithinRadius(vtkKdNode *node, double R2, const double x[3], vtkIdList *ids)
vtkKdTree::SetCuts
void SetCuts(vtkBSPCuts *cuts, int userDefined)
vtkKdTree::_generateRepresentationDataBounds
void _generateRepresentationDataBounds(vtkKdNode *kd, vtkPoints *pts, vtkCellArray *polys, int level)
vtkPointSet
concrete class for storing a set of points
Definition: vtkPointSet.h:106
vtkKdTree::NumberOfLocatorPoints
int NumberOfLocatorPoints
Definition: vtkKdTree.h:947
vtkKdTree::BuildRegionList
void BuildRegionList()
vtkKdTree::SetNewBounds
void SetNewBounds(double *bounds)
There are certain applications where you want the bounds of the k-d tree space to be at least as larg...
vtkKdTree::FindClosestPointInRegion
vtkIdType FindClosestPointInRegion(int regionId, double *x, double &dist2)
Find the Id of the point in the given region which is closest to the given point.
vtkKdTree::MinimalNumberOfConvexSubRegions
int MinimalNumberOfConvexSubRegions(vtkIntArray *regionIdList, double **convexRegionBounds)
Given a list of region IDs, determine the decomposition of these regions into the minimal number of c...
vtkKdTree::AddAllPointsInRegion
void AddAllPointsInRegion(vtkKdNode *node, vtkIdList *ids)
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:195
vtkKdTree::_Select
static void _Select(int dim, float *X, int *ids, int L, int R, int K)
vtkKdTree::AddAllPointsInRegion
void AddAllPointsInRegion(vtkKdNode *node, vtkIdTypeArray *ids)
vtkKdTree::PrintVerboseTree
void PrintVerboseTree()
Print out nodes of kd tree.
vtkKdTree::GetRegionBounds
void GetRegionBounds(int regionID, double bounds[6])
Get the spatial bounds of k-d tree region.
vtkKdTree::ComputeCellCenter
void ComputeCellCenter(vtkDataSet *set, int cellId, double *center)
vtkKdTree
a Kd-tree spatial decomposition of a set of points
Definition: vtkKdTree.h:141
vtkKdTree::NumberOfRegionsOrLess
int NumberOfRegionsOrLess
Definition: vtkKdTree.h:923
vtkKdTree::GetRegionContainingPoint
int GetRegionContainingPoint(double x, double y, double z)
Get the id of the region containing the specified location.
vtkDataSetCollection
maintain an unordered list of dataset objects
Definition: vtkDataSetCollection.h:61
vtkKdTree::_ViewOrderRegionsInDirection
int _ViewOrderRegionsInDirection(vtkIntArray *IdsOfInterest, const double dop[3], vtkIntArray *orderedList)
vtkKdTree::__ViewOrderRegionsInDirection
static int __ViewOrderRegionsInDirection(vtkKdNode *node, vtkIntArray *list, vtkIntArray *IdsOfInterest, const double dir[3], int nextId)
vtkKdTree::__ConvexSubRegions
static int __ConvexSubRegions(int *ids, int len, vtkKdNode *tree, vtkKdNode **nodes)
vtkKdTree::Cuts
vtkBSPCuts * Cuts
Definition: vtkKdTree.h:967
vtkKdTree::ComputeCellCenters
float * ComputeCellCenters(int set)
vtkKdTree::FindClosestPointInRegion
vtkIdType FindClosestPointInRegion(int regionId, double x, double y, double z, double &dist2)
Find the Id of the point in the given region which is closest to the given point.
vtkKdTree::DeleteCellLists
void DeleteCellLists()
Free the memory used by the cell lists.
vtkKdTree::findRegion
static int findRegion(vtkKdNode *node, double x, double y, double z)
vtkKdTree::GetRegionContainingCell
int GetRegionContainingCell(vtkIdType cellID)
Get the id of the region containing the cell centroid.
vtkKdTree::LastDataCacheSize
int LastDataCacheSize
Definition: vtkKdTree.h:958
vtkKdTree::RegionList
vtkKdNode ** RegionList
Definition: vtkKdTree.h:735
vtkKdTree::ViewOrderRegionsFromPosition
int ViewOrderRegionsFromPosition(vtkIntArray *regionIds, const double directionOfProjection[3], vtkIntArray *orderedList)
Given a camera position and a list of k-d tree region IDs, this method, creates a list of the k-d tre...
vtkKdTree::operator=
void operator=(const vtkKdTree &)=delete
vtkKdTree::NewGeometry
virtual int NewGeometry()
Return 1 if the geometry of the input data sets has changed since the last time the k-d tree was buil...
vtkX3D::radius
@ radius
Definition: vtkX3D.h:258
vtkKdTree::OmitYZPartitioning
void OmitYZPartitioning()
Omit partitions along the Y and Z axes, yielding slabs along X.
vtkX3D::index
@ index
Definition: vtkX3D.h:252
vtkKdTree::CheckInputDataInfo
int CheckInputDataInfo(int i, int dims[3], double origin[3], double spacing[3])
vtkKdTree::SetCalculator
void SetCalculator(vtkKdNode *kd)
vtkKdTree::GetPointsInRegion
vtkIdTypeArray * GetPointsInRegion(int regionId)
Get a list of the original IDs of all points in a region.
vtkKdTree::_printTree
void _printTree(int verbose)
vtkKdTree::GetNumberOfDataSets
int GetNumberOfDataSets()
Get the number of data sets included in spatial partitioning.
vtkKdTree::FindClosestPoint
vtkIdType FindClosestPoint(double *x, double &dist2)
Find the Id of the point that was previously supplied to BuildLocatorFromPoints() which is closest to...
vtkKdTree::CreateCellLists
void CreateCellLists()
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkKdTree::ViewOrderRegionsInDirection
int ViewOrderRegionsInDirection(vtkIntArray *regionIds, const double directionOfProjection[3], vtkIntArray *orderedList)
Given a direction of projection and a list of k-d tree region IDs, this method, creates a list of the...
vtkKdTree::ZeroNumberOfPoints
static void ZeroNumberOfPoints(vtkKdNode *kd)
vtkKdTree::ComputeCellCenters
float * ComputeCellCenters(vtkDataSet *set)
vtkKdTree::GenerateRepresentationWholeSpace
void GenerateRepresentationWholeSpace(int level, vtkPolyData *pd)
vtkKdTree::UserDefinedCuts
int UserDefinedCuts
Definition: vtkKdTree.h:701
vtkKdTree::GetLeafNodeIds
static void GetLeafNodeIds(vtkKdNode *node, vtkIntArray *ids)
Adds to the vtkIntArray the list of region IDs of all leaf nodes in the given node.
vtkKdTree::MidValue
static int MidValue(int dim, float *c1, int nvals, double &coord)
vtkKdTree::DeleteAllDescendants
static void DeleteAllDescendants(vtkKdNode *nd)