FieldOutput Struct Reference

#include <c4d_fielddata.h>

Detailed Description

The full result from sampling a field. Struct own the sampled data if it is not a sub block of the full sample. FieldOutput used as subblock don't own the memory and don't carry a ref count on the allocated memory, hence the real block must stay valid during the use of a subblock.

Public Member Functions

 FieldOutput ()=default
 
 FieldOutput (FieldOutput &&moveRef)
 
 ~FieldOutput ()
 
 MAXON_OPERATOR_MOVE_ASSIGNMENT (FieldOutput)
 
 operator FieldOutputBlock () const
 
FieldOutputBlock GetBlock () const
 
maxon::Result< FieldOutputBlockGetSubBlock (Int offset, Int blockSize=FIELD_EXECUTION_BLOCK_SIZE) const
 
void Reset ()
 
void Flush ()
 
Int GetCount () const
 
Bool IsValid () const
 
Bool IsPopulated () const
 
Bool IsEqual (const FieldOutput &comp) const
 
maxon::Result< void > CopyFrom (const FieldOutput &src)
 
maxon::Result< void > CopyArrayContentFrom (const FieldOutput &src)
 
maxon::Result< void > CopyArrayContentFrom (const FieldOutputBlock &src)
 
maxon::Result< void > Resize (Int newSize, FIELDSAMPLE_FLAG sampleFlags=FIELDSAMPLE_FLAG::ALL, maxon::COLLECTION_RESIZE_FLAGS resizeFlags=maxon::COLLECTION_RESIZE_FLAGS::DEFAULT)
 
void ClearMemory (Bool deactivatedOnly=true, Bool deactivatedState=false)
 
void ClearMemory (Int startIdx, Int count, Bool deactivatedOnly, Bool deactivatedState)
 
void ClearDeactivated (Bool state=false)
 
UInt32 CalculateCrc () const
 

Static Public Member Functions

static maxon::Result< FieldOutput * > Alloc (Int size, FIELDSAMPLE_FLAG flags=FIELDSAMPLE_FLAG::ALL)
 
static void Free (FieldOutput *&p)
 
static maxon::Result< FieldOutputCreate (Int size, FIELDSAMPLE_FLAG flags=FIELDSAMPLE_FLAG::ALL)
 
static maxon::Result< FieldOutputCreate (FieldOutputBlock &src)
 

Public Attributes

maxon::BaseArray< Float_value
 
maxon::BaseArray< Float_alpha
 
maxon::BaseArray< Vector_color
 
maxon::BaseArray< Vector_direction
 
maxon::BaseArray< Vector_rotation
 
maxon::BaseArray< Vector_pivot
 
maxon::BaseArray< Bool_deactivated
 

Private Member Functions

 MAXON_DISALLOW_COPY_AND_ASSIGN (FieldOutput)
 

Private Attributes

Int _count
 

Constructor & Destructor Documentation

◆ FieldOutput() [1/2]

FieldOutput ( )
default

Creates and empty sample.

◆ FieldOutput() [2/2]

FieldOutput ( FieldOutput &&  moveRef)

Move construction. Takes ownership of the sample memory.

Parameters
[in]moveRefThe source sample.

◆ ~FieldOutput()

Frees sample memory if not a sub block.

Member Function Documentation

◆ MAXON_OPERATOR_MOVE_ASSIGNMENT()

MAXON_OPERATOR_MOVE_ASSIGNMENT ( FieldOutput  )

◆ operator FieldOutputBlock()

operator FieldOutputBlock ( ) const

Casting operator, equivalent to GetBlock().

Returns
A sub block for the whole FieldOutput.

◆ GetBlock()

FieldOutputBlock GetBlock ( ) const

Gets the total arrays in a FieldOutputBlock.

Returns
A sub block for the whole FieldOutput.

◆ GetSubBlock()

maxon::Result<FieldOutputBlock> GetSubBlock ( Int  offset,
Int  blockSize = FIELD_EXECUTION_BLOCK_SIZE 
) const

Gets a sub-section of the total arrays.

Parameters
[in]offsetThe offset index to retrieve a sub-block starting at.
[in]blockSizeSuggested size of the block, will be clamped against the maximum number of entries.
Returns
The sub block.

◆ Reset()

void Reset ( )

Resets the FieldOutput to an empty state. All memory will be deallocated.

◆ Flush()

void Flush ( )

Flush the FieldOutput content, keeping the arrays allocated for future resize.

◆ GetCount()

Int GetCount ( ) const

Gets the number of elements in the FieldOutput

Returns
The count.

◆ IsValid()

Bool IsValid ( ) const

Checks if the FieldOutput allocations and sizes are valid (empty FieldOutput is considered valid).

◆ IsPopulated()

Bool IsPopulated ( ) const

Checks if the FieldOutput is valid and non-empty.

◆ IsEqual()

Bool IsEqual ( const FieldOutput comp) const

Compares the content of both FieldOutput. Count and array content must be the same.

