HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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  virtual ~GT_DARandom();
31  /// @}
32 
33  /// @{
34  /// Methods defined on GT_DataArray
35  virtual const char *className() const { return "GT_DARandom"; }
36  virtual GT_Storage getStorage() const { return GT_STORE_REAL32; }
37  virtual GT_Size entries() const { return myEntries; }
38  virtual GT_Size getTupleSize() const { return myTupleSize; }
39  virtual int64 getMemoryUsage() const { return sizeof(*this); }
40  virtual GT_Type getTypeInfo() const { return myType; }
41 
42  virtual fpreal32 getF32(GT_Offset offset, int idx) const;
43  virtual uint8 getU8(GT_Offset offset, int idx) const;
44  virtual int32 getI32(GT_Offset offset, int idx) const;
45  virtual GT_String getS(GT_Offset offset, int idx) const;
46  virtual GT_Size getStringIndexCount() const { return -1; }
47  virtual GT_Offset getStringIndex(GT_Offset, int) const { return -1; }
49  UT_IntArray &) const {}
50  virtual GT_DataArrayHandle harden() const
51  { return GT_DataArrayHandle(SYSconst_cast(this)); }
52  /// @}
53 
54  /// The random numbers generated will be fit to this range.
56  { myMin = min; myMax = max; }
57 
58 private:
59  fpreal32 myMin, myMax;
60  GT_Size myEntries;
61  int myTupleSize;
62  uint mySeed;
63  GT_Type myType;
64 };
65 
66 #endif
An array of random values.
Definition: GT_DARandom.h:22
GT_Storage
Definition: GT_Types.h:17
virtual GT_Offset getStringIndex(GT_Offset, int) const
Definition: GT_DARandom.h:47
virtual GT_DataArrayHandle harden() const
Definition: GT_DARandom.h:50
const hboost::disable_if_c< VecTraits< T >::IsVec, T >::type & min(const T &a, const T &b)
Definition: Composite.h:128
const char * GT_String
Definition: GT_Types.h:108
SYS_FORCE_INLINE T * SYSconst_cast(const T *foo)
Definition: SYS_Types.h:126
virtual fpreal32 getF32(GT_Offset offset, int idx=0) const =0
#define GT_API
Definition: GT_API.h:11
GT_Type
Definition: GT_Types.h:31
virtual const char * className() const
Definition: GT_DARandom.h:35
virtual GT_Storage getStorage() const
Definition: GT_DARandom.h:36
const hboost::disable_if_c< VecTraits< T >::IsVec, T >::type & max(const T &a, const T &b)
Definition: Composite.h:132
long long int64
Definition: SYS_Types.h:106
Abstract data class for an array of float, int or string data.
Definition: GT_DataArray.h:38
UT_IntrusivePtr< GT_DataArray > GT_DataArrayHandle
Definition: GT_DataArray.h:30
virtual GT_Size entries() const
Definition: GT_DARandom.h:37
GLintptr offset
Definition: glcorearb.h:664
virtual int64 getMemoryUsage() const
Definition: GT_DARandom.h:39
virtual GT_Type getTypeInfo() const
Definition: GT_DARandom.h:40
int int32
Definition: SYS_Types.h:34
unsigned int uint
Definition: SYS_Types.h:39
double fpreal
Definition: SYS_Types.h:269
unsigned char uint8
Definition: SYS_Types.h:31
virtual GT_Size getStringIndexCount() const
Definition: GT_DARandom.h:46
virtual GT_Size getTupleSize() const
Definition: GT_DARandom.h:38
void setRange(fpreal min=0, fpreal max=1)
The random numbers generated will be fit to this range.
Definition: GT_DARandom.h:55
virtual uint8 getU8(GT_Offset offset, int idx=0) const =0
virtual void getIndexedStrings(UT_StringArray &, UT_IntArray &) const
Definition: GT_DARandom.h:48
int64 GT_Offset
Definition: GT_Types.h:110
int64 GT_Size
Definition: GT_Types.h:109
virtual int32 getI32(GT_Offset offset, int idx=0) const =0
float fpreal32
Definition: SYS_Types.h:190
virtual GT_String getS(GT_Offset offset, int idx=0) const =0
GLenum src
Definition: glcorearb.h:1792