OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / SGI / util / SGI / include / graphics / vtkScalarTree.h
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    $RCSfile: vtkScalarTree.h,v $
5   Language:  C++
6   Date:      $Date: 2002/02/01 06:30:47 $
7   Version:   $Revision: 1.1.1.1 $
8
9
10 Copyright (c) 1993-1998 Ken Martin, Will Schroeder, Bill Lorensen.
11
12 This software is copyrighted by Ken Martin, Will Schroeder and Bill Lorensen.
13 The following terms apply to all files associated with the software unless
14 explicitly disclaimed in individual files. This copyright specifically does
15 not apply to the related textbook "The Visualization Toolkit" ISBN
16 013199837-4 published by Prentice Hall which is covered by its own copyright.
17
18 The authors hereby grant permission to use, copy, and distribute this
19 software and its documentation for any purpose, provided that existing
20 copyright notices are retained in all copies and that this notice is included
21 verbatim in any distributions. Additionally, the authors grant permission to
22 modify this software and its documentation for any purpose, provided that
23 such modifications are not distributed without the explicit consent of the
24 authors and that existing copyright notices are retained in all copies. Some
25 of the algorithms implemented by this software are patented, observe all
26 applicable patent law.
27
28 IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
29 DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
30 OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
31 EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33 THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
34 BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
35 PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE IS PROVIDED ON AN
36 "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
37 MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
38
39
40 =========================================================================*/
41 // .NAME vtkScalarTree - organize data according to scalar values (used to accelerate contouring operations)
42 // .SECTION Description
43 // vtkScalarTree creates a pointerless binary tree that helps search for
44 // cells that lie within a particular scalar range. This object is used to
45 // accelerate some contouring (and other scalar-baed techniques).
46 // 
47 // The tree consists of an array of (min,max) scalar range pairs per node in
48 // the tree. The (min,max) range is determined from looking at the range of
49 // the children of the tree node. If the node is a leaf, then the range is
50 // determined by scanning the range of scalar data in n cells in the
51 // dataset. The n cells are determined by arbitrary selecting cell ids from
52 // id(i) to id(i+n), and where n is specified using the BranchingFactor
53 // ivar. Note that leaf node i=0 contains the scalar range computed from
54 // cell ids (0,n-1); leaf node i=1 contains the range from cell ids (n,2n-1);
55 // and so on. The implication is that there are no direct lists of cell ids
56 // per leaf node, instead the cell ids are implicitly known.
57
58 #ifndef __vtkScalarTree_h
59 #define __vtkScalarTree_h
60
61 #include "vtkDataSet.h"
62
63 typedef struct _vtkScalarRange
64   {
65   float min;
66   float max;
67   } vtkScalarRange;
68
69
70 class VTK_EXPORT vtkScalarTree : public vtkObject
71 {
72 public:
73   vtkScalarTree();
74   ~vtkScalarTree();
75   static vtkScalarTree *New() {return new vtkScalarTree;};
76   const char *GetClassName() {return "vtkScalarTree";};
77   void PrintSelf(ostream& os, vtkIndent indent);
78
79   // Description:
80   // Build the tree from the points/cells defining this dataset.
81   vtkSetObjectMacro(DataSet,vtkDataSet);
82   vtkGetObjectMacro(DataSet,vtkDataSet);
83
84   // Description:
85   // Set the branching factor for the tree. This is the number of
86   // children per tree node. Smaller values (minimum is 2) mean deeper
87   // trees and more memory overhead. Larger values mean shallower
88   // trees, less memory usage, but worse performance.
89   vtkSetClampMacro(BranchingFactor,int,2,VTK_LARGE_INTEGER);
90   vtkGetMacro(BranchingFactor,int);
91
92   // Description:
93   // Get the level of the locator (determined automatically if Automatic is 
94   // true). The value of this ivar may change each time the locator is built.
95   vtkGetMacro(Level,int);
96
97   // Description:
98   // Set the maximum allowable level for the tree. 
99   vtkSetClampMacro(MaxLevel,int,1,VTK_LARGE_INTEGER);
100   vtkGetMacro(MaxLevel,int);
101
102   // Methods control building of tree
103   void BuildTree();
104   void Initialize();
105
106   // Methods provided for traversing cells based on scalar value
107   void InitTraversal(float scalarValue);
108   vtkCell *GetNextCell(int& cellId, vtkIdList* &ptIds,
109                        vtkScalars& cellScalars);
110
111 protected:
112   vtkDataSet *DataSet;
113   vtkScalars *Scalars;
114   int MaxLevel;
115   int Level;
116   int BranchingFactor; //number of children per node
117
118   vtkScalarRange *Tree; //pointerless scalar range tree
119   int TreeSize; //allocated size of tree
120   vtkTimeStamp BuildTime; //time at which tree was built
121
122 private:
123   float ScalarValue; //current scalar value for traversal
124   int TreeIndex; //traversal location within tree
125   int LeafOffset; //offset to leaf nodes of tree
126   int ChildNumber; //current child in traversal
127   int CellId; //current cell id being examined
128   int FindStartLeaf(int index, int level);
129   int FindNextLeaf(int index,int level);
130 };
131
132 #endif
133
134