VTK
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
vtkSphereTree Class Reference

class to build and traverse sphere trees More...

#include <vtkSphereTree.h>

Inheritance diagram for vtkSphereTree:
[legend]
Collaboration diagram for vtkSphereTree:
[legend]

Public Types

typedef vtkObject Superclass
 Standard type related macros and PrintSelf() method. More...
 

Public Member Functions

virtual vtkTypeBool IsA (const char *type)
 Return 1 if this class is the same type of (or a subclass of) the named class. More...
 
vtkSphereTreeNewInstance () const
 
void PrintSelf (ostream &os, vtkIndent indent) override
 Methods invoked by print to print information about the object including superclasses. More...
 
virtual void SetDataSet (vtkDataSet *)
 Specify the dataset from which to build the sphere tree. More...
 
virtual vtkDataSetGetDataSet ()
 
void Build ()
 Build the sphere tree (if necessary) from the data set specified. More...
 
void Build (vtkDataSet *input)
 
virtual void SetBuildHierarchy (bool)
 Control whether the tree hierarchy is built. More...
 
virtual bool GetBuildHierarchy ()
 
virtual void BuildHierarchyOn ()
 
virtual void BuildHierarchyOff ()
 
const unsigned char * SelectPoint (double point[3], vtkIdType &numSelected)
 Methods for cell selection based on a geometric query. More...
 
const unsigned char * SelectLine (double origin[3], double ray[3], vtkIdType &numSelected)
 
const unsigned char * SelectPlane (double origin[3], double normal[3], vtkIdType &numSelected)
 
void SelectPoint (double point[3], vtkIdList *cellIds)
 Methods for cell selection based on a geometric query. More...
 
void SelectLine (double origin[3], double ray[3], vtkIdList *cellIds)
 
void SelectPlane (double origin[3], double normal[3], vtkIdList *cellIds)
 
virtual void SetResolution (int)
 Sphere tree creation requires gathering spheres into groups. More...
 
virtual int GetResolution ()
 
virtual void SetMaxLevel (int)
 Specify the maximum number of levels for the tree. More...
 
virtual int GetMaxLevel ()
 
virtual int GetNumberOfLevels ()
 Get the current depth of the sphere tree. More...
 
const double * GetCellSpheres ()
 Special methods to retrieve the sphere tree data. More...
 
const double * GetTreeSpheres (int level, vtkIdType &numSpheres)
 
- Public Member Functions inherited from vtkObject
 vtkBaseTypeMacro (vtkObject, vtkObjectBase)
 
virtual void DebugOn ()
 Turn debugging output on. More...
 
virtual void DebugOff ()
 Turn debugging output off. More...
 
bool GetDebug ()
 Get the value of the debug flag. More...
 
void SetDebug (bool debugFlag)
 Set the value of the debug flag. More...
 
virtual void Modified ()
 Update the modification time for this object. More...
 
virtual vtkMTimeType GetMTime ()
 Return this object's modified time. More...
 
unsigned long AddObserver (unsigned long event, vtkCommand *, float priority=0.0f)
 Allow people to add/remove/invoke observers (callbacks) to any VTK object. More...
 
unsigned long AddObserver (const char *event, vtkCommand *, float priority=0.0f)
 
vtkCommandGetCommand (unsigned long tag)
 
void RemoveObserver (vtkCommand *)
 
void RemoveObservers (unsigned long event, vtkCommand *)
 
void RemoveObservers (const char *event, vtkCommand *)
 
vtkTypeBool HasObserver (unsigned long event, vtkCommand *)
 
vtkTypeBool HasObserver (const char *event, vtkCommand *)
 
void RemoveObserver (unsigned long tag)
 
void RemoveObservers (unsigned long event)
 
void RemoveObservers (const char *event)
 
void RemoveAllObservers ()
 
vtkTypeBool HasObserver (unsigned long event)
 
