VTK  9.3.20240419
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
topologically and geometrically regular array of data
Definition: vtkImageData.h:156
2D Noise Generator.
void DeleteValues(unsigned char *vals)
Delete the passed in array of values.
vtkLICRandomNoise2D()=default
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).
static vtkImageData * GetNoiseResource()
An interface to a random number generator.
double GetRandomNumber()
Get a random number in the range of 0 to 1.
void SetSeed(int seedVal)
Seed the random number generator.
Park and Miller Sequence of pseudo random numbers.
double GetValue() override
Current value.
void Next() override
Move to the next number in the random sequence.
void SetSeed(int value)
Set the seed of the random sequence.
static vtkMinimalStandardRandomSequence * New()
Standard methods for instantiation, type information, and printing.
virtual void Delete()
Delete a VTK object.
@ type
Definition: vtkX3D.h:516