HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
wrapArray.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_BASE_VT_WRAP_ARRAY_H
25 #define PXR_BASE_VT_WRAP_ARRAY_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/base/vt/api.h"
29 #include "pxr/base/vt/array.h"
30 #include "pxr/base/vt/types.h"
31 #include "pxr/base/vt/value.h"
33 #include "pxr/base/vt/functions.h"
34 
35 #include "pxr/base/arch/math.h"
36 #include "pxr/base/arch/inttypes.h"
37 #include "pxr/base/arch/pragmas.h"
38 #include "pxr/base/gf/half.h"
40 #include "pxr/base/tf/pyFunction.h"
41 #include "pxr/base/tf/pyLock.h"
44 #include "pxr/base/tf/pyUtils.h"
45 #include "pxr/base/tf/iterator.h"
46 #include "pxr/base/tf/span.h"
48 #include "pxr/base/tf/tf.h"
50 
51 #include <hboost/preprocessor/punctuation/comma_if.hpp>
52 #include <hboost/preprocessor/repetition/repeat.hpp>
53 #include <hboost/preprocessor/seq/for_each.hpp>
54 
55 #include <hboost/python/class.hpp>
56 #include <hboost/python/copy_const_reference.hpp>
57 #include <hboost/python/def.hpp>
58 #include <hboost/python/detail/api_placeholder.hpp>
59 #include <hboost/python/extract.hpp>
60 #include <hboost/python/implicit.hpp>
61 #include <hboost/python/iterator.hpp>
62 #include <hboost/python/make_constructor.hpp>
63 #include <hboost/python/object.hpp>
64 #include <hboost/python/operators.hpp>
65 #include <hboost/python/return_arg.hpp>
66 #include <hboost/python/slice.hpp>
67 #include <hboost/python/type_id.hpp>
68 #include <hboost/python/overloads.hpp>
69 
70 #include <algorithm>
71 #include <numeric>
72 #include <ostream>
73 #include <string>
74 #include <memory>
75 #include <vector>
76 
78 
79 namespace Vt_WrapArray {
80 
81 using namespace hboost::python;
82 
83 using std::unique_ptr;
84 using std::vector;
85 using std::string;
86 
87 template <typename T>
88 object
89 getitem_ellipsis(VtArray<T> const &self, object idx)
90 {
91  object ellipsis = object(handle<>(borrowed(Py_Ellipsis)));
92  if (idx != ellipsis) {
93  PyErr_SetString(PyExc_TypeError, "unsupported index type");
94  throw_error_already_set();
95  }
96  return object(self);
97 }
98 
99 template <typename T>
100 object
101 getitem_index(VtArray<T> const &self, int64_t idx)
102 {
103  static const bool throwError = true;
104  idx = TfPyNormalizeIndex(idx, self.size(), throwError);
105  return object(self[idx]);
106 }
107 
108 template <typename T>
109 object
110 getitem_slice(VtArray<T> const &self, slice idx)
111 {
112  try {
113  slice::range<typename VtArray<T>::const_iterator> range =
114  idx.get_indices(self.begin(), self.end());
115  const size_t setSize = 1 + (range.stop - range.start) / range.step;
116  VtArray<T> result(setSize);
117  size_t i = 0;
118  for (; range.start != range.stop; range.start += range.step, ++i) {
119  result[i] = *range.start;
120  }
121  result[i] = *range.start;
122  return object(result);
123  }
124  catch (std::invalid_argument const &) {
125  return object();
126  }
127 }
128 
129 template <typename T, typename S>
130 void
132  slice::range<T*>& range, size_t setSize, bool tile = false)
133 {
134  // Check size.
135  const size_t length = len(value);
136  if (length == 0)
137  TfPyThrowValueError("No values with which to set array slice.");
138  if (!tile && length < setSize) {
139  string msg = TfStringPrintf
140  ("Not enough values to set slice. Expected %zu, got %zu.",
141  setSize, length);
142  TfPyThrowValueError(msg);
143  }
144 
145  // Extract the values before setting any. If we can extract the
146  // whole vector at once then do that since it should be faster.
147  std::vector<T> extracted;
148  extract<std::vector<T> > vectorExtraction(value);
149  if (vectorExtraction.check()) {
150  std::vector<T> tmp = vectorExtraction();
151  extracted.swap(tmp);
152  }
153  else {
154  extracted.reserve(length);
155  for (size_t i = 0; i != length; ++i) {
156  extracted.push_back(extract<T>(value[i]));
157  }
158  }
159 
160  // We're fine, go through and set them. Handle common case as a fast
161  // path.
162  if (range.step == 1 && length >= setSize) {
163  std::copy(extracted.begin(), extracted.begin() + setSize, range.start);
164  }
165  else {
166  for (size_t i = 0; i != setSize; range.start += range.step, ++i) {
167  *range.start = extracted[i % length];
168  }
169  }
170 }
171 
172 template <typename T>
173 void
174 setArraySlice(VtArray<T> &self, slice idx, object value, bool tile = false)
175 {
176  // Get the range.
177  slice::range<T*> range;
178  try {
179  T* data = self.data();
180  range = idx.get_indices(data, data + self.size());
181  }
182  catch (std::invalid_argument const &) {
183  // Do nothing
184  return;
185  }
186 
187  // Get the number of items to be set.
188  const size_t setSize = 1 + (range.stop - range.start) / range.step;
189 
190  // Copy from VtArray. We only want to take this path if the passed value is
191  // *exactly* a VtArray. That is, we don't want to take this path if it can
192  // merely *convert* to a VtArray, so we check that we can extract a mutable
193  // lvalue reference from the python object, which requires that there be a
194  // real VtArray there.
195  if (extract< VtArray<T> &>(value).check()) {
196  const VtArray<T> val = extract< VtArray<T> >(value);
197  const size_t length = val.size();
198  if (length == 0)
199  TfPyThrowValueError("No values with which to set array slice.");
200  if (!tile && length < setSize) {
201  string msg = TfStringPrintf
202  ("Not enough values to set slice. Expected %zu, got %zu.",
203  setSize, length);
204  TfPyThrowValueError(msg);
205  }
206 
207  // We're fine, go through and set them.
208  for (size_t i = 0; i != setSize; range.start += range.step, ++i) {
209  *range.start = val[i % length];
210  }
211  }
212 
213  // Copy from scalar.
214  else if (extract<T>(value).check()) {
215  if (!tile) {
216  // XXX -- We're allowing implicit tiling; do we want to?
217  //TfPyThrowValueError("can only assign an iterable.");
218  }
219 
220  // Use scalar to fill entire slice.
221  const T val = extract<T>(value);
222  for (size_t i = 0; i != setSize; range.start += range.step, ++i) {
223  *range.start = val;
224  }
225  }
226 
227  // Copy from list.
228  else if (extract<list>(value).check()) {
229  setArraySlice(self, extract<list>(value)(), range, setSize, tile);
230  }
231 
232  // Copy from tuple.
233  else if (extract<tuple>(value).check()) {
234  setArraySlice(self, extract<tuple>(value)(), range, setSize, tile);
235  }
236 
237  // Copy from iterable.
238  else {
239  setArraySlice(self, list(value), range, setSize, tile);
240  }
241 }
242 
243 
244 template <typename T>
245 void
246 setitem_ellipsis(VtArray<T> &self, object idx, object value)
247 {
248  object ellipsis = object(handle<>(borrowed(Py_Ellipsis)));
249  if (idx != ellipsis) {
250  PyErr_SetString(PyExc_TypeError, "unsupported index type");
251  throw_error_already_set();
252  }
253  setArraySlice(self, slice(0, self.size()), value);
254 }
255 
256 template <typename T>
257 void
258 setitem_index(VtArray<T> &self, int64_t idx, object value)
259 {
260  idx = TfPyNormalizeIndex(idx, self.size(), /*throwError=*/true);
261  setArraySlice(self, slice(idx, idx+1), value, /*tile=*/true);
262 }
263 
264 template <typename T>
265 void
266 setitem_slice(VtArray<T> &self, slice idx, object value)
267 {
268  setArraySlice(self, idx, value);
269 }
270 
271 
272 template <class T>
273 VT_API string GetVtArrayName();
274 
275 
276 // To avoid overhead we stream out certain builtin types directly
277 // without calling TfPyRepr().
278 template <typename T>
279 static void streamValue(std::ostringstream &stream, T const &value) {
280  stream << TfPyRepr(value);
281 }
282 
283 // This is the same types as in VT_INTEGRAL_BUILTIN_VALUE_TYPES with char
284 // and bool types removed.
285 #define _OPTIMIZED_STREAM_INTEGRAL_TYPES \
286  (short) \
287  (unsigned short) \
288  (int) \
289  (unsigned int) \
290  (long) \
291  (unsigned long) \
292  (long long) \
293  (unsigned long long)
294 
295 #define MAKE_STREAM_FUNC(r, unused, type) \
296 static inline void \
297 streamValue(std::ostringstream &stream, type const &value) { \
298  stream << value; \
299 }
301 #undef MAKE_STREAM_FUNC
302 #undef _OPTIMIZED_STREAM_INTEGRAL_TYPES
303 
304 // Explicitly convert half to float here instead of relying on implicit
305 // conversion to float to work around the fact that libc++ only provides
306 // implementations of std::isfinite for types where std::is_arithmetic
307 // is true.
308 template <typename T>
309 static bool _IsFinite(T const &value) {
310  return std::isfinite(value);
311 }
312 static bool _IsFinite(GfHalf const &value) {
313  return std::isfinite(static_cast<float>(value));
314 }
315 
316 // For float types we need to be make sure to represent infs and nans correctly.
317 #define MAKE_STREAM_FUNC(r, unused, elem) \
318 static inline void \
319 streamValue(std::ostringstream &stream, VT_TYPE(elem) const &value) { \
320  if (_IsFinite(value)) { \
321  stream << value; \
322  } else { \
323  stream << TfPyRepr(value); \
324  } \
325 }
328 #undef MAKE_STREAM_FUNC
329 
330 static unsigned int
331 Vt_ComputeEffectiveRankAndLastDimSize(
332  Vt_ShapeData const *sd, size_t *lastDimSize)
333 {
334  unsigned int rank = sd->GetRank();
335  if (rank == 1)
336  return rank;
337 
339  sd->otherDims, sd->otherDims + rank-1,
340  1, [](size_t x, size_t y) { return x * y; });
341 
342  size_t remainder = divisor ? sd->totalSize % divisor : 0;
343  *lastDimSize = divisor ? sd->totalSize / divisor : 0;
344 
345  if (remainder)
346  rank = 1;
347 
348  return rank;
349 }
350 
351 template <typename T>
352 string __repr__(VtArray<T> const &self)
353 {
354  if (self.empty())
355  return TF_PY_REPR_PREFIX +
356  TfStringPrintf("%s()", GetVtArrayName<VtArray<T> >().c_str());
357 
358  std::ostringstream stream;
359  stream.precision(17);
360  stream << "(";
361  for (size_t i = 0; i < self.size(); ++i) {
362  stream << (i ? ", " : "");
363  streamValue(stream, self[i]);
364  }
365  stream << (self.size() == 1 ? ",)" : ")");
366 
367  const std::string repr = TF_PY_REPR_PREFIX +
368  TfStringPrintf("%s(%zd, %s)",
369  GetVtArrayName<VtArray<T> >().c_str(),
370  self.size(), stream.str().c_str());
371 
372  // XXX: This is to deal with legacy shaped arrays and should be removed
373  // once all shaped arrays have been eliminated.
374  // There is no nice way to make an eval()able __repr__ for shaped arrays
375  // that preserves the shape information, so put it in <> to make it
376  // clearly not eval()able. That has the advantage that, if somebody passes
377  // the repr into eval(), it'll raise a SyntaxError that clearly points to
378  // the beginning of the __repr__.
379  Vt_ShapeData const *shapeData = self._GetShapeData();
380  size_t lastDimSize = 0;
381  unsigned int rank =
382  Vt_ComputeEffectiveRankAndLastDimSize(shapeData, &lastDimSize);
383  if (rank > 1) {
384  std::string shapeStr = "(";
385  for (size_t i = 0; i != rank-1; ++i) {
386  shapeStr += TfStringPrintf(
387  i ? ", %d" : "%d", shapeData->otherDims[i]);
388  }
389  shapeStr += TfStringPrintf(", %zu)", lastDimSize);
390  return TfStringPrintf("<%s with shape %s>",
391  repr.c_str(), shapeStr.c_str());
392  }
393 
394  return repr;
395 }
396 
397 template <typename T>
399 {
400  // Make an array.
401  unique_ptr<VtArray<T> > ret(new VtArray<T>(len(values)));
402 
403  // Set the values. This is equivalent to saying 'ret[...] = values'
404  // in python, except that we allow tiling here.
405  static const bool tile = true;
406  setArraySlice(*ret, slice(0, ret->size()), values, tile);
407  return ret.release();
408 }
409 template <typename T>
410 VtArray<T> *VtArray__init__2(size_t size, object const &values)
411 {
412  // Make the array.
413  unique_ptr<VtArray<T> > ret(new VtArray<T>(size));
414 
415  // Set the values. This is equivalent to saying 'ret[...] = values'
416  // in python, except that we allow tiling here.
417  static const bool tile = true;
418  setArraySlice(*ret, slice(0, ret->size()), values, tile);
419 
420  return ret.release();
421 }
422 
423 // overloading for operator special methods, to allow tuple / list & array
424 // combinations
428 
429 VTOPERATOR_WRAP(__add__,__radd__)
430 VTOPERATOR_WRAP_NONCOMM(__sub__,__rsub__)
431 VTOPERATOR_WRAP(__mul__,__rmul__)
432 VTOPERATOR_WRAP_NONCOMM(__div__,__rdiv__)
433 VTOPERATOR_WRAP_NONCOMM(__mod__,__rmod__)
434 
435 VTOPERATOR_WRAP_BOOL(Equal,==)
436 VTOPERATOR_WRAP_BOOL(NotEqual,!=)
437 VTOPERATOR_WRAP_BOOL(Greater,>)
438 VTOPERATOR_WRAP_BOOL(Less,<)
439 VTOPERATOR_WRAP_BOOL(GreaterOrEqual,>=)
440 VTOPERATOR_WRAP_BOOL(LessOrEqual,<=)
442 }
443 
444 template <typename T>
445 static std::string _VtStr(T const &self)
446 {
447  return hboost::lexical_cast<std::string>(self);
448 }
449 
450 template <typename T>
452 {
453  using namespace Vt_WrapArray;
454 
455  typedef T This;
456  typedef typename This::ElementType Type;
457 
458  string name = GetVtArrayName<This>();
459  string typeStr = ArchGetDemangled(typeid(Type));
460  string docStr = TfStringPrintf("An array of type %s.", typeStr.c_str());
461 
462  auto selfCls = class_<This>(name.c_str(), docStr.c_str(), no_init)
463  .setattr("_isVtArray", true)
464  .def(TfTypePythonClass())
465  .def(init<>())
466  .def("__init__", make_constructor(VtArray__init__<Type>),
467  (const char *)
468  "__init__(values)\n\n"
469  "values: a sequence (tuple, list, or another VtArray with "
470  "element type convertible to the new array's element type)\n\n"
471  )
472  .def("__init__", make_constructor(VtArray__init__2<Type>))
473  .def(init<unsigned int>())
474 
475  .def("__getitem__", getitem_ellipsis<Type>)
476  .def("__getitem__", getitem_slice<Type>)
477  .def("__getitem__", getitem_index<Type>)
478  .def("__setitem__", setitem_ellipsis<Type>)
479  .def("__setitem__", setitem_slice<Type>)
480  .def("__setitem__", setitem_index<Type>)
481 
482  .def("__len__", &This::size)
483  .def("__iter__", iterator<This>())
484 
485  .def("__repr__", __repr__<Type>)
486 
487 // .def(str(self))
488  .def("__str__", _VtStr<T>)
489  .def(self == self)
490  .def(self != self)
491 
492 #ifdef NUMERIC_OPERATORS
493 #define ADDITION_OPERATOR
494 #define SUBTRACTION_OPERATOR
495 #define MULTIPLICATION_OPERATOR
496 #define DIVISION_OPERATOR
497 #define UNARY_NEG_OPERATOR
498 #endif
499 
500 #ifdef ADDITION_OPERATOR
501  VTOPERATOR_WRAPDECLARE(+,__add__,__radd__)
502 #endif
503 #ifdef SUBTRACTION_OPERATOR
504  VTOPERATOR_WRAPDECLARE(-,__sub__,__rsub__)
505 #endif
506 #ifdef MULTIPLICATION_OPERATOR
507  VTOPERATOR_WRAPDECLARE(*,__mul__,__rmul__)
508 #endif
509 #ifdef DIVISION_OPERATOR
510  VTOPERATOR_WRAPDECLARE(/,__div__,__rdiv__)
511 #endif
512 #ifdef MOD_OPERATOR
513  VTOPERATOR_WRAPDECLARE(%,__mod__,__rmod__)
514 #endif
515 #ifdef DOUBLE_MULT_OPERATOR
516  .def(self * double())
517  .def(double() * self)
518 #endif
519 #ifdef DOUBLE_DIV_OPERATOR
520  .def(self / double())
521 #endif
522 #ifdef UNARY_NEG_OPERATOR
523  .def(- self)
524 #endif
525 
526  ;
527 
528 #define WRITE(z, n, data) HBOOST_PP_COMMA_IF(n) data
529 #define VtCat_DEF(z, n, unused) \
530  def("Cat",(VtArray<Type> (*)( HBOOST_PP_REPEAT(n, WRITE, VtArray<Type> const &) ))VtCat<Type>);
531  HBOOST_PP_REPEAT_FROM_TO(1, VT_FUNCTIONS_MAX_ARGS, VtCat_DEF, ~)
532 #undef VtCat_DEF
533 
536 
537  // Wrap conversions from python sequences.
539  This,
542 
543  // Wrap implicit conversions from VtArray to TfSpan.
544  implicitly_convertible<This, TfSpan<Type> >();
545  implicitly_convertible<This, TfSpan<const Type> >();
546 }
547 
548 // wrapping for functions that work for base types that support comparisons
549 template <typename T>
551 {
552  using namespace Vt_WrapArray;
553 
554  typedef T This;
555  typedef typename This::ElementType Type;
556 
557  def("AnyTrue", VtAnyTrue<Type>);
558  def("AllTrue", VtAllTrue<Type>);
559 
562  VTOPERATOR_WRAPDECLARE_BOOL(GreaterOrEqual)
563  VTOPERATOR_WRAPDECLARE_BOOL(LessOrEqual)
564 }
565 
566 template <class Array>
567 VtValue
569 {
570  typedef typename Array::ElementType ElemType;
571  TfPyLock lock;
572  if (PySequence_Check(obj.ptr())) {
573  Py_ssize_t len = PySequence_Length(obj.ptr());
574  Array result(len);
575  ElemType *elem = result.data();
576  for (Py_ssize_t i = 0; i != len; ++i) {
577  hboost::python::handle<> h(PySequence_ITEM(obj.ptr(), i));
578  if (!h) {
579  if (PyErr_Occurred())
580  PyErr_Clear();
581  return VtValue();
582  }
583  hboost::python::extract<ElemType> e(h.get());
584  if (!e.check())
585  return VtValue();
586  *elem++ = e();
587  }
588  return VtValue(result);
589  } else if (PyIter_Check(obj.ptr())) {
590  Array result;
591  while (PyObject *item = PyIter_Next(obj.ptr())) {
592  hboost::python::handle<> h(item);
593  if (!h) {
594  if (PyErr_Occurred())
595  PyErr_Clear();
596  return VtValue();
597  }
598  hboost::python::extract<ElemType> e(h.get());
599  if (!e.check())
600  return VtValue();
601  result.push_back(e());
602  }
603  return VtValue(result);
604  }
605  return VtValue();
606 }
607 
608 template <class Array, class Iter>
609 VtValue
611 {
612  typedef typename Array::ElementType ElemType;
613  Array result(distance(begin, end));
614  for (ElemType *e = result.data(); begin != end; ++begin) {
615  VtValue cast = VtValue::Cast<ElemType>(*begin);
616  if (cast.IsEmpty())
617  return cast;
618  cast.Swap(*e++);
619  }
620  return VtValue(result);
621 }
622 
623 template <class T>
624 VtValue
626  VtValue ret;
627  TfPyObjWrapper obj;
628  // Attempt to convert from either python sequence or vector<VtValue>.
629  if (v.IsHolding<TfPyObjWrapper>()) {
630  ret = Vt_ConvertFromPySequenceOrIter<T>(v.UncheckedGet<TfPyObjWrapper>());
631  } else if (v.IsHolding<std::vector<VtValue> >()) {
632  std::vector<VtValue> const &vec = v.UncheckedGet<std::vector<VtValue> >();
633  ret = Vt_ConvertFromRange<T>(vec.begin(), vec.end());
634  }
635  return ret;
636 }
637 
638 /// Register casts with VtValue from python sequences to VtArray types.
639 template <class Elem>
641 {
642  typedef VtArray<Elem> Array;
643  VtValue::RegisterCast<TfPyObjWrapper, Array>(Vt_CastToArray<Array>);
644  VtValue::RegisterCast<std::vector<VtValue>, Array>(Vt_CastToArray<Array>);
645 }
646 
647 #define VT_WRAP_ARRAY(r, unused, elem) \
648  VtWrapArray< VtArray< VT_TYPE(elem) > >();
649 #define VT_WRAP_COMPARISON(r, unused, elem) \
650  VtWrapComparisonFunctions< VtArray< VT_TYPE(elem) > >();
651 
653 
654 #endif // PXR_BASE_VT_WRAP_ARRAY_H
GLuint GLuint stream
Definition: glcorearb.h:1832
TF_API std::string TfStringPrintf(const char *fmt,...)
Definition: ImfArray.h:47
#define VTOPERATOR_WRAPDECLARE(op, lmethod, rmethod)
Definition: pyOperators.h:117
#define VTOPERATOR_WRAPDECLARE_BOOL(func)
Definition: pyOperators.h:157
GLenum GLint * range
Definition: glcorearb.h:1925
T const & UncheckedGet() const &
Definition: value.h:1094
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
const GLdouble * v
Definition: glcorearb.h:837
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
GLsizei const GLfloat * value
Definition: glcorearb.h:824
#define VTOPERATOR_WRAP_BOOL(func, op)
Definition: pyOperators.h:152
#define ARCH_PRAGMA_POP
Definition: pragmas.h:170
ARCH_API std::string ArchGetDemangled(const std::string &typeName)
#define VT_API
Definition: api.h:40
GLuint GLsizei GLsizei * length
Definition: glcorearb.h:795
#define VT_FUNCTIONS_MAX_ARGS
Definition: functions.h:41
unsigned int GetRank() const
Definition: types.h:283
string __repr__(VtArray< T > const &self)
Definition: wrapArray.h:352
#define ARCH_PRAGMA_UNSAFE_USE_OF_BOOL
Definition: pragmas.h:246
VtValue & Swap(VtValue &rhs) noexcept
Swap this with rhs.
Definition: value.h:975
GLint y
Definition: glcorearb.h:103
TF_API void TfPyThrowValueError(const char *msg)
**But if you need a result
Definition: thread.h:613
bool IsEmpty() const
Returns true iff this value is empty.
Definition: value.h:1272
object getitem_index(VtArray< T > const &self, int64_t idx)
Definition: wrapArray.h:101
VtValue Vt_ConvertFromRange(Iter begin, Iter end)
Definition: wrapArray.h:610
#define MAKE_STREAM_FUNC(r, unused, type)
Definition: wrapArray.h:317
size_t totalSize
Definition: types.h:305
VtValue Vt_CastToArray(VtValue const &v)
Definition: wrapArray.h:625
size_t remainder
Definition: wrapArray.h:342
std::string TfPyRepr(T const &t)
Definition: pyUtils.h:180
OIIO_FORCEINLINE bool extract(const vbool4 &a)
Definition: simd.h:3426
bool lexical_cast(const std::string &input, T &output)
Integer conversion.
Definition: CLI11.h:1835
void setitem_slice(VtArray< T > &self, slice idx, object value)
Definition: wrapArray.h:266
object getitem_slice(VtArray< T > const &self, slice idx)
Definition: wrapArray.h:110
#define ARCH_PRAGMA_PUSH
Definition: pragmas.h:166
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER class IMF_EXPORT_TEMPLATE_TYPE Array
Definition: ImfForward.h:22
#define _OPTIMIZED_STREAM_INTEGRAL_TYPES
Definition: wrapArray.h:285
GLuint GLuint end
Definition: glcorearb.h:475
VtArray< T > * VtArray__init__(object const &values)
Definition: wrapArray.h:398
void setArraySlice(VtArray< T > &self, S value, slice::range< T * > &range, size_t setSize, bool tile=false)
Definition: wrapArray.h:131
void setitem_ellipsis(VtArray< T > &self, object idx, object value)
Definition: wrapArray.h:246
GLuint const GLchar * name
Definition: glcorearb.h:786
Definition: types.h:173
VT_API string GetVtArrayName()
GLint GLenum GLint x
Definition: glcorearb.h:409
#define ARCH_PRAGMA_UNARY_MINUS_ON_UNSIGNED
Definition: pragmas.h:250
void VtRegisterValueCastsFromPythonSequencesToArray()
Register casts with VtValue from python sequences to VtArray types.
Definition: wrapArray.h:640
#define VT_FLOATING_POINT_BUILTIN_VALUE_TYPES
Definition: types.h:55
VtArray< T > * VtArray__init__2(size_t size, object const &values)
Definition: wrapArray.h:410
GLsizeiptr size
Definition: glcorearb.h:664
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
unsigned int otherDims[NumOtherDims]
Definition: types.h:306
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1602
VtValue Vt_ConvertFromPySequenceOrIter(TfPyObjWrapper const &obj)
Definition: wrapArray.h:568
void VtWrapComparisonFunctions()
Definition: wrapArray.h:550
object getitem_ellipsis(VtArray< T > const &self, object idx)
Definition: wrapArray.h:89
void setitem_index(VtArray< T > &self, int64_t idx, object value)
Definition: wrapArray.h:258
size_t *lastDimSize unsigned int rank
Definition: wrapArray.h:334
bool IsHolding() const
Definition: value.h:1054
GLuint GLfloat * val
Definition: glcorearb.h:1608
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
if(rank==1) return rank
Definition: core.h:1131
TF_API int64_t TfPyNormalizeIndex(int64_t index, uint64_t size, bool throwError=false)
bool accumulate(const PointDataTreeT &points, const std::string &attribute, typename PromoteType< ValueT >::Highest &total, const FilterT &filter, typename PointDataTreeT::template ValueConverter< ResultTreeT >::Type *totalTree)
Evaluates the total value of a point attribute and returns whether the value is valid. Optionally constructs localised total value trees.
#define TF_PY_REPR_PREFIX
Definition: pyUtils.h:59
#define const
Definition: zconf.h:214
SIM_API const UT_StringHolder distance
#define VtCat_DEF(z, n, unused)
GLuint divisor
Definition: glcorearb.h:1670
#define VTOPERATOR_WRAP(lmethod, rmethod)
Definition: pyOperators.h:96
Definition: value.h:167
Definition: format.h:895
void VtWrapArray()
Definition: wrapArray.h:451
#define VTOPERATOR_WRAP_NONCOMM(lmethod, rmethod)
Definition: pyOperators.h:103
HBOOST_PP_SEQ_FOR_EACH(MAKE_STREAM_FUNC,~, VT_FLOATING_POINT_BUILTIN_VALUE_TYPES) static unsigned int Vt_ComputeEffectiveRankAndLastDimSize(Vt_ShapeData const *sd
PcpNodeRef_ChildrenIterator begin(const PcpNodeRef::child_const_range &r)
Support for range-based for loops for PcpNodeRef children ranges.
Definition: node.h:483