vtkTypeBool HasObserver (const char *event)
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, void(T::*callback)(), float priority=0.0f)
 Overloads to AddObserver that allow developers to add class member functions as callbacks for events. More...
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, void(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, bool(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
 Allow user to set the AbortFlagOn() with the return value of the callback method. More...
 
int InvokeEvent (unsigned long event, void *callData)
 This method invokes an event and return whether the event was aborted or not. More...
 
int InvokeEvent (const char *event, void *callData)
 
int InvokeEvent (unsigned long event)
 
int InvokeEvent (const char *event)
 
- Public Member Functions inherited from vtkObjectBase
const char * GetClassName () const
 Return the class name as a string. More...
 
virtual void Delete ()
 Delete a VTK object. More...
 
virtual void FastDelete ()
 Delete a reference to this object. More...
 
void InitializeObjectBase ()
 
void Print (ostream &os)
 Print an object to an ostream. More...
 
virtual void PrintHeader (ostream &os, vtkIndent indent)
 
virtual void PrintTrailer (ostream &os, vtkIndent indent)
 
virtual void Register (vtkObjectBase *o)
 Increase the reference count (mark as used by another object). More...
 
virtual void UnRegister (vtkObjectBase *o)
 Decrease the reference count (release by another object). More...
 
int GetReferenceCount ()
 Return the current reference count of this object. More...
 
void SetReferenceCount (int)
 Sets the reference count. More...
 
void PrintRevisions (ostream &)
 Legacy. More...
 

Static Public Member Functions

static vtkSphereTreeNew ()
 Instantiate the sphere tree. More...
 
static vtkTypeBool IsTypeOf (const char *type)
 
static vtkSphereTreeSafeDownCast (vtkObjectBase *o)
 
- Static Public Member Functions inherited from vtkObject
static vtkObjectNew ()
 Create an object with Debug turned off, modified time initialized to zero, and reference counting on. More...
 
static void BreakOnError ()
 This method is called when vtkErrorMacro executes. More...
 
static void SetGlobalWarningDisplay (int val)
 This is a global flag that controls whether any debug, warning or error messages are displayed. More...
 
static void GlobalWarningDisplayOn ()
 
static void GlobalWarningDisplayOff ()
 
static int GetGlobalWarningDisplay ()
 
- Static Public Member Functions inherited from vtkObjectBase
static vtkTypeBool IsTypeOf (const char *name)
 Return 1 if this class type is the same type of (or a subclass of) the named class. More...
 
static vtkObjectBaseNew ()
 Create an object with Debug turned off, modified time initialized to zero, and reference counting on. More...
 

Protected Member Functions

virtual vtkObjectBaseNewInstanceInternal () const
 
 vtkSphereTree ()
 
 ~vtkSphereTree () override
 
void BuildTreeSpheres (vtkDataSet *input)
 
void ExtractCellIds (const unsigned char *selected, vtkIdList *cellIds, vtkIdType numSelected)
 
void BuildTreeHierarchy (vtkDataSet *input)
 
void BuildStructuredHierarchy (vtkStructuredGrid *input, double *tree)
 
void BuildUnstructuredHierarchy (vtkDataSet *input, double *tree)
 
- Protected Member Functions inherited from vtkObject
 vtkObject ()
 
 ~vtkObject () override
 
void RegisterInternal (vtkObjectBase *, vtkTypeBool check) override
 
void UnRegisterInternal (vtkObjectBase *, vtkTypeBool check) override
 
void InternalGrabFocus (vtkCommand *mouseEvents, vtkCommand *keypressEvents=nullptr)
 These methods allow a command to exclusively grab all events. More...
 
void InternalReleaseFocus ()
 
- Protected Member Functions inherited from vtkObjectBase
 vtkObjectBase ()
 
virtual ~vtkObjectBase ()
 
virtual void CollectRevisions (ostream &)
 
virtual void ReportReferences (vtkGarbageCollector *)
 
 vtkObjectBase (const vtkObjectBase &)
 
void operator= (const vtkObjectBase &)
 

Protected Attributes

vtkDataSetDataSet
 
unsigned char * Selected
 
int Resolution
 
int MaxLevel
 
int NumberOfLevels
 
bool BuildHierarchy
 
vtkDoubleArrayTree
 
double * TreePtr
 
vtkSphereTreeHierarchy * Hierarchy
 
double AverageRadius
 
double SphereBounds [6]
 
vtkTimeStamp BuildTime
 
int SphereTreeType
 
- Protected Attributes inherited from vtkObject
bool Debug
 
vtkTimeStamp MTime
 
vtkSubjectHelper * SubjectHelper
 
- Protected Attributes inherited from vtkObjectBase
std::atomic< int32_t > ReferenceCount
 
vtkWeakPointerBase ** WeakPointers
 

Detailed Description

class to build and traverse sphere trees

vtkSphereTree is a helper class used to build and traverse sphere trees. Various types of trees can be constructed for different VTK dataset types, as well well as different approaches to organize the tree into hierarchies.

Typically building a complete sphere tree consists of two parts: 1) creating spheres for each cell in the dataset, then 2) creating an organizing hierarchy. The structure of the hierarchy varies depending on the topological characteristics of the dataset.

Once the tree is constructed, various geometric operations are available for quickly selecting cells based on sphere tree operations; for example, process all cells intersecting a plane (i.e., use the sphere tree to identify candidate cells for plane intersection).

