HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_Handle.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_Handle.h ( GA Library, C++)
7  *
8  * COMMENTS: A lightweight probe to deal with specific attributes of
9  * a specific type.
10  */
11 
12 #pragma once
13 
14 #ifndef __GA_Handle__
15 #define __GA_Handle__
16 
17 #include "GA_API.h"
18 
19 #include "GA_ATINumeric.h"
20 #include "GA_PageArray.h"
21 
22 #include "GA_AIFNumericArray.h"
25 #include "GA_AIFSharedDictTuple.h"
26 #include "GA_ATIString.h"
27 #include "GA_ATIDict.h"
28 #include "GA_OffsetList.h"
29 #include "GA_Types.h"
30 
31 #if UT_ASSERT_LEVEL >= UT_ASSERT_LEVEL_PARANOID
32 #include "GA_IndexMap.h"
33 #endif
34 
35 #include <UT/UT_Assert.h>
36 #include <UT/UT_FixedVector.h>
37 #include <UT/UT_Matrix2.h>
38 #include <UT/UT_Matrix3.h>
39 #include <UT/UT_Matrix4.h>
40 #include <UT/UT_Quaternion.h>
41 #include <UT/UT_Storage.h>
42 #include <UT/UT_StringHolder.h>
43 #include <UT/UT_Vector2.h>
44 #include <UT/UT_Vector3.h>
45 #include <UT/UT_Vector4.h>
46 #include <UT/UT_VectorTypes.h>
47 
48 #include <SYS/SYS_Inline.h>
49 #include <SYS/SYS_Types.h>
50 #include <SYS/SYS_TypeTraits.h>
51 
52 
53 class GA_Attribute;
54 class GA_Detail;
55 class GA_Range;
56 class UT_StringArray;
57 
58 
59 namespace {
60 
61 class ga_OffsetToIndexTrivial
62 {
63 public:
64  ga_OffsetToIndexTrivial(GA_Offset start)
65  : myStartOffset(start)
66  {
67  }
68 
70  {
71  return GA_Index((GA_Size)(offset - myStartOffset));
72  }
73 
74 protected:
75  const GA_Offset myStartOffset;
76 
77 };
78 
79 class ga_OffsetToIndex
80 {
81 public:
82  ga_OffsetToIndex(GA_Offset startoff, const GA_ListType<GA_Offset, GA_Index> &offtoindex)
83  : myStartIndex(offtoindex(startoff))
84  , myOffsetToIndex(offtoindex)
85  {
86  }
87 
88  GA_Index operator()(GA_Offset offset) const
89  {
90  return myOffsetToIndex(offset) - myStartIndex;
91  }
92 
93 protected:
94  const GA_Index myStartIndex;
95  const GA_ListType<GA_Offset, GA_Index> &myOffsetToIndex;
96 };
97 
98 }
99 
100 /// Read-only handle for vector attribute data.
101 ///
102 /// @tparam T Return vector type for get methods. Requires T::value_type to
103 /// describe the underlying element type of the vector.
104 ///
105 /// @tparam ENABLE Use SYS_EnableIf to specialize arithmetic template
106 /// implementations (i.e. see the SCALAR implementation)
107 ///
108 template <typename T, typename ENABLE = void>
110 {
111 public:
113  typedef typename T::value_type BASETYPE;
117 
119  {
120  clear();
121  }
122  GA_ROHandleT(const GA_Attribute *attrib)
123  {
124  bind(attrib);
125  }
126  GA_ROHandleT(const GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1);
127 
128  void operator=(const GA_Attribute *attrib)
129  {
130  bind(attrib);
131  }
132 
133  void bind(const GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1);
134 
136  void bind(const GA_Attribute *attrib, int minsize=1)
137  {
138  bind(GA_ATINumeric::cast(attrib), minsize);
139  }
140 
141  void bind(const GA_ATINumeric *attrib, int minsize=1)
142  {
143  myExactMatch = nullptr;
144  myAlmostMatch = nullptr;
145  myAttrib = SYSconst_cast(attrib);
146  if (!myAttrib)
147  return;
148 
149  int actual_tuple_size = myAttrib->getTupleSize();
150  if (actual_tuple_size < minsize * theTupleSize)
151  {
152  myAttrib = nullptr;
153  return;
154  }
155 
156  if (actual_tuple_size == theTupleSize)
157  {
158  UT_Storage actual_storage = myAttrib->getData().Base::getStorage();
159  if (actual_storage == UT_StorageNum<BASETYPE>::theStorage)
160  myExactMatch = &myAttrib->getData().castType<BASETYPE>().template castTupleSize<theTupleSize>();
161  else if (actual_storage == UT_StorageNum<typename UT_StorageNum<BASETYPE>::SecondGuess>::theStorage)
162  myAlmostMatch = &myAttrib->getData().castType<typename UT_StorageNum<BASETYPE>::SecondGuess>().template castTupleSize<theTupleSize>();
163  }
164  }
165 
166  const GA_ATINumeric *getAttribute() const { return myAttrib; }
167 
169  {
170  if (myAttrib)
171  return myAttrib->getDataId();
172  return GA_INVALID_DATAID;
173  }
174 
175 
176  // Check whether the attribute is GA_TYPE_HPOINT
177  bool isRational() const
178  { return myAttrib->getTypeInfo() == GA_TYPE_HPOINT; }
179 
180  void clear()
181  {
182  myAttrib = nullptr;
183  myExactMatch = nullptr;
184  myAlmostMatch = nullptr;
185  }
186 
188  {
189  return myAttrib;
190  }
192  {
193  return !myAttrib;
194  }
195 
196  /// True if we've bound the Almost match, which we consider our alternate
197  /// binding.
199  {
200  return myAlmostMatch != nullptr;
201  }
202 
203  SYS_FORCE_INLINE T get(GA_Offset off, int comp=0) const
204  {
205  UT_ASSERT_P(comp == 0 &&
206  "Component offset not currently supported for vector/matrix types");
208  UT_ASSERT_P(GAisValid(off));
210 
211  if (myExactMatch)
212  return UT_FromFixed<T>{}(myExactMatch->template getVector<BASETYPE,theTupleSize>(off));
213  return getNonInlinePart(off);
214  }
215 
216  SYS_FORCE_INLINE ALTTYPE getAlt(GA_Offset off, int comp=0) const
217  {
218  UT_ASSERT_P(comp == 0 &&
219  "Component offset not currently supported for vector/matrix types");
221  UT_ASSERT_P(GAisValid(off));
223 
224  if (myAlmostMatch)
225  return ALTTYPE(myAlmostMatch->template getVector<ALTBASETYPE,theTupleSize>(off));
226  return ALTTYPE(getAltNonInlinePart(off));
227  }
228 private:
229  T getNonInlinePart(GA_Offset off) const
230  {
231  if (myAlmostMatch)
232  return UT_FromFixed<T>{}(myAlmostMatch->template getVector<BASETYPE,theTupleSize>(off));
234  }
235  ALTTYPE getAltNonInlinePart(GA_Offset off) const
236  {
237  if (myExactMatch)
238  return ALTTYPE(myExactMatch->template getVector<ALTBASETYPE,theTupleSize>(off));
240  }
241 public:
242 
243  /// Copies attribute values from a contiguous block of offsets
244  /// into the dest array.
245  /// NOTE: The block of offsets is assumed to have no holes, else
246  /// data could be read from offsets that don't have
247  /// corresponding elements.
248  void getBlock(GA_Offset startoff, GA_Size nelements, T *dest, int deststride = 1, int component = 0) const;
249 
250  /// Copies attribute values from a contiguous block of indices
251  /// into the dest array.
252  /// This allows there to be holes in the geometry.
253  void getBlockFromIndices(GA_Index startidx, GA_Size nelements, T *dest, int deststride = 1, int component = 0) const;
254 
256  {
257  return get(off);
258  }
260  {
261  return get(off);
262  }
263  /// Returns true iff the specified page is constant-compressed,
264  /// where a single value is stored to represent GA_PAGE_SIZE
265  /// values in the page, (or possibly fewer if only one page).
267  {
268  return myAttrib->isPageConstant(pagenum);
269  }
270  bool operator==(const GA_ROHandleT<T> &handle) const
271  {
272  return myAttrib == handle.myAttrib;
273  }
274  bool operator!=(const GA_ROHandleT<T> &handle) const
275  {
276  return myAttrib != handle.myAttrib;
277  }
278  const GA_ATINumeric *operator->() const
279  {
280  return myAttrib;
281  }
282 protected:
286 };
287 
288 /// Read-write handle for vector attribute data.
289 ///
290 /// @tparam T Return vector type for get methods. Requires T::value_type to
291 /// describe the underlying element type of the vector.
292 ///
293 template <typename T, typename ENABLE = void>
294 class GA_RWHandleT : public GA_ROHandleT<T, ENABLE>
295 {
296 public:
297  typedef void (*GAprobeAttribSetter)(GA_Attribute *atr, GA_Offset, const T &);
299  typedef typename T::value_type BASETYPE;
300 private:
301  using Base::myAttrib;
302  using Base::myExactMatch;
303  using Base::myAlmostMatch;
304  using Base::theTupleSize;
305 public:
308 
310  {
311  clear();
312  }
314  {
315  bind(attrib);
316  }
317  GA_RWHandleT(GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1);
318 
319  void operator=(GA_Attribute *attrib)
320  {
321  bind(attrib);
322  }
323 
324  void bind(GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1);
325 
327  void bind(GA_Attribute *attrib, int minsize=1)
328  {
329  bind(GA_ATINumeric::cast(attrib), minsize);
330  }
332  void bind(GA_ATINumeric *attrib, int minsize=1)
333  {
334  Base::bind(attrib, minsize);
335  }
336 
337  using Base::clear;
338 
339  GA_ATINumeric *getAttribute() const { return myAttrib; }
340 
341  void bumpDataId() const
342  {
343  if (myAttrib)
344  myAttrib->bumpDataId();
345  }
346 
348  {
349  if (myAttrib)
350  return myAttrib->getDataId();
351  return GA_INVALID_DATAID;
352  }
353 
354  SYS_FORCE_INLINE void set(GA_Offset off, const T &val) const
355  {
357  UT_ASSERT_P(GAisValid(off));
359  if (myExactMatch)
360  myExactMatch->setVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<T>::FixedVectorType &>(val));
361  else if (myAlmostMatch)
362  myAlmostMatch->setVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<T>::FixedVectorType &>(val));
363  else
364  myAttrib->getData().setVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<T>::FixedVectorType &>(val));
365  }
366 
367  SYS_FORCE_INLINE void setAlt(GA_Offset off, const ALTTYPE &val) const
368  {
370  UT_ASSERT_P(GAisValid(off));
372  if (myAlmostMatch)
373  myAlmostMatch->setVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<ALTTYPE>::FixedVectorType &>(val));
374  else if (myExactMatch)
375  myExactMatch->setVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<ALTTYPE>::FixedVectorType &>(val));
376  else
377  myAttrib->getData().setVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<ALTTYPE>::FixedVectorType &>(val));
378  }
379 
380  SYS_FORCE_INLINE void set(GA_Offset off, int comp, const T &val) const
381  {
382  UT_ASSERT(comp == 0 && "Component sets on vector types unsupported");
384  UT_ASSERT_P(GAisValid(off));
386  if (myExactMatch)
387  myExactMatch->setVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<T>::FixedVectorType &>(val));
388  else if (myAlmostMatch)
389  myAlmostMatch->setVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<T>::FixedVectorType &>(val));
390  else
391  myAttrib->getData().setVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<T>::FixedVectorType &>(val));
392  }
393 
394  SYS_FORCE_INLINE void setAlt(GA_Offset off, int comp, const ALTTYPE &val) const
395  {
396  UT_ASSERT(comp == 0 && "Component sets on vector types unsupported");
398  UT_ASSERT_P(GAisValid(off));
400  if (myAlmostMatch)
401  myAlmostMatch->setVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<ALTTYPE>::FixedVectorType &>(val));
402  else if (myExactMatch)
403  myExactMatch->setVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<ALTTYPE>::FixedVectorType &>(val));
404  else
405  myAttrib->getData().setVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<ALTTYPE>::FixedVectorType &>(val));
406  }
407 
408  SYS_FORCE_INLINE void add(GA_Offset off, const T &val) const
409  {
411  UT_ASSERT_P(GAisValid(off));
413  if (myExactMatch)
414  myExactMatch->addVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<T>::FixedVectorType &>(val));
415  else if (myAlmostMatch)
416  myAlmostMatch->addVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<T>::FixedVectorType &>(val));
417  else
418  myAttrib->getData().addVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<T>::FixedVectorType &>(val));
419  }
420 
421  SYS_FORCE_INLINE void addAlt(GA_Offset off, const ALTTYPE &val) const
422  {
424  UT_ASSERT_P(GAisValid(off));
426  if (myAlmostMatch)
427  myAlmostMatch->addVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<ALTTYPE>::FixedVectorType &>(val));
428  else if (myExactMatch)
429  myExactMatch->addVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<ALTTYPE>::FixedVectorType &>(val));
430  else
431  myAttrib->getData().addVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<ALTTYPE>::FixedVectorType &>(val));
432  }
433 
434  SYS_FORCE_INLINE void add(GA_Offset off, int comp, const T &val) const
435  {
436  UT_ASSERT(comp == 0 && "Component sets on vector types unsupported");
438  UT_ASSERT_P(GAisValid(off));
440  if (myExactMatch)
441  myExactMatch->addVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<T>::FixedVectorType &>(val));
442  else if (myAlmostMatch)
443  myAlmostMatch->addVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<T>::FixedVectorType &>(val));
444  else
445  myAttrib->getData().addVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<T>::FixedVectorType &>(val));
446  }
447 
448  SYS_FORCE_INLINE void addAlt(GA_Offset off, int comp, const ALTTYPE &val) const
449  {
450  UT_ASSERT(comp == 0 && "Component sets on vector types unsupported");
452  UT_ASSERT_P(GAisValid(off));
454  if (myAlmostMatch)
455  myAlmostMatch->addVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<ALTTYPE>::FixedVectorType &>(val));
456  else if (myExactMatch)
457  myExactMatch->addVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<ALTTYPE>::FixedVectorType &>(val));
458  else
459  myAttrib->getData().addVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<ALTTYPE>::FixedVectorType &>(val));
460  }
461 
462  /// Copies attribute values from the source array into a contiguous
463  /// block of offsets.
464  /// NOTE: The block of offsets is assumed to have no holes, else
465  /// data could be written to offsets that don't have
466  /// corresponding elements.
467  void setBlock(GA_Offset startoff, GA_Size nelements, const T *source, int sourcestride = 1, int component = 0) const;
468 
469  void setBlockFromIndices(GA_Index startidx, GA_Size nelements, const T *source, int sourcestride = 1, int component = 0) const;
470 
471  void makeConstant(const T &cval) const
472  {
474  myAttrib->getAIFTuple()->makeConstant(myAttrib, &cval.data()[0], sizeof(T)/sizeof(BASETYPE), 0);
475  }
476 
477  /// Sets all components of all elements of the specified page to
478  /// the given values.
479  /// NOTE: The length of values must be equal to the tuple size.
480  void setPageConstant(GA_PageNum pagenum, const BASETYPE *values) const
481  {
482  if (myExactMatch)
483  myExactMatch->setPageConstant(pagenum, values);
484  else if (myAlmostMatch)
485  myAlmostMatch->setPageConstant(pagenum, values);
486  else
487  myAttrib->getData().setPageConstant(pagenum, values);
488  }
489 
491  {
492  return myAttrib;
493  }
494 
495 };
496 
497 /// Simplify checking for scalar types
498 #define SCALAR(T) SYS_EnableIf< SYS_IsArithmetic<T>::value >::type
499 
500 /// Read-only handle for scalar attribute data.
501 ///
502 /// @tparam T Return type for get methods
503 ///
504 template <typename T>
505 class GA_ROHandleT<T, typename SCALAR(T) >
506 {
507 public:
508  typedef T (*GAprobeAttribGetter)(const GA_Attribute *atr, GA_Offset, int);
509  typedef T BASETYPE;
510 
512  {
513  clear();
514  }
515  GA_ROHandleT(const GA_Attribute *attrib)
516  {
517  bind(attrib);
518  }
519  GA_ROHandleT(const GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1);
520 
521  void operator=(const GA_Attribute *attrib)
522  {
523  bind(attrib);
524  }
525 
526  void bind(const GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1);
527 
529  void bind(const GA_Attribute *attrib, int minsize=1)
530  {
531  bind(GA_ATINumeric::cast(attrib), minsize);
532  }
533  void bind(const GA_ATINumeric *attrib, int minsize=1)
534  {
535  myExactMatch = nullptr;
536  myAlmostMatch = nullptr;
537  myAttrib = SYSconst_cast(attrib);
538  if (!myAttrib)
539  return;
540 
541  int actual_tuple_size = myAttrib->getTupleSize();
542  if (actual_tuple_size < minsize)
543  {
544  myAttrib = nullptr;
545  return;
546  }
547 
548  UT_Storage actual_storage = attrib->getData().Base::getStorage();
549  if (actual_storage == UT_StorageNum<BASETYPE>::theStorage)
550  {
551  if (actual_tuple_size == 1)
552  myExactMatch = &myAttrib->getData().castType<BASETYPE>().template castTupleSize<1>();
553  else
555  }
556  }
557 
558  const GA_ATINumeric *getAttribute() const { return myAttrib; }
559  int getTupleSize() const { return myAttrib->getTupleSize(); }
560 
562  {
563  if (myAttrib)
564  return myAttrib->getDataId();
565  return GA_INVALID_DATAID;
566  }
567 
568  // Check whether the attribute is GA_TYPE_HPOINT
569  bool isRational() const
570  { return myAttrib->getTypeInfo() == GA_TYPE_HPOINT; }
571 
572  void clear()
573  {
574  myAttrib = nullptr;
575  myExactMatch = nullptr;
576  myAlmostMatch = nullptr;
577  }
578 
580  {
581  return myAttrib;
582  }
584  {
585  return !myAttrib;
586  }
587 
588  SYS_FORCE_INLINE T get(GA_Offset off, int comp = 0) const
589  {
591  UT_ASSERT_P(GAisValid(off));
593  UT_ASSERT_P(comp >= 0 && comp < myAttrib->getTupleSize());
594  if (myExactMatch)
595  {
596  UT_ASSERT_P(comp == 0);
597  return myExactMatch->template get<T>(off);
598  }
599  return getNotInline(off, comp);
600  }
601 private:
602  T getNotInline(GA_Offset off, int comp) const
603  {
604  if (myAlmostMatch)
605  return myAlmostMatch->template get<T>(off, comp);
606  return myAttrib->getData().get<T>(off, comp);
607  }
608 public:
609  SYS_FORCE_INLINE void getV(GA_Offset off, T *data, int size) const
610  {
612  UT_ASSERT_P(size >= 0 && size <= myAttrib->getTupleSize());
613  if (myExactMatch)
614  {
615  UT_ASSERT_P(size<=1);
616  if (size==1)
617  data[0] = myExactMatch->template get<T>(off);
618  }
619  else if (myAlmostMatch)
620  {
621  for (int comp = 0; comp < size; ++comp)
622  data[comp] = myAlmostMatch->template get<T>(off, comp);
623  }
624  else
625  {
626  auto &src = myAttrib->getData();
627  for (int comp = 0; comp < size; ++comp)
628  data[comp] = src.get<T>(off, comp);
629  }
630  }
631 
632  /// Copies attribute values from a contiguous block of offsets
633  /// into the dest array.
634  /// NOTE: The block of offsets is assumed to have no holes, else
635  /// data could be read from offsets that don't have
636  /// corresponding elements.
637  void getBlock(GA_Offset startoff, GA_Size nelements, T *dest, int deststride = 1, int component = 0) const;
638 
639  /// Copies attribute values from a contiguous block of indices
640  /// into the dest array.
641  /// This allows there to be holes in the geometry.
642  void getBlockFromIndices(GA_Index startidx, GA_Size nelements, T *dest, int deststride = 1, int component = 0) const;
643 
644  SYS_FORCE_INLINE T operator()(GA_Offset off, int comp = 0) const
645  {
646  return get(off, comp);
647  }
649  {
650  return get(off);
651  }
652  /// Returns true iff the specified page is constant-compressed,
653  /// where a single value is stored to represent GA_PAGE_SIZE
654  /// values in the page, (or possibly fewer if only one page).
656  {
657  return myAttrib->isPageConstant(pagenum);
658  }
659  bool operator==(const GA_ROHandleT<T> &handle) const
660  {
661  return myAttrib == handle.myAttrib;
662  }
663  bool operator!=(const GA_ROHandleT<T> &handle) const
664  {
665  return myAttrib != handle.myAttrib;
666  }
667  const GA_ATINumeric *operator->() const
668  {
669  return myAttrib;
670  }
671 
672 protected:
676 };
677 
678 /// Read-write handle for scalar attribute data.
679 ///
680 /// @tparam T Return type for get methods
681 ///
682 template <typename T>
683 class GA_RWHandleT<T, typename SCALAR(T) > : public GA_ROHandleT<T, typename SCALAR(T) >
684 {
685 public:
688  typedef T BASETYPE;
689 private:
690  using Base::myAttrib;
691  using Base::myExactMatch;
692  using Base::myAlmostMatch;
693 public:
694 
696  {
697  clear();
698  }
700  {
701  bind(attrib);
702  }
703  GA_RWHandleT(GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1);
704 
705  void operator=(GA_Attribute *attrib)
706  {
707  bind(attrib);
708  }
709 
710  void bind(GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1);
711 
713  void bind(GA_Attribute *attrib, int minsize=1)
714  {
715  bind(GA_ATINumeric::cast(attrib), minsize);
716  }
717  void bind(GA_ATINumeric *attrib, int minsize=1)
718  {
719  Base::bind(attrib, minsize);
720  }
721 
722  using Base::clear;
723 
724  GA_ATINumeric *getAttribute() const { return myAttrib; }
725 
726  void bumpDataId() const
727  {
728  if (myAttrib)
729  myAttrib->bumpDataId();
730  }
731 
733  {
734  if (myAttrib)
735  return myAttrib->getDataId();
736  return GA_INVALID_DATAID;
737  }
738 
739  SYS_FORCE_INLINE void set(GA_Offset off, T val) const
740  {
742  UT_ASSERT_P(GAisValid(off));
744  if (myExactMatch)
745  myExactMatch->set(off, val);
746  else if (myAlmostMatch)
747  myAlmostMatch->set(off, val);
748  else
749  myAttrib->getData().set(off, val);
750  }
751 
752  SYS_FORCE_INLINE void add(GA_Offset off, T val) const
753  {
755  UT_ASSERT_P(GAisValid(off));
757  if (myExactMatch)
758  myExactMatch->add(off, val);
759  else if (myAlmostMatch)
760  myAlmostMatch->add(off, val);
761  else
762  myAttrib->getData().add(off, val);
763  }
764 
765  SYS_FORCE_INLINE void set(GA_Offset off, int comp, T val) const
766  {
767  UT_ASSERT_P(myAttrib != nullptr);
768  UT_ASSERT_P(comp >= 0 && comp < myAttrib->getTupleSize());
769  UT_ASSERT_P(GAisValid(off));
771  if (myExactMatch)
772  myExactMatch->set(off, comp, val);
773  else if (myAlmostMatch)
774  myAlmostMatch->set(off, comp, val);
775  else
776  myAttrib->getData().set(off, comp, val);
777  }
778  SYS_FORCE_INLINE void setV(GA_Offset off, const T *data, int size) const
779  {
781  UT_ASSERT_P(size >= 0 && size <= myAttrib->getTupleSize());
782  if (myExactMatch)
783  {
784  UT_ASSERT_P(size<=1);
785  if (size==1)
786  myExactMatch->set(off, data[0]);
787  }
788  else if (myAlmostMatch)
789  {
790  for (int comp = 0; comp < size; ++comp)
791  myAlmostMatch->set(off, comp, data[comp]);
792  }
793  else
794  {
795  auto &src = myAttrib->getData();
796  for (int comp = 0; comp < size; ++comp)
797  src.set(off, comp, data[comp]);
798  }
799  }
800 
801  SYS_FORCE_INLINE void add(GA_Offset off, int comp, T val) const
802  {
803  UT_ASSERT_P(myAttrib != nullptr);
804  UT_ASSERT_P(comp >= 0 && comp < myAttrib->getTupleSize());
805  UT_ASSERT_P(GAisValid(off));
807  if (myExactMatch)
808  myExactMatch->add(off, comp, val);
809  else if (myAlmostMatch)
810  myAlmostMatch->add(off, comp, val);
811  else
812  myAttrib->getData().add(off, comp, val);
813  }
814 
815  /// Copies attribute values from the source array into a contiguous
816  /// block of offsets.
817  /// NOTE: The block of offsets is assumed to have no holes, else
818  /// data could be written to offsets that don't have
819  /// corresponding elements.
820  void setBlock(GA_Offset startoff, GA_Size nelements, const T *source, int sourcestride=1, int component=0) const;
821 
822  void setBlockFromIndices(GA_Index startidx, GA_Size nelements, const T *source, int sourcestride = 1, int component = 0) const;
823 
824  // -1 comp means to set all components to cval.
825  void makeConstant(T cval, int comp = -1) const
826  {
828  myAttrib->getAIFTuple()->makeConstant(myAttrib, cval, comp);
829  }
830  void makeConstantV(const T *cval, int size) const
831  {
833  myAttrib->getAIFTuple()->makeConstant(myAttrib, cval, size, 0);
834  }
835  /// Sets all components of all elements of the specified page to
836  /// the given values.
837  /// NOTE: The length of values must be equal to the tuple size.
838  void setPageConstant(GA_PageNum pagenum, const T *values) const
839  {
840  if (myExactMatch)
841  myExactMatch->setPageConstant(pagenum, values);
842  else if (myAlmostMatch)
843  myAlmostMatch->setPageConstant(pagenum, values);
844  else
845  myAttrib->getData().setPageConstant(pagenum, values);
846  }
847 
849  {
850  return myAttrib;
851  }
852 
853 };
854 
855 #undef SCALAR
856 
857 /// Read-only handle for string attribute data.
858 template <typename HOLDER, typename INDEXTYPE, typename ATI>
860 {
861 public:
863  {
864  clear();
865  }
867  {
868  bind(attrib);
869  }
871  const UT_StringRef &name, int minsize=1);
872  void operator=(const GA_Attribute *attrib)
873  {
874  bind(attrib);
875  }
876  void bind(const GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1);
877 
878  /// Bind the handle to the given attribute
879  void bind(const GA_Attribute *attrib, int minsize=1)
880  {
881  myAttrib = ATI::cast(attrib);
882  if (myAttrib && myAttrib->getTupleSize() < minsize)
883  {
884  myAttrib = nullptr;
885  }
886  }
887 
888  /// Access to attribute
889  const GA_Attribute *getAttribute() const { return myAttrib; }
890  /// Tuple size of the attribute
891  int getTupleSize() const { return myAttrib->getTupleSize(); }
892 
894  {
895  if (myAttrib)
896  return myAttrib->getDataId();
897  return GA_INVALID_DATAID;
898  }
899 
900 
901  /// Clear the handle
902  void clear() { myAttrib = 0; }
903 
904  /// @{
905  /// Validity checks
906  SYS_FORCE_INLINE bool isValid() const { return myAttrib; }
907  SYS_FORCE_INLINE bool isInvalid() const { return !myAttrib; }
908  /// @}
909 
910  /// Get the string at the given offset
911  SYS_FORCE_INLINE const HOLDER &get(GA_Offset off, int comp = 0) const
912  {
914  UT_ASSERT_P(GAisValid(off));
915  UT_ASSERT_P(myAttrib->getIndexMap().isOffsetActive(off) || myAttrib->getIndexMap().isOffsetTransient(off));
916  return myAttrib->getHolder(off, comp);
917  }
918  /// Get the string index at the given offset
919  SYS_FORCE_INLINE INDEXTYPE getIndex(GA_Offset off, int comp = 0) const
920  {
922  UT_ASSERT_P(GAisValid(off));
923  UT_ASSERT_P(myAttrib->getIndexMap().isOffsetActive(off) || myAttrib->getIndexMap().isOffsetTransient(off));
924  return myAttrib->getHolderIndex(off, comp);
925  }
926  const ATI *operator->() const
927  {
928  return myAttrib;
929  }
930 
931  /// Copies attribute string indices from a contiguous block of offsets
932  /// into the dest array.
933  /// NOTE: The block of offsets is assumed to have no holes, else
934  /// data could be read from offsets that don't have
935  /// corresponding elements.
936  void getIndexBlock(GA_Offset startoff, GA_Size nelements, INDEXTYPE *dest, int deststride = 1, int component = 0) const;
937 
938  /// Copies attribute string indices from a contiguous block of indices
939  /// into the dest array.
940  /// This allows there to be holes in the geometry. The dest array
941  /// will be densely filled as per the index mapping.
942  void getIndexBlockFromIndices(GA_Index startidx, GA_Size nelements, INDEXTYPE *dest, int deststride = 1, int component = 0) const;
943 
944 
945 protected:
946  const ATI *myAttrib;
947 };
948 
949 /// Read-Write string handle
950 template <typename HOLDER, typename INDEXTYPE, typename ATI>
951 class GA_RWHandleTHolder : public GA_ROHandleTHolder<HOLDER, INDEXTYPE, ATI>
952 {
953 public:
955 
956 private:
957  using Base::myAttrib;
958 public:
959 
961  : Base()
962  {
963  }
965  : Base(attrib)
966  {
967  }
969  const UT_StringRef &name, int minsize=1)
970  : Base(gdp, owner, name, minsize)
971  {
972  }
973  void operator=(GA_Attribute *attrib)
974  {
975  Base::bind(attrib);
976  }
977 
978  GA_Attribute *getAttribute() const { return rwAttrib(); }
979 
980  void bumpDataId() const
981  {
982  if (rwAttrib())
983  rwAttrib()->bumpDataId();
984  }
985 
987  {
988  if (rwAttrib())
989  return rwAttrib()->getDataId();
990  return GA_INVALID_DATAID;
991  }
992 
993  /// Store the @c str at the given offset
994  SYS_FORCE_INLINE void set(GA_Offset off, const HOLDER &str) const
995  {
996  set(off, 0, str);
997  }
998  SYS_FORCE_INLINE void set(GA_Offset off, int comp, const HOLDER &str) const
999  {
1000  UT_ASSERT_P(rwAttrib() != nullptr);
1001  UT_ASSERT_P(GAisValid(off));
1002  UT_ASSERT_P(rwAttrib()->getIndexMap().isOffsetActive(off) || rwAttrib()->getIndexMap().isOffsetTransient(off));
1003  rwAttrib()->setHolder(off, str, comp);
1004  }
1005  /// Store the string indexed by the @c idx at the given offset
1006  SYS_FORCE_INLINE void set(GA_Offset off, INDEXTYPE idx) const
1007  {
1008  set(off, 0, idx);
1009  }
1010  SYS_FORCE_INLINE void set(GA_Offset off, int comp, INDEXTYPE idx) const
1011  {
1012  UT_ASSERT_P(rwAttrib() != nullptr);
1013  UT_ASSERT_P(GAisValid(off));
1014  UT_ASSERT_P(rwAttrib()->getIndexMap().isOffsetActive(off) || rwAttrib()->getIndexMap().isOffsetTransient(off));
1015  rwAttrib()->setHolderIndex(off, idx, comp);
1016  }
1017  ATI *operator->() const
1018  {
1019  return rwAttrib();
1020  }
1021 protected:
1022  ATI *rwAttrib() const
1023  { return SYSconst_cast(myAttrib); }
1024 };
1025 
1026 /// Read-Write string handle
1027 /// Batches all reference counts until a flush() or its destructor.
1028 /// Because it tracks this locally, you MUST create a separate one
1029 /// per thread! (Even if this were made thread safe, that would
1030 /// defeat the purpose of this, which is to use thread-local reference
1031 /// counts to avoid write contention)
1032 /// NOTE: This bumps the data ID of any attribute it's bound to
1033 /// upon destruction.
1034 template <typename HOLDER, typename INDEXTYPE, typename ATI, typename DELAYEDWRITER>
1036 {
1037 public:
1039  {
1040  clear();
1041  }
1043  {
1044  bind(attrib);
1045  }
1047  const UT_StringRef &name, int minsize=1);
1048  void operator=(GA_Attribute *attrib)
1049  {
1050  bind(attrib);
1051  }
1052  void bind(GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1);
1053 
1054  /// Bind the handle to the given attribute
1055  void bind(GA_Attribute *attrib, int minsize=1)
1056  {
1057  myAttrib = ATI::cast(attrib);
1058  if (myAttrib && myAttrib->getTupleSize() < minsize)
1059  {
1060  myAttrib = nullptr;
1061  }
1062  myWriter.bind(myAttrib);
1063  }
1064 
1065  /// Access to attribute
1066  GA_Attribute *getAttribute() const { return myAttrib; }
1067  /// Tuple size of the attribute
1068  int getTupleSize() const { return myAttrib->getTupleSize(); }
1070  {
1071  if (myAttrib)
1072  return myAttrib->getDataId();
1073  return GA_INVALID_DATAID;
1074  }
1075 
1076  /// Clear the handle
1077  void clear()
1078  {
1079  myAttrib = 0;
1080  myWriter.bind(myAttrib); // Also flushes.
1081  }
1082 
1083  /// @{
1084  /// Validity checks
1085  SYS_FORCE_INLINE bool isValid() const { return myAttrib; }
1086  SYS_FORCE_INLINE bool isInvalid() const { return !myAttrib; }
1087  /// @}
1088 
1089  /// Get the string at the given offset
1090  SYS_FORCE_INLINE HOLDER get(GA_Offset off, int comp = 0) const
1091  {
1093  UT_ASSERT_P(GAisValid(off));
1094  UT_ASSERT_P(myAttrib->getIndexMap().isOffsetActive(off) || myAttrib->getIndexMap().isOffsetTransient(off));
1095  return myAttrib->getHolder(off, comp);
1096  }
1097  /// Get the string index at the given offset
1098  SYS_FORCE_INLINE INDEXTYPE getIndex(GA_Offset off, int comp = 0) const
1099  {
1101  UT_ASSERT_P(GAisValid(off));
1102  UT_ASSERT_P(myAttrib->getIndexMap().isOffsetActive(off) || myAttrib->getIndexMap().isOffsetTransient(off));
1103  return myAttrib->getHolderIndex(off, comp);
1104  }
1105 
1106  /// Store the @c str at the given offset
1107  SYS_FORCE_INLINE void set(GA_Offset off, const HOLDER &str)
1108  {
1109  set(off, 0, str);
1110  }
1111  SYS_FORCE_INLINE void set(const GA_Range &range, const HOLDER &str)
1112  {
1113  set(range, 0, str);
1114  }
1115  SYS_FORCE_INLINE void set(GA_Offset off, int comp, const HOLDER &str)
1116  {
1118  UT_ASSERT_P(GAisValid(off));
1119  UT_ASSERT_P(myAttrib->getIndexMap().isOffsetActive(off) || myAttrib->getIndexMap().isOffsetTransient(off));
1120  myWriter.setHolder(off, str, comp);
1121  }
1122  SYS_FORCE_INLINE void set(const GA_Range &range, int comp, const HOLDER &str)
1123  {
1124  myWriter.setHolder(range, str, comp);
1125  }
1126  /// Store the string indexed by the @c idx at the given offset
1127  SYS_FORCE_INLINE void set(GA_Offset off, INDEXTYPE idx)
1128  {
1129  set(off, 0, idx);
1130  }
1131  SYS_FORCE_INLINE void set(const GA_Range &range, INDEXTYPE idx)
1132  {
1133  set(range, 0, idx);
1134  }
1135  SYS_FORCE_INLINE void set(GA_Offset off, int comp, INDEXTYPE idx)
1136  {
1138  UT_ASSERT_P(GAisValid(off));
1139  UT_ASSERT_P(myAttrib->getIndexMap().isOffsetActive(off) || myAttrib->getIndexMap().isOffsetTransient(off));
1140  myWriter.setHolderIndex(off, idx, comp);
1141  }
1142  SYS_FORCE_INLINE void set(const GA_Range &range, int comp, INDEXTYPE idx)
1143  {
1144  myWriter.setStringIndex(range, idx, comp);
1145  }
1146 
1148  {
1149  return myWriter.hasChanges();
1150  }
1151 protected:
1152  ATI *myAttrib;
1153  DELAYEDWRITER myWriter;
1154 };
1155 
1156 namespace GA_HandleDetail
1157 {
1158 // Helper for determining AIF type given the array type T
1159 template <typename T> struct ArrayAIF;
1160 template <> struct ArrayAIF<UT_Uint8Array> { typedef GA_AIFNumericArray type; };
1161 template <> struct ArrayAIF<UT_Int8Array> { typedef GA_AIFNumericArray type; };
1162 template <> struct ArrayAIF<UT_Int16Array> { typedef GA_AIFNumericArray type; };
1163 template <> struct ArrayAIF<UT_Int32Array> { typedef GA_AIFNumericArray type; };
1164 template <> struct ArrayAIF<UT_Int64Array> { typedef GA_AIFNumericArray type; };
1165 template <> struct ArrayAIF<UT_ValArray<fpreal16>> { typedef GA_AIFNumericArray type; };
1166 template <> struct ArrayAIF<UT_Fpreal32Array> { typedef GA_AIFNumericArray type; };
1167 template <> struct ArrayAIF<UT_Fpreal64Array> { typedef GA_AIFNumericArray type; };
1168 template <> struct ArrayAIF<UT_StringArray> { typedef GA_AIFSharedStringArray type; };
1170 // Helper for determining if we have an acceptable array type
1171 template <typename T> struct IsArray { static const bool value = false; };
1172 template <> struct IsArray<UT_Uint8Array> { static const bool value = true; };
1173 template <> struct IsArray<UT_Int8Array> { static const bool value = true; };
1174 template <> struct IsArray<UT_Int16Array> { static const bool value = true; };
1175 template <> struct IsArray<UT_Int32Array> { static const bool value = true; };
1176 template <> struct IsArray<UT_Int64Array> { static const bool value = true; };
1177 template <> struct IsArray<UT_ValArray<fpreal16>> { static const bool value = true; };
1178 template <> struct IsArray<UT_Fpreal32Array> { static const bool value = true; };
1179 template <> struct IsArray<UT_Fpreal64Array> { static const bool value = true; };
1180 template <> struct IsArray<UT_StringArray> { static const bool value = true; };
1181 template <> struct IsArray<UT_Array<UT_OptionsHolder>> { static const bool value = true; };
1182 }
1183 
1184 #define ENABLE_ARRAY(T) SYS_EnableIf< GA_HandleDetail::IsArray<T>::value >::type
1185 
1186 /// Read-only handle for array attribute data
1187 template <typename T>
1188 class GA_ROHandleT<T, typename ENABLE_ARRAY(T)>
1189 {
1190 public:
1192 
1194  {
1195  clear();
1196  }
1198  {
1199  bind(attrib);
1200  }
1201  GA_ROHandleT(const GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1);
1202 
1203  void operator=(const GA_Attribute *attrib)
1204  {
1205  bind(attrib);
1206  }
1207 
1208  void bind(const GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1);
1209  void bind(const GA_Attribute *attrib, int minsize=1)
1210  {
1211  myAttrib = const_cast<GA_Attribute *>(attrib);
1212  if (!myAttrib)
1213  return;
1214  myAIF = myAttrib->getAIF<AIFType>();
1215  if (!myAIF)
1216  myAttrib = nullptr;
1217  }
1218 
1219  const GA_Attribute *getAttribute() const { return myAttrib; }
1220 
1221  void clear()
1222  {
1223  myAttrib = nullptr;
1224  myAIF = nullptr;
1225  }
1226 
1227  SYS_FORCE_INLINE bool isValid() const { return myAttrib; }
1228  SYS_FORCE_INLINE bool isInvalid() const { return !myAttrib; }
1229 
1230  SYS_FORCE_INLINE void get(GA_Offset off, T &value) const
1231  {
1233  UT_ASSERT_P(GAisValid(off));
1235  myAIF->get(myAttrib, off, value);
1236  }
1237 
1238  bool operator==(const GA_ROHandleT<T> &handle) const
1239  {
1240  UT_ASSERT_P(myAIF == handle.myAIF);
1241  return myAttrib == handle.myAttrib;
1242  }
1243  bool operator!=(const GA_ROHandleT<T> &handle) const
1244  {
1245  UT_ASSERT_P(myAIF == handle.myAIF);
1246  return myAttrib != handle.myAttrib;
1247  }
1248  const GA_Attribute *operator->() const
1249  {
1250  return myAttrib;
1251  }
1252 
1253 protected:
1255  const AIFType* myAIF;
1256 };
1257 
1258 /// Read-Write handle for array attribute data
1259 template <typename T>
1260 class GA_RWHandleT<T, typename ENABLE_ARRAY(T)>
1261  : public GA_ROHandleT<T, typename ENABLE_ARRAY(T)>
1262 {
1263 public:
1265 
1266 private:
1267  using Base::myAttrib;
1268 public:
1269 
1271  {
1272  this->clear();
1273  }
1275  {
1276  bind(attrib);
1277  }
1278  GA_RWHandleT(GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1);
1279 
1280  void operator=(GA_Attribute *attrib)
1281  {
1282  bind(attrib);
1283  }
1284 
1285  void bind(GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1);
1286  void bind(GA_Attribute *attrib, int minsize=1)
1287  {
1288  Base::bind(attrib, minsize);
1289  }
1290 
1292 
1293  void bumpDataId() const
1294  {
1295  if (myAttrib)
1296  myAttrib->bumpDataId();
1297  }
1298 
1300  {
1301  if (myAttrib)
1302  return myAttrib->getDataId();
1303  return GA_INVALID_DATAID;
1304  }
1305 
1306  SYS_FORCE_INLINE void set(GA_Offset off, const T &value) const
1307  {
1309  UT_ASSERT_P(GAisValid(off));
1311  Base::myAIF->set(myAttrib, off, value);
1312  }
1314  {
1315  return myAttrib;
1316  }
1317 
1318 private:
1319 };
1320 
1321 #undef ENABLE_ARRAY
1322 
1323 template <typename T>
1325 {
1326 public:
1329 };
1330 
1334 
1338 
1339 // Hacky workaround for now
1340 template <>
1341 class GA_HandleT<const char*>
1342 {
1343 public:
1344  typedef GA_ROHandleS ROType;
1345  typedef GA_RWHandleS RWType;
1346 };
1347 
1350 
1353 
1356 
1359 
1362 
1365 
1368 
1371 
1374 
1377 
1380 
1383 
1386 
1389 
1392 
1395 
1398 
1401 
1404 
1407 
1410 
1413 
1416 
1419 
1422 
1425 
1428 
1431 
1432 #endif
GA_RWHandleT(GA_Attribute *attrib)
Definition: GA_Handle.h:313
void setBlockFromIndices(GA_Index startidx, GA_Size nelements, const T *source, int sourcestride=1, int component=0) const
void setPageConstant(GA_PageNum pagenum, const T *values) const
Definition: GA_Handle.h:838
SYS_FORCE_INLINE void bumpDataId()
Definition: GA_Attribute.h:306
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
T::value_type BASETYPE
Definition: GA_Handle.h:113
Definition of a geometry attribute.
Definition: GA_Attribute.h:198
void makeConstant(const T &cval) const
Definition: GA_Handle.h:471
GA_RWHandleT< UT_Int32Array > GA_RWHandleIA
Definition: GA_Handle.h:1415
GA_ATINumeric * operator->() const
Definition: GA_Handle.h:490
void SecondGuess
Definition: UT_Storage.h:90
GA_RWBatchHandleTHolder(GA_Attribute *attrib)
Definition: GA_Handle.h:1042
GA_RWHandleT< UT_Vector2D > GA_RWHandleV2D
Definition: GA_Handle.h:1403
SYS_FORCE_INLINE void set(GA_Offset off, INDEXTYPE idx) const
Store the string indexed by the idx at the given offset.
Definition: GA_Handle.h:1006
Generic Attribute Interface class to access an attribute as a array.
SYS_FORCE_INLINE ALTTYPE getAlt(GA_Offset off, int comp=0) const
Definition: GA_Handle.h:216
GLenum GLint * range
Definition: glcorearb.h:1925
GA_PageArray< BASETYPE, 1 > * myExactMatch
Definition: GA_Handle.h:674
GA_ROHandleT< UT_StringArray > GA_ROHandleSA
Definition: GA_Handle.h:1426
UT_Storage
Definition: UT_Storage.h:28
SYS_FORCE_INLINE bool isPageConstant(GA_PageNum pagenum) const
Definition: GA_Handle.h:655
GA_RWHandleTHolder(GA_Attribute *attrib)
Definition: GA_Handle.h:964
GA_ROHandleT< int8 > GA_ROHandleC
Definition: GA_Handle.h:1360
void bind(const GA_Attribute *attrib, int minsize=1)
Definition: GA_Handle.h:1209
GA_RWHandleT< UT_FprealArray > GA_RWHandleRA
Definition: GA_Handle.h:1412
void
Definition: png.h:1083
void bind(GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1)
GA_RWHandleTHolder< UT_OptionsHolder, GA_DictIndexType, GA_ATIDict > GA_RWHandleDict
Definition: GA_Handle.h:1336
GA_ROHandleT< UT_Vector4D > GA_ROHandleV4D
Definition: GA_Handle.h:1408
SYS_FORCE_INLINE void bind(const GA_Attribute *attrib, int minsize=1)
Definition: GA_Handle.h:529
const DataType & getData() const
int64 GA_DataId
Definition: GA_Types.h:687
#define ENABLE_ARRAY(T)
Definition: GA_Handle.h:1184
SYS_FORCE_INLINE bool isInvalid() const
Definition: GA_Handle.h:1228
virtual bool makeConstant(GA_Attribute *attrib, int32 data, int index=0) const =0
void makeConstantV(const T *cval, int size) const
Definition: GA_Handle.h:830
SYS_FORCE_INLINE void set(GA_Offset off, int comp, const T &val) const
Definition: GA_Handle.h:380
SYS_FORCE_INLINE const GA_IndexMap & getIndexMap() const
Definition: GA_Attribute.h:207
GA_RWHandleT< UT_QuaternionD > GA_RWHandleQD
Definition: GA_Handle.h:1400
void clear()
Clear the handle.
Definition: GA_Handle.h:1077
void bind(const GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1)
void clear()
Clear the handle.
Definition: GA_Handle.h:902
GA_PageArray< BASETYPE, theTupleSize > * myExactMatch
Definition: GA_Handle.h:284
GLuint start
Definition: glcorearb.h:475
GLsizei const GLfloat * value
Definition: glcorearb.h:824
bool GAisValid(GA_Size v)
Definition: GA_Types.h:649
void bind(GA_Attribute *attrib, int minsize=1)
Definition: GA_Handle.h:1286
GA_RWHandleT< fpreal > GA_RWHandleR
Definition: GA_Handle.h:1349
GA_DataId getDataId() const
Definition: GA_Handle.h:893
int getTupleSize() const
const GA_Attribute * getAttribute() const
Access to attribute.
Definition: GA_Handle.h:889
GA_RWHandleT< UT_Int64Array > GA_RWHandleIDA
Definition: GA_Handle.h:1418
GA_ROHandleT< UT_Vector4F > GA_ROHandleV4
Definition: GA_Handle.h:1384
GA_ROHandleT< UT_Vector2F > GA_ROHandleV2
Definition: GA_Handle.h:1378
SYS_FORCE_INLINE T * SYSconst_cast(const T *foo)
Definition: SYS_Types.h:136
SYS_FORCE_INLINE bool isValid() const
Definition: GA_Handle.h:1085
GA_ROHandleTHolder< UT_OptionsHolder, GA_DictIndexType, GA_ATIDict > GA_ROHandleDict
Definition: GA_Handle.h:1335
GA_ROHandleT< UT_Array< UT_OptionsHolder > > GA_ROHandleDictA
Definition: GA_Handle.h:1429
SYS_FORCE_INLINE void add(IDX_T i, SRC_DATA_T v)
component == 0 in this version
Definition: UT_PageArray.h:630
Read-Write string handle.
Definition: GA_Handle.h:951
SYS_FORCE_INLINE void setAlt(GA_Offset off, const ALTTYPE &val) const
Definition: GA_Handle.h:367
SYS_FORCE_INLINE void addAlt(GA_Offset off, const ALTTYPE &val) const
Definition: GA_Handle.h:421
int64 exint
Definition: SYS_Types.h:125
SYS_FORCE_INLINE bool isValid() const
Definition: GA_Handle.h:906
SYS_FORCE_INLINE DEST_DATA_T get(IDX_T i, exint component=0) const
Definition: UT_PageArray.h:488
GA_ATINumeric * operator->() const
Definition: GA_Handle.h:848
GA_ROHandleT< UT_Vector3D > GA_ROHandleV3D
Definition: GA_Handle.h:1405
void operator=(GA_Attribute *attrib)
Definition: GA_Handle.h:1280
bool operator==(const GA_ROHandleT< T > &handle) const
Definition: GA_Handle.h:270
GA_ROHandleT(const GA_Attribute *attrib)
Definition: GA_Handle.h:515
SYS_FORCE_INLINE void bind(GA_Attribute *attrib, int minsize=1)
Definition: GA_Handle.h:327
GA_ATINumeric * getAttribute() const
Definition: GA_Handle.h:724
GA_ROHandleT< UT_Matrix4D > GA_ROHandleM4D
Definition: GA_Handle.h:1396
GA_RWHandleT< int64 > GA_RWHandleID
Definition: GA_Handle.h:1388
void setPageConstant(GA_PageNum pagenum, const BASETYPE *values) const
Definition: GA_Handle.h:480
SYS_FORCE_INLINE void set(GA_Offset off, T val) const
Definition: GA_Handle.h:739
GA_RWHandleT< UT_Vector4D > GA_RWHandleV4D
Definition: GA_Handle.h:1409
SYS_FORCE_INLINE INDEXTYPE getIndex(GA_Offset off, int comp=0) const
Get the string index at the given offset.
Definition: GA_Handle.h:919
**But if you need a result
Definition: thread.h:613
int getTupleSize() const
Tuple size of the attribute.
Definition: GA_Handle.h:1068
ATI * operator->() const
Definition: GA_Handle.h:1017
SYS_FORCE_INLINE UT_FixedVector< DEST_DATA_T, DEST_TSIZE > getVector(IDX_T i) const
Definition: UT_PageArray.h:498
#define GA_INVALID_DATAID
Definition: GA_Types.h:688
SYS_FORCE_INLINE void bind(const GA_Attribute *attrib, int minsize=1)
Definition: GA_Handle.h:136
SYS_FORCE_INLINE void set(const GA_Range &range, int comp, INDEXTYPE idx)
Definition: GA_Handle.h:1142
void operator=(GA_Attribute *attrib)
Definition: GA_Handle.h:705
SYS_FORCE_INLINE void addAlt(GA_Offset off, int comp, const ALTTYPE &val) const
Definition: GA_Handle.h:448
GA_ROHandleT< int64 > GA_ROHandleID
Definition: GA_Handle.h:1387
SYS_FORCE_INLINE void set(IDX_T i, SRC_DATA_T v)
component == 0 in this version
Definition: UT_PageArray.h:624
const ATI * myAttrib
Definition: GA_Handle.h:946
SYS_FORCE_INLINE void bind(GA_ATINumeric *attrib, int minsize=1)
Definition: GA_Handle.h:332
SYS_FORCE_INLINE void set(GA_Offset off, int comp, const HOLDER &str)
Definition: GA_Handle.h:1115
uint64 value_type
Definition: GA_PrimCompat.h:29
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:235
GA_ATINumeric * getAttribute() const
Definition: GA_Handle.h:339
GA_ROHandleTHolder< HOLDER, INDEXTYPE, ATI > Base
Definition: GA_Handle.h:954
const GA_Attribute * getAttribute() const
Definition: GA_Handle.h:1219
GA_ROHandleT< UT_Vector3F > GA_ROHandleV3
Definition: GA_Handle.h:1381
SYS_FORCE_INLINE bool isValid() const
Definition: GA_Handle.h:1227
GA_DataId getDataId() const
Definition: GA_Handle.h:986
void operator=(const GA_Attribute *attrib)
Definition: GA_Handle.h:128
A range of elements in an index-map.
Definition: GA_Range.h:42
GA_ROHandleT< UT_Matrix3D > GA_ROHandleM3D
Definition: GA_Handle.h:1393
SYS_FORCE_INLINE void getV(GA_Offset off, T *data, int size) const
Definition: GA_Handle.h:609
GA_ROHandleT< UT_Matrix2F > GA_ROHandleM2
Definition: GA_Handle.h:1366
GA_RWHandleT< UT_Vector3F > GA_RWHandleV3
Definition: GA_Handle.h:1382
const GA_ATINumeric * getAttribute() const
Definition: GA_Handle.h:166
GA_Size GA_Offset
Definition: GA_Types.h:641
GA_RWBatchHandleTHolder< UT_OptionsHolder, GA_DictIndexType, GA_ATIDict, GA_ATIDictDelayedWriter > GA_RWBatchHandleDict
Definition: GA_Handle.h:1337
GA_PageArray< BASETYPE > * myAlmostMatch
Definition: GA_Handle.h:675
void makeConstant(T cval, int comp=-1) const
Definition: GA_Handle.h:825
SYS_FORCE_INLINE bool isInvalid() const
Definition: GA_Handle.h:583
void bind(const GA_ATINumeric *attrib, int minsize=1)
Definition: GA_Handle.h:533
SYS_FORCE_INLINE void add(GA_Offset off, const T &val) const
Definition: GA_Handle.h:408
GA_ROHandleT< UT_Matrix3F > GA_ROHandleM3
Definition: GA_Handle.h:1369
GA_ROHandleT< int32 > GA_ROHandleI
Definition: GA_Handle.h:1363
GA_RWHandleT< UT_Fpreal64Array > GA_RWHandleDA
Definition: GA_Handle.h:1424
SYS_FORCE_INLINE void add(GA_Offset off, int comp, T val) const
Definition: GA_Handle.h:801
SYS_FORCE_INLINE void set(GA_Offset off, int comp, const HOLDER &str) const
Definition: GA_Handle.h:998
GLintptr offset
Definition: glcorearb.h:665
SYS_FORCE_INLINE void set(GA_Offset off, int comp, T val) const
Definition: GA_Handle.h:765
GA_RWHandleTHolder< UT_StringHolder, GA_StringIndexType, GA_ATIString > GA_RWHandleS
Definition: GA_Handle.h:1332
SYS_FORCE_INLINE void add(GA_Offset off, T val) const
Definition: GA_Handle.h:752
const GA_AIFTuple * getAIFTuple() const override
Return the attribute's tuple interface or NULL.
ATI * rwAttrib() const
Definition: GA_Handle.h:1022
T::value_type BASETYPE
Definition: GA_Handle.h:299
SYS_FORCE_INLINE void setV(GA_Offset off, const T *data, int size) const
Definition: GA_Handle.h:778
void bind(const GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1)
void clear()
Definition: GA_Handle.h:180
void getIndexBlockFromIndices(GA_Index startidx, GA_Size nelements, INDEXTYPE *dest, int deststride=1, int component=0) const
GA_RWHandleT< UT_Fpreal32Array > GA_RWHandleFA
Definition: GA_Handle.h:1421
bool isOffsetTransient(GA_Offset offset) const
SYS_FORCE_INLINE void set(GA_Offset off, int comp, INDEXTYPE idx) const
Definition: GA_Handle.h:1010
SYS_FORCE_INLINE void set(const GA_Range &range, INDEXTYPE idx)
Definition: GA_Handle.h:1131
void getBlockFromIndices(GA_Index startidx, GA_Size nelements, T *dest, int deststride=1, int component=0) const
void operator=(GA_Attribute *attrib)
Definition: GA_Handle.h:973
GA_RWHandleT< UT_Vector4F > GA_RWHandleV4
Definition: GA_Handle.h:1385
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:155
GA_RWHandleT< UT_Matrix2F > GA_RWHandleM2
Definition: GA_Handle.h:1367
bool operator!=(const GA_ROHandleT< T > &handle) const
Definition: GA_Handle.h:1243
SYS_FORCE_INLINE void setPageConstant(UT_PageNum pagenum, const NotVoidType &val)
static SYS_FORCE_INLINE GA_ATINumeric * cast(GA_Attribute *attrib)
Definition: GA_ATINumeric.h:65
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
void(* GAprobeAttribSetter)(GA_Attribute *atr, GA_Offset, const T &)
Definition: GA_Handle.h:297
void getIndexBlock(GA_Offset startoff, GA_Size nelements, INDEXTYPE *dest, int deststride=1, int component=0) const
GA_ROHandleT< fpreal32 > GA_ROHandleF
Definition: GA_Handle.h:1354
SYS_FORCE_INLINE void set(GA_Offset off, const T &value) const
Definition: GA_Handle.h:1306
GA_ATINumeric * myAttrib
Definition: GA_Handle.h:283
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
const GA_ATINumeric * operator->() const
Definition: GA_Handle.h:667
void getBlock(GA_Offset startoff, GA_Size nelements, T *dest, int deststride=1, int component=0) const
A specialization of GA_AIFStringArray to access "shared strings".
GA_RWHandleT< fpreal64 > GA_RWHandleD
Definition: GA_Handle.h:1358
void(* GAprobeAttribGetter)(T &result, const GA_Attribute *atr, GA_Offset)
Definition: GA_Handle.h:112
void bind(GA_Attribute *attrib, int minsize=1)
Bind the handle to the given attribute.
Definition: GA_Handle.h:1055
GA_ROHandleT< UT_Fpreal64Array > GA_ROHandleDA
Definition: GA_Handle.h:1423
GA_RWHandleT< UT_Matrix4F > GA_RWHandleM4
Definition: GA_Handle.h:1373
bool operator!=(const GA_ROHandleT< T > &handle) const
Definition: GA_Handle.h:663
GA_RWHandleT< UT_Matrix3D > GA_RWHandleM3D
Definition: GA_Handle.h:1394
GA_RWHandleTHolder(const GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1)
Definition: GA_Handle.h:968
GA_ROHandleT< fpreal64 > GA_ROHandleD
Definition: GA_Handle.h:1357
GA_RWHandleT< T > RWType
Definition: GA_Handle.h:1328
const GA_Attribute * operator->() const
Definition: GA_Handle.h:1248
SYS_FORCE_INLINE T operator()(GA_Offset off, int comp=0) const
Definition: GA_Handle.h:644
GA_HandleDetail::ArrayAIF< T >::type AIFType
Definition: GA_Handle.h:1191
GLuint const GLchar * name
Definition: glcorearb.h:786
SYS_FORCE_INLINE GA_DataId getDataId() const
Definition: GA_Attribute.h:299
SYS_FORCE_INLINE T operator[](GA_Offset off) const
Definition: GA_Handle.h:648
GA_DataId getDataId() const
Definition: GA_Handle.h:347
SYS_FORCE_INLINE bool isInvalid() const
Definition: GA_Handle.h:191
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
Definition: GA_Types.h:635
void bumpDataId() const
Definition: GA_Handle.h:341
GA_RWHandleT< fpreal16 > GA_RWHandleH
Definition: GA_Handle.h:1352
SYS_FORCE_INLINE void set(const GA_Range &range, const HOLDER &str)
Definition: GA_Handle.h:1111
Read-only handle for string attribute data.
Definition: GA_Handle.h:859
UT_FixedVector< ALTBASETYPE, theTupleSize > ALTTYPE
Definition: GA_Handle.h:116
SYS_FORCE_INLINE bool isPageConstant(GA_PageNum pagenum) const
SYS_FORCE_INLINE void add(GA_Offset off, int comp, const T &val) const
Definition: GA_Handle.h:434
SYS_FORCE_INLINE void addVector(IDX_T i, const TS &as)
Definition: UT_PageArray.h:737
GA_ROHandleT< UT_Int32Array > GA_ROHandleIA
Definition: GA_Handle.h:1414
GA_ROHandleT< fpreal16 > GA_ROHandleH
Definition: GA_Handle.h:1351
GA_Attribute * getAttribute() const
Access to attribute.
Definition: GA_Handle.h:1066
const ATI * operator->() const
Definition: GA_Handle.h:926
SYS_FORCE_INLINE bool isValid() const
Definition: GA_Handle.h:187
void bumpDataId() const
Definition: GA_Handle.h:980
SYS_FORCE_INLINE void set(GA_Offset off, int comp, INDEXTYPE idx)
Definition: GA_Handle.h:1135
bool isRational() const
Definition: GA_Handle.h:177
GLsizeiptr size
Definition: glcorearb.h:664
void setBlock(GA_Offset startoff, GA_Size nelements, const T *source, int sourcestride=1, int component=0) const
GA_AttributeOwner
Definition: GA_Types.h:34
GA_ROHandleTHolder(const GA_Attribute *attrib)
Definition: GA_Handle.h:866
bool operator==(const GA_ROHandleT< T > &handle) const
Definition: GA_Handle.h:659
GA_ROHandleT(const GA_Attribute *attrib)
Definition: GA_Handle.h:1197
GA_RWHandleT< UT_Vector2F > GA_RWHandleV2
Definition: GA_Handle.h:1379
#define SCALAR(T)
Simplify checking for scalar types.
Definition: GA_Handle.h:498
SYS_FORCE_INLINE bool isPageConstant(GA_PageNum pagenum) const
Definition: GA_Handle.h:266
GA_ROHandleT< fpreal > GA_ROHandleR
Definition: GA_Handle.h:1348
SYS_FORCE_INLINE void setAlt(GA_Offset off, int comp, const ALTTYPE &val) const
Definition: GA_Handle.h:394
void bind(const GA_Attribute *attrib, int minsize=1)
Bind the handle to the given attribute.
Definition: GA_Handle.h:879
GA_RWHandleT< UT_Matrix4D > GA_RWHandleM4D
Definition: GA_Handle.h:1397
GA_ROHandleT< UT_FprealArray > GA_ROHandleRA
Definition: GA_Handle.h:1411
bool isOffsetActive(GA_Offset offset) const
Returns true if the specified offset is referenced by an ordered element.
Definition: GA_IndexMap.h:483
SYS_FORCE_INLINE void set(const GA_Range &range, int comp, const HOLDER &str)
Definition: GA_Handle.h:1122
GA_ROHandleT< T > Base
Definition: GA_Handle.h:298
void operator=(const GA_Attribute *attrib)
Definition: GA_Handle.h:521
GA_ROHandleT< UT_Matrix4F > GA_ROHandleM4
Definition: GA_Handle.h:1372
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1602
GA_RWHandleT< UT_Vector3D > GA_RWHandleV3D
Definition: GA_Handle.h:1406
GA_ROHandleT< UT_QuaternionF > GA_ROHandleQ
Definition: GA_Handle.h:1375
GA_RWHandleT< UT_Array< UT_OptionsHolder > > GA_RWHandleDictA
Definition: GA_Handle.h:1430
SYS_FORCE_INLINE GA_TypeInfo getTypeInfo() const
Definition: GA_Attribute.h:252
SYS_FORCE_INLINE void set(GA_Offset off, const T &val) const
Definition: GA_Handle.h:354
void operator=(GA_Attribute *attrib)
Definition: GA_Handle.h:319
SYS_FORCE_INLINE void set(GA_Offset off, const HOLDER &str) const
Store the str at the given offset.
Definition: GA_Handle.h:994
void operator=(const GA_Attribute *attrib)
Definition: GA_Handle.h:872
GA_Size GA_PageNum
Definition: GA_Types.h:644
const T * getAIF() const
Generic method for getting an AIF by type.
Definition: GA_Attribute.h:416
GA_ROHandleT< UT_Int64Array > GA_ROHandleIDA
Definition: GA_Handle.h:1417
SYS_FORCE_INLINE bool isInvalid() const
Definition: GA_Handle.h:907
void bind(GA_ATINumeric *attrib, int minsize=1)
Definition: GA_Handle.h:717
SYS_FORCE_INLINE bool isValid() const
Definition: GA_Handle.h:579
A specialization of GA_AIFDictArray to access "shared strings".
void operator=(GA_Attribute *attrib)
Definition: GA_Handle.h:1048
GA_RWHandleT< fpreal32 > GA_RWHandleF
Definition: GA_Handle.h:1355
GA_RWHandleT< int8 > GA_RWHandleC
Definition: GA_Handle.h:1361
GA_ROHandleT(const GA_Attribute *attrib)
Definition: GA_Handle.h:122
GLuint GLfloat * val
Definition: glcorearb.h:1608
GA_ROHandleT< T > ROType
Definition: GA_Handle.h:1327
GA_RWHandleT(GA_Attribute *attrib)
Definition: GA_Handle.h:699
GA_ROHandleT< UT_QuaternionD > GA_ROHandleQD
Definition: GA_Handle.h:1399
DELAYEDWRITER myWriter
Definition: GA_Handle.h:1153
GA_DataId getDataId() const
Definition: GA_Handle.h:1069
Container class for all geometry.
Definition: GA_Detail.h:96
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
GA_RWBatchHandleTHolder< UT_StringHolder, GA_StringIndexType, GA_ATIString, GA_ATIStringDelayedWriter > GA_RWBatchHandleS
Definition: GA_Handle.h:1333
Definition: core.h:1131
SYS_FORCE_INLINE bool hasChanges() const
Definition: GA_Handle.h:1147
SYS_FORCE_INLINE const GA_PageArray< DEST_DATA_T, TSIZE, TABLEHARDENED, PAGESHARDENED > & castType() const
Definition: GA_PageArray.h:732
GA_DataId getDataId() const
Definition: GA_Handle.h:168
void bind(GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1)
GA_ROHandleT< UT_Matrix2D > GA_ROHandleM2D
Definition: GA_Handle.h:1390
SYS_FORCE_INLINE void set(GA_Offset off, const HOLDER &str)
Store the str at the given offset.
Definition: GA_Handle.h:1107
bool operator==(const GA_ROHandleT< T > &handle) const
Definition: GA_Handle.h:1238
GA_ROHandleTHolder< UT_StringHolder, GA_StringIndexType, GA_ATIString > GA_ROHandleS
Definition: GA_Handle.h:1331
int getTupleSize() const
Tuple size of the attribute.
Definition: GA_Handle.h:891
#define const
Definition: zconf.h:214
SYS_FORCE_INLINE void setVector(IDX_T i, const TS &as)
Definition: UT_PageArray.h:731
SYS_FORCE_INLINE bool isAltBound() const
Definition: GA_Handle.h:198
GA_RWHandleT< UT_QuaternionF > GA_RWHandleQ
Definition: GA_Handle.h:1376
GA_RWHandleT< int32 > GA_RWHandleI
Definition: GA_Handle.h:1364
typename UT_StorageNum< BASETYPE >::SecondGuess ALTBASETYPE
Definition: GA_Handle.h:115
SYS_FORCE_INLINE bool isInvalid() const
Definition: GA_Handle.h:1086
GA_ROHandleT< UT_Fpreal32Array > GA_ROHandleFA
Definition: GA_Handle.h:1420
UT_StringHolder & operator()(exint i)
Definition: UT_Array.h:747
GA_RWHandleT< UT_Matrix3F > GA_RWHandleM3
Definition: GA_Handle.h:1370
const GA_ATINumeric * operator->() const
Definition: GA_Handle.h:278
GA_PageArray< typename UT_StorageNum< BASETYPE >::SecondGuess, theTupleSize > * myAlmostMatch
Definition: GA_Handle.h:285
SYS_FORCE_INLINE T operator()(GA_Offset off) const
Definition: GA_Handle.h:255
SYS_FORCE_INLINE T operator[](GA_Offset off) const
Definition: GA_Handle.h:259
SYS_FORCE_INLINE void bind(GA_Attribute *attrib, int minsize=1)
Definition: GA_Handle.h:713
bool operator!=(const GA_ROHandleT< T > &handle) const
Definition: GA_Handle.h:274
GA_Attribute * getAttribute() const
Definition: GA_Handle.h:1291
GA_RWHandleT< UT_Matrix2D > GA_RWHandleM2D
Definition: GA_Handle.h:1391
Definition: format.h:895
SYS_FORCE_INLINE INDEXTYPE getIndex(GA_Offset off, int comp=0) const
Get the string index at the given offset.
Definition: GA_Handle.h:1098
const GA_ATINumeric * getAttribute() const
Definition: GA_Handle.h:558
GA_RWHandleT< UT_StringArray > GA_RWHandleSA
Definition: GA_Handle.h:1427
void operator=(const GA_Attribute *attrib)
Definition: GA_Handle.h:1203
GA_Attribute * getAttribute() const
Definition: GA_Handle.h:978
GA_ROHandleT< UT_Vector2D > GA_ROHandleV2D
Definition: GA_Handle.h:1402
static const exint theTupleSize
Definition: GA_Handle.h:114
void bind(const GA_ATINumeric *attrib, int minsize=1)
Definition: GA_Handle.h:141
GLenum src
Definition: glcorearb.h:1793
SYS_FORCE_INLINE void set(GA_Offset off, INDEXTYPE idx)
Store the string indexed by the idx at the given offset.
Definition: GA_Handle.h:1127