BaseSelect Class Reference

#include <c4d_baseselect.h>

Inheritance diagram for BaseSelect:

详细描述

This class is used to keep track of point and polygon selections, it may also be used to track other types of element selections.

注意
Has to be created with Alloc() and destroyed with Free() 。使用 AutoAlloc to automate the allocation and destruction based on scope.

私有成员函数

  BaseSelect ()
  ~BaseSelect ()

Alloc/Free

static BaseSelect Alloc (void)
static void  Free ( BaseSelect *&bs)

Selection/Segment Count

Int32   GetCount (void) const
Int32   GetSegments (void) const

Select/Deselect/Toggle

Bool   选择 ( Int32 num)
Bool   SelectAll ( Int32 min, Int32 max, Bool deselectAll=true)
Bool   Deselect ( Int32 num)
Bool   DeselectAll (void)
Bool   Toggle ( Int32 num)
Bool   ToggleAll ( Int32 min, Int32 max)

Get/Check Selection

Bool   GetRange ( Int32 seg, Int32 maxElements, Int32 *a, Int32 *b) const
Bool   IsSelected ( Int32 num) const

Copy/Clone

Bool   CopyTo ( BaseSelect *dest) const
BaseSelect GetClone (void) const

Merge/Deselect/cross

Bool   Merge (const BaseSelect *src)
Bool   Deselect (const BaseSelect *src)
Bool   Cross (const BaseSelect *src)

Conversion from/to Array

Bool   FromArray ( UChar *selection, Int32 count)
UChar ToArray ( Int32 count) const
Bool   ToBitSet ( Int32 count, maxon::BaseBitSet < maxon::DefaultAllocator > &bitSet) const

Read/Write

Bool   读取 ( HyperFile *hf)
void  Write ( HyperFile *hf)

杂项

Bool   FindSegment ( Int32 num, Int32 *segment) const
Int32   GetDirty () const
Int32   GetLastElement (void) const
Bool   IsAllSelected ( Int32 num) const
Bool   IsNothingSelected () const

Private

BaseSelectData GetData ()
Bool   CopyFrom ( BaseSelectData *ndata, Int32 ncnt)

构造函数 & 析构函数文档编制

◆  BaseSelect()

BaseSelect () private

◆  ~BaseSelect()

~ BaseSelect () private

成员函数文档编制

◆  Alloc()

static BaseSelect * Alloc ( void  )
static

Allocates a base selection. Destroy the allocated base selection with Free() 。使用 AutoAlloc to automate the allocation and destruction based on scope.

返回
The allocated base selection, or nullptr if the allocation failed.

◆  Free()

static void Free ( BaseSelect *&  bs )
static

Destructs base selections allocated with Alloc() 。使用 AutoAlloc to automate the allocation and destruction based on scope.

参数
[in,out] bs The base selection to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards.

◆  GetCount()

Int32 GetCount ( void  ) const

Gets the number of selected elements.

返回
The number of selected elements.

◆  GetSegments()

Int32 GetSegments ( void  ) const

Gets the number of segments that contain elements.

注意
For example: with the selections 0 .. 4 , 6 .. 7 , 9 .. 12 , GetSegments() would return 3 and GetCount() would return 11 .
返回
The number of segments with selected elements.

◆  Select()

Bool 选择 ( Int32   num )

Selects an element.

参数
[in] num The element index to select.
返回
true if the element was already selected, otherwise false .

◆  SelectAll()

Bool SelectAll ( Int32   min ,
Int32   max ,
Bool   deselectAll = true  
)

Selects all elements in the given range.

参数
[in] min The first element to select.
[in] max The last element in the range to select.
[in] deselectAll Since R17. Deselects all previously selected elements before creating the new selection (equivalent to SELECTION_NEW ).
返回
Success of selecting the elements.

◆  Deselect() [1/2]

Bool Deselect ( Int32   num )

Deselects an element.

参数
[in] num The element index to deselect.
返回
true if the element was already deselected, otherwise false .

◆  DeselectAll()

Bool DeselectAll ( void  )

Deselects all elements.

返回
Success of deselecting all elements.

◆  Toggle()

Bool Toggle ( Int32   num )

Toggles the selection state of an element.

参数
[in] num The element index to toggle.
返回
Success of changing the selection state of the element.

◆  ToggleAll()

Bool ToggleAll ( Int32   min ,
Int32   max  
)

Toggles the selection state of all elements in the given range.

参数
[in] min The first element to toggle.
[in] max The last element to toggle in the range.
返回
Success of changing the selection state.

◆  GetRange()

Bool GetRange ( Int32   seg ,
Int32   maxElements ,
Int32 a ,
Int32 b  
) const

Gets the selected elements contained in a segment.

