VTK  9.1.20211115
vtkSphereTree.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkSphereTree.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 =========================================================================*/
49 #ifndef vtkSphereTree_h
50 #define vtkSphereTree_h
51 
52 #include "vtkCommonExecutionModelModule.h" // For export macro
53 #include "vtkObject.h"
54 #include "vtkPlane.h" // to specify the cutting plane
55 
56 class vtkDoubleArray;
57 class vtkDataArray;
58 class vtkIdList;
59 class vtkDataSet;
60 class vtkStructuredGrid;
62 class vtkTimeStamp;
63 struct vtkSphereTreeHierarchy;
64 
65 #define VTK_MAX_SPHERE_TREE_RESOLUTION 10
66 #define VTK_MAX_SPHERE_TREE_LEVELS 20
67 
68 // VTK Class proper
69 class VTKCOMMONEXECUTIONMODEL_EXPORT vtkSphereTree : public vtkObject
70 {
71 public:
75  static vtkSphereTree* New();
76 
78 
81  vtkTypeMacro(vtkSphereTree, vtkObject);
82  void PrintSelf(ostream& os, vtkIndent indent) override;
84 
86 
89  virtual void SetDataSet(vtkDataSet*);
90  vtkGetObjectMacro(DataSet, vtkDataSet);
92 
94 
100  void Build();
101  void Build(vtkDataSet* input);
103 
105 
109  vtkSetMacro(BuildHierarchy, bool);
110  vtkGetMacro(BuildHierarchy, bool);
111  vtkBooleanMacro(BuildHierarchy, bool);
113 
115 
124  const unsigned char* SelectPoint(double point[3], vtkIdType& numSelected);
125  const unsigned char* SelectLine(double origin[3], double ray[3], vtkIdType& numSelected);
126  const unsigned char* SelectPlane(double origin[3], double normal[3], vtkIdType& numSelected);
128 
130 
140  void SelectPoint(double point[3], vtkIdList* cellIds);
141  void SelectLine(double origin[3], double ray[3], vtkIdList* cellIds);
142  void SelectPlane(double origin[3], double normal[3], vtkIdList* cellIds);
144 
146 
153  vtkSetClampMacro(Resolution, int, 2, VTK_MAX_SPHERE_TREE_RESOLUTION);
154  vtkGetMacro(Resolution, int);
156 
158 
165  vtkSetClampMacro(MaxLevel, int, 1, VTK_MAX_SPHERE_TREE_LEVELS);
166  vtkGetMacro(MaxLevel, int);
168 
175  vtkGetMacro(NumberOfLevels, int);
176 
178 
189  const double* GetCellSpheres();
190  const double* GetTreeSpheres(int level, vtkIdType& numSpheres);
192 
193 protected:
195  ~vtkSphereTree() override;
196 
197  // Data members
199  unsigned char* Selected;
201  int MaxLevel;
204 
205  // The tree and its hierarchy
207  double* TreePtr;
208  vtkSphereTreeHierarchy* Hierarchy;
209 
210  // Supporting data members
211  double AverageRadius; // average radius of cell sphere
212  double SphereBounds[6]; // the dataset bounds computed from cell spheres
213  vtkTimeStamp BuildTime; // time at which tree was built
214 
215  // Supporting methods
217  void ExtractCellIds(const unsigned char* selected, vtkIdList* cellIds, vtkIdType numSelected);
218 
220  void BuildStructuredHierarchy(vtkStructuredGrid* input, double* tree);
221  void BuildUnstructuredHierarchy(vtkDataSet* input, double* tree);
222  int SphereTreeType; // keep track of the type of tree hierarchy generated
223 
224 private:
225  vtkSphereTree(const vtkSphereTree&) = delete;
226  void operator=(const vtkSphereTree&) = delete;
227 };
228 
229 #endif
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:159
abstract class to specify dataset behavior
Definition: vtkDataSet.h:166
dynamic, self-adjusting array of double
list of point or cell ids
Definition: vtkIdList.h:140
a simple class to control print indentation
Definition: vtkIndent.h:113
abstract base class for most VTK objects
Definition: vtkObject.h:82
class to build and traverse sphere trees
Definition: vtkSphereTree.h:70
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:52
dataset represents arbitrary combinations of all possible cell types
@ point
Definition: vtkX3D.h:242
@ level
Definition: vtkX3D.h:401
std::map< std::string, DataArray > DataSet
key: variable name, value: DataArray
Definition: VTXTypes.h:39
#define VTK_MAX_SPHERE_TREE_RESOLUTION
Definition: vtkSphereTree.h:65
#define VTK_MAX_SPHERE_TREE_LEVELS
Definition: vtkSphereTree.h:66
int vtkIdType
Definition: vtkType.h:332