1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: vtkLocator.h,v $
6 Date: $Date: 2003/01/06 20:36:14 $
7 Version: $Revision: 1.49 $
9 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
11 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notice for more information.
17 =========================================================================*/
18 // .NAME vtkLocator - abstract base class for objects that accelerate spatial searches
19 // .SECTION Description
20 // vtkLocator is an abstract base class for spatial search objects, or
21 // locators. The principle behind locators is that they divide 3-space into
22 // small pieces (or "buckets") that can be quickly found in response to
23 // queries like point location, line intersection, or object-object
26 // The purpose of this base class is to provide ivars and methods shared by
27 // all locators. The GenerateRepresentation() is one such interesting method.
28 // This method works in conjunction with vtkLocatorFilter to create polygonal
29 // representations for the locator. For example, if the locator is an OBB tree
30 // (i.e., vtkOBBTree.h), then the representation is a set of one or more
31 // oriented bounding boxes, depending upon the specified level.
33 // Locators typically work as follows. One or more "entities", such as
34 // points or cells, are inserted into the tree. These entities are associated
35 // with one or more buckets. Then, when performing geometric operations, the
36 // operations are performed first on the buckets, and then if the operation
37 // tests positive, then on the entities in the bucket. For example, during
38 // collision tests, the locators are collided first to identify intersecting
39 // buckets. If an intersection is found, more expensive operations are then
40 // carried out on the entities in the bucket.
42 // To obtain good performance, locators are often organized in a tree
43 // structure. In such a structure, there are frequently multiple "levels"
44 // corresponding to different nodes in the tree. So the word level (in the
45 // context of the locator) can be used to specify a particular representation
46 // in the tree. For example, in an octree (which is a tree with 8 children),
47 // level 0 is the bounding box, or root octant, and level 1 consists of its
51 // vtkPointLocator vtkCellLocator vtkOBBTree vtkLocatorFilter
53 #ifndef __vtkLocator_h
54 #define __vtkLocator_h
56 #include "vtkObject.h"
61 class VTK_COMMON_EXPORT vtkLocator : public vtkObject
64 vtkTypeRevisionMacro(vtkLocator,vtkObject);
65 void PrintSelf(ostream& os, vtkIndent indent);
68 // Build the locator from the points/cells defining this dataset.
69 virtual void SetDataSet(vtkDataSet*);
70 vtkGetObjectMacro(DataSet,vtkDataSet);
73 // Set the maximum allowable level for the tree. If the Automatic ivar is
74 // off, this will be the target depth of the locator.
75 vtkSetClampMacro(MaxLevel,int,0,VTK_LARGE_INTEGER);
76 vtkGetMacro(MaxLevel,int);
79 // Get the level of the locator (determined automatically if Automatic is
80 // true). The value of this ivar may change each time the locator is built.
81 vtkGetMacro(Level,int);
84 // Boolean controls whether locator depth/resolution of locator is computed
85 // automatically from average number of entities in bucket. If not set,
86 // there will be an explicit method to control the construction of the
87 // locator (found in the subclass).
88 vtkSetMacro(Automatic,int);
89 vtkGetMacro(Automatic,int);
90 vtkBooleanMacro(Automatic,int);
93 // Specify absolute tolerance (in world coordinates) for performing
94 // geometric operations.
95 vtkSetClampMacro(Tolerance,float,0.0f,VTK_LARGE_FLOAT);
96 vtkGetMacro(Tolerance,float);
99 // Boolean controls whether to maintain list of entities in each bucket.
100 // Normally the lists are maintained, but if the locator is being used
101 // as a geometry simplification technique, there is no need to keep them.
102 vtkSetMacro(RetainCellLists,int);
103 vtkGetMacro(RetainCellLists,int);
104 vtkBooleanMacro(RetainCellLists,int);
107 // Cause the locator to rebuild itself if it or its input dataset has
109 virtual void Update();
112 // Initialize locator. Frees memory and resets object as appropriate.
113 virtual void Initialize();
116 // Build the locator from the input dataset.
117 virtual void BuildLocator() = 0;
120 // Free the memory required for the spatial data structure.
121 virtual void FreeSearchStructure() = 0;
124 // Method to build a representation at a particular level. Note that the
125 // method GetLevel() returns the maximum number of levels available for
126 // the tree. You must provide a vtkPolyData object into which to place the
128 virtual void GenerateRepresentation(int level, vtkPolyData *pd) = 0;
131 // Return the time of the last data structure build.
132 vtkGetMacro(BuildTime, unsigned long);
139 int Automatic; // boolean controls automatic subdivision (or uses user spec.)
140 float Tolerance; // for performing merging
145 vtkTimeStamp BuildTime; // time at which locator was built
148 vtkLocator(const vtkLocator&); // Not implemented.
149 void operator=(const vtkLocator&); // Not implemented.