VTK  9.0.1
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 =========================================================================*/
20 #ifndef vtkLICNoiseHelper_h
21 #define vtkLICNoiseHelper_h
22 #ifndef __VTK_WRAP__
23 
24 #include "vtkRenderingLICOpenGL2Module.h" // for export
25 
27 
28 class vtkImageData;
29 
37 {
38 public:
40 
42 
46  void SetSeed(int seedVal) { this->RNG->SetSeed(seedVal); }
47 
51  double GetRandomNumber()
52  {
53  double val = this->RNG->GetValue();
54  this->RNG->Next();
55  return val;
56  }
57 
58 private:
59  void operator=(const vtkLICRandomNumberGeneratorInterface&) = delete;
61 
62 private:
64 };
65 
73 {
74 public:
76 
78 
95  enum
96  {
97  UNIFORM = 0,
98  GAUSSIAN = 1,
99  PERLIN = 2
100  };
101  float* Generate(int type, int& sideLen, int& grainLize, float minNoiseVal, float maxNoiseVal,
102  int nLevels, double impulseProb, float impulseBgNoiseVal, int seed);
104 
108  void DeleteValues(unsigned char* vals) { free(vals); }
109 
110  static vtkImageData* GetNoiseResource();
111 
112 private:
116  float* GenerateUniform(int sideLen, int grainLize, float minNoiseVal, float maxNoiseVal,
117  int nLevels, double impulseProb, float impulseBgNoiseVal, int seed);
118 
122  float* GenerateGaussian(int sideLen, int grainLize, float minNoiseVal, float maxNoiseVal,
123  int nLevels, double impulseProb, float impulseBgNoiseVal, int seed);
124 
128  float* GeneratePerlin(int sideLen, int grainLize, float minNoiseVal, float maxNoiseVal,
129  int nLevels, double impulseProb, float impulseBgNoiseVal, int seed);
130 
137  int ShouldGenerateValue(double prob);
138 
144  void GetValidDimensionAndGrainSize(int type, int& dim, int& grainSize);
145 
146 private:
149 };
150 
151 #endif
152 #endif
153 // VTK-HeaderTest-Exclude: vtkLICNoiseHelper.h
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:41
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.