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
|
/*=========================================================================
Program: Visualization Toolkit
Module: vtkHyperTreeGridScales.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 vtkHyperTreeGridScales
* @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 Jacques-Bernard Lekien (CEA)
* This work was supported by Commissariat a l'Energie Atomique
* CEA, DAM, DIF, F-91297 Arpajon, France.
*/
#ifndef vtkHyperTreeGridScales_h
#define vtkHyperTreeGridScales_h
#include <vector> // For std::vector
class vtkHyperTreeGridScales
{
public:
/**
* JB Construit cette classe a partir du scale de la maille
* d'origine d'un HyperTree et du subdivision factor
*/
vtkHyperTreeGridScales(double branchfactor, const double scale[3])
: BranchFactor(branchfactor)
, CurrentFailLevel(1)
, CellScales(scale, scale + 3)
{
}
~vtkHyperTreeGridScales() = default;
/**
* JB Retourne le scale des mailles du niveau demande
*/
double GetBranchFactor() const { return this->BranchFactor; }
/**
* JB Retourne le scale des mailles du niveau demande
*/
double* GetScale(unsigned int level) const
{
this->Update(level);
return this->CellScales.data() + 3 * level;
}
/**
* JB
*/
double GetScaleX(unsigned int level) const
{
this->Update(level);
return this->CellScales[3 * level + 0];
}
/**
* JB
*/
double GetScaleY(unsigned int level) const
{
this->Update(level);
return this->CellScales[3 * level + 1];
}
/**
* JB
*/
double GetScaleZ(unsigned int level) const
{
this->Update(level);
return this->CellScales[3 * level + 2];
}
/**
* JB Retourne le scale des mailles du niveau demande
*/
void GetScale(unsigned int level, double scale[3]) const
{
this->Update(level);
memcpy(scale, this->CellScales.data() + 3 * level, 3 * sizeof(double));
}
/**
* JB
*/
unsigned int GetCurrentFailLevel() const { return this->CurrentFailLevel; }
private:
/**
* JB Update the cell scales table afin de repondre que la
* table puisse retourner la taille de la maille pour ce niveau
* demande
*/
void Update(unsigned int level) const
{
if (level < this->CurrentFailLevel)
{
return;
}
this->CurrentFailLevel = level + 1;
this->CellScales.resize(3 * this->CurrentFailLevel);
auto current = this->CellScales.begin() + 3 * (this->CurrentFailLevel - 1);
auto previous = current - 3;
auto end = this->CellScales.end();
for (; current != end; ++current, ++previous)
{
*current = *previous / this->BranchFactor;
}
}
/**
* The subdivision factor in the grid refinement scheme
*/
const double BranchFactor;
/**
* The cache cell scales table
*/
mutable unsigned int CurrentFailLevel;
mutable std::vector<double> CellScales;
};
#endif
// VTK-HeaderTest-Exclude: vtkHyperTreeGridScales.h
|