HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_IndexMap Class Reference

A class to manage an ordered array which has fixed offset handles. More...

#include <GA_IndexMap.h>

+ Inheritance diagram for GA_IndexMap:

Classes

class  AttributeCompare
 
class  IndexCompare
 
class  Marker
 

Public Member Functions

 GA_IndexMap (GA_Detail &detail, GA_AttributeOwner type)
 
 ~GA_IndexMap ()
 
GA_DetailgetDetail () const
 Access the detail this index map belongs to. More...
 
GA_AttributeOwner getOwner () const
 What type of element is stored in the index. More...
 
int64 getMemoryUsage (bool inclusive) const
 Report the memory used (includes all shared memory) More...
 
void countMemory (UT_MemoryCounter &counter, bool inclusive) const
 
SYS_FORCE_INLINE GA_Offset getOffsetCapacity () const
 
SYS_FORCE_INLINE GA_Offset offsetSize () const
 
SYS_FORCE_INLINE GA_Index indexSize () const
 
SYS_FORCE_INLINE GA_Offset offsetFromIndex (GA_Index ordered_index) const
 
SYS_FORCE_INLINE GA_Index indexFromOffset (GA_Offset data_offset) const
 
SYS_FORCE_INLINE GA_Offset lastOffset () const
 
GA_OffsetList getOffsetFromIndexList () const
 
GA_Offset findOffsetInIndices (GA_Index ordered_index) const
 
GA_Offset findNextOffsetInIndices (GA_Offset data_offset, GA_Index step) const
 
GA_Index findIndexInOffsets (GA_Offset data_offset) const
 
GA_Index reorder (GA_Offset data_offset, GA_Index new_order)
 
SYS_FORCE_INLINE bool isTrivialMap () const
 
SYS_FORCE_INLINE bool isMonotonicMap () const
 
bool sortIndices (IndexCompare &compare, bool stable=true)
 Sort the index order using a comparator. More...
 
bool sortIndices (IndexCompare &compare, const GA_Range &range, bool stable=true)
 Sort a selection of elements. More...
 
bool sortOffsetArray (GA_OffsetArray &offsets, IndexCompare &compare, bool stable=true) const
 Sort an array of GA_Offset data according to a comparator. More...
 
GA_Offset addElement ()
 
GA_Offset addElementBlock (GA_Size nelements)
 
GA_Offset nextNewElementOffset () const
 
void destroyIndex (GA_Index where)
 Delete an element from the list by specifying the order. More...
 
void destroyOffset (GA_Offset where)
 Delete an element from the list by the data offset. More...
 
bool isOffsetInRange (GA_Offset offset) const
 
bool isOffsetVacant (GA_Offset offset) const
 
bool isOffsetActiveFast (GA_Offset offset) const
 
SYS_FORCE_INLINE GA_Offset findInactiveOffset (GA_Offset start, GA_Offset end) const
 
SYS_FORCE_INLINE GA_Offset findActiveOffset (GA_Offset start, GA_Offset end) const
 
bool isOffsetActive (GA_Offset offset) const
 Returns true if the specified offset is referenced by an ordered element. More...
 
bool isOffsetTransient (GA_Offset offset) const
 
template<typename FUNCTOR >
SYS_FORCE_INLINE void forEachOffset (FUNCTOR &&functor) const
 Calls functor on every active offset in this index map. More...
 
template<typename FUNCTOR >
SYS_FORCE_INLINE void forEachOffsetBreak (FUNCTOR &&functor) const
 
bool isSame (const GA_IndexMap &that) const
 
void checkTrivial ()
 
bool swapOrderByOffset (GA_Offset offset1, GA_Offset offset2)
 
bool swapOrderByIndex (GA_Index order1, GA_Index order2)
 
bool cycleIndices (GA_Size offset)
 
bool cycleIndices (GA_Size offset, const GA_Range &range)
 
bool reverseIndices ()
 
bool reverseIndices (const GA_Range &range)
 

Friends

