HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_PointDeform.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: GU_Cosserat.h ( CE Library, C++)
7  *
8  * COMMENTS: Functions to perform stable cosserat rods simulation.
9  */
10 
11 #pragma once
12 
13 #include "GU_API.h"
14 #include <CE/CE_Array.h>
15 #include <UT/UT_Array.h>
16 #include <UT/UT_Quaternion.h>
17 #include <UT/UT_Span.h>
18 #include <UT/UT_Matrix3.h>
19 #include <UT/UT_Vector3.h>
20 #include <UT/UT_ErrorLog.h>
21 #include <variant>
22 
23 class CE_Context;
24 
25 namespace GU_PointDeform
26 {
27 
29 {
30 public:
31  void loadKernels(
32  CE_Context &context,
33  int n,
34  int ndeformerpts,
35  bool recompile);
36 
37  template <typename T>
38  class Buffer
39  {
40  public:
42  {
43  if (std::holds_alternative<CE_Array<T>>(myBuffer))
44  return std::get<CE_Array<T>>(myBuffer).init(size);
45  };
46 
48  {
49  if (std::holds_alternative<CE_Array<T>>(myBuffer))
50  return std::get<CE_Array<T>>(myBuffer).buffer();
51  else
52  return std::get<cl::Buffer>(myBuffer);
53  }
54 
55  void setExternal(cl::Buffer buffer) { myBuffer = buffer; }
56 
57  void setInternal()
58  {
59  if (!std::holds_alternative<CE_Array<T>>(myBuffer))
60  myBuffer = CE_Array<T>();
61  }
62  bool isExternal()
63  {
64  return std::holds_alternative<cl::Buffer>(myBuffer);
65  }
66 
67  private:
68  std::variant<CE_Array<T>, cl::Buffer> myBuffer;
69  };
70 
71  class Buffers
72  {
73  public:
74  bool init(int npts, int ndeformerpts);
75 
83 
92 
93  } myBuffers;
94 
95  struct Kernels
96  {
102  } myKernels;
103 
104 public:
105  Buffers &getBuffers() { return myBuffers; }
106  Kernels &getKernels() { return myKernels; }
107 };
108 
109 } // namespace GU_PointDeform
110 
111 GU_API bool
113  GU_PointDeform::CachedItems &cached_items,
114  CE_Context &context,
115  int npts,
116  int ndeformerpts,
117  bool recompile);
118 
119 GU_API bool
121  GU_PointDeform::CachedItems &cached_items,
122  CE_Context &context,
123  int ndeformerpts,
124  bool recompile);
125 
126 GU_API bool
128  GU_PointDeform::CachedItems &cached_items,
129  CE_Context &context,
130  int ndeformerpts,
131  bool recompile);
132 
133 GU_API void
135  GU_PointDeform::CachedItems &cached_items,
136  CE_Context &context,
137  int npts,
138  bool recompile);
139 
140 GU_API void
142  const cl::Buffer &outpos,
143  const cl::Buffer &inpos,
144  GU_PointDeform::CachedItems &cached_items,
145  CE_Context &context,
146  int npts,
147  bool recompile,
148  const cl::Buffer *mask = nullptr);
149 
150 GU_API void
152  const cl::Buffer &outorient,
153  const cl::Buffer &inorient,
154  GU_PointDeform::CachedItems &cached_items,
155  CE_Context &context,
156  int npts,
157  bool recompile);
158 
159 GU_API void
161  UT_IntArray &captStarts,
162  UT_IntArray &captPts,
163  UT_FloatArray &captWeights,
165  UT_Span<const UT_Vector3F> deformerpos,
166  float radius,
167  int maxpts,
168  int minpts);
A simple OpenCL-based array class.
Definition: CE_Array.h:28
GU_API bool GUpointDeformOrientXform(GU_PointDeform::CachedItems &cached_items, CE_Context &context, int ndeformerpts, bool recompile)
int64 exint
Definition: SYS_Types.h:125
struct GU_PointDeform::CachedItems::Kernels myKernels
GLuint buffer
Definition: glcorearb.h:660
bool init(int npts, int ndeformerpts)
GLdouble n
Definition: glcorearb.h:2008
GU_API void GUpointDeformComputeCapture(UT_IntArray &captStarts, UT_IntArray &captPts, UT_FloatArray &captWeights, UT_Span< const UT_Vector3F > querypos, UT_Span< const UT_Vector3F > deformerpos, float radius, int maxpts, int minpts)
GU_API void GUpointDeformComputeTransform(GU_PointDeform::CachedItems &cached_items, CE_Context &context, int npts, bool recompile)
GU_API bool GUpointDeformSeqXform(GU_PointDeform::CachedItems &cached_items, CE_Context &context, int ndeformerpts, bool recompile)
GU_API void GUpointDeformTranslate(const cl::Buffer &outpos, const cl::Buffer &inpos, GU_PointDeform::CachedItems &cached_items, CE_Context &context, int npts, bool recompile, const cl::Buffer *mask=nullptr)
GLint GLuint mask
Definition: glcorearb.h:124
GU_API bool GUpointDeformInit(GU_PointDeform::CachedItems &cached_items, CE_Context &context, int npts, int ndeformerpts, bool recompile)
#define GU_API
Definition: GU_API.h:14
class GU_PointDeform::CachedItems::Buffers myBuffers
void setExternal(cl::Buffer buffer)
GLsizeiptr size
Definition: glcorearb.h:664
GU_API void GUpointDeformRotateQuat(const cl::Buffer &outorient, const cl::Buffer &inorient, GU_PointDeform::CachedItems &cached_items, CE_Context &context, int npts, bool recompile)
void loadKernels(CE_Context &context, int n, int ndeformerpts, bool recompile)
Kernel functor interface.
Definition: cl.hpp:3587
Memory buffer interface.
Definition: cl.hpp:1867