17 #ifndef __GA_IndexMap__
18 #define __GA_IndexMap__
75 int64 getMemoryUsage(
bool inclusive)
const;
98 {
return myIndexFromOffset.entries(); }
104 {
return myIndexCount; }
120 ordered_index < myIndexCount);
126 if (myOffsetFromIndex.isTrivial())
127 return myOffsetFromIndex(ordered_index);
133 compactIndicesIfNeeded();
134 UT_ASSERT_P(ordered_index < myOffsetFromIndex.entries());
136 return myOffsetFromIndex(ordered_index);
148 data_offset <= myMaxOccupiedOffset);
154 if (myIndexFromOffset.isTrivial())
155 return myIndexFromOffset(data_offset);
164 if (
GAisValid(first_free_i) && index >= first_free_i)
167 index = myIndexFromOffset(data_offset);
181 if (isMonotonicMap() && myTempCount == 0)
186 return myMaxOccupiedOffset;
190 "Why is GA_IndexMap::lastOffset() being called between "
191 "sorting and defragmenting the offsets? It's almost "
192 "certainly a recipe for disaster.");
195 return offsetFromIndex(n - 1);
214 : myIndexMap(indexmap)
215 , myBegin(getOffset())
225 {
return GA_Range(myIndexMap, getBegin(), getEnd()); }
234 {
return myIndexMap.lastOffset() + 1; }
246 compactIndicesIfNeeded();
249 return *
reinterpret_cast<GA_OffsetList *
>(&myOffsetFromIndex);
303 return myOffsetFromIndex.isTrivial();
383 const char *attribute_name,
398 {
return myAttribute; }
424 bool stable=
true)
const;
466 {
return GAisValid(myIndexFromOffset(offset)); }
474 {
return myIndexFromOffset.findInvalidInRange(start, end); }
480 {
return myIndexFromOffset.findValidInRange(start, end); }
493 template<
typename FUNCTOR>
507 const GA_Offset veryend(myMaxOccupiedOffset+1);
519 }
while (off != end);
526 template<
typename FUNCTOR>
541 const GA_Offset veryend(myMaxOccupiedOffset+1);
554 }
while (off != end);
562 void clear(
bool clear_capacity);
570 GA_Size getTempCount()
const {
return myTempCount; }
580 bool fwd=
true)
const;
584 bool fwd=
true)
const;
602 void shrinkOffsets();
605 void makeMonotonic();
610 {
return myIndexFromOffset; }
638 return (myIndexCount == that.myIndexCount) &&
639 myOffsetFromIndex.isSame(that.myOffsetFromIndex) &&
640 myOwner == that.myOwner &&
641 myOffsetCapacity == that.myOffsetCapacity &&
642 myFreeHead == that.myFreeHead &&
643 myFreeTrailerBase == that.myFreeTrailerBase &&
644 myMaxOccupiedOffset == that.myMaxOccupiedOffset &&
645 myMaxTouchedOffset == that.myMaxTouchedOffset &&
647 myTempCount == 0 && that.myTempCount == 0;
670 void compactIndices()
const;
674 void compactIndicesIfNeeded()
const
687 void compactIndicesIfNeeded()
695 GA_Index first_free_i(myFirstFreeIndex.relaxedLoad());
703 void pruneFreeList(
GA_Offset upper_bound);
714 void computeTrivial();
717 bool computeMonotonic();
781 friend class GU_DetailHandleRef;
A class to manage an ordered array which has fixed offset handles.
GA_AttributeOwner getOwner() const
What type of element is stored in the index.
bool isOffsetActiveFast(GA_Offset offset) const
Definition of a geometry attribute.
GA_Offset nextNewElementOffset() const
void destroyOffset(GA_Offset where)
Delete an element from the list by the data offset.
virtual void finish(const GA_IndexMap &map)=0
bool sortIndices(IndexCompare &compare, bool stable=true)
Sort the index order using a comparator.
SYS_FORCE_INLINE GA_Offset getOffsetCapacity() const
bool cycleIndices(GA_Size offset)
bool isOffsetVacant(GA_Offset offset) const
The merge map keeps track of information when merging details.
SYS_FORCE_INLINE bool isMonotonicMap() const
SYS_FORCE_INLINE void forEachOffset(FUNCTOR &&functor) const
Calls functor on every active offset in this index map.
const GA_AIFTuple * getAIFTuple() const
GA_Detail & getDetail() const
Access the detail this index map belongs to.
SYS_FORCE_INLINE bool GAisValid(GA_Size v)
exint GA_Size
Defines the bit width for index and offset types in GA.
SYS_FORCE_INLINE GA_Index indexFromOffset(GA_Offset data_offset) const
GA_Offset getBegin() const
Returns the lower-bound on the beginning of the range.
#define GA_INVALID_OFFSET
SYS_FORCE_INLINE GA_Offset findActiveOffset(GA_Offset start, GA_Offset end) const
A range of elements in an index-map.
GLuint GLsizei const GLuint const GLintptr * offsets
#define UT_ASSERT_MSG(ZZ,...)
CompareResults OIIO_API compare(const ImageBuf &A, const ImageBuf &B, float failthresh, float warnthresh, ROI roi={}, int nthreads=0)
bool isOffsetTransient(GA_Offset offset) const
Marker(const GA_IndexMap &indexmap)
const GA_AIFStringTuple * getAIFStringTuple() const
T load(SYS_MemoryOrder order=SYS_MEMORY_ORDER_SEQ_CST) const
bool sortOffsetArray(GA_OffsetArray &offsets, IndexCompare &compare, bool stable=true) const
Sort an array of GA_Offset data according to a comparator.
Keeps track of offset mapping when merging index lists.
bool isSame(const GA_IndexMap &that) const
SYS_FORCE_INLINE GA_Offset findInactiveOffset(GA_Offset start, GA_Offset end) const
Defragmentation of IndexMaps.
const GA_Attribute * getAttribute() const
OPENVDB_API void initialize()
Global registration of native Grid, Transform, Metadata and Point attribute types. Also initializes blosc (if enabled).
SYS_FORCE_INLINE GA_Offset lastOffset() const
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
SYS_FORCE_INLINE bool isTrivialMap() const
virtual int compare(const GA_IndexMap &map, GA_Offset item1, GA_Offset item2)=0
Compare two elements using strcmp() semantics.
bool isOffsetActive(GA_Offset offset) const
Returns true if the specified offset is referenced by an ordered element.
SYS_FORCE_INLINE GA_Index indexSize() const
SYS_FORCE_INLINE GA_Offset offsetFromIndex(GA_Index ordered_index) const
void destroyIndex(GA_Index where)
Delete an element from the list by specifying the order.
OIIO_API bool attribute(string_view name, TypeDesc type, const void *val)
Container class for all geometry.
bool isOffsetInRange(GA_Offset offset) const
virtual bool initialize(const GA_IndexMap &map)=0
GA_Offset addElementBlock(GA_Size nelements)
SYS_FORCE_INLINE void forEachOffsetBreak(FUNCTOR &&functor) const
Generic Attribute Interface class to access an attribute as a tuple.
int getTupleIndex() const
GA_Range getRange() const
GA_OffsetList getOffsetFromIndexList() const
GA_Offset getEnd() const
Returns the upper-bound on the end of the range.
SYS_FORCE_INLINE GA_Offset offsetSize() const
Generic Attribute Interface class to work with string indices directly, rather than string values...