VTK  9.3.0
vtkRandomPool.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
30 #ifndef vtkRandomPool_h
31 #define vtkRandomPool_h
32 
33 #include "vtkCommonCoreModule.h" // For export macro
34 #include "vtkObject.h"
35 
36 VTK_ABI_NAMESPACE_BEGIN
37 class vtkRandomSequence;
38 class vtkDataArray;
39 
40 class VTKCOMMONCORE_EXPORT vtkRandomPool : public vtkObject
41 {
42 public:
44 
47  static vtkRandomPool* New();
48  vtkTypeMacro(vtkRandomPool, vtkObject);
49  void PrintSelf(ostream& os, vtkIndent indent) override;
51 
53 
57  virtual void SetSequence(vtkRandomSequence* seq);
58  vtkGetObjectMacro(Sequence, vtkRandomSequence);
60 
62 
67  vtkSetClampMacro(Size, vtkIdType, 1, VTK_ID_MAX);
68  vtkGetMacro(Size, vtkIdType);
70 
72 
77  vtkSetClampMacro(NumberOfComponents, vtkIdType, 1, VTK_INT_MAX);
78  vtkGetMacro(NumberOfComponents, vtkIdType);
80 
85  vtkIdType GetTotalSize() { return (this->Size * this->NumberOfComponents); }
86 
88 
100  const double* GeneratePool();
101  const double* GetPool() { return this->Pool; }
102  double GetValue(vtkIdType i) { return this->Pool[(i % this->TotalSize)]; }
103  double GetValue(vtkIdType i, int compNum)
104  {
105  return this->Pool[(compNum + this->NumberOfComponents * i) % this->TotalSize];
106  }
108 
110 
122  void PopulateDataArray(vtkDataArray* da, double minRange, double maxRange);
123  void PopulateDataArray(vtkDataArray* da, int compNumber, double minRange, double maxRange);
125 
127 
132  vtkSetClampMacro(ChunkSize, vtkIdType, 1000, VTK_INT_MAX);
133  vtkGetMacro(ChunkSize, vtkIdType);
135 
136 protected:
138  ~vtkRandomPool() override;
139 
140  // Keep track of last generation time
142 
143  // Data members to support public API
148 
149  // Internal data members
151  double* Pool;
152 
153 private:
154  vtkRandomPool(const vtkRandomPool&) = delete;
155  void operator=(const vtkRandomPool&) = delete;
156 };
157 
158 VTK_ABI_NAMESPACE_END
159 #endif
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
a simple class to control print indentation
Definition: vtkIndent.h:38
abstract base class for most VTK objects
Definition: vtkObject.h:61
convenience class to quickly generate a pool of random numbers
Definition: vtkRandomPool.h:41
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:85
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:34
int vtkIdType
Definition: vtkType.h:315
#define VTK_ID_MAX
Definition: vtkType.h:319
#define VTK_INT_MAX
Definition: vtkType.h:144