class GA_Detail
 NOTE: These are friends so that they can call compactIndicesIfNeeded. More...
 
class GU_DetailHandleRef
 
class GA_AttributeSet
 NOTE: This friend is so that GA_AttributeSet::replace can call copyFrom. More...
 

Additional Inherited Members

- Protected Member Functions inherited from UT_NonCopyableNS::UT_NonCopyable
 UT_NonCopyable ()=default
 
 ~UT_NonCopyable ()=default
 
 UT_NonCopyable (const UT_NonCopyable &)=delete
 
UT_NonCopyableoperator= (const UT_NonCopyable &)=delete
 

Detailed Description

A class to manage an ordered array which has fixed offset handles.

The GA_Detail keeps an ordered list of elements (points, vertices etc.) maintained by this class. Each ordered element (named "index") also has a fixed offset. The offset remains constant as elements are added/removed from the detail. The offset is used for indexing into

  • The attribute arrays
  • Groups
  • Primitive lists etc. Since the offset is not mutable, as elements are added and deleted, vacancies become available in the attribute arrays. These vacancies may then be filled as new elements get allocated.

This class (GA_IndexMap) keeps track of the vacancies and the order of elements.

During some operations, temporary elements are also created. This class maintains temporary elements too.

Definition at line 63 of file GA_IndexMap.h.

Constructor & Destructor Documentation

GA_IndexMap::GA_IndexMap ( GA_Detail detail,
GA_AttributeOwner  type 
)
GA_IndexMap::~GA_IndexMap ( )

Member Function Documentation

GA_Offset GA_IndexMap::addElement ( )
inline

Add a new element to the list, returning the data offset of the new element.

Definition at line 442 of file GA_IndexMap.h.

GA_Offset GA_IndexMap::addElementBlock ( GA_Size  nelements)

Add new elements to the list, returning the first offset of the contiguous block

void GA_IndexMap::checkTrivial ( )
inline

This is used as a quick check in defragmentation, in case this index map is actually defragmented, but not trivial for some reason.

Definition at line 653 of file GA_IndexMap.h.

void GA_IndexMap::countMemory ( UT_MemoryCounter counter,
bool  inclusive 
) const

Count memory usage using a UT_MemoryCounter in order to count shared memory correctly. If inclusive is true, the size of this object is counted, else only memory owned by this object is counted. If this is pointed to by the calling object, inclusive should be true. If this is contained in the calling object, inclusive should be false. (Its memory was already counted in the size of the calling object.)

bool GA_IndexMap::cycleIndices ( GA_Size  offset)

Shift/cycle elements in the list.

bool GA_IndexMap::cycleIndices ( GA_Size  offset,
const GA_Range range 
)

Shift/cycle elements in the list.

void GA_IndexMap::destroyIndex ( GA_Index  where)

Delete an element from the list by specifying the order.

void GA_IndexMap::destroyOffset ( GA_Offset  where)

Delete an element from the list by the data offset.

SYS_FORCE_INLINE GA_Offset GA_IndexMap::findActiveOffset ( GA_Offset  start,
GA_Offset  end 
) const
inline

Returns the first offset in [start, end) which is active If none are vacant, return end. No bounds checking is done.

Definition at line 479 of file GA_IndexMap.h.

SYS_FORCE_INLINE GA_Offset GA_IndexMap::findInactiveOffset ( GA_Offset  start,
GA_Offset  end 
) const
inline

Returns the first offset in [start, end) which is inactive. If none are inactive, return end. No bounds checking is done.

Definition at line 473 of file GA_IndexMap.h.

GA_Index GA_IndexMap::findIndexInOffsets ( GA_Offset  data_offset) const

Non-compacting method to find the true order of the given data_offset. This method may need to search the non-compact mapping for holes, and so sequential calls can easily result in O(n^2) behaviour.

GA_Offset GA_IndexMap::findNextOffsetInIndices ( GA_Offset  data_offset,
GA_Index  step 
) const

