VTK  9.1.0
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
46class vtkDataArray;
47
48class VTKCOMMONCORE_EXPORT vtkRandomPool : public vtkObject
49{
50public:
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 {
113 return this->Pool[(compNum + this->NumberOfComponents * i) % this->TotalSize];
114 }
116
118
130 void PopulateDataArray(vtkDataArray* da, double minRange, double maxRange);
131 void PopulateDataArray(vtkDataArray* da, int compNumber, double minRange, double maxRange);
133
135
140 vtkSetClampMacro(ChunkSize, vtkIdType, 1000, VTK_INT_MAX);
141 vtkGetMacro(ChunkSize, vtkIdType);
143
144protected:
146 ~vtkRandomPool() override;
147
148 // Keep track of last generation time
150
151 // Data members to support public API
156
157 // Internal data members
159 double* Pool;
160
161private:
162 vtkRandomPool(const vtkRandomPool&) = delete;
163 void operator=(const vtkRandomPool&) = delete;
164};
165
166#endif
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:159
a simple class to control print indentation
Definition: vtkIndent.h:113
abstract base class for most VTK objects
Definition: vtkObject.h:82
convenience class to quickly generate a pool of random numbers
Definition: vtkRandomPool.h:49
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
vtkIdType Size
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.
Definition: vtkRandomPool.h:93
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
Definition: vtkTimeStamp.h:52
int vtkIdType
Definition: vtkType.h:332
#define VTK_ID_MAX
Definition: vtkType.h:336
#define VTK_INT_MAX
Definition: vtkType.h:155