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:
148  vtkRandomPool();
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
vtkIdType TotalSize
double GetValue(vtkIdType i, int compNum)
These methods provide access to the raw random pool as a double array.
abstract base class for most VTK objects
Definition: vtkObject.h:62
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
#define VTK_INT_MAX
Definition: vtkType.h:155
record modification and/or execution time
Definition: vtkTimeStamp.h:35
convenience class to quickly generate a pool of random numbers
Definition: vtkRandomPool.h:51
int vtkIdType
Definition: vtkType.h:332
Generate a sequence of random numbers.
vtkTimeStamp GenerateTime
a simple class to control print indentation
Definition: vtkIndent.h:39
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
vtkIdType GetTotalSize()
This convenience method returns the total size of the memory pool, i.e., Size*NumberOfComponents.
Definition: vtkRandomPool.h:96
double GetValue(vtkIdType i)
These methods provide access to the raw random pool as a double array.
vtkRandomSequence * Sequence
#define VTK_ID_MAX
Definition: vtkType.h:336
vtkIdType ChunkSize
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkIdType Size
const double * GetPool()
These methods provide access to the raw random pool as a double array.