This class does not necessarily create optimal sphere trees because some of its requirements (fast build time, provide simple reference code, a single bounding sphere per cell, etc.) precludes optimal performance. It is also oriented to computing on cells versus the classic problem of collision detection for polygonal models. For more information you want to read Gareth Bradshaw's PhD thesis "Bounding Volume Hierarchies for Level-of-Detail Collision Handling" which does a nice job of laying out the challenges and important algorithms relative to sphere trees and BVH (bounding volume hierarchies).

See also
vtkSphereTreeFilter vtkPlaneCutter

Definition at line 69 of file vtkSphereTree.h.

Member Typedef Documentation

◆ Superclass

Standard type related macros and PrintSelf() method.

Definition at line 81 of file vtkSphereTree.h.

Constructor & Destructor Documentation

◆ vtkSphereTree()

vtkSphereTree::vtkSphereTree ( )
protected

◆ ~vtkSphereTree()

vtkSphereTree::~vtkSphereTree ( )
overrideprotected

Member Function Documentation

◆ New()

static vtkSphereTree* vtkSphereTree::New ( )
static

Instantiate the sphere tree.

◆ IsTypeOf()

static vtkTypeBool vtkSphereTree::IsTypeOf ( const char *  type)
static

◆ IsA()

virtual vtkTypeBool vtkSphereTree::IsA ( const char *  name)
virtual

Return 1 if this class is the same type of (or a subclass of) the named class.

Returns 0 otherwise. This method works in combination with vtkTypeMacro found in vtkSetGet.h.

Reimplemented from vtkObjectBase.

◆ SafeDownCast()

static vtkSphereTree* vtkSphereTree::SafeDownCast ( vtkObjectBase o)
static

◆ NewInstanceInternal()

virtual vtkObjectBase* vtkSphereTree::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkSphereTree* vtkSphereTree::NewInstance ( ) const

◆ PrintSelf()

void vtkSphereTree::PrintSelf ( ostream &  os,
vtkIndent  indent 
)
overridevirtual

Methods invoked by print to print information about the object including superclasses.

Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.

Reimplemented from vtkObject.

◆ SetDataSet()

virtual void vtkSphereTree::SetDataSet ( vtkDataSet )
virtual

Specify the dataset from which to build the sphere tree.

◆ GetDataSet()

virtual vtkDataSet* vtkSphereTree::GetDataSet ( )
virtual

◆ Build() [1/2]

void vtkSphereTree::Build ( )

Build the sphere tree (if necessary) from the data set specified.

The build time is recorded so the sphere tree will only build if something has changed. An alternative method is available to both set the dataset and then build the sphere tree.

◆ Build() [2/2]

void vtkSphereTree::Build ( vtkDataSet input)

◆ SetBuildHierarchy()

virtual void vtkSphereTree::SetBuildHierarchy ( bool  )
virtual

Control whether the tree hierarchy is built.

If not, then just cell spheres are created (one for each cell).

◆ GetBuildHierarchy()

virtual bool vtkSphereTree::GetBuildHierarchy ( )
virtual

◆ BuildHierarchyOn()

virtual void vtkSphereTree::BuildHierarchyOn ( )
virtual

◆ BuildHierarchyOff()

virtual void vtkSphereTree::BuildHierarchyOff ( )
virtual

◆ SelectPoint() [1/2]

const unsigned char* vtkSphereTree::SelectPoint ( double  point[3],
vtkIdType numSelected 
)

Methods for cell selection based on a geometric query.

Internally different methods are used depending on the dataset type. The array returned is set to non-zero for each cell that intersects the geometric entity. SelectPoint marks all cells with a non-zero value that may contain a point. SelectLine marks all cells that may intersect an infinite line. SelectPlane marks all cells that may intersect with an infinite plane.

◆ SelectLine() [1/2]

const unsigned char* vtkSphereTree::SelectLine ( double  origin[3],
double  ray[3],
vtkIdType numSelected 
)

◆ SelectPlane() [1/2]

const unsigned char* vtkSphereTree::SelectPlane ( double  origin[3],
double  normal[3],
vtkIdType numSelected 
)

◆ SelectPoint() [2/2]

void vtkSphereTree::SelectPoint ( double  point[3],
vtkIdList cellIds 
)

Methods for cell selection based on a geometric query.

Internally different methods are used depending on the dataset type. The method pupulates an vtkIdList with cell ids that may satisfy the geometric query (the user must provide a vtkLdList which the methods fill in). SelectPoint lists all cells with a non-zero value that may contain a point. SelectLine lists all cells that may intersect an infinite line. SelectPlane lists all cells that may intersect with an infinite plane.

◆ SelectLine() [2/2]

void vtkSphereTree::SelectLine ( double  origin[3],
double  ray[3],
vtkIdList cellIds 
)

