VTK  9.1.0
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=========================================================================*/
46#ifndef vtkCellTreeLocator_h
47#define vtkCellTreeLocator_h
48
50#include "vtkFiltersGeneralModule.h" // For export macro
51#include <vector> // Needed for internal class
52
53class vtkCellPointTraversal;
54class vtkIdTypeArray;
55class vtkCellArray;
56
57class VTKFILTERSGENERAL_EXPORT vtkCellTreeLocator : public vtkAbstractCellLocator
58{
59public:
60 class vtkCellTree;
61 class vtkCellTreeNode;
62
64 void PrintSelf(ostream& os, vtkIndent indent) override;
65
72
77 vtkIdType FindCell(double pos[3], double vtkNotUsed(tol2), vtkGenericCell* cell,
78 double pcoords[3], double* weights) override;
79
84 int IntersectWithLine(const double a0[3], const double a1[3], double tol, double& t, double x[3],
85 double pcoords[3], int& subId, vtkIdType& cellId, vtkGenericCell* cell) override;
86
92 void FindCellsWithinBounds(double* bbox, vtkIdList* cells) override;
93
94 /*
95 if the borland compiler is ever removed, we can use these declarations
96 instead of reimplementaing the calls in this subclass
97 using vtkAbstractCellLocator::IntersectWithLine;
98 using vtkAbstractCellLocator::FindClosestPoint;
99 using vtkAbstractCellLocator::FindClosestPointWithinRadius;
100 */
101
105 int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t, double x[3],
106 double pcoords[3], int& subId) override
107 {
108 return this->Superclass::IntersectWithLine(p1, p2, tol, t, x, pcoords, subId);
109 }
110
117 int IntersectWithLine(const double p1[3], const double p2[3], double tol, double& t, double x[3],
118 double pcoords[3], int& subId, vtkIdType& cellId) override;
119
124 const double p1[3], const double p2[3], vtkPoints* points, vtkIdList* cellIds) override
125 {
126 return this->Superclass::IntersectWithLine(p1, p2, points, cellIds);
127 }
128
132 vtkIdType FindCell(double x[3]) override { return this->Superclass::FindCell(x); }
133
135
138 void FreeSearchStructure() override;
139 void GenerateRepresentation(int level, vtkPolyData* pd) override;
140 virtual void BuildLocatorInternal();
141 virtual void BuildLocatorIfNeeded();
142 virtual void ForceBuildLocator();
143 void BuildLocator() override;
145
147
151 class VTKFILTERSGENERAL_EXPORT vtkCellTree
152 {
153 public:
154 std::vector<vtkCellTreeNode> Nodes;
155 std::vector<unsigned int> Leaves;
156 friend class vtkCellPointTraversal;
157 friend class vtkCellTreeNode;
158 friend class vtkCellTreeBuilder;
160
161 public:
162 float DataBBox[6]; // This store the bounding values of the dataset
163 };
164
175 class VTKFILTERSGENERAL_EXPORT vtkCellTreeNode
176 {
177 public:
178 protected:
179 unsigned int Index;
180 float LeftMax; // left max value
181 float RightMin; // right min value
182
183 unsigned int Sz; // size
184 unsigned int St; // start
185
186 friend class vtkCellTree;
187 friend class vtkCellPointTraversal;
188 friend class vtkCellTreeBuilder;
189
190 public:
191 void MakeNode(unsigned int left, unsigned int d, float b[2]);
192 void SetChildren(unsigned int left);
193 bool IsNode() const;
194 unsigned int GetLeftChildIndex() const;
195 unsigned int GetRightChildIndex() const;
196 unsigned int GetDimension() const;
197 const float& GetLeftMaxValue() const;
198 const float& GetRightMinValue() const;
199 void MakeLeaf(unsigned int start, unsigned int size);
200 bool IsLeaf() const;
201 unsigned int Start() const;
202 unsigned int Size() const;
203 };
204
205protected:
208
209 // Test ray against node BBox : clip t values to extremes
210 bool RayMinMaxT(const double origin[3], const double dir[3], double& rTmin, double& rTmax);
211
212 bool RayMinMaxT(const double bounds[6], const double origin[3], const double dir[3],
213 double& rTmin, double& rTmax);
214
215 int getDominantAxis(const double dir[3]);
216
217 // Order nodes as near/far relative to ray
218 void Classify(const double origin[3], const double dir[3], double& rDist, vtkCellTreeNode*& near,
219 vtkCellTreeNode*& mid, vtkCellTreeNode*& far, int& mustCheck);
220
221 // From vtkModifiedBSPTRee
222 // We provide a function which does the cell/ray test so that
223 // it can be overridden by subclasses to perform special treatment
224 // (Example : Particles stored in tree, have no dimension, so we must
225 // override the cell test to return a value based on some particle size
226 virtual int IntersectCellInternal(vtkIdType cell_ID, const double p1[3], const double p2[3],
227 const double tol, double& t, double ipt[3], double pcoords[3], int& subId);
228
230
232
233 friend class vtkCellPointTraversal;
234 friend class vtkCellTreeNode;
235 friend class vtkCellTreeBuilder;
236
237private:
238 vtkCellTreeLocator(const vtkCellTreeLocator&) = delete;
239 void operator=(const vtkCellTreeLocator&) = delete;
240};
241
242#endif
an abstract base class for locators which find cells
object to represent cell connectivity
This class is the basic building block of the cell tree.
void MakeLeaf(unsigned int start, unsigned int size)
unsigned int GetRightChildIndex() const
unsigned int GetDimension() const
const float & GetRightMinValue() const
void SetChildren(unsigned int left)
void MakeNode(unsigned int left, unsigned int d, float b[2])
const float & GetLeftMaxValue() const
unsigned int GetLeftChildIndex() const
Internal classes made public to allow subclasses to create customized some traversal algorithms.
std::vector< unsigned int > Leaves
std::vector< vtkCellTreeNode > Nodes
This class implements the data structures, construction algorithms for fast cell location presented i...
void FindCellsWithinBounds(double *bbox, vtkIdList *cells) override
Return a list of unique cell ids inside of a given bounding box.
int IntersectWithLine(const double p1[3], const double p2[3], vtkPoints *points, vtkIdList *cellIds) override
reimplemented from vtkAbstractCellLocator to support bad compilers
int IntersectWithLine(const double a0[3], const double a1[3], double tol, double &t, double x[3], double pcoords[3], int &subId, vtkIdType &cellId, vtkGenericCell *cell) override
Return intersection point (if any) AND the cell which was intersected by the finite line.
bool RayMinMaxT(const double bounds[6], const double origin[3], const double dir[3], double &rTmin, double &rTmax)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int IntersectWithLine(const double p1[3], const double p2[3], double tol, double &t, double x[3], double pcoords[3], int &subId) override
reimplemented from vtkAbstractCellLocator to support bad compilers
int getDominantAxis(const double dir[3])
void Classify(const double origin[3], const double dir[3], double &rDist, vtkCellTreeNode *&near, vtkCellTreeNode *&mid, vtkCellTreeNode *&far, int &mustCheck)
virtual void BuildLocatorIfNeeded()
Satisfy vtkLocator abstract interface.
vtkIdType FindCell(double x[3]) override
reimplemented from vtkAbstractCellLocator to support bad compilers
virtual void ForceBuildLocator()
Satisfy vtkLocator abstract interface.
~vtkCellTreeLocator() override
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)
bool RayMinMaxT(const double origin[3], const double dir[3], double &rTmin, double &rTmax)
virtual void BuildLocatorInternal()
Satisfy vtkLocator abstract interface.
vtkIdType FindCell(double pos[3], double vtkNotUsed(tol2), vtkGenericCell *cell, double pcoords[3], double *weights) override
Test a point to find if it is inside a cell.
void FreeSearchStructure() override
Satisfy vtkLocator abstract interface.
int IntersectWithLine(const double p1[3], const double p2[3], double tol, double &t, double x[3], double pcoords[3], int &subId, vtkIdType &cellId) override
Return intersection point (if any) AND the cell which was intersected by the finite line.
void GenerateRepresentation(int level, vtkPolyData *pd) override
Satisfy vtkLocator abstract interface.
void BuildLocator() override
Satisfy vtkLocator abstract interface.
static vtkCellTreeLocator * New()
Constructor sets the maximum number of cells in a leaf to 8 and number of buckets to 5.
provides thread-safe access to cells
list of point or cell ids
Definition vtkIdList.h:40
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition vtkIndent.h:43
represent and manipulate 3D points
Definition vtkPoints.h:43
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:95
int vtkIdType
Definition vtkType.h:332