1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkHyperTreeGridEntry.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 =========================================================================*/ 15 /** 16 * @class vtkHyperTreeGridEntry 17 * @brief Entries are cache data for cursors 18 * 19 * Entries are relevant for cursor/supercursor developers. Filters 20 * developers should have a look at cursors/supercursors documentation. 21 * (cf. vtkHyperTreeGridNonOrientedCursor). When writing a new cursor or 22 * supercursor the choice of the entry is very important: it will drive 23 * the performance and memory cost. This is even more important for 24 * supercursors which have several neighbors: 6x for VonNeuman and 26x for 25 * Moore. 26 * 27 * Several types of Entries exist: 28 * 1. vtkHyperTreeGridEntry 29 * This cache only memorizes the current cell index in one HyperTree. 30 * Using the index, this entry provides several services such as: 31 * is the cell coarse or leaf, get or set global index (to access 32 * field value, cf. vtkHyperTree), descend into selected child, 33 * subdivise the cell. Equivalent services are available for all entries. 34 * 35 * 2. vtkHyperTreeGridGeometryEntry 36 * This cache adds the origin coordinates of the cell atop 37 * vtkHyperTreeGridEntry. Getter is provided, as well as services related 38 * to the bounding box and cell center. 39 * 40 * 3. vtkHyperTreeGridLevelEntry 41 * This cache adds the following information with their getters atop 42 * vtkHyperTreeGridEntry: pointer to the HyperTree, level of the current 43 * cell. 44 * 45 * 4. vtkHyperTreeGridGeometryLevelEntry 46 * This cache is a combination of vtkHyperTreeGridLevelEntry and 47 * vtkHyperTreeGridLevelEntry: it provides all combined services. 48 * 49 * @sa 50 * vtkHyperTreeGridEntry 51 * vtkHyperTreeGridLevelEntry 52 * vtkHyperTreeGridGeometryEntry 53 * vtkHyperTreeGridGeometryLevelEntry 54 * vtkHyperTreeGridOrientedCursor 55 * vtkHyperTreeGridNonOrientedCursor 56 * 57 * @par Thanks: 58 * This class was written by Jacques-Bernard Lekien, Jerome Dubois and 59 * Guenole Harel, CEA 2018. 60 * This work was supported by Commissariat a l'Energie Atomique 61 * CEA, DAM, DIF, F-91297 Arpajon, France. 62 */ 63 64 #ifndef vtkHyperTreeGridEntry_h 65 #define vtkHyperTreeGridEntry_h 66 67 #ifndef __VTK_WRAP__ 68 69 #include "vtkObject.h" 70 71 class vtkHyperTree; 72 class vtkHyperTreeGrid; 73 74 class vtkHyperTreeGridEntry 75 { 76 public: 77 /** 78 * Display info about the entry 79 */ 80 void PrintSelf(ostream& os, vtkIndent indent); 81 82 /** 83 * Dump information 84 */ 85 void Dump(ostream& os); 86 87 /** 88 * Constructor 89 */ vtkHyperTreeGridEntry()90 vtkHyperTreeGridEntry() { this->Index = 0; } 91 92 /** 93 * Constructor 94 */ vtkHyperTreeGridEntry(vtkIdType index)95 vtkHyperTreeGridEntry(vtkIdType index) { this->Index = index; } 96 97 /** 98 * Destructor 99 */ 100 ~vtkHyperTreeGridEntry() = default; 101 102 /** 103 * Initialize cursor at root of given tree index in grid. 104 */ 105 vtkHyperTree* Initialize(vtkHyperTreeGrid* grid, vtkIdType treeIndex, bool create = false); 106 107 /** 108 * Initialize cursor at root of given tree index in grid. 109 */ Initialize(vtkIdType index)110 void Initialize(vtkIdType index) { this->Index = index; } 111 112 /** 113 * Copy function 114 */ Copy(const vtkHyperTreeGridEntry * entry)115 void Copy(const vtkHyperTreeGridEntry* entry) { this->Index = entry->Index; } 116 117 /** 118 * Return the index of the current vertex in the tree. 119 */ GetVertexId()120 vtkIdType GetVertexId() const { return this->Index; } 121 122 /** 123 * Return the global index for the current cell (cf. vtkHyperTree). 124 * \pre not_tree: tree 125 */ 126 vtkIdType GetGlobalNodeIndex(const vtkHyperTree* tree) const; 127 128 /** 129 * Set the global index for the root cell of the HyperTree. 130 * \pre not_tree: tree 131 */ 132 void SetGlobalIndexStart(vtkHyperTree* tree, vtkIdType index); 133 134 /** 135 * Set the global index for the current cell of the HyperTree. 136 * \pre not_tree: tree 137 */ 138 void SetGlobalIndexFromLocal(vtkHyperTree* tree, vtkIdType index); 139 140 /** 141 * Set the blanking mask is empty or not 142 * \pre not_tree: tree 143 */ 144 void SetMask(const vtkHyperTreeGrid* grid, const vtkHyperTree* tree, bool state); 145 146 /** 147 * Determine whether blanking mask is empty or not 148 * \pre not_tree: tree 149 */ 150 bool IsMasked(const vtkHyperTreeGrid* grid, const vtkHyperTree* tree) const; 151 152 /** 153 * Is the cursor pointing to a leaf? 154 * \pre not_tree: tree 155 * Return true if level == grid->GetDepthLimiter() 156 */ 157 bool IsLeaf(const vtkHyperTreeGrid* grid, const vtkHyperTree* tree, unsigned int level) const; 158 159 /** 160 * Change the current cell's status: if leaf then becomes coarse and 161 * all its children are created, cf. HyperTree. 162 * \pre not_tree: tree 163 * \pre depth_limiter: level == grid->GetDepthLimiter() 164 * \pre is_masked: IsMasked 165 */ 166 void SubdivideLeaf(const vtkHyperTreeGrid* grid, vtkHyperTree* tree, unsigned int level); 167 168 /** 169 * Is the cursor pointing to a coarse with all childrens being leaves? 170 * \pre not_tree: tree 171 */ 172 bool IsTerminalNode( 173 const vtkHyperTreeGrid* grid, const vtkHyperTree* tree, unsigned int level) const; 174 175 /** 176 * Is the cursor at HyperTree root? 177 */ IsRoot()178 bool IsRoot() const { return (this->Index == 0); } 179 180 /** 181 * Move the cursor to i-th child of the current cell. 182 * \pre not_tree: tree 183 * \pre not_leaf: !IsLeaf() 184 * \pre valid_child: ichild>=0 && ichild<this->GetNumberOfChildren() 185 * \pre depth_limiter: level == grid->GetDepthLimiter() 186 * \pre is_masked: !IsMasked() 187 */ 188 void ToChild(const vtkHyperTreeGrid* grid, const vtkHyperTree* tree, unsigned int level, 189 unsigned char ichild); 190 191 protected: 192 /** 193 * index of the current cell in the HyperTree. 194 */ 195 vtkIdType Index; 196 }; 197 198 #endif // __VTK_WRAP__ 199 200 #endif // vtkHyperTreeGridEntry_h 201 // VTK-HeaderTest-Exclude: vtkHyperTreeGridEntry.h 202