HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GA_KnotVector.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: GA Library (C++)
7  *
8  */
9 
10 #ifndef __GA_KnotVector_h__
11 #define __GA_KnotVector_h__
12 
13 #include "GA_API.h"
14 
15 #include "GA_Types.h"
16 
17 #include <UT/UT_Array.h>
18 #include <UT/UT_ValArray.h>
19 
20 #include <SYS/SYS_Types.h>
21 
22 
23 class UT_JSONWriter;
24 class UT_JSONParser;
26 
27 
28 typedef fpreal64 GA_KnotFloat;
29 
30 template <typename T>
31 class GA_KnotVectorT : public UT_ValArray<T>
32 {
33 public:
35  : UT_ValArray<T>(a)
36  {}
37  GA_KnotVectorT(unsigned int sz, unsigned int count)
38  : UT_ValArray<T>(sz, count)
39  {}
40  explicit GA_KnotVectorT(unsigned int sz = 0)
41  : UT_ValArray<T>(sz)
42  {}
43  ~GA_KnotVectorT(void);
44 
45  /// Save data to a JSON stream.
46  /// @section JSON-GA_KnotVector JSON Schema: GA_KnotVector
47  /// @code
48  /// {
49  /// "name" : "GA_KnotVector",
50  /// "description" : "An knot vector array.",
51  /// "type" : "array",
52  /// "items" : "number",
53  /// }
54  /// @endcode
55  /// @see @ref JSON_FileFormat
56  bool jsonSave(UT_JSONWriter &w) const;
57 
58  /// Save to a JSON value
59  bool jsonSave(UT_JSONValue &w) const;
60 
61  /// Load from a JSON stream
62  bool jsonLoad(UT_JSONParser &p);
63 
64  /// Load from a JSON value
65  bool jsonLoad(UT_JSONParser &p, const UT_JSONValue &v);
66 
67 
68  void copyMemory(const GA_KnotVectorT &from)
69  {
70  *this = from;
71  }
72 
73  // Move howMany objects starting at index srcIndex to destIndex;
74  // Method returns 0 if OK, -1 if overflow.
75  int shift(GA_Size srcIdx, GA_Size destIdx, GA_Size howMany);
76 
77  const T &getValue(GA_Size index) const
78  {
79  return UT_Array<T>::operator()(index);
80  }
82  {
83  if (index >= UT_Array<T>::entries())
84  UT_Array<T>::entries(index + 1);
85  UT_Array<T>::operator()(index) = v;
86  }
87  void reserve(int size)
89 
91  { return insert(idx); }
93  { return insert(t, i); }
94 
95 private:
96  /// @{
97  /// The order of arguments for insert() is different for GA_Basis and for
98  /// UT_ValArray. Thus, we make the insert methods private and ask people
99  /// to use "insertKnot" instead.
100  unsigned int insert(unsigned index)
101  { return UT_ValArray<T>::insert(index); }
102  unsigned int insert(const T &t, unsigned int i)
103  { return UT_ValArray<T>::insert(t, i); }
104  /// @}
105 
106 };
107 
109 
110 #endif
GA_Size insertKnot(fpreal t, GA_Size i)
Definition: GA_KnotVector.h:92
void copyMemory(const GA_KnotVectorT &from)
Definition: GA_KnotVector.h:68
const GLdouble * v
Definition: glcorearb.h:836
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1221
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:72
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:32
GA_KnotVectorT(unsigned int sz=0)
Definition: GA_KnotVector.h:40
bool jsonLoad(UT_JSONParser &p)
Load from a JSON stream.
png_uint_32 i
Definition: png.h:2877
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:211
GLsizeiptr size
Definition: glcorearb.h:663
~GA_KnotVectorT(void)
GA_Size insertKnot(GA_Size idx)
Definition: GA_KnotVector.h:90
const T & getValue(GA_Size index) const
Definition: GA_KnotVector.h:77
double fpreal64
Definition: SYS_Types.h:191
GA_KnotVectorT(unsigned int sz, unsigned int count)
Definition: GA_KnotVector.h:37
int shift(GA_Size srcIdx, GA_Size destIdx, GA_Size howMany)
GA_KnotVectorT(const GA_KnotVectorT &a)
Definition: GA_KnotVector.h:34
bool jsonSave(UT_JSONWriter &w) const
GLint GLsizei count
Definition: glcorearb.h:404
void reserve(int size)
Definition: GA_KnotVector.h:87
exint entries() const
Alias of size(). size() is preferred.
Definition: UT_Array.h:446
double fpreal
Definition: SYS_Types.h:269
void setValue(GA_Size index, fpreal v)
Definition: GA_KnotVector.h:81
GLuint index
Definition: glcorearb.h:785
GA_KnotVectorT< GA_KnotFloat > GA_KnotVector
Class to store JSON objects as C++ objects.
Definition: UT_JSONValue.h:75
void setCapacityIfNeeded(exint mincapacity)
Definition: UT_Array.h:401
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
T & operator()(exint i)
Definition: UT_Array.h:535
fpreal64 GA_KnotFloat
Definition: GA_KnotVector.h:25
exint insert(exint index)
Definition: UT_ArrayImpl.h:122