VTK  9.2.6
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 =========================================================================*/
42 #ifndef vtkRandomPool_h
43 #define vtkRandomPool_h
44 
45 #include "vtkCommonCoreModule.h" // For export macro
46 #include "vtkObject.h"
47 
48 class vtkRandomSequence;
49 class vtkDataArray;
50 
51 class VTKCOMMONCORE_EXPORT vtkRandomPool : public vtkObject
52 {
53 public:
55 
58  static vtkRandomPool* New();
59  vtkTypeMacro(vtkRandomPool, vtkObject);
60  void PrintSelf(ostream& os, vtkIndent indent) override;
62 
64 
68  virtual void SetSequence(vtkRandomSequence* seq);
69  vtkGetObjectMacro(Sequence, vtkRandomSequence);
71 
73 
78  vtkSetClampMacro(Size, vtkIdType, 1, VTK_ID_MAX);
79  vtkGetMacro(Size, vtkIdType);
81 
83 
88  vtkSetClampMacro(NumberOfComponents, vtkIdType, 1, VTK_INT_MAX);
89  vtkGetMacro(NumberOfComponents, vtkIdType);
91 
96  vtkIdType GetTotalSize() { return (this->Size * this->NumberOfComponents); }
97 
99 
111  const double* GeneratePool();
112  const double* GetPool() { return this->Pool; }
113  double GetValue(vtkIdType i) { return this->Pool[(i % this->TotalSize)]; }
114  double GetValue(vtkIdType i, int compNum)
115  {
116  return this->Pool[(compNum + this->NumberOfComponents * i) % this->TotalSize];
117  }
119 
121 
133  void PopulateDataArray(vtkDataArray* da, double minRange, double maxRange);
134  void PopulateDataArray(vtkDataArray* da, int compNumber, double minRange, double maxRange);
136 
138 
143  vtkSetClampMacro(ChunkSize, vtkIdType, 1000, VTK_INT_MAX);
144  vtkGetMacro(ChunkSize, vtkIdType);
146 
147 protected:
149  ~vtkRandomPool() override;
150 
151  // Keep track of last generation time
153 
154  // Data members to support public API
159 
160  // Internal data members
162  double* Pool;
163 
164 private:
165  vtkRandomPool(const vtkRandomPool&) = delete;
166  void operator=(const vtkRandomPool&) = delete;
167 };
168 
169 #endif
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:165
a simple class to control print indentation
Definition: vtkIndent.h:119
abstract base class for most VTK objects
Definition: vtkObject.h:82
convenience class to quickly generate a pool of random numbers
Definition: vtkRandomPool.h:52
virtual void SetSequence(vtkRandomSequence *seq)
Specify the random sequence generator used to produce the random pool.
~vtkRandomPool() override
const double * GeneratePool()
These methods provide access to the raw random pool as a double array.
vtkRandomSequence * Sequence
double GetValue(vtkIdType i)
These methods provide access to the raw random pool as a double array.
vtkTimeStamp GenerateTime
vtkIdType Size
void PopulateDataArray(vtkDataArray *da, double minRange, double maxRange)
Methods to populate data arrays of various types with values within a specified (min,...
const double * GetPool()
These methods provide access to the raw random pool as a double array.
vtkIdType ChunkSize
double GetValue(vtkIdType i, int compNum)
These methods provide access to the raw random pool as a double array.
vtkIdType GetTotalSize()
This convenience method returns the total size of the memory pool, i.e., Size*NumberOfComponents.
Definition: vtkRandomPool.h:96
void PopulateDataArray(vtkDataArray *da, int compNumber, double minRange, double maxRange)
Methods to populate data arrays of various types with values within a specified (min,...
static vtkRandomPool * New()
Standard methods for instantiation, type information, and printing.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instantiation, type information, and printing.
vtkIdType TotalSize
Generate a sequence of random numbers.
record modification and/or execution time
Definition: vtkTimeStamp.h:55
int vtkIdType
Definition: vtkType.h:332
#define VTK_ID_MAX
Definition: vtkType.h:336
#define VTK_INT_MAX
Definition: vtkType.h:155