1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
|
/*=========================================================================
Program: Visualization Toolkit
Module: vtkHyperTreeGridGeometryEntry.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/**
* @class vtkHyperTreeGridGeometryEntry
JB
* @brief GeometryEntry is a cache data for cursors requiring coordinates
*
* cf. vtkHyperTreeGridEntry
*
* @sa
* vtkHyperTreeGridEntry
* vtkHyperTreeGridLevelEntry
* vtkHyperTreeGridGeometryEntry
* vtkHyperTreeGridGeometryLevelEntry
* vtkHyperTreeGridNonOrientedGeometryCursor
* vtkHyperTreeGridNonOrientedSuperCursor
* vtkHyperTreeGridNonOrientedSuperCursorLight
*
* @par Thanks:
* This class was written by Jacques-Bernard Lekien, Jerome Dubois and
* Guenole Harel, CEA 2018.
* This work was supported by Commissariat a l'Energie Atomique
* CEA, DAM, DIF, F-91297 Arpajon, France.
*/
#ifndef vtkHyperTreeGridGeometryEntry_h
#define vtkHyperTreeGridGeometryEntry_h
#ifndef __VTK_WRAP__
#include "vtkObject.h"
class vtkHyperTree;
class vtkHyperTreeGrid;
class vtkHyperTreeGridGeometryEntry
{
public:
/**
* Display info about the entry
*/
void PrintSelf(ostream& os, vtkIndent indent);
/**
* Constructor
*/
vtkHyperTreeGridGeometryEntry();
/**
* Constructor
*/
vtkHyperTreeGridGeometryEntry(vtkIdType index, const double* origin)
{
this->Index = index;
for (unsigned int d = 0; d < 3; ++d)
{
this->Origin[d] = origin[d];
}
}
/**
* Destructor
*/
~vtkHyperTreeGridGeometryEntry() = default;
/**
* Dump information
*/
void Dump(ostream& os);
/**
* Initialize cursor at root of given tree index in grid.
*/
vtkHyperTree* Initialize(vtkHyperTreeGrid* grid, vtkIdType treeIndex, bool create = false);
/**
* Initialize cursor from explicit required data
*/
void Initialize(vtkIdType index, const double* origin)
{
this->Index = index;
for (unsigned int d = 0; d < 3; ++d)
{
this->Origin[d] = origin[d];
}
}
/**
* Copy function
*/
void Copy(const vtkHyperTreeGridGeometryEntry* entry)
{
this->Index = entry->Index;
for (unsigned int d = 0; d < 3; ++d)
{
this->Origin[d] = entry->Origin[d];
}
}
/**
* Return the index of the current vertex in the tree.
*/
vtkIdType GetVertexId() const { return this->Index; }
/**
* Return the global index (relative to the grid) of the
* current vertex in the tree.
* \pre not_tree: tree
*/
vtkIdType GetGlobalNodeIndex(const vtkHyperTree* tree) const;
/**
* Set the global index for the root cell of the HyperTree.
* \pre not_tree: tree
*/
void SetGlobalIndexStart(vtkHyperTree* tree, vtkIdType index);
/**
* Set the global index for the current cell of the HyperTree.
* \pre not_tree: tree
*/
void SetGlobalIndexFromLocal(vtkHyperTree* tree, vtkIdType index);
/**
* Set the blanking mask is empty or not
* \pre not_tree: tree
*/
void SetMask(const vtkHyperTreeGrid* grid, const vtkHyperTree* tree, bool state);
/**
* Determine whether blanking mask is empty or not
* \pre not_tree: tree
*/
bool IsMasked(const vtkHyperTreeGrid* grid, const vtkHyperTree* tree) const;
/**
* Is the cursor pointing to a leaf?
* \pre not_tree: tree
* Return true if level == grid->GetDepthLimiter()
*/
bool IsLeaf(const vtkHyperTreeGrid* grid, const vtkHyperTree* tree, unsigned int level) const;
/**
* Change the current cell's status: if leaf then becomes coarse and
* all its children are created, cf. HyperTree.
* \pre not_tree: tree
* \pre depth_limiter: level == grid->GetDepthLimiter()
* \pre is_masked: IsMasked
*/
void SubdivideLeaf(const vtkHyperTreeGrid* grid, vtkHyperTree* tree, unsigned int level);
/**
* Is the cursor pointing to a coarse with all childrens leaves ?
* \pre not_tree: tree
*/
bool IsTerminalNode(
const vtkHyperTreeGrid* grid, const vtkHyperTree* tree, unsigned int level) const;
/**
* Is the cursor at tree root?
*/
bool IsRoot() const { return (this->Index == 0); }
/**
* Move the cursor to child `child' of the current vertex.
* \pre not_tree: tree
* \pre not_leaf: !IsLeaf()
* \pre valid_child: ichild>=0 && ichild<this->GetNumberOfChildren()
* \pre depth_limiter: level == grid->GetDepthLimiter()
* \pre is_masked: !IsMasked()
*/
void ToChild(const vtkHyperTreeGrid* grid, const vtkHyperTree* tree, unsigned int level,
const double* sizeChild, unsigned char ichild);
/**
* Getter for origin coordinates of the current cell.
*/
double* GetOrigin() { return this->Origin; }
const double* GetOrigin() const { return this->Origin; }
/**
* Getter for bounding box of the current cell.
*/
void GetBounds(const double* sizeChild, double bounds[6]) const
{
// Compute bounds
bounds[0] = this->Origin[0];
bounds[1] = this->Origin[0] + sizeChild[0];
bounds[2] = this->Origin[1];
bounds[3] = this->Origin[1] + sizeChild[1];
bounds[4] = this->Origin[2];
bounds[5] = this->Origin[2] + sizeChild[2];
}
/**
* Getter for center of the current cell.
*/
void GetPoint(const double* sizeChild, double point[3]) const
{
// Compute center point coordinates
point[0] = this->Origin[0] + sizeChild[0] / 2.;
point[1] = this->Origin[1] + sizeChild[1] / 2.;
point[2] = this->Origin[2] + sizeChild[2] / 2.;
}
private:
/**
* index of the current cell in the HyperTree.
*/
vtkIdType Index;
/**
* origin coiordinates of the current cell
*/
double Origin[3];
};
#endif // __VTK_WRAP__
#endif // vtkHyperTreeGridGeometryEntry_h
// VTK-HeaderTest-Exclude: vtkHyperTreeGridGeometryEntry.h
|