VTK  9.7.1
vtkHyperTreeGridNonOrientedSuperCursorLight.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
25 #ifndef vtkHyperTreeGridNonOrientedSuperCursorLight_h
26 #define vtkHyperTreeGridNonOrientedSuperCursorLight_h
27 
28 #include "vtkCommonDataModelModule.h" // For export macro
29 #include "vtkObject.h"
30 #include "vtkSmartPointer.h" // Used internally
31 
32 #include "vtkHyperTreeGridLevelEntry.h" // Used internally
33 
34 #include <cassert> // Used internally
35 #include <vector> // std::vector
36 
37 VTK_ABI_NAMESPACE_BEGIN
38 class vtkHyperTree;
39 class vtkHyperTreeGrid;
41 
42 class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGridNonOrientedSuperCursorLight : public vtkObject
43 {
44 public:
46  void PrintSelf(ostream& os, vtkIndent indent) override;
47 
53 
58  virtual void Initialize(vtkHyperTreeGrid* grid, vtkIdType treeIndex, bool create = false) = 0;
59 
61 
64  vtkHyperTreeGrid* GetGrid();
66 
68 
71  bool HasTree();
73 
77  bool HasTree(unsigned int icursor);
78 
80 
83  vtkHyperTree* GetTree();
84  vtkHyperTree* GetTree(unsigned int icursor);
86 
90  vtkIdType GetVertexId();
91  vtkIdType GetVertexId(unsigned int icursor);
92 
97  vtkIdType GetGlobalNodeIndex();
98 
103  vtkIdType GetGlobalNodeIndex(unsigned int icursor);
104 
105  vtkHyperTree* GetInformation(
106  unsigned int icursor, unsigned int& level, bool& leaf, vtkIdType& id);
107 
112  unsigned char GetDimension();
113 
118  unsigned char GetNumberOfChildren();
119 
120  void SetGlobalIndexStart(vtkIdType index);
121 
122  void SetGlobalIndexFromLocal(vtkIdType index);
123 
124  double* GetOrigin();
125  double* GetSize();
126 
131  void SetMask(bool state);
132  void SetMask(unsigned int icursor, bool state);
133 
137  bool IsMasked();
138  bool IsMasked(unsigned int icursor);
139 
143  void GetBounds(double bounds[6]);
144 
148  void GetPoint(double point[3]);
149 
153  bool IsLeaf();
154  bool IsLeaf(unsigned int icursor);
155 
156  void SubdivideLeaf();
157 
161  bool IsRoot();
162 
166  unsigned int GetLevel();
167  unsigned int GetLevel(unsigned int icursor);
168 
174  void ToChild(unsigned char);
175 
181  void ToRoot();
182 
188  void ToParent();
189 
190  unsigned int GetNumberOfCursors() { return this->NumberOfCursors; }
191 
192 protected:
197 
202 
207 
209 
214  std::vector<unsigned int> FirstNonValidEntryByLevel;
215  std::vector<vtkHyperTreeGridLevelEntry> Entries;
216 
222  std::vector<unsigned int> ReferenceEntries;
223 
224  unsigned int GetIndiceEntry(unsigned int icursor)
225  {
226  assert("pre: icursor != IndiceCentralCursor" && icursor != this->IndiceCentralCursor);
227  assert("pre: valid_icursor" && icursor < this->NumberOfCursors);
228  if (icursor > this->IndiceCentralCursor)
229  {
230  assert("pre: valid_icursor" &&
231  0 <= long(this->FirstCurrentNeighboorReferenceEntry + icursor) - 1 &&
232  long(this->FirstCurrentNeighboorReferenceEntry + icursor) - 1 <
233  long(this->ReferenceEntries.size()));
234  assert("pre: valid_icursor" &&
235  this->ReferenceEntries[this->FirstCurrentNeighboorReferenceEntry + icursor - 1] <
236  this->Entries.size());
237  return this->ReferenceEntries[this->FirstCurrentNeighboorReferenceEntry + icursor - 1];
238  }
239  else
240  {
241  assert("pre: valid_icursor" &&
242  this->FirstCurrentNeighboorReferenceEntry + icursor < this->ReferenceEntries.size());
243  assert("pre: valid_icursor" &&
244  this->ReferenceEntries[this->FirstCurrentNeighboorReferenceEntry + icursor] <
245  this->Entries.size());
246  return this->ReferenceEntries[this->FirstCurrentNeighboorReferenceEntry + icursor];
247  }
248  }
249 
253  unsigned int GetIndicePreviousEntry(unsigned int icursor)
254  {
255  assert("pre: icursor != IndiceCentralCursor" && icursor != IndiceCentralCursor);
256  assert("pre: valid_icursor" && icursor < this->NumberOfCursors);
257  if (icursor > this->IndiceCentralCursor)
258  {
259  assert("pre: valid_icursor" &&
260  0 <=
261  long(this->FirstCurrentNeighboorReferenceEntry - (this->NumberOfCursors - 1) + icursor) -
262  1 &&
263  long(this->FirstCurrentNeighboorReferenceEntry - (this->NumberOfCursors - 1) + icursor) -
264  1 <
265  long(this->ReferenceEntries.size()));
266  assert("pre: valid_icursor" &&
267  this->ReferenceEntries[this->FirstCurrentNeighboorReferenceEntry -
268  (this->NumberOfCursors - 1) + icursor - 1] < this->Entries.size());
269  return this->ReferenceEntries[this->FirstCurrentNeighboorReferenceEntry -
270  (this->NumberOfCursors - 1) + icursor - 1];
271  }
272  else
273  {
274  assert("pre: valid_icursor" &&
275  this->FirstCurrentNeighboorReferenceEntry - (this->NumberOfCursors - 1) + icursor <
276  this->ReferenceEntries.size());
277  assert("pre: valid_icursor" &&
278  this->ReferenceEntries[this->FirstCurrentNeighboorReferenceEntry -
279  (this->NumberOfCursors - 1) + icursor] < this->Entries.size());
280  return this->ReferenceEntries[this->FirstCurrentNeighboorReferenceEntry -
281  (this->NumberOfCursors - 1) + icursor];
282  }
283  }
284 
285  unsigned int IndiceCentralCursor;
286 
287  // Number of cursors in supercursor
288  unsigned int NumberOfCursors;
289 
290  // Super cursor traversal table to go retrieve the parent index for each cursor
291  // of the child node. There are f^d * NumberOfCursors entries in the table.
292  const unsigned int* ChildCursorToParentCursorTable;
293 
294  // Super cursor traversal table to go retrieve the child index for each cursor
295  // of the child node. There are f^d * NumberOfCursors entries in the table.
296  const unsigned int* ChildCursorToChildTable;
297 
298 private:
301  void operator=(const vtkHyperTreeGridNonOrientedSuperCursorLight&) = delete;
302 };
303 
304 VTK_ABI_NAMESPACE_END
305 #endif
void GetBounds(T a, double bds[6])
abstract base class for most VTK objects
Definition: vtkObject.h:52
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
unsigned int FirstCurrentNeighboorReferenceEntry
The last valid reference to describe neighbors.
A dataset containing a grid of vtkHyperTree instances arranged as a rectilinear grid.
vtkSmartPointer< vtkHyperTreeGridNonOrientedGeometryCursor > CentralCursor
int vtkIdType
Definition: vtkType.h:363
a simple class to control print indentation
Definition: vtkIndent.h:28
unsigned int GetIndicePreviousEntry(unsigned int icursor)
The previous value.
void GetPoint(int i, int j, int k, double pnt[3])
A data object structured as a tree.
Definition: vtkHyperTree.h:170
vtkHyperTreeGrid * Grid
Currently processed Hyper Tree.
unsigned int CurrentFirstNonValidEntryByLevel
Hyper tree grid to which the cursor is attached.
bool HasTree(const T &e)