1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkHyperTreeGridNonOrientedCursor.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 Nonice for more information. 13 14 =========================================================================*/ 15 /** 16 * @class vtkHyperTreeGridNonOrientedCursor 17 * @brief Objects for traversal a HyperTreeGrid. 18 * 19 * JB A REVOIR 20 * Objects that can perform depth traversal of a hyper tree grid, 21 * take into account more parameters (related to the grid structure) than 22 * the compact hyper tree cursor implemented in vtkHyperTree can. 23 * This is an abstract class. 24 * Cursors are created by the HyperTreeGrid implementation. 25 * 26 * @sa 27 * vtkHyperTreeCursor vtkHyperTree vtkHyperTreeGrid 28 * 29 * @par Thanks: 30 * This class was written by Guenole Harel and Jacques-Bernard Lekien, 2014. 31 * This class was re-written by Philippe Pebay, 2016. 32 * JB This class was re-written for more optimisation by Jacques-Bernard Lekien, 33 * Guenole Harel and Jerome Dubois, 2018. 34 * This work was supported by Commissariat a l'Energie Atomique 35 * CEA, DAM, DIF, F-91297 Arpajon, France. 36 */ 37 38 #ifndef vtkHyperTreeGridNonOrientedCursor_h 39 #define vtkHyperTreeGridNonOrientedCursor_h 40 41 #include "vtkCommonDataModelModule.h" // For export macro 42 #include "vtkObject.h" 43 44 #include <vector> // For std::vector 45 46 class vtkHyperTree; 47 class vtkHyperTreeGrid; 48 class vtkHyperTreeGridEntry; 49 50 class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGridNonOrientedCursor : public vtkObject 51 { 52 public: 53 vtkTypeMacro(vtkHyperTreeGridNonOrientedCursor, vtkObject); 54 void PrintSelf(ostream& os, vtkIndent indent) override; 55 static vtkHyperTreeGridNonOrientedCursor* New(); 56 57 /** 58 * Create a copy of `this'. 59 * \post results_exists:result!=0 60 */ 61 vtkHyperTreeGridNonOrientedCursor* Clone(); 62 63 /** 64 * Initialize cursor at root of given tree index in grid. 65 */ 66 void Initialize(vtkHyperTreeGrid* grid, vtkIdType treeIndex, bool create = false); 67 68 /** 69 * Initialize cursor at root of given tree index in grid. 70 */ 71 void Initialize( 72 vtkHyperTreeGrid* grid, vtkHyperTree* tree, unsigned int level, vtkHyperTreeGridEntry& entry); 73 74 /** 75 * Initialize cursor at root of given tree index in grid. 76 */ 77 void Initialize(vtkHyperTreeGrid* grid, vtkHyperTree* tree, unsigned int level, vtkIdType index); 78 79 ///@{ 80 /** 81 * Set the hyper tree grid to which the cursor is pointing. 82 */ 83 vtkHyperTreeGrid* GetGrid(); 84 ///@} 85 86 ///@{ 87 /** 88 * Return if a Tree pointing exist 89 */ 90 bool HasTree() const; 91 ///@} 92 93 ///@{ 94 /** 95 * Set the hyper tree to which the cursor is pointing. 96 */ 97 vtkHyperTree* GetTree() const; 98 ///@} 99 100 /** 101 * Return the index of the current vertex in the tree. 102 */ 103 vtkIdType GetVertexId(); 104 105 /** 106 * Return the global index (relative to the grid) of the 107 * current vertex in the tree. 108 */ 109 vtkIdType GetGlobalNodeIndex(); 110 111 /** 112 * Return the dimension of the tree. 113 * \post positive_result: result>0 114 */ 115 unsigned char GetDimension(); 116 117 /** 118 * Return the number of children for each node (non-vertex leaf) of the tree. 119 * \post positive_number: result>0 120 */ 121 unsigned char GetNumberOfChildren(); 122 123 /** 124 * JB 125 */ 126 void SetGlobalIndexStart(vtkIdType index); 127 128 /** 129 * JB 130 */ 131 void SetGlobalIndexFromLocal(vtkIdType index); 132 133 /** 134 * Set the blanking mask is empty or not 135 * \pre not_tree: tree 136 */ 137 void SetMask(bool state); 138 139 /** 140 * Determine whether blanking mask is empty or not 141 */ 142 bool IsMasked(); 143 144 /** 145 * Is the cursor pointing to a leaf? 146 */ 147 bool IsLeaf(); 148 149 /** 150 * JB 151 */ 152 void SubdivideLeaf(); 153 154 /** 155 * Is the cursor at tree root? 156 */ 157 bool IsRoot(); 158 159 /** 160 * Get the level of the tree vertex pointed by the cursor. 161 */ 162 unsigned int GetLevel(); 163 164 /** 165 * Move the cursor to child `child' of the current vertex. 166 * \pre not_tree: HasTree() 167 * \pre not_leaf: !IsLeaf() 168 * \pre valid_child: ichild>=0 && ichild<GetNumberOfChildren() 169 * \pre depth_limiter: GetLevel() <= GetDepthLimiter() 170 */ 171 void ToChild(unsigned char ichild); 172 173 /** 174 * Move the cursor to the root vertex. 175 * \pre can be root 176 * \post is_root: IsRoot() 177 */ 178 void ToRoot(); 179 180 /** 181 * Move the cursor to the parent of the current vertex. 182 * Authorized if HasHistory return true. 183 * \pre Non_root: !IsRoot() 184 */ 185 void ToParent(); 186 187 protected: 188 /** 189 * Constructor 190 */ 191 vtkHyperTreeGridNonOrientedCursor(); 192 193 /** 194 * Destructor 195 */ 196 ~vtkHyperTreeGridNonOrientedCursor() override; 197 198 /** 199 * JB Reference sur l'hyper tree grid parcouru actuellement. 200 */ 201 vtkHyperTreeGrid* Grid; 202 203 /** 204 * JB 205 */ 206 vtkHyperTree* Tree; 207 208 /** 209 * JB . 210 */ 211 unsigned int Level; 212 213 /** 214 * JB Le dernier noeud valid enregistre 215 */ 216 int LastValidEntry; 217 218 /** 219 * JB Hyper tree grid to which the cursor is attached 220 */ 221 std::vector<vtkHyperTreeGridEntry> Entries; 222 223 private: 224 vtkHyperTreeGridNonOrientedCursor(const vtkHyperTreeGridNonOrientedCursor&) = delete; 225 void operator=(const vtkHyperTreeGridNonOrientedCursor&) = delete; 226 }; 227 #endif 228