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