Parameters
[in]compSource for the comparison.
Returns
True if equal.

◆ CopyFrom()

maxon::Result<void> CopyFrom ( const FieldOutput src)

Copies from the FieldOutput described by src. Performs a deep copy.

Parameters
[in]srcSource for the duplication.
Returns
OK on success.

◆ CopyArrayContentFrom() [1/2]

maxon::Result<void> CopyArrayContentFrom ( const FieldOutput src)

Copies from the FieldOutput array content from src. Size and flags will not be affected by this action. Source data content will be copied into target up to current size. If target is bigger than source, the remaining items are cleared.

Parameters
[in]srcSource for the duplication.
Returns
OK on success.

◆ CopyArrayContentFrom() [2/2]

maxon::Result<void> CopyArrayContentFrom ( const FieldOutputBlock src)

Copies from the FieldOutput array content from src. Size and flags will not be affected by this action. Source data content will be copied into target up to current size. If target is bigger than source, the remaining items are cleared.

Parameters
[in]srcSource for the duplication.
Returns
OK on success.

◆ Resize()

Resizes the arrays held in the FieldOutput. Unspecified channel arrays will be resized to 0 length (according to resizeFlags).

Parameters
[in]newSizeThe size that the arrays should become.
[in]sampleFlagsThe channels to sample.
[in]resizeFlagsThe flags for which channels should be resized.
Returns
OK on success.

◆ ClearMemory() [1/2]

void ClearMemory ( Bool  deactivatedOnly = true,
Bool  deactivatedState = false 
)

Reset the sample's data to default values, optionally only the deactivated content too. Values are reset to 0, colors to 1.0, direction to 0, deactivated to 0.

Parameters
[in]deactivatedOnlyTrue to deactivated only.
[in]deactivatedState(Optional) The state the deactivated should be cleared to

◆ ClearMemory() [2/2]

void ClearMemory ( Int  startIdx,
Int  count,
Bool  deactivatedOnly,
Bool  deactivatedState 
)

Reset the sample's data to default values, optionally only the deactivated content too. Values are reset to 0, colors to 1.0, direction to 0, deactivated to 0.

Parameters
[in]startIdxArray clear start index.
[in]countNumber of array items to reset to default value.
[in]deactivatedOnlyTrue to deactivated only.
[in]deactivatedState(Optional) The state the deactivated should be cleared to

◆ ClearDeactivated()

void ClearDeactivated ( Bool  state = false)

Clears the deactivated array.

◆ CalculateCrc()

UInt32 CalculateCrc ( ) const

Calculates a crc on all internal data using maxon::Crc32C. Crc is not kept internally and will be calculated from scratch on each CalculateCrc call.

Returns
The crc.

◆ Alloc()

static maxon::Result<FieldOutput*> Alloc ( Int  size,
FIELDSAMPLE_FLAG  flags = FIELDSAMPLE_FLAG::ALL 
)
static

Allocate a heap FieldOutput with all specified sampling arrays. Equivalent of calling empty constructor followed by Resize. Use FieldOutputRef to have a scoped or auto deleted FieldOutput.

Parameters
[in]sizeThe size.
[in]flagsThe flags.
Returns
A MemoryError if it fails, else a FieldOutput*.

◆ Free()

static void Free ( FieldOutput *&  p)
static

Frees the given FieldOutput and all internal allocations.

Parameters
[in]pThe FieldOutput to free.

◆ Create() [1/2]

static maxon::Result<FieldOutput> Create ( Int  size,
FIELDSAMPLE_FLAG  flags = FIELDSAMPLE_FLAG::ALL 
)
static

Create a FieldOutput with all specified sampling arrays. Same as Alloc, but on the stack. Equivalent of calling empty constructor followed by Resize.

Parameters
[in]sizeThe size.
[in]flagsThe flags.
Returns
The resulting FieldOutput.

◆ Create() [2/2]

static maxon::Result<FieldOutput> Create ( FieldOutputBlock src)
static

Create a FieldOutput with all specified sampling arrays. Size will be fetched from the source FieldOutput. Array content will be copied from source FieldOutput. Equivalent of calling empty constructor followed by CopyFrom.

Parameters
[in]srcThe source FieldOutput.
Returns
The resulting FieldOutput.

◆ MAXON_DISALLOW_COPY_AND_ASSIGN()

MAXON_DISALLOW_COPY_AND_ASSIGN ( FieldOutput  )
private

Member Data Documentation

◆ _value

◆ _alpha

The weight value at this point in space.

◆ _color

The alpha value for color and direction at this point in space, only available when color or direction are allocated.

◆ _direction

maxon::BaseArray<Vector> _direction

The color at this point in space.

◆ _rotation

The direction at this point in space.

◆ _pivot

The rotational velocity (axle + magnitude)

◆ _deactivated

maxon::BaseArray<Bool> _deactivated

The rotational pivot point in space.

◆ _count

Int _count
private

The deactivated state for this point (i.e. cut from interior shape will be true) this skips remapping.