VTK  9.0.3
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  {
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 
144 protected:
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 
161 private:
162  vtkRandomPool(const vtkRandomPool&) = delete;
163  void operator=(const vtkRandomPool&) = delete;
164 };
165 
166 #endif
167 // VTK-HeaderTest-Exclude: vtkRandomPool.h
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:50
a simple class to control print indentation
Definition: vtkIndent.h:34
abstract base class for most VTK objects
Definition: vtkObject.h:63
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
const double * GeneratePool()
These methods provide access to the raw random pool as a double array.
vtkRandomSequence * Sequence
double GetValue(vtkIdType i)
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()
vtkIdType ChunkSize
double GetValue(vtkIdType i, int compNum)
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)
static vtkRandomPool * New()
Standard methods for instantiation, type information, and printing.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkIdType TotalSize
Generate a sequence of random numbers.
record modification and/or execution time
Definition: vtkTimeStamp.h:33
int vtkIdType
Definition: vtkType.h:338
#define VTK_ID_MAX
Definition: vtkType.h:342
#define VTK_INT_MAX
Definition: vtkType.h:155