VTK  9.3.20240226
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:
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
209  void ExtractCellIds(const unsigned char* selected, vtkIdList* cellIds, vtkIdType numSelected);
210 
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 superclass for arrays of numeric data
Definition: vtkDataArray.h:154
abstract class to specify dataset behavior
Definition: vtkDataSet.h:165
dynamic, self-adjusting array of double
list of point or cell ids
Definition: vtkIdList.h:132
a simple class to control print indentation
Definition: vtkIndent.h:108
abstract base class for most VTK objects
Definition: vtkObject.h:161
class to build and traverse sphere trees
Definition: vtkSphereTree.h:62
const unsigned char * SelectPoint(double point[3], vtkIdType &numSelected)
Methods for cell selection based on a geometric query.
virtual void SetDataSet(vtkDataSet *)
Specify the dataset from which to build the sphere tree.
~vtkSphereTree() override
const double * GetCellSpheres()
Special methods to retrieve the sphere tree data.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard type related macros and PrintSelf() method.
void SelectPlane(double origin[3], double normal[3], vtkIdList *cellIds)
Methods for cell selection based on a geometric query.
void BuildStructuredHierarchy(vtkStructuredGrid *input, double *tree)
void BuildTreeSpheres(vtkDataSet *input)
void SelectLine(double origin[3], double ray[3], vtkIdList *cellIds)
Methods for cell selection based on a geometric query.
vtkTimeStamp BuildTime
void SelectPoint(double point[3], vtkIdList *cellIds)
Methods for cell selection based on a geometric query.
double * TreePtr
vtkDataSet * DataSet
unsigned char * Selected
void ExtractCellIds(const unsigned char *selected, vtkIdList *cellIds, vtkIdType numSelected)
void Build()
Build the sphere tree (if necessary) from the data set specified.
vtkSphereTreeHierarchy * Hierarchy
const unsigned char * SelectLine(double origin[3], double ray[3], vtkIdType &numSelected)
Methods for cell selection based on a geometric query.
const double * GetTreeSpheres(int level, vtkIdType &numSpheres)
Special methods to retrieve the sphere tree data.
vtkDoubleArray * Tree
void Build(vtkDataSet *input)
Build the sphere tree (if necessary) from the data set specified.
void BuildUnstructuredHierarchy(vtkDataSet *input, double *tree)
void BuildTreeHierarchy(vtkDataSet *input)
const unsigned char * SelectPlane(double origin[3], double normal[3], vtkIdType &numSelected)
Methods for cell selection based on a geometric query.
double AverageRadius
static vtkSphereTree * New()
Instantiate the sphere tree.
topologically regular array of data
record modification and/or execution time
Definition: vtkTimeStamp.h:44
dataset represents arbitrary combinations of all possible cell types
@ point
Definition: vtkX3D.h:236
@ level
Definition: vtkX3D.h:395
std::map< std::string, DataArray > DataSet
key: variable name, value: DataArray
Definition: VTXTypes.h:28
#define VTK_MAX_SPHERE_TREE_RESOLUTION
Definition: vtkSphereTree.h:57
#define VTK_MAX_SPHERE_TREE_LEVELS
Definition: vtkSphereTree.h:58
int vtkIdType
Definition: vtkType.h:315