◆ SelectPlane() [2/2]

void vtkSphereTree::SelectPlane ( double  origin[3],
double  normal[3],
vtkIdList cellIds 
)

◆ SetResolution()

virtual void vtkSphereTree::SetResolution ( int  )
virtual

Sphere tree creation requires gathering spheres into groups.

The Resolution variable is a rough guide to the size of each group (the size different meanings depending on the type of data (structured versus unstructured). For example, in 3D structured data, blocks of resolution Resolution^3 are created. By default the Resolution is three.

◆ GetResolution()

virtual int vtkSphereTree::GetResolution ( )
virtual

◆ SetMaxLevel()

virtual void vtkSphereTree::SetMaxLevel ( int  )
virtual

Specify the maximum number of levels for the tree.

By default, the number of levels is set to ten. If the number of levels is set to one or less, then no hierarchy is built (i.e., just the spheres for each cell are created). Note that the actual level of the tree may be less than this value depending on the number of cells and Resolution factor.

◆ GetMaxLevel()

virtual int vtkSphereTree::GetMaxLevel ( )
virtual

◆ GetNumberOfLevels()

virtual int vtkSphereTree::GetNumberOfLevels ( )
virtual

Get the current depth of the sphere tree.

This value may change each time the sphere tree is built and the branching factor (i.e., resolution) changes. Note that after building the sphere tree there are [0,this->NumberOfLevels) defined levels.

◆ GetCellSpheres()

const double* vtkSphereTree::GetCellSpheres ( )

Special methods to retrieve the sphere tree data.

This is generally used for debugging or with filters like vtkSphereTreeFilter. Both methods return an array of double* where four doubles represent a sphere (center + radius). In the first method a sphere per cell is returned. In the second method the user must also specify a level in the sphere tree (used to retrieve the hierarchy of the tree). Note that null pointers can be returned if the request is not consistent with the state of the sphere tree.

◆ GetTreeSpheres()

const double* vtkSphereTree::GetTreeSpheres ( int  level,
vtkIdType numSpheres 
)

◆ BuildTreeSpheres()

void vtkSphereTree::BuildTreeSpheres ( vtkDataSet input)
protected

◆ ExtractCellIds()

void vtkSphereTree::ExtractCellIds ( const unsigned char *  selected,
vtkIdList cellIds,
vtkIdType  numSelected 
)
protected

◆ BuildTreeHierarchy()

void vtkSphereTree::BuildTreeHierarchy ( vtkDataSet input)
protected

◆ BuildStructuredHierarchy()

void vtkSphereTree::BuildStructuredHierarchy ( vtkStructuredGrid input,
double *  tree 
)
protected

◆ BuildUnstructuredHierarchy()

void vtkSphereTree::BuildUnstructuredHierarchy ( vtkDataSet input,
double *  tree 
)
protected

Member Data Documentation

◆ DataSet

vtkDataSet* vtkSphereTree::DataSet
protected

Definition at line 198 of file vtkSphereTree.h.

◆ Selected

unsigned char* vtkSphereTree::Selected
protected

Definition at line 199 of file vtkSphereTree.h.

◆ Resolution

int vtkSphereTree::Resolution
protected

Definition at line 200 of file vtkSphereTree.h.

◆ MaxLevel

int vtkSphereTree::MaxLevel
protected

Definition at line 201 of file vtkSphereTree.h.

◆ NumberOfLevels

int vtkSphereTree::NumberOfLevels
protected

Definition at line 202 of file vtkSphereTree.h.

◆ BuildHierarchy

bool vtkSphereTree::BuildHierarchy
protected

Definition at line 203 of file vtkSphereTree.h.

◆ Tree

vtkDoubleArray* vtkSphereTree::Tree
protected

Definition at line 206 of file vtkSphereTree.h.

◆ TreePtr

double* vtkSphereTree::TreePtr
protected

Definition at line 207 of file vtkSphereTree.h.

◆ Hierarchy

vtkSphereTreeHierarchy* vtkSphereTree::Hierarchy
protected

Definition at line 208 of file vtkSphereTree.h.

◆ AverageRadius

double vtkSphereTree::AverageRadius
protected

Definition at line 211 of file vtkSphereTree.h.

◆ SphereBounds

double vtkSphereTree::SphereBounds[6]
protected

Definition at line 212 of file vtkSphereTree.h.

◆ BuildTime

vtkTimeStamp vtkSphereTree::BuildTime
protected

Definition at line 213 of file vtkSphereTree.h.

◆ SphereTreeType

int vtkSphereTree::SphereTreeType
protected

Definition at line 222 of file vtkSphereTree.h.


The documentation for this class was generated from the following file: