Class: QgsMeshDataBlock

A block of integers/doubles from a mesh dataset.

QgsMeshDataBlock can be used to retrieve:

  • active flags (e.g. face’s active integer flag)

  • scalars (e.g. scalar dataset double values)

  • vectors (e.g. vector dataset doubles x,y values)

Data are implicitly shared, so the class can be quickly copied std.numeric_limits<double>.quiet_NaN() represents NODATA value

Data can be accessed all at once with values() (faster) or value by value (slower) with active() or value()

Added in version 3.6.

Methods

active

Returns a value for active flag by the index For scalar and vector 2d the behavior is undefined

count

Number of items stored in the block

isValid

Whether the block is valid

setActive

Sets active flag values.

setValid

Sets block validity

setValues

Sets values

type

Type of data stored in the block

value

Returns a value represented by the index For active flag the behavior is undefined

values

Returns buffer to the array with values For vector it is pairs (x1, y1, x2, y2, .

Attributes

ActiveFlagInteger

ScalarDouble

Vector2DDouble

class qgis.core.QgsMeshDataBlock[source]

Bases: object

__init__()

Constructs an invalid block

__init__(type: QgsMeshDataBlock.DataType, count: int)

Constructs a new block

Parameters:
__init__(a0: QgsMeshDataBlock)
Parameters:

a0 (QgsMeshDataBlock)

ActiveFlagInteger = 0
class DataType

Bases: int

ScalarDouble = 1
Vector2DDouble = 2
active(self, index: int) bool[source]

Returns a value for active flag by the index For scalar and vector 2d the behavior is undefined

Parameters:

index (int)

Return type:

bool

active(self) List[int][source]

Returns active flag array

Even for active flag valid dataset, the returned array could be empty. This means that the data provider/dataset does not support active flag capability, so all faces are active by default.

For scalar and vector 2d the behavior is undefined

Added in version 3.12.

Return type:

List[int]

count(self) int[source]

Number of items stored in the block

Return type:

int

isValid(self) bool[source]

Whether the block is valid

Return type:

bool

setActive(self, vals: Iterable[int])[source]

Sets active flag values.

If the data provider/datasets does not have active flag capability (== all values are valid), just set block validity by setValid( True )

Parameters:

vals (Iterable[int]) – value vector with size count()

For scalar and vector 2d the behavior is undefined

Added in version 3.12.

setValid(self, valid: bool)[source]

Sets block validity

Parameters:

valid (bool)

setValues(self, vals: Iterable[float])[source]

Sets values

For scalar datasets, it must have size count() For vector datasets, it must have size 2 * count() For active flag the behavior is undefined

Added in version 3.12.

Parameters:

vals (Iterable[float])

type(self) QgsMeshDataBlock.DataType[source]

Type of data stored in the block

Return type:

QgsMeshDataBlock.DataType

value(self, index: int) QgsMeshDatasetValue[source]

Returns a value represented by the index For active flag the behavior is undefined

Parameters:

index (int)

Return type:

QgsMeshDatasetValue

values(self) List[float]

Returns buffer to the array with values For vector it is pairs (x1, y1, x2, y2, … )

Added in version 3.12.

Return type:

List[float]