VTK  9.3.1
vtkSphereTree.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
40 #ifndef vtkSphereTree_h
41 #define vtkSphereTree_h
42 
43 #include "vtkCommonExecutionModelModule.h" // For export macro
44 #include "vtkObject.h"
45 #include "vtkPlane.h" // to specify the cutting plane
46 
47 VTK_ABI_NAMESPACE_BEGIN
48 class vtkDoubleArray;
49 class vtkDataArray;
50 class vtkIdList;
51 class vtkDataSet;
52 class vtkStructuredGrid;
54 class vtkTimeStamp;
55 struct vtkSphereTreeHierarchy;
56 
57 #define VTK_MAX_SPHERE_TREE_RESOLUTION 10
58 #define VTK_MAX_SPHERE_TREE_LEVELS 20
59 
60 // VTK Class proper
61 class VTKCOMMONEXECUTIONMODEL_EXPORT vtkSphereTree : public vtkObject
62 {
63 public:
67  static vtkSphereTree* New();
68 
70 
73  vtkTypeMacro(vtkSphereTree, vtkObject);
74  void PrintSelf(ostream& os, vtkIndent indent) override;
76 
78 
81  virtual void SetDataSet(vtkDataSet*);
82  vtkGetObjectMacro(DataSet, vtkDataSet);
84 
86 
92  void Build();
93  void Build(vtkDataSet* input);
95 
97 
101  vtkSetMacro(BuildHierarchy, bool);
102  vtkGetMacro(BuildHierarchy, bool);
103  vtkBooleanMacro(BuildHierarchy, bool);
105 
107 
116  const unsigned char* SelectPoint(double point[3], vtkIdType& numSelected);
117  const unsigned char* SelectLine(double origin[3], double ray[3], vtkIdType& numSelected);
118  const unsigned char* SelectPlane(double origin[3], double normal[3], vtkIdType& numSelected);
120 
122 
132  void SelectPoint(double point[3], vtkIdList* cellIds);
133  void SelectLine(double origin[3], double ray[3], vtkIdList* cellIds);
134  void SelectPlane(double origin[3], double normal[3], vtkIdList* cellIds);
136 
138 
145  vtkSetClampMacro(Resolution, int, 2, VTK_MAX_SPHERE_TREE_RESOLUTION);
146  vtkGetMacro(Resolution, int);
148 
150 
157  vtkSetClampMacro(MaxLevel, int, 1, VTK_MAX_SPHERE_TREE_LEVELS);
158  vtkGetMacro(MaxLevel, int);
160 
167  vtkGetMacro(NumberOfLevels, int);
168 
170 
181  const double* GetCellSpheres();
182  const double* GetTreeSpheres(int level, vtkIdType& numSpheres);
184 
185 protected:
186  vtkSphereTree();
187  ~vtkSphereTree() override;
188 
189  // Data members
191  unsigned char* Selected;
193  int MaxLevel;
196 
197  // The tree and its hierarchy
199  double* TreePtr;
200  vtkSphereTreeHierarchy* Hierarchy;
201 
202  // Supporting data members
203  double AverageRadius; // average radius of cell sphere
204  double SphereBounds[6]; // the dataset bounds computed from cell spheres
205  vtkTimeStamp BuildTime; // time at which tree was built
206 
207  // Supporting methods
208  void BuildTreeSpheres(vtkDataSet* input);
209  void ExtractCellIds(const unsigned char* selected, vtkIdList* cellIds, vtkIdType numSelected);
210 
211  void BuildTreeHierarchy(vtkDataSet* input);
212  void BuildStructuredHierarchy(vtkStructuredGrid* input, double* tree);
213  void BuildUnstructuredHierarchy(vtkDataSet* input, double* tree);
214  int SphereTreeType; // keep track of the type of tree hierarchy generated
215 
216 private:
217  vtkSphereTree(const vtkSphereTree&) = delete;
218  void operator=(const vtkSphereTree&) = delete;
219 };
220 
221 VTK_ABI_NAMESPACE_END
222 #endif
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.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:52
record modification and/or execution time
Definition: vtkTimeStamp.h:24
int vtkIdType
Definition: vtkType.h:315
dynamic, self-adjusting array of double
vtkSphereTreeHierarchy * Hierarchy
double * TreePtr
vtkDataSet * DataSet
vtkDoubleArray * Tree
unsigned char * Selected
a simple class to control print indentation
Definition: vtkIndent.h:28
list of point or cell ids
Definition: vtkIdList.h:22
dataset represents arbitrary combinations of all possible cell types
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
std::map< std::string, DataArray > DataSet
key: variable name, value: DataArray
Definition: VTXTypes.h:28
vtkTimeStamp BuildTime
#define VTK_MAX_SPHERE_TREE_LEVELS
Definition: vtkSphereTree.h:58
topologically regular array of data
class to build and traverse sphere trees
Definition: vtkSphereTree.h:61
double AverageRadius
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
#define VTK_MAX_SPHERE_TREE_RESOLUTION
Definition: vtkSphereTree.h:57