vtkVisItScalarTree.h 3.22 KB
Newer Older
hrchilds's avatar
hrchilds committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    $RCSfile: vtkVisItScalarTree.h,v $
  Language:  C++
  Date:      $Date: 2002/01/22 15:29:13 $
  Version:   $Revision: 1.54 $

  Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
// .NAME vtkVisItScalarTree - Takes in point data from a dataset and
// organizes the range of values a cell takes into a tree, which can
// return what cells may potentially contain a value. Used for
// accelerating contouring code.

#ifndef __vtkVisItScalarTree_h
#define __vtkVisItScalarTree_h

#include <visit_vtk_exports.h>
#include "vtkDataSet.h"
#include "vtkObject.h"

#include <vector>

class VISIT_VTK_API vtkVisItScalarTree : public vtkObject
{
public:
35
  vtkTypeMacro(vtkVisItScalarTree,vtkObject);
hrchilds's avatar
hrchilds committed
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51

  // Description:
  // Instantiate scalar tree with maximum level of 20 and branching
  // factor of 3.
  static vtkVisItScalarTree *New();

  // Description:
  // Build the tree from the points/cells defining this dataset.
  vtkSetObjectMacro(DataSet,vtkDataSet);
  vtkGetObjectMacro(DataSet,vtkDataSet);

  // Description:
  // Set the branching factor for the tree. This is the number of
  // children per tree node. Smaller values (minimum is 2) mean deeper
  // trees and more memory overhead. Larger values mean shallower
  // trees, less memory usage, but worse performance.
bonnell's avatar
bonnell committed
52
  vtkSetClampMacro(BranchingFactor,vtkIdType,2,VTK_INT_MAX);
53
  vtkGetMacro(BranchingFactor,vtkIdType);
hrchilds's avatar
hrchilds committed
54 55 56

  // Description:
  // Set the maximum allowable level for the tree. 
bonnell's avatar
bonnell committed
57
  vtkSetClampMacro(MaxLevel,vtkIdType,1,VTK_INT_MAX);
58
  vtkGetMacro(MaxLevel,vtkIdType);
hrchilds's avatar
hrchilds committed
59 60 61 62 63 64 65 66 67 68 69 70 71

  // Description:
  // Construct the scalar tree from the dataset provided.
  // Checks modified time stamp to see if tree needs regenerating.
  void BuildTree();
  
  // Description:
  // Initialize locator. Frees memory and resets object as appropriate.
  void Initialize();

  // Description:
  // Fill a vector of cells that may contain a particular scalar
  // value. Automatically calls BuildTree.
72
  void GetCellList(double scalarValue, std::vector<vtkIdType> &v);
hrchilds's avatar
hrchilds committed
73 74 75 76 77 78 79 80 81 82 83 84 85

  // Description:
  // Free the allocated tree structure.
  void FreeSearchStructure()
  {
      if (tree)
          delete tree;
      tree = NULL;
  }

protected:
  vtkVisItScalarTree();
  ~vtkVisItScalarTree();
86 87
  vtkVisItScalarTree(const vtkVisItScalarTree&);  // Not implemented.
  void operator=(const vtkVisItScalarTree&); // Not implemented.
hrchilds's avatar
hrchilds committed
88

89
  void RecursiveSearch(std::vector<vtkIdType> &v, vtkIdType index, vtkIdType lev);
hrchilds's avatar
hrchilds committed
90 91 92 93

  vtkTimeStamp BuildTime;
  
  vtkDataSet *DataSet;
94 95 96 97
  vtkIdType levels;
  vtkIdType bucketSize;
  vtkIdType nCells;
  vtkIdType leafOffset;
hrchilds's avatar
hrchilds committed
98

99 100
  vtkIdType MaxLevel;
  vtkIdType BranchingFactor;
hrchilds's avatar
hrchilds committed
101 102 103

  struct ScalarRange
  {
104
      double min, max;
hrchilds's avatar
hrchilds committed
105 106 107
  };
  
  ScalarRange *tree;
108
  vtkIdType treeSize;
hrchilds's avatar
hrchilds committed
109

110
  double searchValue;
hrchilds's avatar
hrchilds committed
111 112 113 114 115 116
};


#endif