HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_TransformArray.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_TransformArray.h ( GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_TransformArray__
12 #define __GT_TransformArray__
13 
14 #include "GT_API.h"
15 #include "GT_Handles.h"
16 #include "GT_Types.h"
17 #include <UT/UT_IntrusivePtr.h>
18 #include <UT/UT_Array.h>
19 #include <UT/UT_VectorTypes.h>
20 
21 class UT_JSONWriter;
22 
24  : public UT_IntrusiveRefCounter<GT_TransformArray>
25 {
26 public:
28  virtual ~GT_TransformArray() { setEntries(0); }
29 
30  /// Return the number of entries
31  GT_Size entries() const { return myTransforms.entries(); }
32 
33  /// Return approximate memory usage
34  int64 getMemoryUsage() const;
35 
36  /// Return the number of motion segments. We assume that all transforms
37  /// have the same number of segments.
38  int getMotionSegments() const;
39 
40  /// Set the number of entries
41  void setEntries(GT_Size n);
42 
43  /// Return a transform handle
44  const GT_TransformHandle &get(GT_Size i) const
45  { return myTransforms(i); }
46  /// Set a transform handle
47  void set(GT_Size i, const GT_TransformHandle &h)
48  { myTransforms(i) = h; }
49 
50  /// Append a transform handle
51  void append(const GT_TransformHandle &h);
52 
53  /// Append a transform array
54  void append(const GT_TransformArrayHandle &h);
55 
56  /// Multiply all the transforms by a single transform
58 
59  /// Pre-multiply all the transforms by a single transform
60  GT_TransformArrayHandle preMultiply(const GT_TransformHandle &h) const;
61 
62  /// @{
63  /// For memory tracking, we override the new/delete operators
64  static void *operator new(size_t size);
65  static void *operator new(size_t size, void *p);
66  static void operator delete(void *p, size_t size);
67  /// @}
68 
69  /// Save to JSON
70  bool save(UT_JSONWriter &w) const;
71 
72  void setTransforms(const UT_Matrix4FArray &transforms);
73  void setTransforms(const UT_Matrix4DArray &transforms);
74 
75  void getTransforms(UT_Matrix4FArray &transforms);
76  void getTransforms(UT_Matrix4DArray &transforms);
77 
78  /// Data id support for derived classes (-1 means always re-update).
79  virtual int64 getDataId() const { return -1; }
80 
81  /// Dump array
82  void dump(const char *msg="") const;
83 
84 private:
85  UT_Array<GT_TransformHandle> myTransforms;
86 };
87 
88 #endif
#define GT_API
Definition: GT_API.h:13
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:37
A reference counter base class for use with UT_IntrusivePtr.
virtual int64 getDataId() const
Data id support for derived classes (-1 means always re-update).
GLdouble n
Definition: glcorearb.h:2008
long long int64
Definition: SYS_Types.h:116
int64 GT_Size
Definition: GT_Types.h:128
GLsizeiptr size
Definition: glcorearb.h:664
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
void set(GT_Size i, const GT_TransformHandle &h)
Set a transform handle.
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
virtual ~GT_TransformArray()
uint64_t multiply(uint64_t lhs, uint64_t rhs)
Definition: format-inl.h:258
GT_Size entries() const
Return the number of entries.