11 #ifndef __GT_CurveEval__
12 #define __GT_CurveEval__
37 static int maximumBezierOrder();
38 static void orderRange(
GT_Basis basis,
int &min_order,
int &max_order);
40 GT_CurveEval(
GT_Basis basis,
bool periodic);
41 GT_CurveEval(
const GT_CurveEval &
eval);
43 void setOrder(
int order)
46 cacheOrderComputation(order);
66 bool valid()
const {
return myKnots && mySize > 1; }
68 const fpreal *knots()
const {
return myKnots; }
75 int n = span + order - 1;
77 return SYSlerp(myKnots[n], myKnots[n+1], t);
80 int size()
const {
return mySize; }
82 fpreal operator()(
int i)
const
88 fpreal operator[](
int i)
const
104 void dump(
const char *msg=
"");
113 bool validCount(
int nvertices,
int order)
const;
122 int step()
const {
return myStep; }
125 int spanCount(
int nvtx,
int order)
const
142 const fpreal *
w()
const {
return myW; }
147 int conditional()
const {
return myConditional; }
148 void setConditional(
int c) { myConditional =
c; }
152 void computeConditional(
int nvals)
155 for (
int i = 1; i < nvals; ++i)
156 if (myW[i] > myW[myConditional])
161 fpreal myW[EVAL_BUF_SIZE];
169 template <
typename DATA_T>
170 inline DATA_T
eval(
int order,
const EvalBuffer &ebuf,
171 const DATA_T *hull,
int stride=1)
const
172 {
return hull[ebuf.conditional()*
stride]; }
180 template <
typename DATA_T>
181 inline DATA_T evalIndex(
int order,
const EvalBuffer &ebuf,
182 const DATA_T *hull,
const int *
index)
const
183 {
return hull[index[ebuf.conditional()]]; }
228 int segment=0)
const;
231 int segment=0)
const;
236 const Knots &knots)
const;
239 void cacheOrderComputation(
int order);
241 template <
typename T>
242 inline T evalF(
int order,
const EvalBuffer &ebuf,
243 const T *hull,
int stride)
const
247 for (
int i = 0; i <
order; ++i)
248 v += w[i] * hull[i*stride];
251 template <
typename DATA_T>
252 inline DATA_T evalFIndex(
int order,
const EvalBuffer &ebuf,
254 const int *index)
const
257 const fpreal *w = ebuf.w();
258 for (
int i = 0; i <
order; ++i)
259 v += w[i] * hull[index[i]];
271 GT_CurveEval::eval<fpreal16>(
int order,
const EvalBuffer &ebuf,
273 {
return evalF(order, ebuf, hull, stride); }
275 GT_CurveEval::eval<fpreal32>(
int order,
const EvalBuffer &ebuf,
277 {
return evalF(order, ebuf, hull, stride); }
279 GT_CurveEval::eval<fpreal64>(
int order,
const EvalBuffer &ebuf,
281 {
return evalF(order, ebuf, hull, stride); }
284 GT_CurveEval::evalIndex<fpreal16>(
int order,
const EvalBuffer &ebuf,
286 {
return evalFIndex<fpreal16>(
order, ebuf, hull,
index); }
288 GT_CurveEval::evalIndex<fpreal32>(
int order,
const EvalBuffer &ebuf,
290 {
return evalFIndex<fpreal32>(
order, ebuf, hull,
index); }
292 GT_CurveEval::evalIndex<fpreal64>(
int order,
const EvalBuffer &ebuf,
294 {
return evalFIndex<fpreal64>(
order, ebuf, hull,
index); }
GLuint GLsizei GLsizei * length
Class which writes ASCII or binary JSON streams.
void preCompute(int order, EvalBuffer &ebuf, int span, fpreal t, const Knots &knots) const
When computing with knots, there need to be Order*2+1 knots for a span.
UT_Matrix2T< T > SYSlerp(const UT_Matrix2T< T > &v1, const UT_Matrix2T< T > &v2, S t)
bool copyToAttributes(GT_AttributeListHandle &dest, UT_Array< GT_DataArrayHandle > &arrays, int segment=0) const
GLint GLenum GLboolean GLsizei stride
GLdouble GLdouble GLint GLint order
HUSD_API bool eval(VtValue &val, T &ret_val)
bool refineToNumeric(int order, UT_Array< GT_DataArrayHandle > &arrays, GT_Offset dest_offset, GT_Size dest_count, const GT_AttributeListHandle &hull, GT_Offset hull_offset, GT_Size hull_count, const GT_DataArrayHandle &knots, GT_Offset knot_offset, int segment=0) const
GLubyte GLubyte GLubyte GLubyte w
GT_API GT_Size GTbasisSpans(GT_Basis basis, GT_Size count, bool wrapped, int order=4)
void allocateNumericArrays(UT_Array< GT_DataArrayHandle > &arrays, const GT_AttributeListHandle &hull, GT_Size total_points) const
GLenum GLenum GLsizei void GLsizei void void * span