VTK
vtkCellTreeLocator.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkCellTreeLocator.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 =========================================================================*/
39 #ifndef vtkCellTreeLocator_h
40 #define vtkCellTreeLocator_h
41 
42 #include "vtkFiltersGeneralModule.h" // For export macro
43 #include "vtkAbstractCellLocator.h"
44 #include <vector> // Needed for internal class
45 
46 class vtkCellPointTraversal;
47 class vtkIdTypeArray;
48 class vtkCellArray;
49 
51 {
52  public:
53  class vtkCellTree;
54  class vtkCellTreeNode;
55 
57  void PrintSelf(ostream& os, vtkIndent indent);
58 
63 
65 
67  virtual vtkIdType FindCell(double pos[3], double vtkNotUsed, vtkGenericCell *cell, double pcoords[3],
68  double* weights );
70 
72 
75  virtual int IntersectWithLine(double a0[3], double a1[3], double tol,
76  double& t, double x[3], double pcoords[3],
77  int &subId, vtkIdType &cellId,
78  vtkGenericCell *cell);
80 
84  virtual void FindCellsWithinBounds(double *bbox, vtkIdList *cells);
85 
86  //BTX
87  /*
88  if the borland compiler is ever removed, we can use these declarations
89  instead of reimplementaing the calls in this subclass
90  using vtkAbstractCellLocator::IntersectWithLine;
91  using vtkAbstractCellLocator::FindClosestPoint;
92  using vtkAbstractCellLocator::FindClosestPointWithinRadius;
93  */
94  //ETX
96 
97  virtual int IntersectWithLine(
98  double p1[3], double p2[3], double tol, double& t, double x[3],
99  double pcoords[3], int &subId)
100  {
101  return this->Superclass::IntersectWithLine(p1, p2, tol, t, x, pcoords, subId);
102  }
104 
106 
111  virtual int IntersectWithLine(
112  double p1[3], double p2[3], double tol, double &t, double x[3],
113  double pcoords[3], int &subId, vtkIdType &cellId);
115 
117 
118  virtual int IntersectWithLine(
119  const double p1[3], const double p2[3],
120  vtkPoints *points, vtkIdList *cellIds)
121  {
122  return this->Superclass::IntersectWithLine(p1, p2, points, cellIds);
123  }
125 
127 
128  virtual vtkIdType FindCell(double x[3])
129  { return this->Superclass::FindCell(x); }
131 
133 
134  virtual void FreeSearchStructure();
135  virtual void GenerateRepresentation(int level, vtkPolyData *pd);
136  virtual void BuildLocatorInternal();
137  virtual void BuildLocatorIfNeeded();
138  virtual void ForceBuildLocator();
139  virtual void BuildLocator();
141 
142 
143 //BTX
145 
148  {
149  public:
150  std::vector<vtkCellTreeNode> Nodes;
151  std::vector<unsigned int> Leaves;
152  friend class vtkCellPointTraversal;
153  friend class vtkCellTreeNode;
154  friend class vtkCellTreeBuilder;
156 
157  public:
158  float DataBBox[6]; // This store the bounding values of the dataset
159  };
160 
162 
171  {
172  public:
174 
175  protected:
176  unsigned int Index;
177  float LeftMax; // left max value
178  float RightMin; // right min value
179 
180  unsigned int Sz; // size
181  unsigned int St; // start
182 
183  friend class vtkCellTree;
184  friend class vtkCellPointTraversal;
185  friend class vtkCellTreeBuilder;
186 
187  public:
188  void MakeNode( unsigned int left, unsigned int d, float b[2] );
189  void SetChildren( unsigned int left );
190  bool IsNode() const;
191  unsigned int GetLeftChildIndex() const;
192  unsigned int GetRightChildIndex() const;
193  unsigned int GetDimension() const;
194  const float& GetLeftMaxValue() const;
195  const float& GetRightMinValue() const;
196  void MakeLeaf( unsigned int start, unsigned int size );
197  bool IsLeaf() const;
198  unsigned int Start() const;
199  unsigned int Size() const;
200  };
201 //ETX
202 
203 protected:
206 
207  // Test ray against node BBox : clip t values to extremes
208  bool RayMinMaxT(const double origin[3],
209  const double dir[3],
210  double &rTmin,
211  double &rTmax);
212 
213  bool RayMinMaxT(const double bounds[6],
214  const double origin[3],
215  const double dir[3],
216  double &rTmin,
217  double &rTmax);
218 
219  int getDominantAxis(const double dir[3]);
220 
221  // Order nodes as near/far relative to ray
222  void Classify(const double origin[3],
223  const double dir[3],
224  double &rDist,
225  vtkCellTreeNode *&near, vtkCellTreeNode *&mid,
226  vtkCellTreeNode *&far, int &mustCheck);
227 
228  // From vtkModifiedBSPTRee
229  // We provide a function which does the cell/ray test so that
230  // it can be overriden by subclasses to perform special treatment
231  // (Example : Particles stored in tree, have no dimension, so we must
232  // override the cell test to return a value based on some particle size
233  virtual int IntersectCellInternal( vtkIdType cell_ID, const double p1[3],
234  const double p2[3],
235  const double tol,
236  double &t,
237  double ipt[3],
238  double pcoords[3],
239  int &subId);
240 
241 
243 
245 
246  friend class vtkCellPointTraversal;
247  friend class vtkCellTreeNode;
248  friend class vtkCellTreeBuilder;
249 
250 private:
251  vtkCellTreeLocator(const vtkCellTreeLocator&); // Not implemented.
252  void operator=(const vtkCellTreeLocator&); // Not implemented.
253 };
254 
255 #endif
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:39
vtkgl::weights
const GLbyte * weights
Definition: vtkgl.h:12766
vtkCellTreeLocator::vtkCellTreeNode::GetRightMinValue
const float & GetRightMinValue() const
vtkCellTreeLocator::vtkCellTree
Definition: vtkCellTreeLocator.h:148
vtkCellTreeLocator::vtkCellTree::Nodes
std::vector< vtkCellTreeNode > Nodes
Definition: vtkCellTreeLocator.h:150
vtkgl::b
GLboolean GLboolean GLboolean b
Definition: vtkgl.h:12312
vtkCellTreeLocator::vtkCellTreeNode::St
unsigned int St
Definition: vtkCellTreeLocator.h:181
vtkCellTreeLocator::BuildLocatorInternal
virtual void BuildLocatorInternal()
vtkCellTreeLocator::vtkCellTreeNode
Definition: vtkCellTreeLocator.h:171
vtkIdType
int vtkIdType
Definition: vtkType.h:275
vtkCellTreeLocator::vtkCellTreeNode::SetChildren
void SetChildren(unsigned int left)
vtkCellTreeLocator::BuildLocator
virtual void BuildLocator()
vtkCellTreeLocator::vtkCellTreeNode::GetLeftChildIndex
unsigned int GetLeftChildIndex() const
vtkTypeMacro
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:642
vtkCellTreeLocator::IntersectWithLine
virtual int IntersectWithLine(double p1[3], double p2[3], double tol, double &t, double x[3], double pcoords[3], int &subId)
Definition: vtkCellTreeLocator.h:97
vtkAbstractCellLocator.h
vtkX3D::dir
@ dir
Definition: vtkX3D.h:324
vtkgl::x
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
vtkCellTreeLocator::IntersectWithLine
virtual int IntersectWithLine(double p1[3], double p2[3], double tol, double &t, double x[3], double pcoords[3], int &subId, vtkIdType &cellId)
vtkgl::left
GLint left
Definition: vtkgl.h:14367
vtkCellTreeLocator::vtkCellTreeLocator
vtkCellTreeLocator()
vtkCellTreeLocator::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
vtkgl::points
GLsizei const GLfloat * points
Definition: vtkgl.h:14786
vtkCellTreeLocator::FindCell
virtual vtkIdType FindCell(double x[3])
Definition: vtkCellTreeLocator.h:128
vtkCellTreeLocator::vtkCellTreeNode::MakeLeaf
void MakeLeaf(unsigned int start, unsigned int size)
vtkCellTreeLocator::vtkCellTreeNode::Sz
unsigned int Sz
Definition: vtkCellTreeLocator.h:180
vtkCellTreeLocator::Tree
vtkCellTree * Tree
Definition: vtkCellTreeLocator.h:244
vtkCellTreeLocator::vtkCellTreeNode::IsNode
bool IsNode() const
vtkCellTreeLocator::GenerateRepresentation
virtual void GenerateRepresentation(int level, vtkPolyData *pd)
vtkNotUsed
#define vtkNotUsed(x)
Definition: vtkSetGet.h:557
vtkCellTreeLocator::FindCellsWithinBounds
virtual void FindCellsWithinBounds(double *bbox, vtkIdList *cells)
vtkFiltersGeneralModule.h
vtkCellTreeLocator::vtkCellTreeNode::Start
unsigned int Start() const
vtkCellTreeLocator::vtkCellTreeNode::Index
unsigned int Index
Definition: vtkCellTreeLocator.h:176
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkgl::start
GLuint start
Definition: vtkgl.h:11315
vtkCellArray
object to represent cell connectivity
Definition: vtkCellArray.h:50
vtkCellTreeLocator::Classify
void Classify(const double origin[3], const double dir[3], double &rDist, vtkCellTreeNode *&near, vtkCellTreeNode *&mid, vtkCellTreeNode *&far, int &mustCheck)
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:36
VTKFILTERSGENERAL_EXPORT
#define VTKFILTERSGENERAL_EXPORT
Definition: vtkFiltersGeneralModule.h:15
vtkCellTreeLocator::RayMinMaxT
bool RayMinMaxT(const double origin[3], const double dir[3], double &rTmin, double &rTmax)
vtkCellTreeLocator::BuildLocatorIfNeeded
virtual void BuildLocatorIfNeeded()
vtkCellTreeLocator::FreeSearchStructure
virtual void FreeSearchStructure()
vtkCellTreeLocator::IntersectWithLine
virtual int IntersectWithLine(double a0[3], double a1[3], double tol, double &t, double x[3], double pcoords[3], int &subId, vtkIdType &cellId, vtkGenericCell *cell)
vtkgl::level
GLint level
Definition: vtkgl.h:11316
vtkAbstractCellLocator
an abstract base class for locators which find cells
Definition: vtkAbstractCellLocator.h:50
vtkCellTreeLocator::vtkCellTreeNode::GetLeftMaxValue
const float & GetLeftMaxValue() const
vtkCellTreeLocator::IntersectCellInternal
virtual int IntersectCellInternal(vtkIdType cell_ID, const double p1[3], const double p2[3], const double tol, double &t, double ipt[3], double pcoords[3], int &subId)
vtkCellTreeLocator::vtkCellTreeNode::GetDimension
unsigned int GetDimension() const
vtkCellTreeLocator::NumberOfBuckets
int NumberOfBuckets
Definition: vtkCellTreeLocator.h:242
vtkCellTreeLocator::vtkCellTreeNode::GetRightChildIndex
unsigned int GetRightChildIndex() const
vtkgl::t
GLdouble GLdouble t
Definition: vtkgl.h:11602
vtkIdTypeArray
dynamic, self-adjusting array of vtkIdType
Definition: vtkIdTypeArray.h:49
vtkCellTreeLocator::vtkCellTreeNode::MakeNode
void MakeNode(unsigned int left, unsigned int d, float b[2])
vtkCellTreeLocator::New
static vtkCellTreeLocator * New()
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
vtkGenericCell
provides thread-safe access to cells
Definition: vtkGenericCell.h:42
vtkCellTreeLocator::~vtkCellTreeLocator
~vtkCellTreeLocator()
vtkCellTreeLocator::vtkCellTreeNode::LeftMax
float LeftMax
Definition: vtkCellTreeLocator.h:177
vtkCellTreeLocator::vtkCellTree::Leaves
std::vector< unsigned int > Leaves
Definition: vtkCellTreeLocator.h:151
vtkCellTreeLocator::ForceBuildLocator
virtual void ForceBuildLocator()
vtkCellTreeLocator::RayMinMaxT
bool RayMinMaxT(const double bounds[6], const double origin[3], const double dir[3], double &rTmin, double &rTmax)
vtkCellTreeLocator
This class implements the data structures, construction algorithms for fast cell location presented i...
Definition: vtkCellTreeLocator.h:51
vtkCellTreeLocator::FindCell
virtual vtkIdType FindCell(double pos[3], double vtkNotUsed, vtkGenericCell *cell, double pcoords[3], double *weights)
vtkCellTreeLocator::IntersectWithLine
virtual int IntersectWithLine(const double p1[3], const double p2[3], vtkPoints *points, vtkIdList *cellIds)
Definition: vtkCellTreeLocator.h:118
vtkCellTreeLocator::getDominantAxis
int getDominantAxis(const double dir[3])
vtkCellTreeLocator::vtkCellTreeNode::RightMin
float RightMin
Definition: vtkCellTreeLocator.h:178
vtkCellTreeLocator::vtkCellTreeNode::Size
unsigned int Size() const
vtkgl::size
GLsizeiptr size
Definition: vtkgl.h:11843
vtkCellTreeLocator::vtkCellTreeNode::IsLeaf
bool IsLeaf() const