VTK
vtkRandomPool.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkRandomPool.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
39 #ifndef vtkRandomPool_h
40 #define vtkRandomPool_h
41 
42 #include "vtkCommonCoreModule.h" // For export macro
43 #include "vtkObject.h"
44 
45 class vtkRandomSequence;
46 class vtkDataArray;
47 
48 class VTKCOMMONCORE_EXPORT vtkRandomPool : public vtkObject
49 {
50 public:
52 
55  static vtkRandomPool* New();
56  vtkTypeMacro(vtkRandomPool,vtkObject);
57  void PrintSelf(ostream& os, vtkIndent indent) override;
59 
61 
65  virtual void SetSequence(vtkRandomSequence *seq);
66  vtkGetObjectMacro(Sequence,vtkRandomSequence);
68 
70 
75  vtkSetClampMacro(Size,vtkIdType,1,VTK_ID_MAX);
76  vtkGetMacro(Size,vtkIdType);
78 
80 
85  vtkSetClampMacro(NumberOfComponents,vtkIdType,1,VTK_INT_MAX);
86  vtkGetMacro(NumberOfComponents,vtkIdType);
88 
93  vtkIdType GetTotalSize() {return (this->Size*this->NumberOfComponents);}
94 
96 
108  const double* GeneratePool();
109  const double* GetPool() {return this->Pool;}
110  double GetValue(vtkIdType i) {return this->Pool[(i%this->TotalSize)];}
111  double GetValue(vtkIdType i, int compNum)
112  {return this->Pool[(compNum + this->NumberOfComponents*i) % this->TotalSize];}
114 
116 
128  void PopulateDataArray(vtkDataArray *da, double minRange, double maxRange);
129  void PopulateDataArray(vtkDataArray *da, int compNumber,
130  double minRange, double maxRange);
132 
134 
139  vtkSetClampMacro(ChunkSize, vtkIdType, 1000, VTK_INT_MAX);
140  vtkGetMacro(ChunkSize, vtkIdType);
142 
143 protected:
144  vtkRandomPool();
145  ~vtkRandomPool() override;
146 
147  // Keep track of last generation time
149 
150  // Data members to support public API
155 
156  // Internal data members
158  double *Pool;
159 
160 private:
161  vtkRandomPool(const vtkRandomPool&) = delete;
162  void operator=(const vtkRandomPool&) = delete;
163 };
164 
165 #endif
166 // VTK-HeaderTest-Exclude: vtkRandomPool.h
vtkIdType TotalSize
double GetValue(vtkIdType i, int compNum)
These methods provide access to the raw random pool as a double array.
abstract base class for most VTK objects
Definition: vtkObject.h:59
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
#define VTK_INT_MAX
Definition: vtkType.h:159
record modification and/or execution time
Definition: vtkTimeStamp.h:35
convenience class to quickly generate a pool of random numbers
Definition: vtkRandomPool.h:48
int vtkIdType
Definition: vtkType.h:347
Generate a sequence of random numbers.
vtkTimeStamp GenerateTime
a simple class to control print indentation
Definition: vtkIndent.h:39
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
vtkIdType GetTotalSize()
This convenience method returns the total size of the memory pool, i.e., Size*NumberOfComponents.
Definition: vtkRandomPool.h:93
double GetValue(vtkIdType i)
These methods provide access to the raw random pool as a double array.
vtkRandomSequence * Sequence
#define VTK_ID_MAX
Definition: vtkType.h:351
vtkIdType ChunkSize
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkIdType Size
const double * GetPool()
These methods provide access to the raw random pool as a double array.