VTK
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 
23 #include "vtkRenderingLICOpenGL2Module.h" // for export
24 
26 
27 class vtkImageData;
28 
36 {
37 public:
39  {
41  }
42 
44  {
45  this->RNG->Delete();
46  }
47 
51  void SetSeed(int seedVal)
52  {
53  this->RNG->SetSeed(seedVal);
54  }
55 
59  double GetRandomNumber()
60  {
61  double val = this->RNG->GetValue();
62  this->RNG->Next();
63  return val;
64  }
65 
66 private:
67  void operator=(const vtkLICRandomNumberGeneratorInterface &) VTK_DELETE_FUNCTION;
69 
70 private:
72 };
73 
81 {
82 public:
84 
86 
103  enum {
104  UNIFORM = 0,
105  GAUSSIAN = 1,
106  PERLIN = 2
107  };
108  float *Generate(
109  int type,
110  int &sideLen,
111  int &grainLize,
112  float minNoiseVal,
113  float maxNoiseVal,
114  int nLevels,
115  double impulseProb,
116  float impulseBgNoiseVal,
117  int seed);
119 
123  void DeleteValues(unsigned char *vals){ free(vals); }
124 
125  static vtkImageData *GetNoiseResource();
126 
127 private:
131  float *GenerateUniform(
132  int sideLen,
133  int grainLize,
134  float minNoiseVal,
135  float maxNoiseVal,
136  int nLevels,
137  double impulseProb,
138  float impulseBgNoiseVal,
139  int seed);
140 
144  float *GenerateGaussian(
145  int sideLen,
146  int grainLize,
147  float minNoiseVal,
148  float maxNoiseVal,
149  int nLevels,
150  double impulseProb,
151  float impulseBgNoiseVal,
152  int seed);
153 
157  float *GeneratePerlin(
158  int sideLen,
159  int grainLize,
160  float minNoiseVal,
161  float maxNoiseVal,
162  int nLevels,
163  double impulseProb,
164  float impulseBgNoiseVal,
165  int seed);
166 
173  int ShouldGenerateValue(double prob);
174 
180  void GetValidDimensionAndGrainSize(int type, int &dim, int &grainSize);
181 
182 private:
185 };
186 
187 #endif
188 // VTK-HeaderTest-Exclude: vtkLICNoiseHelper.h
void Next() override
Move to the next number in the random sequence.
An interface to a random number generator.
void SetSeed(int seedVal)
Seed the random number generator.
void SetSeed(int value)
Set the seed of the random sequence.
static vtkMinimalStandardRandomSequence * New()
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
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.
virtual void Delete()
Delete a VTK object.
void DeleteValues(unsigned char *vals)
Delete the passed in array of values.