VTK  9.3.1
vtkLICNoiseHelper.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
8 #ifndef vtkLICNoiseHelper_h
9 #define vtkLICNoiseHelper_h
10 
11 #include "vtkRenderingLICOpenGL2Module.h" // for export
12 
14 
15 VTK_ABI_NAMESPACE_BEGIN
16 class vtkImageData;
17 
25 {
26 public:
28 
30 
34  void SetSeed(int seedVal) { this->RNG->SetSeed(seedVal); }
35 
39  double GetRandomNumber()
40  {
41  double val = this->RNG->GetValue();
42  this->RNG->Next();
43  return val;
44  }
45 
46 private:
47  void operator=(const vtkLICRandomNumberGeneratorInterface&) = delete;
49 
51 };
52 
60 {
61 public:
62  vtkLICRandomNoise2D() = default;
63 
65 
82  enum
83  {
84  UNIFORM = 0,
85  GAUSSIAN = 1,
86  PERLIN = 2
87  };
88  float* Generate(int type, int& sideLen, int& grainLize, float minNoiseVal, float maxNoiseVal,
89  int nLevels, double impulseProb, float impulseBgNoiseVal, int seed);
91 
95  void DeleteValues(unsigned char* vals) { free(vals); }
96 
98 
99 private:
103  float* GenerateUniform(int sideLen, int grainLize, float minNoiseVal, float maxNoiseVal,
104  int nLevels, double impulseProb, float impulseBgNoiseVal, int seed);
105 
109  float* GenerateGaussian(int sideLen, int grainLize, float minNoiseVal, float maxNoiseVal,
110  int nLevels, double impulseProb, float impulseBgNoiseVal, int seed);
111 
115  float* GeneratePerlin(int sideLen, int grainLize, float minNoiseVal, float maxNoiseVal,
116  int nLevels, double impulseProb, float impulseBgNoiseVal, int seed);
117 
124  int ShouldGenerateValue(double prob);
125 
131  void GetValidDimensionAndGrainSize(int type, int& dim, int& grainSize);
132 
135 };
136 
137 VTK_ABI_NAMESPACE_END
138 #endif
139 // VTK-HeaderTest-Exclude: vtkLICNoiseHelper.h
vtkLICRandomNoise2D()=default
void Next() override
Move to the next number in the random sequence.
An interface to a random number generator.
static vtkImageData * GetNoiseResource()
void SetSeed(int seedVal)
Seed the random number generator.
void SetSeed(int value)
Set the seed of the random sequence.
static vtkMinimalStandardRandomSequence * New()
Standard methods for instantiation, type information, and printing.
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
double GetRandomNumber()
Get a random number in the range of 0 to 1.
Park and Miller Sequence of pseudo random numbers.
2D Noise Generator.
double GetValue() override
Current value.
float * Generate(int type, int &sideLen, int &grainLize, float minNoiseVal, float maxNoiseVal, int nLevels, double impulseProb, float impulseBgNoiseVal, int seed)
Generate a patch of random gray scale values along with an alpha channel (in vtk array format)...
virtual void Delete()
Delete a VTK object.
void DeleteValues(unsigned char *vals)
Delete the passed in array of values.