HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_WorkVertexBuffer.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_WorkVertexBuffer.h ( GA Library, C++)
7  *
8  * COMMENTS: Container to allocate/store temporary vertices
9  */
10 
11 #ifndef __GA_WorkVertexBuffer__
12 #define __GA_WorkVertexBuffer__
13 
14 #include "GA_API.h"
15 #include "GA_Defines.h"
16 #include "GA_TempBuffer.h"
17 #include "GA_Types.h"
18 #include "GA_VertexPool.h"
19 
20 
22 {
23 public:
24  /// Construct a buffer of temporary vertices/points for a given detail.
25  /// Thes vertices can be used for intermediate computations.
26  /// The @c size parameter specifies the initial allocation size of the
27  /// buffer.
28  ///
29  /// When the vertex buffer represents a 2D array of vertices, the @c
30  /// matrix_number_columns variable specifies the number of columns in the
31  /// array (i.e. nu).
33  GA_Size matrix_number_colums = GA_MAXORDER);
34  /// Virtual solely for GEO backward compatibility
35  virtual ~GA_WorkVertexBuffer();
36 
37  /// Release all the vertices
38  void clear();
39 
40  /// @{
41  /// Look up the vertex at the index specified. If the index requested is
42  /// greater than the allocated number of vertices, new vertices will be
43  /// allocated. The const method will not append new vertices, and will
44  /// return GA_INVALID_INDEX if the index is out of range.
45  GA_Offset getVertexOffset(GA_Size idx, GA_Offset pt=GA_INVALID_OFFSET);
46  GA_Offset getVertexOffset(GA_Size idx) const;
47  /// @}
48 
49  /// Grow the buffer to the size specified. Temporary points will be
50  /// created for each temporary vertex
51  void growBuffer(GA_Size newsize);
52 
53  /// Reserve memory for the given amount of vertices/points without growing
54  /// the the buffer. Only has an effect when num_elems is larger than the
55  /// current number of entries.
56  void reserve(GA_Size num_elems);
57 
58  /// Append a single vertex. If a point is not specified, a temporary point
59  /// will be created to handle point attributes.
60  GA_Offset appendVertexOffset(GA_Offset point=GA_INVALID_OFFSET);
61 
62  /// Append a single temporary point.
63  GA_Offset appendPointOffset();
64 
65 
66  /// Allocate @c N vertices in the provided buffer
68  {
69  reserve(n);
70  for (GA_Size i = 0; i < n; i++)
71  buffer[i] = appendVertexOffset();
72  }
73 
74  /// Allocate @c N points into the provided buffer
76  {
77  reserve(n);
78  for (GA_Size i = 0; i < n; ++i)
79  buffer[i] = appendPointOffset();
80  }
81 
82  GA_VertexPool &getVertexPool() const { return myVertexPool; }
83 
84  /// @{
85  /// Query
86  GA_Size getVertexEntries() const { return myVertices.entries(); }
87  /// @}
88 
89  /// Get a vertex in a mesh (rather than a linear array). This uses the
90  /// MatrixSize to determine the number of columns in the matrix.
93  { return getVertexOffset(r*myMatrixSize+c, pt); }
94  /// The matrix size is the number of columns in the 2D array of vertices
95  GA_Size getMatrixSize() const { return myMatrixSize; }
96 
97 
98  /// Swap two entries in the vertex array. This changes the vertex order in
99  /// the buffer, but has no effect on the geometry.
101  { myVertices.swap(i1, i2); }
102 
103 private:
104  GA_VertexPoolIndex appendVertex(GA_Offset point)
105  {
107  vertex = myVertexPool.appendVertex(point);
108  myVertices.append(vertex);
109  return vertex;
110  }
111 
112  GA_VertexPool &myVertexPool;
114  GA_Size myMatrixSize;
115 };
116 
117 #endif
SIM_API const UT_StringHolder vertex
void appendVertices(GA_Offset *buffer, GA_Size n)
Allocate N vertices in the provided buffer.
void swapVertices(GA_Size i1, GA_Size i2)
GA_Size getMatrixSize() const
The matrix size is the number of columns in the 2D array of vertices.
GLint GLint i2
Definition: glad.h:2724
Manages allocation/deletion of temporary vertex/points for a detail.
Definition: GA_VertexPool.h:35
#define GA_MAXORDER
Definition: GA_Defines.h:17
#define GA_API
Definition: GA_API.h:14
GA_Size GA_VertexPoolIndex
Definition: GA_VertexPool.h:20
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:235
void appendPoints(GA_Offset *buffer, GA_Size n)
Allocate N points into the provided buffer.
GA_VertexPool & getVertexPool() const
#define GA_INVALID_OFFSET
Definition: GA_Types.h:678
GA_Size GA_Offset
Definition: GA_Types.h:641
GLdouble n
Definition: glcorearb.h:2008
Definition: core.h:760
GLint i1
Definition: glad.h:2724
auto reserve(std::back_insert_iterator< Container > it, size_t n) -> checked_ptr< typename Container::value_type >
Definition: format.h:357
GLsizeiptr size
Definition: glcorearb.h:664
GLboolean r
Definition: glcorearb.h:1222
GA_Offset getBasisVertexOffset(GA_Size r, GA_Size c, GA_Offset pt=GA_INVALID_OFFSET)
**Note that the tasks the is the thread number *for the pool
Definition: thread.h:637
GA_Size getVertexEntries() const