VTK
vtkHyperOctree.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkHyperOctree.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 =========================================================================*/
118 #ifndef vtkHyperOctree_h
119 #define vtkHyperOctree_h
120 
121 #include "vtkCommonDataModelModule.h" // For export macro
122 #include "vtkDataSet.h"
123 
126 class vtkHyperOctreeInternal;
128 
129 class vtkHyperOctreeIdSet; // Pimpl idiom
130 class vtkPolygon;
131 class vtkIdTypeArray;
132 class vtkPoints;
133 class vtkPointLocator;
136 
137 class vtkLine;
138 class vtkPixel;
139 class vtkVoxel;
140 class vtkCellLinks;
141 
143 {
144 public:
145  static vtkInformationIntegerKey* LEVELS();
146  static vtkInformationIntegerKey* DIMENSION();
147  static vtkInformationDoubleVectorKey* SIZES();
148  static vtkHyperOctree *New();
149 
150  vtkTypeMacro(vtkHyperOctree,vtkDataSet);
151  void PrintSelf(ostream& os, vtkIndent indent);
152 
154  int GetDataObjectType();
155 
158  void CopyStructure(vtkDataSet *ds);
159 
160  // Return the node describes by the path from the root.
161  // Path is a sequence of number between 0 and 7.
162  // \pre path_exists: path!=0
163  // \pre node_exists: IsANode(path)
164 // vtkOctree *GetNode(vtkPath *path);
165 
169  int GetDimension();
170 
174  void SetDimension(int dim);
175 
176  // Return if the node for the given path exists or not.
177  // \pre path_exists: path!=0
178 // int IsANode(vtkPath *path);
179 
180  // Return if the node for the given path is a leaf or not.
181  // \pre path_exists: path!=0
182  // \pre node_exists: IsANode(path)
183 // int IsALeaf(vtkPath *path);
184 
185  // Measurement: topology
186 
190 
192  vtkIdType GetNumberOfLeaves();
193 
197 
204  vtkIdType GetMaxNumberOfPoints(int level);
205 
216  vtkIdType GetMaxNumberOfPointsOnBoundary(int level);
217 
222  vtkIdType GetMaxNumberOfCellsOnBoundary(int level);
223 
226  vtkIdType GetNumberOfLevels();
227 
228  // Measurement: geometry
229 
231 
232  vtkSetVector3Macro(Size,double);
234 
236 
237  vtkGetVector3Macro(Size,double);
239 
241 
242  vtkSetVector3Macro(Origin,double);
243  // Return the origin (position of corner (0,0,0) ) of the root.
244  vtkGetVector3Macro(Origin,double);
246 
249  vtkHyperOctreeCursor *NewCellCursor();
250 
254  void SubdivideLeaf(vtkHyperOctreeCursor *leaf);
255 
260  void CollapseTerminalNode(vtkHyperOctreeCursor *node);
261 
264  virtual double *GetPoint(vtkIdType ptId);
265 
269  virtual void GetPoint(vtkIdType id, double x[3]);
270 
273  virtual vtkCell *GetCell(vtkIdType cellId);
274 
279  virtual void GetCell(vtkIdType cellId, vtkGenericCell *cell);
280 
281 
285  virtual int GetCellType(vtkIdType cellId);
286 
288 
291  virtual void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds);
292  virtual void GetCellPoints(vtkIdType cellId, vtkIdType& npts,
293  vtkIdType* &pts);
295 
299  virtual void GetPointCells(vtkIdType ptId, vtkIdList *cellIds);
300 
301 
303 
307  virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds,
308  vtkIdList *cellIds);
310 
311  virtual vtkIdType FindPoint(double x[3]);
312 
314 
322  virtual vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId,
323  double tol2, int& subId, double pcoords[3],
324  double *weights);
326 
328 
333  virtual vtkIdType FindCell(double x[3], vtkCell *cell,
334  vtkGenericCell *gencell, vtkIdType cellId,
335  double tol2, int& subId, double pcoords[3],
336  double *weights);
338 
340  void Initialize();
341 
345  virtual int GetMaxCellSize();
346 
348 
349  void ShallowCopy(vtkDataObject *src);
350  void DeepCopy(vtkDataObject *src);
352 
354 
359  void GetPointsOnFace(vtkHyperOctreeCursor *sibling,
360  int face,
361  int level,
362  vtkHyperOctreePointsGrabber *grabber);
364 
366 
371  void GetPointsOnParentFaces(int faces[3],
372  int level,
373  vtkHyperOctreeCursor *cursor,
374  vtkHyperOctreePointsGrabber *grabber);
376 
378 
389  void GetPointsOnEdge(vtkHyperOctreeCursor *sibling,
390  int level,
391  int axis,
392  int k,
393  int j,
394  vtkHyperOctreePointsGrabber *grabber);
396 
398 
407  void GetPointsOnParentEdge(vtkHyperOctreeCursor *cursor,
408  int level,
409  int axis,
410  int k,
411  int j,
412  vtkHyperOctreePointsGrabber *grabber);
414 
416 
421  void GetPointsOnEdge2D(vtkHyperOctreeCursor *sibling,
422  int edge,
423  int level,
424  vtkHyperOctreePointsGrabber *grabber);
426 
428 
433  void GetPointsOnParentEdge2D(vtkHyperOctreeCursor *cursor,
434  int edge,
435  int level,
436  vtkHyperOctreePointsGrabber *grabber);
438 
441  vtkDataSetAttributes* GetLeafData();
442 
444 
445  void SetDualGridFlag(int flag);
446  vtkGetMacro(DualGridFlag,int);
448 
454  unsigned long GetActualMemorySize();
455 
456  //BTX
458 
460  static vtkHyperOctree* GetData(vtkInformationVector* v, int i=0);
461  //ETX
463 
464 protected:
465  // Constructor with default bounds (0,1, 0,1, 0,1).
466  vtkHyperOctree();
467  ~vtkHyperOctree();
468 
469  void ComputeBounds();
470 
471  int Dimension; // 1, 2 or 3.
472 
473  double Size[3]; // size on each axis
474  double Origin[3]; // position of corner (0,0,0) of the root.
475 
476  vtkHyperOctreeInternal *CellTree;
477 
478  vtkHyperOctreeCursor *TmpChild; // to avoid allocation in the loop
479 
480  //BTX
482  //ETX
483 
484  // Initialize the arrays if necessary, then return it.
485  void UpdateDualArrays();
486  vtkPoints* GetLeafCenters();
487  vtkIdTypeArray* GetCornerLeafIds();
490 
491  void UpdateGridArrays();
492  vtkPoints* GetCornerPoints();
493  vtkIdTypeArray* GetLeafCornerIds();
496 
497  void DeleteInternalArrays();
498 
499  void TraverseDualRecursively(vtkHyperOctreeLightWeightCursor* neighborhood,
500  unsigned short *xyzIds, int level);
501  void TraverseGridRecursively(vtkHyperOctreeLightWeightCursor* neighborhood,
502  unsigned char* visited,
503  double* origin, double* size);
504  void EvaluateDualCorner(vtkHyperOctreeLightWeightCursor* neighborhood);
505  vtkIdType EvaluateGridCorner(int level,vtkHyperOctreeLightWeightCursor* neighborhood,
506  unsigned char* visited, int* cornerNeighborIds);
507 
508  // This is a table for traversing a neighborhood down an octree.
509  // 8 children x 27 cursors
510  // First three bits encode the child, rest encode the cursor id.
511  // 8xCursorId + childId.
512  // This will be shorter when we get rid of the 3x3x3 neighborhood.
513  // I was using unsigned char, but VS60 optimized build had a problem.
514  int NeighborhoodTraversalTable[216];
515  void GenerateGridNeighborhoodTraversalTable();
516  void GenerateDualNeighborhoodTraversalTable();
517 
518  // for the GetCell method
522 
524  void BuildLinks();
525 
526  vtkIdType RecursiveFindPoint(double x[3],
528  double *origin, double *size);
529 
530  // This toggles the data set API between the leaf cells and
531  // the dual grid (leaves are points, corners are cells).
533 
534 private:
535  vtkHyperOctree(const vtkHyperOctree&); // Not implemented.
536  void operator=(const vtkHyperOctree&); // Not implemented.
537 };
538 
539 
540 //BTX
541 
543 {
544 public:
546  void Initialize(vtkHyperOctree* tree);
547  void ToRoot();
548  void ToChild(int child);
549  unsigned short GetIsLeaf();
550  int GetLeafIndex() {return this->Index;} // Only valid for leaves.
551  vtkHyperOctree* GetTree() { return this->Tree; }
552  unsigned short GetLevel() {return this->Level;}
553 private:
554  vtkHyperOctree* Tree;
555  int Index;
556  unsigned short IsLeaf;
557  unsigned short Level;
558 };
559 
560 //ETX
561 
562 #endif
vtkVoxel * Voxel
virtual vtkIdType GetNumberOfCells()=0
virtual void GetPointCells(vtkIdType ptId, vtkIdList *cellIds)=0
vtkIdTypeArray * CornerLeafIds
unsigned long GetActualMemorySize()
vtkPoints * CornerPoints
static vtkDataObject * New()
virtual vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId, double tol2, int &subId, double pcoords[3], double *weights)=0
quickly locate points in 3-space
Store vtkAlgorithm input/output information.
virtual vtkIdType GetNumberOfPoints()=0
abstract class to specify dataset behavior
Definition: vtkDataSet.h:61
a cell that represents an orthogonal quadrilateral
Definition: vtkPixel.h:39
vtkPoints * LeafCenters
virtual void ComputeBounds()
An object used by filters to store points computed on face or edge of an hyperoctant. It is an abstract class. vtkClipHyperOctree and vtkHyperOctreeCutter use vtkHyperOctreeClipCutPointsGrabber vtkHyperOctreeContourFilter use an internal one: vtkHyperOctreeContourFilterPointsGrabber.
helper class to generate triangulations
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:275
A dataset structured as a tree where each node has exactly 2^n children.
static vtkDataSet * GetData(vtkInformation *info)
provides thread-safe access to cells
cell represents a 1D line
Definition: vtkLine.h:34
abstract class to specify cell behavior
Definition: vtkCell.h:61
void PrintSelf(ostream &os, vtkIndent indent)
a cell that represents a 3D orthogonal parallelepiped
Definition: vtkVoxel.h:43
Key for double vector values.
a simple class to control print indentation
Definition: vtkIndent.h:38
virtual int GetMaxCellSize()=0
list of point or cell ids
Definition: vtkIdList.h:35
virtual void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds)=0
Key for integer values in vtkInformation.
int GetDataObjectType()
Definition: vtkDataSet.h:278
a cell that represents an n-sided polygon
Definition: vtkPolygon.h:44
vtkCellLinks * Links
vtkPixel * Pixel
represent and manipulate attribute data in a dataset
virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds, vtkIdList *cellIds)
void DeepCopy(vtkDataObject *src)
Objects that can traverse hyperoctree nodes.
vtkHyperOctreeInternal * CellTree
void Initialize()
virtual void CopyStructure(vtkDataSet *ds)=0
Store zero or more vtkInformation instances.
virtual double * GetPoint(vtkIdType ptId)=0
vtkIdTypeArray * LeafCornerIds
vtkHyperOctreeCursor * TmpChild
general representation of visualization data
Definition: vtkDataObject.h:64
vtkIdType FindPoint(double x, double y, double z)
Definition: vtkDataSet.h:154
#define VTKCOMMONDATAMODEL_EXPORT
virtual vtkCell * GetCell(vtkIdType cellId)=0
represent and manipulate 3D points
Definition: vtkPoints.h:38
virtual int GetCellType(vtkIdType cellId)=0
void ShallowCopy(vtkDataObject *src)