Given an offset, this skips the step ordered index and returns the next fixed offset. This method may do an O(N) search for the result, but is guaranteed to be const. It's primarily designed for use in GA_RTIIndex.

GA_Offset GA_IndexMap::findOffsetInIndices ( GA_Index  ordered_index) const

Given an ordered index, this returns the fixed offset associated with the index. This method may do an O(N) search for the result, but is guaranteed to be const. It's primarily designed for use in GA_RTIIndex.

template<typename FUNCTOR >
SYS_FORCE_INLINE void GA_IndexMap::forEachOffset ( FUNCTOR &&  functor) const
inline

Calls functor on every active offset in this index map.

Definition at line 495 of file GA_IndexMap.h.

template<typename FUNCTOR >
SYS_FORCE_INLINE void GA_IndexMap::forEachOffsetBreak ( FUNCTOR &&  functor) const
inline

Calls functor on every active offset in this index map, until functor returns false for some element.

Definition at line 528 of file GA_IndexMap.h.

GA_Detail& GA_IndexMap::getDetail ( ) const
inline

Access the detail this index map belongs to.

Definition at line 70 of file GA_IndexMap.h.

int64 GA_IndexMap::getMemoryUsage ( bool  inclusive) const

Report the memory used (includes all shared memory)

SYS_FORCE_INLINE GA_Offset GA_IndexMap::getOffsetCapacity ( ) const
inline

The capacity for offsets. Attribute arrays must be able to store at least this much storage.

Definition at line 89 of file GA_IndexMap.h.

GA_OffsetList GA_IndexMap::getOffsetFromIndexList ( ) const
inline

Returns a copy of our offset from index list, first ensuring it is up to date. Note this is a copy so will not remain in sync.

Definition at line 244 of file GA_IndexMap.h.

GA_AttributeOwner GA_IndexMap::getOwner ( ) const
inline

What type of element is stored in the index.

Definition at line 72 of file GA_IndexMap.h.

SYS_FORCE_INLINE GA_Index GA_IndexMap::indexFromOffset ( GA_Offset  data_offset) const
inline

Given an element offset, this returns the ordered index. NOTE: Calling the indexFromOffset() function may invoke internal data modifications (i.e. these operations may be mutable). These operations are potentially expensive and should be avoided if possible.

See Also
findIndexInOffsets()

Definition at line 145 of file GA_IndexMap.h.

SYS_FORCE_INLINE GA_Index GA_IndexMap::indexSize ( ) const
inline

Return number of elements in the list. This indexSize() is always <= the offsetSize()

Examples:
SOP/SOP_SParticle.C.

Definition at line 103 of file GA_IndexMap.h.

SYS_FORCE_INLINE bool GA_IndexMap::isMonotonicMap ( ) const
inline

Definition at line 307 of file GA_IndexMap.h.

bool GA_IndexMap::isOffsetActive ( GA_Offset  offset) const
inline

Returns true if the specified offset is referenced by an ordered element.

Definition at line 483 of file GA_IndexMap.h.

bool GA_IndexMap::isOffsetActiveFast ( GA_Offset  offset) const
inline

Returns true if the specified offset is referenced by an ordered element No bounds checking is done.

Definition at line 465 of file GA_IndexMap.h.

bool GA_IndexMap::isOffsetInRange ( GA_Offset  offset) const
inline

Returns whether the offset is in the valid range of offsets for this index map.

Definition at line 456 of file GA_IndexMap.h.

bool GA_IndexMap::isOffsetTransient ( GA_Offset  offset) const

Returns true if the specified offset is being used for a temporary element.

See Also
GA_WorkVertexBuffer
bool GA_IndexMap::isOffsetVacant ( GA_Offset  offset) const

Returns true if the specified offset is not in use (i.e. vacant) NOTE: Inactive != Vacant. There are temporaries.

bool GA_IndexMap::isSame ( const GA_IndexMap that) const
inline

Returns true iff the index maps are trivial and equal, or non-trivial and share the exact same data. This does not fully check for equality!

