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));
233  return getOutlinePart(off);
234  }
235 
236  // Outline the expensive template instantiations from UT_PageArray when the
237  // attribute is not a match for our type (or the fallback type).
238  T getOutlinePart(GA_Offset off) const;
239 
240  ALTTYPE getAltNonInlinePart(GA_Offset off) const
241  {
242  if (myExactMatch)
243  return ALTTYPE(myExactMatch->template getVector<ALTBASETYPE,theTupleSize>(off));
244  return getAltOutlinePart(off);
245  }
246 
247  ALTTYPE getAltOutlinePart(GA_Offset off) const;
248 
249 public:
250 
251  /// Copies attribute values from a contiguous block of offsets
252  /// into the dest array.
253  /// NOTE: The block of offsets is assumed to have no holes, else
254  /// data could be read from offsets that don't have
255  /// corresponding elements.
256  void getBlock(GA_Offset startoff, GA_Size nelements, T *dest, int deststride = 1, int component = 0) const;
257 
258  /// Copies attribute values from a contiguous block of indices
259  /// into the dest array.
260  /// This allows there to be holes in the geometry.
261  void getBlockFromIndices(GA_Index startidx, GA_Size nelements, T *dest, int deststride = 1, int component = 0) const;
262 
264  {
265  return get(off);
266  }
268  {
269  return get(off);
270  }
271  /// Returns true iff the specified page is constant-compressed,
272  /// where a single value is stored to represent GA_PAGE_SIZE
273  /// values in the page, (or possibly fewer if only one page).
275  {
276  return myAttrib->isPageConstant(pagenum);
277  }
278  bool operator==(const GA_ROHandleT<T> &handle) const
279  {
280  return myAttrib == handle.myAttrib;
281  }
282  bool operator!=(const GA_ROHandleT<T> &handle) const
283  {
284  return myAttrib != handle.myAttrib;
285  }
286  const GA_ATINumeric *operator->() const
287  {
288  return myAttrib;
289  }
290 protected:
294 };
295 
296 /// Read-write handle for vector attribute data.
297 ///
298 /// @tparam T Return vector type for get methods. Requires T::value_type to
299 /// describe the underlying element type of the vector.
300 ///
301 template <typename T, typename ENABLE = void>
302 class GA_RWHandleT : public GA_ROHandleT<T, ENABLE>
303 {
304 public:
305  typedef void (*GAprobeAttribSetter)(GA_Attribute *atr, GA_Offset, const T &);
307  typedef typename T::value_type BASETYPE;
308 private:
309  using Base::myAttrib;
310  using Base::myExactMatch;
311  using Base::myAlmostMatch;
312  using Base::theTupleSize;
313 public:
316 
318  {
319  clear();
320  }
322  {
323  bind(attrib);
324  }
325  GA_RWHandleT(GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1);
326 
327  void operator=(GA_Attribute *attrib)
328  {
329  bind(attrib);
330  }
331 
332  void bind(GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1);
333 
335  void bind(GA_Attribute *attrib, int minsize=1)
336  {
337  bind(GA_ATINumeric::cast(attrib), minsize);
338  }
340  void bind(GA_ATINumeric *attrib, int minsize=1)
341  {
342  Base::bind(attrib, minsize);
343  }
344 
345  using Base::clear;
346 
347  GA_ATINumeric *getAttribute() const { return myAttrib; }
348 
349  void bumpDataId() const
350  {
351  if (myAttrib)
352  myAttrib->bumpDataId();
353  }
354 
356  {
357  if (myAttrib)
358  return myAttrib->getDataId();
359  return GA_INVALID_DATAID;
360  }
361 
362  SYS_FORCE_INLINE void set(GA_Offset off, const T &val) const
363  {
365  UT_ASSERT_P(GAisValid(off));
367  if (myExactMatch)
368  myExactMatch->setVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<T>::FixedVectorType &>(val));
369  else if (myAlmostMatch)
370  myAlmostMatch->setVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<T>::FixedVectorType &>(val));
371  else
372  setOutlinePart(off, val);
373  }
374 
375  SYS_FORCE_INLINE void setAlt(GA_Offset off, const ALTTYPE &val) const
376  {
378  UT_ASSERT_P(GAisValid(off));
380  if (myAlmostMatch)
381  myAlmostMatch->setVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<ALTTYPE>::FixedVectorType &>(val));
382  else if (myExactMatch)
383  myExactMatch->setVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<ALTTYPE>::FixedVectorType &>(val));
384  else
385  setAltOutlinePart(off, val);
386  }
387 
388  SYS_FORCE_INLINE void set(GA_Offset off, int comp, const T &val) const
389  {
390  UT_ASSERT(comp == 0 && "Component sets on vector types unsupported");
392  UT_ASSERT_P(GAisValid(off));
394  if (myExactMatch)
395  myExactMatch->setVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<T>::FixedVectorType &>(val));
396  else if (myAlmostMatch)
397  myAlmostMatch->setVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<T>::FixedVectorType &>(val));
398  else
399  myAttrib->getData().setVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<T>::FixedVectorType &>(val));
400  }
401 
402  SYS_FORCE_INLINE void setAlt(GA_Offset off, int comp, const ALTTYPE &val) const
403  {
404  UT_ASSERT(comp == 0 && "Component sets on vector types unsupported");
406  UT_ASSERT_P(GAisValid(off));
408  if (myAlmostMatch)
409  myAlmostMatch->setVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<ALTTYPE>::FixedVectorType &>(val));
410  else if (myExactMatch)
411  myExactMatch->setVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<ALTTYPE>::FixedVectorType &>(val));
412  else
413  myAttrib->getData().setVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<ALTTYPE>::FixedVectorType &>(val));
414  }
415 
416  SYS_FORCE_INLINE void add(GA_Offset off, const T &val) const
417  {
419  UT_ASSERT_P(GAisValid(off));
421  if (myExactMatch)
422  myExactMatch->addVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<T>::FixedVectorType &>(val));
423  else if (myAlmostMatch)
424  myAlmostMatch->addVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<T>::FixedVectorType &>(val));
425  else
426  addOutlinePart(off, val);
427  }
428 
429  SYS_FORCE_INLINE void addAlt(GA_Offset off, const ALTTYPE &val) const
430  {
432  UT_ASSERT_P(GAisValid(off));
434  if (myAlmostMatch)
435  myAlmostMatch->addVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<ALTTYPE>::FixedVectorType &>(val));
436  else if (myExactMatch)
437  myExactMatch->addVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<ALTTYPE>::FixedVectorType &>(val));
438  else
439  addAltOutlinePart(off, val);
440  }
441 
442  SYS_FORCE_INLINE void add(GA_Offset off, int comp, const T &val) const
443  {
444  UT_ASSERT(comp == 0 && "Component sets on vector types unsupported");
446  UT_ASSERT_P(GAisValid(off));
448  if (myExactMatch)
449  myExactMatch->addVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<T>::FixedVectorType &>(val));
450  else if (myAlmostMatch)
451  myAlmostMatch->addVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<T>::FixedVectorType &>(val));
452  else
453  myAttrib->getData().addVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<T>::FixedVectorType &>(val));
454  }
455 
456  SYS_FORCE_INLINE void addAlt(GA_Offset off, int comp, const ALTTYPE &val) const
457  {
458  UT_ASSERT(comp == 0 && "Component sets on vector types unsupported");
460  UT_ASSERT_P(GAisValid(off));
462  if (myAlmostMatch)
463  myAlmostMatch->addVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<ALTTYPE>::FixedVectorType &>(val));
464  else if (myExactMatch)
465  myExactMatch->addVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<ALTTYPE>::FixedVectorType &>(val));
466  else
467  myAttrib->getData().addVector(off, reinterpret_cast<const typename UT_FixedVectorTraits<ALTTYPE>::FixedVectorType &>(val));
468  }
469 
470  /// Copies attribute values from the source array into a contiguous
471  /// block of offsets.
472  /// NOTE: The block of offsets is assumed to have no holes, else
473  /// data could be written to offsets that don't have
474  /// corresponding elements.
475  void setBlock(GA_Offset startoff, GA_Size nelements, const T *source, int sourcestride = 1, int component = 0) const;
476 
477  void setBlockFromIndices(GA_Index startidx, GA_Size nelements, const T *source, int sourcestride = 1, int component = 0) const;
478 
479  void makeConstant(const T &cval) const
480  {
482  myAttrib->getAIFTuple()->makeConstant(myAttrib, &cval.data()[0], sizeof(T)/sizeof(BASETYPE), 0);
483  }
484 
485  /// Sets all components of all elements of the specified page to
486  /// the given values.
487  /// NOTE: The length of values must be equal to the tuple size.
488  void setPageConstant(GA_PageNum pagenum, const BASETYPE *values) const
489  {
490  if (myExactMatch)
491  myExactMatch->setPageConstant(pagenum, values);
492  else if (myAlmostMatch)
493  myAlmostMatch->setPageConstant(pagenum, values);
494  else
495  myAttrib->getData().setPageConstant(pagenum, values);
496  }
497 
499  {
500  return myAttrib;
501  }
502 
503 private:
504  void setOutlinePart(GA_Offset off, const T &val) const;
505  void setAltOutlinePart(GA_Offset off, const ALTTYPE &val) const;
506  void addOutlinePart(GA_Offset off, const T &val) const;
507  void addAltOutlinePart(GA_Offset off, const ALTTYPE &val) const;
508 };
509 
510 /// Simplify checking for scalar types
511 #define SCALAR(T) SYS_EnableIf< SYS_IsArithmetic<T>::value >::type
512 
513 /// Read-only handle for scalar attribute data.
514 ///
515 /// @tparam T Return type for get methods
516 ///
517 template <typename T>
518 class GA_ROHandleT<T, typename SCALAR(T) >
519 {
520 public:
521  typedef T (*GAprobeAttribGetter)(const GA_Attribute *atr, GA_Offset, int);
522  typedef T BASETYPE;
523 
525  {
526  clear();
527  }
528  GA_ROHandleT(const GA_Attribute *attrib)
529  {
530  bind(attrib);
531  }
532  GA_ROHandleT(const GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1);
533 
534  void operator=(const GA_Attribute *attrib)
535  {
536  bind(attrib);
537  }
538 
539  void bind(const GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1);
540 
542  void bind(const GA_Attribute *attrib, int minsize=1)
543  {
544  bind(GA_ATINumeric::cast(attrib), minsize);
545  }
546  void bind(const GA_ATINumeric *attrib, int minsize=1)
547  {
548  myExactMatch = nullptr;
549  myAlmostMatch = nullptr;
550  myAttrib = SYSconst_cast(attrib);
551  if (!myAttrib)
552  return;
553 
554  int actual_tuple_size = myAttrib->getTupleSize();
555  if (actual_tuple_size < minsize)
556  {
557  myAttrib = nullptr;
558  return;
559  }
560 
561  UT_Storage actual_storage = attrib->getData().Base::getStorage();
562  if (actual_storage == UT_StorageNum<BASETYPE>::theStorage)
563  {
564  if (actual_tuple_size == 1)
565  myExactMatch = &myAttrib->getData().castType<BASETYPE>().template castTupleSize<1>();
566  else
568  }
569  }
570 
571  const GA_ATINumeric *getAttribute() const { return myAttrib; }
572  int getTupleSize() const { return myAttrib->getTupleSize(); }
573 
575  {
576  if (myAttrib)
577  return myAttrib->getDataId();
578  return GA_INVALID_DATAID;
579  }
580 
581  // Check whether the attribute is GA_TYPE_HPOINT
582  bool isRational() const
583  { return myAttrib->getTypeInfo() == GA_TYPE_HPOINT; }
584 
585  void clear()
586  {
587  myAttrib = nullptr;
588  myExactMatch = nullptr;
589  myAlmostMatch = nullptr;
590  }
591 
593  {
594  return myAttrib;
595  }
597  {
598  return !myAttrib;
599  }
600 
601  SYS_FORCE_INLINE T get(GA_Offset off, int comp = 0) const
602  {
604  UT_ASSERT_P(GAisValid(off));
606  UT_ASSERT_P(comp >= 0 && comp < myAttrib->getTupleSize());
607  if (myExactMatch)
608  {
609  UT_ASSERT_P(comp == 0);
610  return myExactMatch->template get<T>(off);
611  }
612  return getNotInline(off, comp);
613  }
614 private:
615  T getNotInline(GA_Offset off, int comp) const
616  {
617  if (myAlmostMatch)
618  return myAlmostMatch->template get<T>(off, comp);
619  return getOutline(off, comp);
620  }
621 
622  T getOutline(GA_Offset off, int comp) const;
623 
624 public:
625  SYS_FORCE_INLINE void getV(GA_Offset off, T *data, int size) const
626  {
628  UT_ASSERT_P(size >= 0 && size <= myAttrib->getTupleSize());
629  if (myExactMatch)
630  {
631  UT_ASSERT_P(size<=1);
632  if (size==1)
633  data[0] = myExactMatch->template get<T>(off);
634  }
635  else if (myAlmostMatch)
636  {
637  for (int comp = 0; comp < size; ++comp)
638  data[comp] = myAlmostMatch->template get<T>(off, comp);
639  }
640  else
641  {
642  auto &src = myAttrib->getData();
643  for (int comp = 0; comp < size; ++comp)
644  data[comp] = src.get<T>(off, comp);
645  }
646  }
647 
648  /// Copies attribute values from a contiguous block of offsets
649  /// into the dest array.
650  /// NOTE: The block of offsets is assumed to have no holes, else
651  /// data could be read from offsets that don't have
652  /// corresponding elements.
653  void getBlock(GA_Offset startoff, GA_Size nelements, T *dest, int deststride = 1, int component = 0) const;
654 
655  /// Copies attribute values from a contiguous block of indices
656  /// into the dest array.
657  /// This allows there to be holes in the geometry.
658  void getBlockFromIndices(GA_Index startidx, GA_Size nelements, T *dest, int deststride = 1, int component = 0) const;
659 
660  SYS_FORCE_INLINE T operator()(GA_Offset off, int comp = 0) const
661  {
662  return get(off, comp);
663  }
665  {
666  return get(off);
667  }
668  /// Returns true iff the specified page is constant-compressed,
669  /// where a single value is stored to represent GA_PAGE_SIZE
670  /// values in the page, (or possibly fewer if only one page).
672  {
673  return myAttrib->isPageConstant(pagenum);
674  }
675  bool operator==(const GA_ROHandleT<T> &handle) const
676  {
677  return myAttrib == handle.myAttrib;
678  }
679  bool operator!=(const GA_ROHandleT<T> &handle) const
680  {
681  return myAttrib != handle.myAttrib;
682  }
683  const GA_ATINumeric *operator->() const
684  {
685  return myAttrib;
686  }
687 
688 protected:
692 };
693 
694 /// Read-write handle for scalar attribute data.
695 ///
696 /// @tparam T Return type for get methods
697 ///
698 template <typename T>
699 class GA_RWHandleT<T, typename SCALAR(T) > : public GA_ROHandleT<T, typename SCALAR(T) >
700 {
701 public:
704  typedef T BASETYPE;
705 private:
706  using Base::myAttrib;
707  using Base::myExactMatch;
708  using Base::myAlmostMatch;
709 public:
710 
712  {
713  clear();
714  }
716  {
717  bind(attrib);
718  }
719  GA_RWHandleT(GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1);
720 
721  void operator=(GA_Attribute *attrib)
722  {
723  bind(attrib);
724  }
725 
726  void bind(GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1);
727 
729  void bind(GA_Attribute *attrib, int minsize=1)
730  {
731  bind(GA_ATINumeric::cast(attrib), minsize);
732  }
733  void bind(GA_ATINumeric *attrib, int minsize=1)
734  {
735  Base::bind(attrib, minsize);
736  }
737 
738  using Base::clear;
739 
740  GA_ATINumeric *getAttribute() const { return myAttrib; }
741 
742  void bumpDataId() const
743  {
744  if (myAttrib)
745  myAttrib->bumpDataId();
746  }
747 
749  {
750  if (myAttrib)
751  return myAttrib->getDataId();
752  return GA_INVALID_DATAID;
753  }
754 
755  SYS_FORCE_INLINE void set(GA_Offset off, T val) const
756  {
758  UT_ASSERT_P(GAisValid(off));
760  if (myExactMatch)
761  myExactMatch->set(off, val);
762  else if (myAlmostMatch)
763  myAlmostMatch->set(off, val);
764  else
765  setOutline(off, val);
766  }
767 
768  SYS_FORCE_INLINE void add(GA_Offset off, T val) const
769  {
771  UT_ASSERT_P(GAisValid(off));
773  if (myExactMatch)
774  myExactMatch->add(off, val);
775  else if (myAlmostMatch)
776  myAlmostMatch->add(off, val);
777  else
778  addOutline(off, val);
779  }
780 
781  SYS_FORCE_INLINE void set(GA_Offset off, int comp, T val) const
782  {
783  UT_ASSERT_P(myAttrib != nullptr);
784  UT_ASSERT_P(comp >= 0 && comp < myAttrib->getTupleSize());
785  UT_ASSERT_P(GAisValid(off));
787  if (myExactMatch)
788  myExactMatch->set(off, comp, val);
789  else if (myAlmostMatch)
790  myAlmostMatch->set(off, comp, val);
791  else
792  setOutline(off, comp, val);
793  }
794  SYS_FORCE_INLINE void setV(GA_Offset off, const T *data, int size) const
795  {
797  UT_ASSERT_P(size >= 0 && size <= myAttrib->getTupleSize());
798  if (myExactMatch)
799  {
800  UT_ASSERT_P(size<=1);
801  if (size==1)
802  myExactMatch->set(off, data[0]);
803  }
804  else if (myAlmostMatch)
805  {
806  for (int comp = 0; comp < size; ++comp)
807  myAlmostMatch->set(off, comp, data[comp]);
808  }
809  else
810  {
811  auto &src = myAttrib->getData();
812  for (int comp = 0; comp < size; ++comp)
813  src.set(off, comp, data[comp]);
814  }
815  }
816 
817  SYS_FORCE_INLINE void add(GA_Offset off, int comp, T val) const
818  {
819  UT_ASSERT_P(myAttrib != nullptr);
820  UT_ASSERT_P(comp >= 0 && comp < myAttrib->getTupleSize());
821  UT_ASSERT_P(GAisValid(off));
823  if (myExactMatch)
824  myExactMatch->add(off, comp, val);
825  else if (myAlmostMatch)
826  myAlmostMatch->add(off, comp, val);
827  else
828  addOutline(off, comp, val);
829  }
830 
831  /// Copies attribute values from the source array into a contiguous
832  /// block of offsets.
833  /// NOTE: The block of offsets is assumed to have no holes, else
834  /// data could be written to offsets that don't have
835  /// corresponding elements.
836  void setBlock(GA_Offset startoff, GA_Size nelements, const T *source, int sourcestride=1, int component=0) const;
837 
838  void setBlockFromIndices(GA_Index startidx, GA_Size nelements, const T *source, int sourcestride = 1, int component = 0) const;
839 
840  // -1 comp means to set all components to cval.
841  void makeConstant(T cval, int comp = -1) const
842  {
844  myAttrib->getAIFTuple()->makeConstant(myAttrib, cval, comp);
845  }
846  void makeConstantV(const T *cval, int size) const
847  {
849  myAttrib->getAIFTuple()->makeConstant(myAttrib, cval, size, 0);
850  }
851  /// Sets all components of all elements of the specified page to
852  /// the given values.
853  /// NOTE: The length of values must be equal to the tuple size.
854  void setPageConstant(GA_PageNum pagenum, const T *values) const
855  {
856  if (myExactMatch)
857  myExactMatch->setPageConstant(pagenum, values);
858  else if (myAlmostMatch)
859  myAlmostMatch->setPageConstant(pagenum, values);
860  else
861  myAttrib->getData().setPageConstant(pagenum, values);
862  }
863 
865  {
866  return myAttrib;
867  }
868 
869 private:
870  void setOutline(GA_Offset off, T val) const;
871  void setOutline(GA_Offset off, int comp, T val) const;
872  void addOutline(GA_Offset off, T val) const;
873  void addOutline(GA_Offset off, int comp, T val) const;
874 };
875 
876 #undef SCALAR
877 
878 /// Read-only handle for string attribute data.
879 template <typename HOLDER, typename INDEXTYPE, typename ATI>
881 {
882 public:
884  {
885  clear();
886  }
888  {
889  bind(attrib);
890  }
892  const UT_StringRef &name, int minsize=1);
893  void operator=(const GA_Attribute *attrib)
894  {
895  bind(attrib);
896  }
897  void bind(const GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1);
898 
899  /// Bind the handle to the given attribute
900  void bind(const GA_Attribute *attrib, int minsize=1)
901  {
902  myAttrib = ATI::cast(attrib);
903  if (myAttrib && myAttrib->getTupleSize() < minsize)
904  {
905  myAttrib = nullptr;
906  }
907  }
908 
909  /// Access to attribute
910  const GA_Attribute *getAttribute() const { return myAttrib; }
911  /// Tuple size of the attribute
912  int getTupleSize() const { return myAttrib->getTupleSize(); }
913 
915  {
916  if (myAttrib)
917  return myAttrib->getDataId();
918  return GA_INVALID_DATAID;
919  }
920 
921 
922  /// Clear the handle
923  void clear() { myAttrib = 0; }
924 
925  /// @{
926  /// Validity checks
927  SYS_FORCE_INLINE bool isValid() const { return myAttrib; }
928  SYS_FORCE_INLINE bool isInvalid() const { return !myAttrib; }
929  /// @}
930 
931  /// Get the string at the given offset
932  SYS_FORCE_INLINE const HOLDER &get(GA_Offset off, int comp = 0) const
933  {
935  UT_ASSERT_P(GAisValid(off));
936  UT_ASSERT_P(myAttrib->getIndexMap().isOffsetActive(off) || myAttrib->getIndexMap().isOffsetTransient(off));
937  return myAttrib->getHolder(off, comp);
938  }
939  /// Get the string index at the given offset
940  SYS_FORCE_INLINE INDEXTYPE getIndex(GA_Offset off, int comp = 0) const
941  {
943  UT_ASSERT_P(GAisValid(off));
944  UT_ASSERT_P(myAttrib->getIndexMap().isOffsetActive(off) || myAttrib->getIndexMap().isOffsetTransient(off));
945  return myAttrib->getHolderIndex(off, comp);
946  }
947  const ATI *operator->() const
948  {
949  return myAttrib;
950  }
951 
952  /// Copies attribute string indices from a contiguous block of offsets
953  /// into the dest array.
954  /// NOTE: The block of offsets is assumed to have no holes, else
955  /// data could be read from offsets that don't have
956  /// corresponding elements.
957  void getIndexBlock(GA_Offset startoff, GA_Size nelements, INDEXTYPE *dest, int deststride = 1, int component = 0) const;
958 
959  /// Copies attribute string indices from a contiguous block of indices
960  /// into the dest array.
961  /// This allows there to be holes in the geometry. The dest array
962  /// will be densely filled as per the index mapping.
963  void getIndexBlockFromIndices(GA_Index startidx, GA_Size nelements, INDEXTYPE *dest, int deststride = 1, int component = 0) const;
964 
965 
966 protected:
967  const ATI *myAttrib;
968 };
969 
970 /// Read-Write string handle
971 template <typename HOLDER, typename INDEXTYPE, typename ATI>
972 class GA_RWHandleTHolder : public GA_ROHandleTHolder<HOLDER, INDEXTYPE, ATI>
973 {
974 public:
976 
977 private:
978  using Base::myAttrib;
979 public:
980 
982  : Base()
983  {
984  }
986  : Base(attrib)
987  {
988  }
990  const UT_StringRef &name, int minsize=1)
991  : Base(gdp, owner, name, minsize)
992  {
993  }
994  void operator=(GA_Attribute *attrib)
995  {
996  Base::bind(attrib);
997  }
998 
999  GA_Attribute *getAttribute() const { return rwAttrib(); }
1000 
1001  void bumpDataId() const
1002  {
1003  if (rwAttrib())
1004  rwAttrib()->bumpDataId();
1005  }
1006 
1008  {
1009  if (rwAttrib())
1010  return rwAttrib()->getDataId();
1011  return GA_INVALID_DATAID;
1012  }
1013 
1014  /// Store the @c str at the given offset
1015  SYS_FORCE_INLINE void set(GA_Offset off, const HOLDER &str) const
1016  {
1017  set(off, 0, str);
1018  }
1019  SYS_FORCE_INLINE void set(GA_Offset off, int comp, const HOLDER &str) const
1020  {
1021  UT_ASSERT_P(rwAttrib() != nullptr);
1022  UT_ASSERT_P(GAisValid(off));
1023  UT_ASSERT_P(rwAttrib()->getIndexMap().isOffsetActive(off) || rwAttrib()->getIndexMap().isOffsetTransient(off));
1024  rwAttrib()->setHolder(off, str, comp);
1025  }
1026  /// Store the string indexed by the @c idx at the given offset
1027  SYS_FORCE_INLINE void set(GA_Offset off, INDEXTYPE idx) const
1028  {
1029  set(off, 0, idx);
1030  }
1031  SYS_FORCE_INLINE void set(GA_Offset off, int comp, INDEXTYPE idx) const
1032  {
1033  UT_ASSERT_P(rwAttrib() != nullptr);
1034  UT_ASSERT_P(GAisValid(off));
1035  UT_ASSERT_P(rwAttrib()->getIndexMap().isOffsetActive(off) || rwAttrib()->getIndexMap().isOffsetTransient(off));
1036  rwAttrib()->setHolderIndex(off, idx, comp);
1037  }
1038  ATI *operator->() const
1039  {
1040  return rwAttrib();
1041  }
1042 protected:
1043  ATI *rwAttrib() const
1044  { return SYSconst_cast(myAttrib); }
1045 };
1046 
1047 /// Read-Write string handle
1048 /// Batches all reference counts until a flush() or its destructor.
1049 /// Because it tracks this locally, you MUST create a separate one
1050 /// per thread! (Even if this were made thread safe, that would
1051 /// defeat the purpose of this, which is to use thread-local reference
1052 /// counts to avoid write contention)
1053 /// NOTE: This bumps the data ID of any attribute it's bound to
1054 /// upon destruction.
1055 template <typename HOLDER, typename INDEXTYPE, typename ATI, typename DELAYEDWRITER>
1057 {
1058 public:
1060  {
1061  clear();
1062  }
1064  {
1065  bind(attrib);
1066  }
1068  const UT_StringRef &name, int minsize=1);
1069  void operator=(GA_Attribute *attrib)
1070  {
1071  bind(attrib);
1072  }
1073  void bind(GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1);
1074 
1075  /// Bind the handle to the given attribute
1076  void bind(GA_Attribute *attrib, int minsize=1)
1077  {
1078  myAttrib = ATI::cast(attrib);
1079  if (myAttrib && myAttrib->getTupleSize() < minsize)
1080  {
1081  myAttrib = nullptr;
1082  }
1083  myWriter.bind(myAttrib);
1084  }
1085 
1086  /// Access to attribute
1087  GA_Attribute *getAttribute() const { return myAttrib; }
1088  /// Tuple size of the attribute
1089  int getTupleSize() const { return myAttrib->getTupleSize(); }
1091  {
1092  if (myAttrib)
1093  return myAttrib->getDataId();
1094  return GA_INVALID_DATAID;
1095  }
1096 
1097  /// Clear the handle
1098  void clear()
1099  {
1100  myAttrib = 0;
1101  myWriter.bind(myAttrib); // Also flushes.
1102  }
1103 
1104  /// @{
1105  /// Validity checks
1106  SYS_FORCE_INLINE bool isValid() const { return myAttrib; }
1107  SYS_FORCE_INLINE bool isInvalid() const { return !myAttrib; }
1108  /// @}
1109 
1110  /// Get the string at the given offset
1111  SYS_FORCE_INLINE HOLDER get(GA_Offset off, int comp = 0) const
1112  {
1114  UT_ASSERT_P(GAisValid(off));
1115  UT_ASSERT_P(myAttrib->getIndexMap().isOffsetActive(off) || myAttrib->getIndexMap().isOffsetTransient(off));
1116  return myAttrib->getHolder(off, comp);
1117  }
1118  /// Get the string index at the given offset
1119  SYS_FORCE_INLINE INDEXTYPE getIndex(GA_Offset off, int comp = 0) const
1120  {
1122  UT_ASSERT_P(GAisValid(off));
1123  UT_ASSERT_P(myAttrib->getIndexMap().isOffsetActive(off) || myAttrib->getIndexMap().isOffsetTransient(off));
1124  return myAttrib->getHolderIndex(off, comp);
1125  }
1126 
1127  /// Store the @c str at the given offset
1128  SYS_FORCE_INLINE void set(GA_Offset off, const HOLDER &str)
1129  {
1130  set(off, 0, str);
1131  }
1132  SYS_FORCE_INLINE void set(const GA_Range &range, const HOLDER &str)
1133  {
1134  set(range, 0, str);
1135  }
1136  SYS_FORCE_INLINE void set(GA_Offset off, int comp, const HOLDER &str)
1137  {
1139  UT_ASSERT_P(GAisValid(off));
1140  UT_ASSERT_P(myAttrib->getIndexMap().isOffsetActive(off) || myAttrib->getIndexMap().isOffsetTransient(off));
1141  myWriter.setHolder(off, str, comp);
1142  }
1143  SYS_FORCE_INLINE void set(const GA_Range &range, int comp, const HOLDER &str)
1144  {
1145  myWriter.setHolder(range, str, comp);
1146  }
1147  /// Store the string indexed by the @c idx at the given offset
1148  SYS_FORCE_INLINE void set(GA_Offset off, INDEXTYPE idx)
1149  {
1150  set(off, 0, idx);
1151  }
1152  SYS_FORCE_INLINE void set(const GA_Range &range, INDEXTYPE idx)
1153  {
1154  set(range, 0, idx);
1155  }
1156  SYS_FORCE_INLINE void set(GA_Offset off, int comp, INDEXTYPE idx)
1157  {
1159  UT_ASSERT_P(GAisValid(off));
1160  UT_ASSERT_P(myAttrib->getIndexMap().isOffsetActive(off) || myAttrib->getIndexMap().isOffsetTransient(off));
1161  myWriter.setHolderIndex(off, idx, comp);
1162  }
1163  SYS_FORCE_INLINE void set(const GA_Range &range, int comp, INDEXTYPE idx)
1164  {
1165  myWriter.setStringIndex(range, idx, comp);
1166  }
1167 
1169  {
1170  return myWriter.hasChanges();
1171  }
1172 protected:
1173  ATI *myAttrib;
1174  DELAYEDWRITER myWriter;
1175 };
1176 
1177 namespace GA_HandleDetail
1178 {
1179 // Helper for determining AIF type given the array type T
1180 template <typename T> struct ArrayAIF;
1181 template <> struct ArrayAIF<UT_Uint8Array> { typedef GA_AIFNumericArray type; };
1182 template <> struct ArrayAIF<UT_Int8Array> { typedef GA_AIFNumericArray type; };
1183 template <> struct ArrayAIF<UT_Int16Array> { typedef GA_AIFNumericArray type; };
1184 template <> struct ArrayAIF<UT_Int32Array> { typedef GA_AIFNumericArray type; };
1185 template <> struct ArrayAIF<UT_Int64Array> { typedef GA_AIFNumericArray type; };
1186 template <> struct ArrayAIF<UT_ValArray<fpreal16>> { typedef GA_AIFNumericArray type; };
1187 template <> struct ArrayAIF<UT_Fpreal32Array> { typedef GA_AIFNumericArray type; };
1188 template <> struct ArrayAIF<UT_Fpreal64Array> { typedef GA_AIFNumericArray type; };
1189 template <> struct ArrayAIF<UT_StringArray> { typedef GA_AIFSharedStringArray type; };
1191 // Helper for determining if we have an acceptable array type
1192 template <typename T> struct IsArray { static const bool value = false; };
1193 template <> struct IsArray<UT_Uint8Array> { static const bool value = true; };
1194 template <> struct IsArray<UT_Int8Array> { static const bool value = true; };
1195 template <> struct IsArray<UT_Int16Array> { static const bool value = true; };
1196 template <> struct IsArray<UT_Int32Array> { static const bool value = true; };
1197 template <> struct IsArray<UT_Int64Array> { static const bool value = true; };
1198 template <> struct IsArray<UT_ValArray<fpreal16>> { static const bool value = true; };
1199 template <> struct IsArray<UT_Fpreal32Array> { static const bool value = true; };
1200 template <> struct IsArray<UT_Fpreal64Array> { static const bool value = true; };
1201 template <> struct IsArray<UT_StringArray> { static const bool value = true; };
1202 template <> struct IsArray<UT_Array<UT_OptionsHolder>> { static const bool value = true; };
1203 }
1204 
1205 #define ENABLE_ARRAY(T) SYS_EnableIf< GA_HandleDetail::IsArray<T>::value >::type
1206 
1207 /// Read-only handle for array attribute data
1208 template <typename T>
1209 class GA_ROHandleT<T, typename ENABLE_ARRAY(T)>
1210 {
1211 public:
1213 
1215  {
1216  clear();
1217  }
1219  {
1220  bind(attrib);
1221  }
1222  GA_ROHandleT(const GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1);
1223 
1224  void operator=(const GA_Attribute *attrib)
1225  {
1226  bind(attrib);
1227  }
1228 
1229  void bind(const GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1);
1230  void bind(const GA_Attribute *attrib, int minsize=1)
1231  {
1232  myAttrib = const_cast<GA_Attribute *>(attrib);
1233  if (!myAttrib)
1234  return;
1235  myAIF = myAttrib->getAIF<AIFType>();
1236  if (!myAIF)
1237  myAttrib = nullptr;
1238  }
1239 
1240  const GA_Attribute *getAttribute() const { return myAttrib; }
1241 
1242  void clear()
1243  {
1244  myAttrib = nullptr;
1245  myAIF = nullptr;
1246  }
1247 
1248  SYS_FORCE_INLINE bool isValid() const { return myAttrib; }
1249  SYS_FORCE_INLINE bool isInvalid() const { return !myAttrib; }
1250 
1251  SYS_FORCE_INLINE void get(GA_Offset off, T &value) const
1252  {
1254  UT_ASSERT_P(GAisValid(off));
1256  myAIF->get(myAttrib, off, value);
1257  }
1258 
1259  bool operator==(const GA_ROHandleT<T> &handle) const
1260  {
1261  UT_ASSERT_P(myAIF == handle.myAIF);
1262  return myAttrib == handle.myAttrib;
1263  }
1264  bool operator!=(const GA_ROHandleT<T> &handle) const
1265  {
1266  UT_ASSERT_P(myAIF == handle.myAIF);
1267  return myAttrib != handle.myAttrib;
1268  }
1269  const GA_Attribute *operator->() const
1270  {
1271  return myAttrib;
1272  }
1273 
1274 protected:
1276  const AIFType* myAIF;
1277 };
1278 
1279 /// Read-Write handle for array attribute data
1280 template <typename T>
1281 class GA_RWHandleT<T, typename ENABLE_ARRAY(T)>
1282  : public GA_ROHandleT<T, typename ENABLE_ARRAY(T)>
1283 {
1284 public:
1286 
1287 private:
1288  using Base::myAttrib;
1289 public:
1290 
1292  {
1293  this->clear();
1294  }
1296  {
1297  bind(attrib);
1298  }
1299  GA_RWHandleT(GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1);
1300 
1301  void operator=(GA_Attribute *attrib)
1302  {
1303  bind(attrib);
1304  }
1305 
1306  void bind(GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1);
1307  void bind(GA_Attribute *attrib, int minsize=1)
1308  {
1309  Base::bind(attrib, minsize);
1310  }
1311 
1313 
1314  void bumpDataId() const
1315  {
1316  if (myAttrib)
1317  myAttrib->bumpDataId();
1318  }
1319 
1321  {
1322  if (myAttrib)
1323  return myAttrib->getDataId();
1324  return GA_INVALID_DATAID;
1325  }
1326 
1327  SYS_FORCE_INLINE void set(GA_Offset off, const T &value) const
1328  {
1330  UT_ASSERT_P(GAisValid(off));
1332  Base::myAIF->set(myAttrib, off, value);
1333  }
1335  {
1336  return myAttrib;
1337  }
1338 
1339 private:
1340 };
1341 
1342 #undef ENABLE_ARRAY
1343 
1344 template <typename T>
1346 {
1347 public:
1350 };
1351 
1355 
1359 
1360 // Hacky workaround for now
1361 template <>
1362 class GA_HandleT<const char*>
1363 {
1364 public:
1365  typedef GA_ROHandleS ROType;
1366  typedef GA_RWHandleS RWType;
1367 };
1368 
1371 
1374 
1377 
1380 
1383 
1386 
1389 
1392 
1395 
1398 
1401 
1404 
1407 
1410 
1413 
1416 
1419 
1422 
1425 
1428 
1431 
1434 
1437 
1440 
1443 
1446 
1449 
1452 
1453 #endif
GA_RWHandleT(GA_Attribute *attrib)
Definition: GA_Handle.h:321
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:854
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:479
GA_RWHandleT< UT_Int32Array > GA_RWHandleIA
Definition: GA_Handle.h:1436
GA_ATINumeric * operator->() const
Definition: GA_Handle.h:498
void SecondGuess
Definition: UT_Storage.h:91
GA_RWBatchHandleTHolder(GA_Attribute *attrib)
Definition: GA_Handle.h:1063
UT_FixedVector< ALTBASETYPE, theTupleSize > ALTTYPE
Definition: GA_Handle.h:315
GA_RWHandleT< UT_Vector2D > GA_RWHandleV2D
Definition: GA_Handle.h:1424
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:1027
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:690
GA_ROHandleT< UT_StringArray > GA_ROHandleSA
Definition: GA_Handle.h:1447
UT_Storage
Definition: UT_Storage.h:28
SYS_FORCE_INLINE bool isPageConstant(GA_PageNum pagenum) const
Definition: GA_Handle.h:671
GA_RWHandleTHolder(GA_Attribute *attrib)
Definition: GA_Handle.h:985
GA_ROHandleT< int8 > GA_ROHandleC
Definition: GA_Handle.h:1381
void bind(const GA_Attribute *attrib, int minsize=1)
Definition: GA_Handle.h:1230
GA_RWHandleT< UT_FprealArray > GA_RWHandleRA
Definition: GA_Handle.h:1433
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:1357
GA_ROHandleT< UT_Vector4D > GA_ROHandleV4D
Definition: GA_Handle.h:1429
SYS_FORCE_INLINE void bind(const GA_Attribute *attrib, int minsize=1)
Definition: GA_Handle.h:542
const DataType & getData() const
int64 GA_DataId
Definition: GA_Types.h:696
#define ENABLE_ARRAY(T)
Definition: GA_Handle.h:1205
SYS_FORCE_INLINE bool isInvalid() const
Definition: GA_Handle.h:1249
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:846
SYS_FORCE_INLINE void set(GA_Offset off, int comp, const T &val) const
Definition: GA_Handle.h:388
SYS_FORCE_INLINE const GA_IndexMap & getIndexMap() const
Definition: GA_Attribute.h:207
GA_RWHandleT< UT_QuaternionD > GA_RWHandleQD
Definition: GA_Handle.h:1421
void clear()
Clear the handle.
Definition: GA_Handle.h:1098
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:923
GA_PageArray< BASETYPE, theTupleSize > * myExactMatch
Definition: GA_Handle.h:292
GLuint start
Definition: glcorearb.h:475
GLsizei const GLfloat * value
Definition: glcorearb.h:824
void bind(GA_Attribute *attrib, int minsize=1)
Definition: GA_Handle.h:1307
GA_RWHandleT< fpreal > GA_RWHandleR
Definition: GA_Handle.h:1370
GA_DataId getDataId() const
Definition: GA_Handle.h:914
int getTupleSize() const
const GA_Attribute * getAttribute() const
Access to attribute.
Definition: GA_Handle.h:910
GA_RWHandleT< UT_Int64Array > GA_RWHandleIDA
Definition: GA_Handle.h:1439
GA_ROHandleT< UT_Vector4F > GA_ROHandleV4
Definition: GA_Handle.h:1405
GA_ROHandleT< UT_Vector2F > GA_ROHandleV2
Definition: GA_Handle.h:1399
SYS_FORCE_INLINE T * SYSconst_cast(const T *foo)
Definition: SYS_Types.h:136
SYS_FORCE_INLINE bool isValid() const
Definition: GA_Handle.h:1106
GA_ROHandleTHolder< UT_OptionsHolder, GA_DictIndexType, GA_ATIDict > GA_ROHandleDict
Definition: GA_Handle.h:1356
GA_ROHandleT< UT_Array< UT_OptionsHolder > > GA_ROHandleDictA
Definition: GA_Handle.h:1450
SYS_FORCE_INLINE void add(IDX_T i, SRC_DATA_T v)
component == 0 in this version
Definition: UT_PageArray.h:592
Read-Write string handle.
Definition: GA_Handle.h:972
SYS_FORCE_INLINE void setAlt(GA_Offset off, const ALTTYPE &val) const
Definition: GA_Handle.h:375
SYS_FORCE_INLINE void addAlt(GA_Offset off, const ALTTYPE &val) const
Definition: GA_Handle.h:429
int64 exint
Definition: SYS_Types.h:125
SYS_FORCE_INLINE bool isValid() const
Definition: GA_Handle.h:927
SYS_FORCE_INLINE DEST_DATA_T get(IDX_T i, exint component=0) const
Definition: UT_PageArray.h:487
GA_ATINumeric * operator->() const
Definition: GA_Handle.h:864
GA_ROHandleT< UT_Vector3D > GA_ROHandleV3D
Definition: GA_Handle.h:1426
void operator=(GA_Attribute *attrib)
Definition: GA_Handle.h:1301
bool operator==(const GA_ROHandleT< T > &handle) const
Definition: GA_Handle.h:278
GA_ROHandleT(const GA_Attribute *attrib)
Definition: GA_Handle.h:528
SYS_FORCE_INLINE void bind(GA_Attribute *attrib, int minsize=1)
Definition: GA_Handle.h:335
GA_ATINumeric * getAttribute() const
Definition: GA_Handle.h:740
GA_ROHandleT< UT_Matrix4D > GA_ROHandleM4D
Definition: GA_Handle.h:1417
GA_RWHandleT< int64 > GA_RWHandleID
Definition: GA_Handle.h:1409
void setPageConstant(GA_PageNum pagenum, const BASETYPE *values) const
Definition: GA_Handle.h:488
SYS_FORCE_INLINE void set(GA_Offset off, T val) const
Definition: GA_Handle.h:755
GA_RWHandleT< UT_Vector4D > GA_RWHandleV4D
Definition: GA_Handle.h:1430
SYS_FORCE_INLINE INDEXTYPE getIndex(GA_Offset off, int comp=0) const
Get the string index at the given offset.
Definition: GA_Handle.h:940
**But if you need a result
Definition: thread.h:622
int getTupleSize() const
Tuple size of the attribute.
Definition: GA_Handle.h:1089
ATI * operator->() const
Definition: GA_Handle.h:1038
#define GA_INVALID_DATAID
Definition: GA_Types.h:697
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:1163
void operator=(GA_Attribute *attrib)
Definition: GA_Handle.h:721
SYS_FORCE_INLINE void addAlt(GA_Offset off, int comp, const ALTTYPE &val) const
Definition: GA_Handle.h:456
GA_ROHandleT< int64 > GA_ROHandleID
Definition: GA_Handle.h:1408
SYS_FORCE_INLINE void set(IDX_T i, SRC_DATA_T v)
component == 0 in this version
Definition: UT_PageArray.h:586
const ATI * myAttrib
Definition: GA_Handle.h:967
SYS_FORCE_INLINE bool GAisValid(GA_Size v)
Definition: GA_Types.h:655
SYS_FORCE_INLINE void bind(GA_ATINumeric *attrib, int minsize=1)
Definition: GA_Handle.h:340
SYS_FORCE_INLINE void set(GA_Offset off, int comp, const HOLDER &str)
Definition: GA_Handle.h:1136
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:236
GA_ATINumeric * getAttribute() const
Definition: GA_Handle.h:347
GA_ROHandleTHolder< HOLDER, INDEXTYPE, ATI > Base
Definition: GA_Handle.h:975
const GA_Attribute * getAttribute() const
Definition: GA_Handle.h:1240
GA_ROHandleT< UT_Vector3F > GA_ROHandleV3
Definition: GA_Handle.h:1402
SYS_FORCE_INLINE bool isValid() const
Definition: GA_Handle.h:1248
GA_DataId getDataId() const
Definition: GA_Handle.h:1007
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:1414
SYS_FORCE_INLINE void getV(GA_Offset off, T *data, int size) const
Definition: GA_Handle.h:625
GA_ROHandleT< UT_Matrix2F > GA_ROHandleM2
Definition: GA_Handle.h:1387
GA_RWHandleT< UT_Vector3F > GA_RWHandleV3
Definition: GA_Handle.h:1403
const GA_ATINumeric * getAttribute() const
Definition: GA_Handle.h:166
GA_Size GA_Offset
Definition: GA_Types.h:646
GA_RWBatchHandleTHolder< UT_OptionsHolder, GA_DictIndexType, GA_ATIDict, GA_ATIDictDelayedWriter > GA_RWBatchHandleDict
Definition: GA_Handle.h:1358
GA_PageArray< BASETYPE > * myAlmostMatch
Definition: GA_Handle.h:691
void makeConstant(T cval, int comp=-1) const
Definition: GA_Handle.h:841
SYS_FORCE_INLINE bool isInvalid() const
Definition: GA_Handle.h:596
void bind(const GA_ATINumeric *attrib, int minsize=1)
Definition: GA_Handle.h:546
SYS_FORCE_INLINE void add(GA_Offset off, const T &val) const
Definition: GA_Handle.h:416
GA_ROHandleT< UT_Matrix3F > GA_ROHandleM3
Definition: GA_Handle.h:1390
GA_ROHandleT< int32 > GA_ROHandleI
Definition: GA_Handle.h:1384
GA_RWHandleT< UT_Fpreal64Array > GA_RWHandleDA
Definition: GA_Handle.h:1445
SYS_FORCE_INLINE void add(GA_Offset off, int comp, T val) const
Definition: GA_Handle.h:817
SYS_FORCE_INLINE void set(GA_Offset off, int comp, const HOLDER &str) const
Definition: GA_Handle.h:1019
GLintptr offset
Definition: glcorearb.h:665
SYS_FORCE_INLINE void set(GA_Offset off, int comp, T val) const
Definition: GA_Handle.h:781
GA_RWHandleTHolder< UT_StringHolder, GA_StringIndexType, GA_ATIString > GA_RWHandleS
Definition: GA_Handle.h:1353
SYS_FORCE_INLINE void add(GA_Offset off, T val) const
Definition: GA_Handle.h:768
const GA_AIFTuple * getAIFTuple() const override
Return the attribute's tuple interface or NULL.
SYS_FORCE_INLINE const X * cast(const InstancablePtr *o)
ATI * rwAttrib() const
Definition: GA_Handle.h:1043
T::value_type BASETYPE
Definition: GA_Handle.h:307
SYS_FORCE_INLINE void setV(GA_Offset off, const T *data, int size) const
Definition: GA_Handle.h:794
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:1442
bool isOffsetTransient(GA_Offset offset) const
SYS_FORCE_INLINE void set(GA_Offset off, int comp, INDEXTYPE idx) const
Definition: GA_Handle.h:1031
SYS_FORCE_INLINE void set(const GA_Range &range, INDEXTYPE idx)
Definition: GA_Handle.h:1152
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:994
GA_RWHandleT< UT_Vector4F > GA_RWHandleV4
Definition: GA_Handle.h:1406
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:155
GA_RWHandleT< UT_Matrix2F > GA_RWHandleM2
Definition: GA_Handle.h:1388
bool operator!=(const GA_ROHandleT< T > &handle) const
Definition: GA_Handle.h:1264
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:305
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:1375
SYS_FORCE_INLINE void set(GA_Offset off, const T &value) const
Definition: GA_Handle.h:1327
GA_ATINumeric * myAttrib
Definition: GA_Handle.h:291
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
const GA_ATINumeric * operator->() const
Definition: GA_Handle.h:683
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:1379
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:1076
GA_ROHandleT< UT_Fpreal64Array > GA_ROHandleDA
Definition: GA_Handle.h:1444
GA_RWHandleT< UT_Matrix4F > GA_RWHandleM4
Definition: GA_Handle.h:1394
bool operator!=(const GA_ROHandleT< T > &handle) const
Definition: GA_Handle.h:679
GA_RWHandleT< UT_Matrix3D > GA_RWHandleM3D
Definition: GA_Handle.h:1415
GA_RWHandleTHolder(const GA_Detail *gdp, GA_AttributeOwner owner, const UT_StringRef &name, int minsize=1)
Definition: GA_Handle.h:989
GA_ROHandleT< fpreal64 > GA_ROHandleD
Definition: GA_Handle.h:1378
GA_RWHandleT< T > RWType
Definition: GA_Handle.h:1349
const GA_Attribute * operator->() const
Definition: GA_Handle.h:1269
SYS_FORCE_INLINE T operator()(GA_Offset off, int comp=0) const
Definition: GA_Handle.h:660
GA_HandleDetail::ArrayAIF< T >::type AIFType
Definition: GA_Handle.h:1212
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:664
GA_DataId getDataId() const
Definition: GA_Handle.h:355
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:640
void bumpDataId() const
Definition: GA_Handle.h:349
GA_RWHandleT< fpreal16 > GA_RWHandleH
Definition: GA_Handle.h:1373
SYS_FORCE_INLINE void set(const GA_Range &range, const HOLDER &str)
Definition: GA_Handle.h:1132
Read-only handle for string attribute data.
Definition: GA_Handle.h:880
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:442
SYS_FORCE_INLINE void addVector(IDX_T i, const TS &as)
Definition: UT_PageArray.h:699
GA_ROHandleT< UT_Int32Array > GA_ROHandleIA
Definition: GA_Handle.h:1435
GA_ROHandleT< fpreal16 > GA_ROHandleH
Definition: GA_Handle.h:1372
GA_Attribute * getAttribute() const
Access to attribute.
Definition: GA_Handle.h:1087
const ATI * operator->() const
Definition: GA_Handle.h:947
SYS_FORCE_INLINE bool isValid() const
Definition: GA_Handle.h:187
void bumpDataId() const
Definition: GA_Handle.h:1001
SYS_FORCE_INLINE void set(GA_Offset off, int comp, INDEXTYPE idx)
Definition: GA_Handle.h:1156
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:35
GA_ROHandleTHolder(const GA_Attribute *attrib)
Definition: GA_Handle.h:887
bool operator==(const GA_ROHandleT< T > &handle) const
Definition: GA_Handle.h:675
GA_ROHandleT(const GA_Attribute *attrib)
Definition: GA_Handle.h:1218
GA_RWHandleT< UT_Vector2F > GA_RWHandleV2
Definition: GA_Handle.h:1400
#define SCALAR(T)
Simplify checking for scalar types.
Definition: GA_Handle.h:511
SYS_FORCE_INLINE bool isPageConstant(GA_PageNum pagenum) const
Definition: GA_Handle.h:274
GA_ROHandleT< fpreal > GA_ROHandleR
Definition: GA_Handle.h:1369
SYS_FORCE_INLINE void setAlt(GA_Offset off, int comp, const ALTTYPE &val) const
Definition: GA_Handle.h:402
void bind(const GA_Attribute *attrib, int minsize=1)
Bind the handle to the given attribute.
Definition: GA_Handle.h:900
GA_RWHandleT< UT_Matrix4D > GA_RWHandleM4D
Definition: GA_Handle.h:1418
GA_ROHandleT< UT_FprealArray > GA_ROHandleRA
Definition: GA_Handle.h:1432
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:1143
GA_ROHandleT< T > Base
Definition: GA_Handle.h:306
void operator=(const GA_Attribute *attrib)
Definition: GA_Handle.h:534
GA_ROHandleT< UT_Matrix4F > GA_ROHandleM4
Definition: GA_Handle.h:1393
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1602
GA_RWHandleT< UT_Vector3D > GA_RWHandleV3D
Definition: GA_Handle.h:1427
GA_ROHandleT< UT_QuaternionF > GA_ROHandleQ
Definition: GA_Handle.h:1396
GA_RWHandleT< UT_Array< UT_OptionsHolder > > GA_RWHandleDictA
Definition: GA_Handle.h:1451
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:362
void operator=(GA_Attribute *attrib)
Definition: GA_Handle.h:327
SYS_FORCE_INLINE void set(GA_Offset off, const HOLDER &str) const
Store the str at the given offset.
Definition: GA_Handle.h:1015
void operator=(const GA_Attribute *attrib)
Definition: GA_Handle.h:893
GA_Size GA_PageNum
Definition: GA_Types.h:649
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:1438
SYS_FORCE_INLINE bool isInvalid() const
Definition: GA_Handle.h:928
void bind(GA_ATINumeric *attrib, int minsize=1)
Definition: GA_Handle.h:733
SYS_FORCE_INLINE bool isValid() const
Definition: GA_Handle.h:592
A specialization of GA_AIFDictArray to access "shared strings".
void operator=(GA_Attribute *attrib)
Definition: GA_Handle.h:1069
GA_RWHandleT< fpreal32 > GA_RWHandleF
Definition: GA_Handle.h:1376
GA_RWHandleT< int8 > GA_RWHandleC
Definition: GA_Handle.h:1382
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:1348
GA_RWHandleT(GA_Attribute *attrib)
Definition: GA_Handle.h:715
GA_ROHandleT< UT_QuaternionD > GA_ROHandleQD
Definition: GA_Handle.h:1420
DELAYEDWRITER myWriter
Definition: GA_Handle.h:1174
GA_DataId getDataId() const
Definition: GA_Handle.h:1090
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:1354
SYS_FORCE_INLINE bool hasChanges() const
Definition: GA_Handle.h:1168
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:1411
SYS_FORCE_INLINE void set(GA_Offset off, const HOLDER &str)
Store the str at the given offset.
Definition: GA_Handle.h:1128
bool operator==(const GA_ROHandleT< T > &handle) const
Definition: GA_Handle.h:1259
GA_ROHandleTHolder< UT_StringHolder, GA_StringIndexType, GA_ATIString > GA_ROHandleS
Definition: GA_Handle.h:1352
int getTupleSize() const
Tuple size of the attribute.
Definition: GA_Handle.h:912
SYS_FORCE_INLINE void setVector(IDX_T i, const TS &as)
Definition: UT_PageArray.h:693
SYS_FORCE_INLINE bool isAltBound() const
Definition: GA_Handle.h:198
GA_RWHandleT< UT_QuaternionF > GA_RWHandleQ
Definition: GA_Handle.h:1397
GA_RWHandleT< int32 > GA_RWHandleI
Definition: GA_Handle.h:1385
typename UT_StorageNum< BASETYPE >::SecondGuess ALTBASETYPE
Definition: GA_Handle.h:115
SYS_FORCE_INLINE bool isInvalid() const
Definition: GA_Handle.h:1107
GA_ROHandleT< UT_Fpreal32Array > GA_ROHandleFA
Definition: GA_Handle.h:1441
UT_StringHolder & operator()(exint i)
Definition: UT_Array.h:774
GA_RWHandleT< UT_Matrix3F > GA_RWHandleM3
Definition: GA_Handle.h:1391
const GA_ATINumeric * operator->() const
Definition: GA_Handle.h:286
GA_PageArray< typename UT_StorageNum< BASETYPE >::SecondGuess, theTupleSize > * myAlmostMatch
Definition: GA_Handle.h:293
SYS_FORCE_INLINE T operator()(GA_Offset off) const
Definition: GA_Handle.h:263
SYS_FORCE_INLINE T operator[](GA_Offset off) const
Definition: GA_Handle.h:267
SYS_FORCE_INLINE void bind(GA_Attribute *attrib, int minsize=1)
Definition: GA_Handle.h:729
bool operator!=(const GA_ROHandleT< T > &handle) const
Definition: GA_Handle.h:282
GA_Attribute * getAttribute() const
Definition: GA_Handle.h:1312
GA_RWHandleT< UT_Matrix2D > GA_RWHandleM2D
Definition: GA_Handle.h:1412
Definition: format.h:1821
SYS_FORCE_INLINE INDEXTYPE getIndex(GA_Offset off, int comp=0) const
Get the string index at the given offset.
Definition: GA_Handle.h:1119
const GA_ATINumeric * getAttribute() const
Definition: GA_Handle.h:571
GA_RWHandleT< UT_StringArray > GA_RWHandleSA
Definition: GA_Handle.h:1448
void operator=(const GA_Attribute *attrib)
Definition: GA_Handle.h:1224
GA_Attribute * getAttribute() const
Definition: GA_Handle.h:999
GA_ROHandleT< UT_Vector2D > GA_ROHandleV2D
Definition: GA_Handle.h:1423
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:1148