VTK  9.3.20240424
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
36VTK_ABI_NAMESPACE_BEGIN
38class vtkDataArray;
39
40class VTKCOMMONCORE_EXPORT vtkRandomPool : public vtkObject
41{
42public:
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
136protected:
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
153private:
154 vtkRandomPool(const vtkRandomPool&) = delete;
155 void operator=(const vtkRandomPool&) = delete;
156};
157
158VTK_ABI_NAMESPACE_END
159#endif
abstract superclass for arrays of numeric data
a simple class to control print indentation
Definition vtkIndent.h:108
abstract base class for most VTK objects
Definition vtkObject.h:162
convenience class to quickly generate a pool of random numbers
virtual void SetSequence(vtkRandomSequence *seq)
Specify the random sequence generator used to produce the random pool.
~vtkRandomPool() override
vtkRandomSequence * Sequence
double GetValue(vtkIdType i)
These methods provide access to the raw random pool as a double array.
static vtkRandomPool * New()
Standard methods for instantiation, type information, and printing.
vtkTimeStamp GenerateTime
const double * GeneratePool()
These methods provide access to the raw random pool as a double array.
void PopulateDataArray(vtkDataArray *da, double minRange, double maxRange)
Methods to populate data arrays of various types with values within a specified (min,...
vtkIdType ChunkSize
const double * GetPool()
These methods provide access to the raw random pool as a double array.
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.
void PopulateDataArray(vtkDataArray *da, int compNumber, double minRange, double maxRange)
Methods to populate data arrays of various types with values within a specified (min,...
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
int vtkIdType
Definition vtkType.h:315
#define VTK_ID_MAX
Definition vtkType.h:319
#define VTK_INT_MAX
Definition vtkType.h:144