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 234 235 236 237 238 239 240 241 242 243 244 245
|
/*=========================================================================
Program: Visualization Toolkit
Module: vtkUniformHyperTreeGrid.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 vtkUniformHyperTreeGrid
* @brief A specifalized type of vtkHyperTreeGrid for the case
* when root cells have uniform sizes in each direction
*
* @sa
* vtkHyperTree vtkHyperTreeGrid vtkRectilinearGrid
*
* @par Thanks:
* This class was written by Philippe Pebay, NexGen Analytics 2017
* JB modify for introduce Scales by Jacques-Bernard Lekien, CEA 2018.
* This work was supported by Commissariat a l'Energie Atomique
* CEA, DAM, DIF, F-91297 Arpajon, France.
*/
#ifndef vtkUniformHyperTreeGrid_h
#define vtkUniformHyperTreeGrid_h
#include "limits.h" // UINT_MAX
#include <memory> // std::shared_ptr
#include "vtkCommonDataModelModule.h" // For export macro
#include "vtkHyperTreeGrid.h"
class vtkDoubleArray;
class vtkHyperTreeGridScales;
class VTKCOMMONDATAMODEL_EXPORT vtkUniformHyperTreeGrid : public vtkHyperTreeGrid
{
public:
static vtkUniformHyperTreeGrid* New();
vtkTypeMacro(vtkUniformHyperTreeGrid, vtkHyperTreeGrid);
void PrintSelf(ostream& os, vtkIndent indent) override;
/**
* Return what type of dataset this is.
*/
int GetDataObjectType() override { return VTK_UNIFORM_HYPER_TREE_GRID; }
/**
* Copy the internal geometric and topological structure of a
* vtkUniformHyperTreeGrid object.
*/
void CopyStructure(vtkDataObject*) override;
virtual void Initialize() override;
//@{
/**
* Set/Get origin of grid
*/
vtkSetVector3Macro(Origin, double);
vtkGetVector3Macro(Origin, double);
//@}
//@{
/**
* Set/Get scale of root cells along each direction
*/
void SetGridScale(double, double, double);
void SetGridScale(double*);
vtkGetVector3Macro(GridScale, double);
//@}
/**
* Set all scales at once when root cells are d-cubes
*/
void SetGridScale(double);
/**
* Return a pointer to the geometry bounding box in the form
* (xmin,xmax, ymin,ymax, zmin,zmax).
* THIS METHOD IS NOT THREAD SAFE.
*/
double* GetBounds() VTK_SIZEHINT(6) override;
//@{
/**
* Set/Get the grid coordinates in the x-direction.
* NB: Set method deactivated in the case of uniform grids.
* Use SetSize() instead.
*/
void SetXCoordinates(vtkDataArray* XCoordinates) override;
vtkDataArray* GetXCoordinates() override;
/* JB A faire pour les Get !
const vtkDataArray* GetXCoordinates() const override {
throw std::domain_error("Cannot use GetZCoordinates on UniformHyperTreeGrid");
}
*/
//@}
//@{
/**
* Set/Get the grid coordinates in the y-direction.
* NB: Set method deactivated in the case of uniform grids.
* Use SetSize() instead.
*/
void SetYCoordinates(vtkDataArray* YCoordinates) override;
vtkDataArray* GetYCoordinates() override;
/* JB A faire pour les Get !
const vtkDataArray* GetYCoordinates() const override {
throw std::domain_error("Cannot use GetZCoordinates on UniformHyperTreeGrid");
}
*/
//@}
//@{
/**
* Set/Get the grid coordinates in the z-direction.
* NB: Set method deactivated in the case of uniform grids.
* Use SetSize() instead.
*/
void SetZCoordinates(vtkDataArray* ZCoordinates) override;
vtkDataArray* GetZCoordinates() override;
/* JB A faire pour les Get !
const vtkDataArray* GetZCoordinates() const override {
throw std::domain_error("Cannot use GetZCoordinates on UniformHyperTreeGrid");
}
*/
// JB A faire pour les autre Get !
//@}
//@{
/**
* JB Augented services on Coordinates.
*/
void CopyCoordinates(const vtkHyperTreeGrid* output) override;
void SetFixedCoordinates(unsigned int axis, double value) override;
//@}
/**
* Convert the global index of a root to its Spacial coordinates origin and size.
*/
void GetLevelZeroOriginAndSizeFromIndex(vtkIdType, double*, double*) override;
/**
* Convert the global index of a root to its Spacial coordinates origin and size.
*/
void GetLevelZeroOriginFromIndex(vtkIdType, double*) override;
/**
* Create shallow copy of hyper tree grid.
*/
void ShallowCopy(vtkDataObject*) override;
/**
* Create deep copy of hyper tree grid.
*/
void DeepCopy(vtkDataObject*) override;
/**
* Return the actual size of the data bytes
*/
unsigned long GetActualMemorySizeBytes() override;
/**
* Return tree located at given index of hyper tree grid
* NB: This will construct a new HyperTree if grid slot is empty.
*/
vtkHyperTree* GetTree(vtkIdType, bool create = false) override;
protected:
/**
* Constructor
*/
vtkUniformHyperTreeGrid();
/**
* Destructor
*/
~vtkUniformHyperTreeGrid() override;
/**
* Grid Origin
*/
double Origin[3];
/**
* Element sizes in each direction
*/
double GridScale[3];
//@{
/**
* Keep track of whether coordinates have been explicitly computed
*/
bool ComputedXCoordinates;
bool ComputedYCoordinates;
bool ComputedZCoordinates;
//@}
unsigned int FindDichotomicX(double value) const override
{
if (value < this->Origin[0] ||
value > this->Origin[0] + this->GridScale[0] * (this->GetDimensions()[0] - 1))
{
return UINT_MAX;
}
return round((value - this->Origin[0]) / this->GridScale[0]);
}
unsigned int FindDichotomicY(double value) const override
{
if (value < this->Origin[1] ||
value > this->Origin[1] + this->GridScale[1] * (this->GetDimensions()[1] - 1))
{
return UINT_MAX;
}
return round((value - this->Origin[1]) / this->GridScale[1]);
}
unsigned int FindDichotomicZ(double value) const override
{
if (value < this->Origin[2] ||
value > this->Origin[2] + this->GridScale[2] * (this->GetDimensions()[2] - 1))
{
return UINT_MAX;
}
return round((value - this->Origin[2]) / this->GridScale[2]);
}
/**
* JB Storage of pre-computed per-level cell scales
*/
mutable std::shared_ptr<vtkHyperTreeGridScales> Scales;
private:
vtkUniformHyperTreeGrid(const vtkUniformHyperTreeGrid&) = delete;
void operator=(const vtkUniformHyperTreeGrid&) = delete;
};
#endif
|