Definition at line 615 of file GA_IndexMap.h.

SYS_FORCE_INLINE bool GA_IndexMap::isTrivialMap ( ) const
inline

A trivial map is one where offsetFromIndex(i) == i for all elements. That is, the offsets are in order and there are no vacancies.

Definition at line 290 of file GA_IndexMap.h.

SYS_FORCE_INLINE GA_Offset GA_IndexMap::lastOffset ( ) const
inline

Obtain offset of the element with the last index. Returns GA_INVALID_OFFSET if empty. NOTE: The offset will never be a temporary element, since temporary elements have no indices.

Definition at line 179 of file GA_IndexMap.h.

GA_Offset GA_IndexMap::nextNewElementOffset ( ) const

Returns the start offset that the next call to addElementBlock would return, (assuming it doesn't exceed the hard limit.)

SYS_FORCE_INLINE GA_Offset GA_IndexMap::offsetFromIndex ( GA_Index  ordered_index) const
inline

When accessing the map functions (i.e. mapping from order to data offsets), the map may be compacted. This is a potentially expensive operation and should be avoided if possible. Given an ordered index, this returns the fixed offset associated with the index. NOTE: Calling the offsetFromIndex() function may invoke internal data modifications (i.e. these operations may be mutable). These operations are potentially expensive and should be avoided if possible.

See Also
findOffsetInIndices(), findNextOffsetInIndices()
Examples:
RAY/RAY_DemoSprite.C.

Definition at line 117 of file GA_IndexMap.h.

SYS_FORCE_INLINE GA_Offset GA_IndexMap::offsetSize ( ) const
inline

This is an exclusive upper bound when iterating over offsets. Every active or temporary offset in this index map will be strictly less than this. It is always guaranteed that: myMaxOccupiedOffset < offsetSize() <= getOffsetCapacity()

Definition at line 97 of file GA_IndexMap.h.

GA_Index GA_IndexMap::reorder ( GA_Offset  data_offset,
GA_Index  new_order 
)

Reorder an element. The index of the element at the given data offset will be changed to the new order (provided that the ordered position is in a valid range).

Warning
You must force defragmentation after swapping the index order to maintain monotonicity of the index map.
Returns
The new index of the element, or -1 if there was an error
bool GA_IndexMap::reverseIndices ( )

Reverse a selection of elements

bool GA_IndexMap::reverseIndices ( const GA_Range range)

Reverse a selection of elements

bool GA_IndexMap::sortIndices ( IndexCompare compare,
bool  stable = true 
)

Sort the index order using a comparator.

bool GA_IndexMap::sortIndices ( IndexCompare compare,
const GA_Range range,
bool  stable = true 
)

Sort a selection of elements.

bool GA_IndexMap::sortOffsetArray ( GA_OffsetArray offsets,
IndexCompare compare,
bool  stable = true 
) const

Sort an array of GA_Offset data according to a comparator.

bool GA_IndexMap::swapOrderByIndex ( GA_Index  order1,
GA_Index  order2 
)

Swap the order of the two specified (ordered, not transient) data offsets.

Warning
You must force defragmentation after swapping the index order to maintain monotonicity of the index map.
Returns
True on success, false on failure.
bool GA_IndexMap::swapOrderByOffset ( GA_Offset  offset1,
GA_Offset  offset2 
)

Swap the order of the two specified (ordered, not transient) data offsets.

Warning
You must force defragmentation after swapping the index order to maintain monotonicity of the index map.
Returns
True on success, false on failure.

Friends And Related Function Documentation

friend class GA_AttributeSet
friend

NOTE: This friend is so that GA_AttributeSet::replace can call copyFrom.

Definition at line 784 of file GA_IndexMap.h.

friend class GA_Detail
friend

NOTE: These are friends so that they can call compactIndicesIfNeeded.

Definition at line 780 of file GA_IndexMap.h.

friend class GU_DetailHandleRef
friend

Definition at line 781 of file GA_IndexMap.h.


The documentation for this class was generated from the following file: