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