HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_DARandom.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GT_DARandom.h ( GT Library, C++)
7  *
8  * COMMENTS: An example of a non-data driven array. This array computes
9  * random values based on a random number seed.
10  */
11 
12 #ifndef __GT_DARandom__
13 #define __GT_DARandom__
14 
15 #include "GT_API.h"
16 #include "GT_DataArray.h"
17 
18 /// @brief An array of random values
19 ///
20 /// This array has minimal storage and represents an array of random values.
21 /// @note The array has issues with more than 2^31 entries
23 {
24 public:
25  /// @{ Constructors/Destructors
26  GT_DARandom(GT_Size array_size, int tuple_size=1,
27  GT_Type tinfo=GT_TYPE_NONE,
28  uint seed=0, fpreal min=0, fpreal max=1);
29  GT_DARandom(const GT_DARandom &src);
30  ~GT_DARandom() override;
31  /// @}
32 
33  /// @{
34  /// Methods defined on GT_DataArray
35  const char *className() const override
36  { return "GT_DARandom"; }
37  GT_Storage getStorage() const override
38  { return GT_STORE_REAL32; }
39  GT_Size entries() const override
40  { return myEntries; }
41  GT_Size getTupleSize() const override
42  { return myTupleSize; }
43  int64 getMemoryUsage() const override
44  { return sizeof(*this); }
45  GT_Type getTypeInfo() const override { return myType; }
46 
47  fpreal32 getF32(GT_Offset offset, int idx) const override;
48  uint8 getU8(GT_Offset offset, int idx) const override;
49  int32 getI32(GT_Offset offset, int idx) const override;
50  GT_String getS(GT_Offset offset, int idx) const override;
51  GT_Size getStringIndexCount() const override
52  { return -1; }
53  GT_Offset getStringIndex(GT_Offset, int) const override
54  { return -1; }
56  UT_IntArray &) const override {}
57  GT_Size getDictIndexCount() const override
58  { return -1; }
59  GT_Offset getDictIndex(GT_Offset, int) const override
60  { return -1; }
62  UT_IntArray &) const override {}
63  GT_DataArrayHandle harden() const override
64  { return GT_DataArrayHandle(SYSconst_cast(this)); }
65  /// @}
66 
67  /// The random numbers generated will be fit to this range.
69  { myMin = min; myMax = max; }
70 
71 private:
72  fpreal32 myMin, myMax;
73  GT_Size myEntries;
74  int myTupleSize;
75  uint mySeed;
76  GT_Type myType;
77 };
78 
79 #endif
An array of random values.
Definition: GT_DARandom.h:22
GT_Storage
Definition: GT_Types.h:19
int int32
Definition: SYS_Types.h:39
GT_Size entries() const override
Definition: GT_DARandom.h:39
SYS_FORCE_INLINE T * SYSconst_cast(const T *foo)
Definition: SYS_Types.h:136
virtual fpreal32 getF32(GT_Offset offset, int idx=0) const =0
#define GT_API
Definition: GT_API.h:13
GT_Type
Definition: GT_Types.h:36
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
float fpreal32
Definition: SYS_Types.h:200
GT_Storage getStorage() const override
Definition: GT_DARandom.h:37
unsigned char uint8
Definition: SYS_Types.h:36
GLintptr offset
Definition: glcorearb.h:665
GT_Offset getStringIndex(GT_Offset, int) const override
Definition: GT_DARandom.h:53
Abstract data class for an array of float, int or string data.
Definition: GT_DataArray.h:40
GT_Type getTypeInfo() const override
Definition: GT_DARandom.h:45
UT_IntrusivePtr< GT_DataArray > GT_DataArrayHandle
Definition: GT_DataArray.h:32
const char * className() const override
Definition: GT_DARandom.h:35
int64 GT_Offset
Definition: GT_Types.h:129
long long int64
Definition: SYS_Types.h:116
GT_Offset getDictIndex(GT_Offset, int) const override
Definition: GT_DARandom.h:59
void getIndexedStrings(UT_StringArray &, UT_IntArray &) const override
Definition: GT_DARandom.h:55
int64 getMemoryUsage() const override
Definition: GT_DARandom.h:43
void getIndexedDicts(UT_Array< UT_OptionsHolder > &, UT_IntArray &) const override
Definition: GT_DARandom.h:61
GT_Size getDictIndexCount() const override
Definition: GT_DARandom.h:57
GT_DataArrayHandle harden() const override
Definition: GT_DARandom.h:63
int64 GT_Size
Definition: GT_Types.h:128
fpreal64 fpreal
Definition: SYS_Types.h:277
void setRange(fpreal min=0, fpreal max=1)
The random numbers generated will be fit to this range.
Definition: GT_DARandom.h:68
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
virtual uint8 getU8(GT_Offset offset, int idx=0) const =0
GT_Size getTupleSize() const override
Definition: GT_DARandom.h:41
GT_Size getStringIndexCount() const override
Definition: GT_DARandom.h:51
virtual int32 getI32(GT_Offset offset, int idx=0) const =0
unsigned int uint
Definition: SYS_Types.h:45
virtual GT_String getS(GT_Offset offset, int idx=0) const =0
GLenum src
Definition: glcorearb.h:1793