参数
[in] seg The segment to get the elements for. 0 <= seg < GetSegments()
[in] maxElements The maximum value for a and b . Makes sure a and b are < maxElements . Pass LIMIT<Int32>::MAX for no additional checks.
[out] a Assigned the index of the first selected element.
[out] b Assigned the index of the last selected element.
返回
true if if the range was successfully retrieved, otherwise false . Only false if seg is not 0 <= seg < GetSegments()
The spans are always sorted (spans with higher index have higher numbers for a / b ), also b is always >= a .

◆  IsSelected()

Bool IsSelected ( Int32   num ) const

Checks the selection state of an element.
To efficiently go through selections use the following code:

Int32 seg = 0, a, b, i; while (bs->GetRange(seg++, LIMIT<Int32>::MAX , &a, &b)) { for (i=a; i<=b; ++i) { // Do something. 'i' is the selected element } }

This is faster than:

for (i=0; i<maxelements; i++) { if (bs->IsSelected(i)) { // Do something } }
参数
[in] num The element index to get the state for.
返回
true if the element num is selected, otherwise false .

◆  CopyTo()

Bool CopyTo ( BaseSelect dest ) const

Copies the selection elements to another BaseSelect .

参数
[out] dest The destination selection. The caller owns the pointed selection.
返回
true if selection elements were copied successfully, otherwise false .

◆  GetClone()

BaseSelect * GetClone ( void  ) const

Makes a duplicate of the selection with its elements.

返回
The cloned BaseSelect or nullptr if failed. The caller owns the pointed BaseSelect .

◆  Merge()

Bool Merge ( const BaseSelect src )

Selects all elements that are in src .

参数
[in] src The source selection. The caller owns the pointed selection.
返回
true if the selection elements were merged successfully, otherwise false .

◆  Deselect() [2/2]

Bool Deselect ( const BaseSelect src )

Deselects all elements that are in src .

参数
[in] src The source selection. The caller owns the pointed selection.
返回
true if the selection elements were deselected successfully, otherwise false .

◆  Cross()

Bool Cross ( const BaseSelect src )

Intersects all elements in src .

参数
[in] src The source selection. The caller owns the pointed selection.
返回
true if the selection elements were crossed successfully, otherwise false .

◆  FromArray()

Bool FromArray ( UChar selection ,
Int32   count  
)

Gets a number of selected elements from an array. The elements in the array are interpreted as Bool : 0 means the element is unselected, and 1 means it is selected.

警告
The old selection will completely be overridden.
参数
[in] selection An array of elements to select. The caller owns the pointed array.
[in] count The number of elements in the array.
返回
true if the elements from the array were selected successfully, otherwise false .

◆  ToArray()

UChar * ToArray ( Int32   count ) const

Gets an array of selected elements. The elements in the array are interpreted as Bool : 0 means the element is unselected, and 1 means it is selected.

警告
The array is created with NewMemClear() and must be freed with DeleteMem() afterward.
参数
[in] count The number of elements to place into the array.
返回
The array containing the selected elements or nullptr if failed. The caller owns the pointed array.

◆  ToBitSet()

Bool ToBitSet ( Int32   count ,
maxon::BaseBitSet < maxon::DefaultAllocator > &  bitSet  
) const
返回
true if the elements from the array were selected successfully, otherwise false .

◆  Read()

Bool 读取 ( HyperFile hf )

Reads a selection from a file.

参数
[in] hf The file to read a selection from. The caller owns the pointed hyper file.
返回
true if a selection was successfully read, otherwise false .

◆  Write()

void Write ( HyperFile hf )

Writes the selection to a file.

参数
[in] hf The file to write the selection to. The caller owns the pointed hyper file.

◆  FindSegment()

Bool FindSegment ( Int32   num ,
Int32 segment  
) const

Calculates which segment contains the element num and returns it in segment .

参数
[in] num An element number.
[out] segment Assigned the found segment index.
返回
true if the segment was found, otherwise false .

◆  GetDirty()

Int32 GetDirty ( ) const

Gets the dirty counter of the selection.

注意
The dirty counter is increased every time a function that changes the selection is called.
返回
The dirty counter.

◆  GetLastElement()

Int32 GetLastElement ( void  ) const

Gets the last selected element, e.g. the last element selected through Select() .

返回
The last selected element.

◆  IsAllSelected()

Bool IsAllSelected ( Int32   num ) const

Checks if all elements from zero to num-1 are selected.

参数
[in] num Number of elements to check.
返回
True, if all elements are selected.

◆  IsNothingSelected()

Bool IsNothingSelected ( ) const

Checks if nothing is selected.

返回
True, if nothing is selected.

◆  GetData()

BaseSelectData * GetData ( )

Private .

◆  CopyFrom()

Bool CopyFrom ( BaseSelectData ndata ,
Int32   ncnt  
)

Private .

LIMIT
定义: apibasemath.h:33
Int32
maxon::Int32 Int32
定义: ge_sys_math.h:58