VTK  9.3.20240420
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
37VTK_ABI_NAMESPACE_BEGIN
38class vtkHyperTree;
41
42class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGridNonOrientedSuperCursorLight : public vtkObject
43{
44public:
46 void PrintSelf(ostream& os, vtkIndent indent) override;
47
53
58 virtual void Initialize(vtkHyperTreeGrid* grid, vtkIdType treeIndex, bool create = false) = 0;
59
61
66
68
71 bool HasTree();
73
77 bool HasTree(unsigned int icursor);
78
80
84 vtkHyperTree* GetTree(unsigned int icursor);
86
91 vtkIdType GetVertexId(unsigned int icursor);
92
98
103 vtkIdType GetGlobalNodeIndex(unsigned int icursor);
104
106 unsigned int icursor, unsigned int& level, bool& leaf, vtkIdType& id);
107
112 unsigned char GetDimension();
113
118 unsigned char GetNumberOfChildren();
119
121
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
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
192protected:
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
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.
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
298private:
301 void operator=(const vtkHyperTreeGridNonOrientedSuperCursorLight&) = delete;
302};
303
304VTK_ABI_NAMESPACE_END
305#endif
void GetBounds(double bounds[6])
Bounding box coordinates.
vtkSmartPointer< vtkHyperTreeGridNonOrientedGeometryCursor > CentralCursor
vtkIdType GetGlobalNodeIndex(unsigned int icursor)
Return the global index (relative to the grid) of the neighbor icursor current vertex in the tree.
bool IsLeaf()
Is the cursor pointing to a leaf?
void SetMask(unsigned int icursor, bool state)
vtkHyperTreeGrid * GetGrid()
Set the hyper tree grid to which the cursor is pointing.
~vtkHyperTreeGridNonOrientedSuperCursorLight() override
Destructor.
vtkHyperTree * GetInformation(unsigned int icursor, unsigned int &level, bool &leaf, vtkIdType &id)
bool IsRoot()
Is the cursor at tree root?
void GetPoint(double point[3])
Mesh center coordinates.
unsigned char GetDimension()
Return the dimension of the tree.
vtkIdType GetGlobalNodeIndex()
Return the global index (relative to the grid) of the current vertex in the tree.
vtkIdType GetVertexId(unsigned int icursor)
unsigned int FirstCurrentNeighboorReferenceEntry
The last valid reference to describe neighbors.
unsigned char GetNumberOfChildren()
Return the number of children for each node (non-vertex leaf) of the tree.
unsigned int GetIndicePreviousEntry(unsigned int icursor)
The previous value.
void ToParent()
Move the cursor to the parent of the current vertex.
unsigned int GetLevel(unsigned int icursor)
virtual vtkHyperTreeGridNonOrientedSuperCursorLight * Clone()
Create a copy of ‘this’.
virtual void Initialize(vtkHyperTreeGrid *grid, vtkIdType treeIndex, bool create=false)=0
Initialize cursor at root of given tree index in grid.
vtkHyperTree * GetTree(unsigned int icursor)
Set the hyper tree to which the cursor is pointing.
vtkIdType GetVertexId()
Return the index of the current vertex in the tree.
vtkHyperTree * GetTree()
Set the hyper tree to which the cursor is pointing.
void ToRoot()
Move the cursor to the root vertex.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
bool IsMasked()
Determine whether blanking mask is empty or not.
unsigned int GetLevel()
Get the level of the tree vertex pointed by the cursor.
void SetMask(bool state)
Set the blanking mask is empty or not.
bool HasTree()
Return if a Tree pointing exist.
bool HasTree(unsigned int icursor)
Return if a Tree pointing exist.
unsigned int CurrentFirstNonValidEntryByLevel
Hyper tree grid to which the cursor is attached.
void ToChild(unsigned char)
Move the cursor to child ‘child’ of the current vertex.
A dataset containing a grid of vtkHyperTree instances arranged as a rectilinear grid.
A data object structured as a tree.
a simple class to control print indentation
Definition vtkIndent.h:108
abstract base class for most VTK objects
Definition vtkObject.h:162
Hold a reference to a vtkObjectBase instance.
int vtkIdType
Definition vtkType.h:315