VTK  9.2.20230527
vtkLICNoiseHelper.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4 
5  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
6  All rights reserved.
7  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notice for more information.
12 
13 =========================================================================*/
19 #ifndef vtkLICNoiseHelper_h
20 #define vtkLICNoiseHelper_h
21 
22 #include "vtkRenderingLICOpenGL2Module.h" // for export
23 
25 
26 VTK_ABI_NAMESPACE_BEGIN
27 class vtkImageData;
28 
36 {
37 public:
39 
41 
45  void SetSeed(int seedVal) { this->RNG->SetSeed(seedVal); }
46 
50  double GetRandomNumber()
51  {
52  double val = this->RNG->GetValue();
53  this->RNG->Next();
54  return val;
55  }
56 
57 private:
58  void operator=(const vtkLICRandomNumberGeneratorInterface&) = delete;
60 
62 };
63 
71 {
72 public:
73  vtkLICRandomNoise2D() = default;
74 
76 
93  enum
94  {
95  UNIFORM = 0,
96  GAUSSIAN = 1,
97  PERLIN = 2
98  };
99  float* Generate(int type, int& sideLen, int& grainLize, float minNoiseVal, float maxNoiseVal,
100  int nLevels, double impulseProb, float impulseBgNoiseVal, int seed);
102 
106  void DeleteValues(unsigned char* vals) { free(vals); }
107 
109 
110 private:
114  float* GenerateUniform(int sideLen, int grainLize, float minNoiseVal, float maxNoiseVal,
115  int nLevels, double impulseProb, float impulseBgNoiseVal, int seed);
116 
120  float* GenerateGaussian(int sideLen, int grainLize, float minNoiseVal, float maxNoiseVal,
121  int nLevels, double impulseProb, float impulseBgNoiseVal, int seed);
122 
126  float* GeneratePerlin(int sideLen, int grainLize, float minNoiseVal, float maxNoiseVal,
127  int nLevels, double impulseProb, float impulseBgNoiseVal, int seed);
128 
135  int ShouldGenerateValue(double prob);
136 
142  void GetValidDimensionAndGrainSize(int type, int& dim, int& grainSize);
143 
146 };
147 
148 VTK_ABI_NAMESPACE_END
149 #endif
150 // VTK-HeaderTest-Exclude: vtkLICNoiseHelper.h
topologically and geometrically regular array of data
Definition: vtkImageData.h:164
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:528