VTK  9.7.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 
186 
189  bool UsesGarbageCollector() const override { return true; }
191 
192 protected:
193  vtkSphereTree();
194  ~vtkSphereTree() override;
195 
196  // Data members
198  unsigned char* Selected;
200  int MaxLevel;
203 
204  // The tree and its hierarchy
206  double* TreePtr;
207  vtkSphereTreeHierarchy* Hierarchy;
208 
209  // Supporting data members
210  double AverageRadius; // average radius of cell sphere
211  double SphereBounds[6]; // the dataset bounds computed from cell spheres
212  vtkTimeStamp BuildTime; // time at which tree was built
213 
214  // Supporting methods
215  void BuildTreeSpheres(vtkDataSet* input);
216  void ExtractCellIds(const unsigned char* selected, vtkIdList* cellIds, vtkIdType numSelected);
217 
218  void BuildTreeHierarchy(vtkDataSet* input);
219  void BuildStructuredHierarchy(vtkStructuredGrid* input, double* tree);
220  void BuildUnstructuredHierarchy(vtkDataSet* input, double* tree);
221  int SphereTreeType; // keep track of the type of tree hierarchy generated
222 
223  void ReportReferences(vtkGarbageCollector*) override;
224 
225 private:
226  vtkSphereTree(const vtkSphereTree&) = delete;
227  void operator=(const vtkSphereTree&) = delete;
228 };
229 
230 VTK_ABI_NAMESPACE_END
231 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:52
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:56
record modification and/or execution time
Definition: vtkTimeStamp.h:24
int vtkIdType
Definition: vtkType.h:363
Detect and break reference loops.
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
virtual void ReportReferences(vtkGarbageCollector *)
list of point or cell ids
Definition: vtkIdList.h:25
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
bool UsesGarbageCollector() const override
Participate in garbage collection via ReportReferences.
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