Class FieldView¶
Defined in File field.h
Inheritance Relationships¶
Derived Type¶
public ouster::sdk::core::FieldClass Field
Class Documentation¶
-
class FieldView¶
Non-owning wrapper over a memory pointer that allows for type safe conversion to typed pointer, eigen array or ArrayView.
Subclassed by ouster::sdk::core::Field
Public Functions
-
FieldView(void *ptr, FieldDescriptor desc)¶
Initialize FieldView with a pointer and a descriptor.
- Parameters:
ptr[in] Memory pointer.
desc[in] Field descriptor.
-
template<typename T = void>
inline T *get()¶ Returns arbitrary pointer type.
- Throws:
std::invalid_argument – on type mismatch unless FieldView was constructed typeless (with type void) or dereference type is void*
- Template Parameters:
T – pointer type
- Returns:
typed pointer to the memory
-
template<typename T = void>
inline const T *get() const¶ Returns arbitrary pointer type.
- Throws:
std::invalid_argument – on type mismatch unless FieldView was constructed typeless (with type void) or dereference type is void*
- Template Parameters:
T – pointer type
- Returns:
typed pointer to the memory
-
template<typename T>
inline operator T*()¶ Arbitrary type ptr conversion.
- Throws:
std::invalid_argument – on type mismatch unless FieldView was constructed with void ptr or the requested ptr type is void*
-
template<typename T>
inline operator const T*() const¶ Arbitrary type const ptr conversion.
- Throws:
std::invalid_argument – on type mismatch unless FieldView was constructed with void ptr or the requested ptr type is void*
-
template<typename T, size_t Dim>
inline operator ArrayView<T, Dim>()¶ Arbitrary type ArrayView conversion.
- Throws:
std::invalid_argument – on type mismatch
std::invalid_argument – on dimensional shape mismatch
-
template<typename T, size_t Dim>
inline operator ConstArrayView<T, Dim>() const¶ Arbitrary type const ArrayView conversion.
- Throws:
std::invalid_argument – on type mismatch
std::invalid_argument – on dimensional shape mismatch
-
template<typename T>
inline operator Eigen::Ref<img_t<T>>()¶ Arbitrary type Eigen 2D array conversion.
- Throws:
std::invalid_argument – on type mismatch
std::invalid_argument – on dimensional shape mismatch
-
template<typename T>
inline operator Eigen::Ref<const img_t<T>>() const¶ Arbitrary type const Eigen 2D array conversion.
- Throws:
std::invalid_argument – on type mismatch
std::invalid_argument – on dimensional shape mismatch
-
template<typename T>
inline operator Eigen::Ref<Eigen::Array<T, Eigen::Dynamic, 1>>()¶ Arbitrary type const Eigen 1D array conversion.
- Throws:
std::invalid_argument – on type mismatch
std::invalid_argument – on dimensional shape mismatch
-
template<typename T>
inline operator Eigen::Ref<const Eigen::Array<T, Eigen::Dynamic, 1>>() const¶ Arbitrary type const Eigen 1D array conversion.
- Throws:
std::invalid_argument – on type mismatch
std::invalid_argument – on dimensional shape mismatch
-
template<typename T>
inline operator Eigen::Ref<Eigen::Array<T, Eigen::Dynamic, 3, Eigen::RowMajor>>()¶ Arbitrary type const Eigen Nx3 array conversion.
- Throws:
std::invalid_argument – on type mismatch
std::invalid_argument – on dimensional shape mismatch
-
template<typename T>
inline operator Eigen::Ref<const Eigen::Array<T, Eigen::Dynamic, 3, Eigen::RowMajor>>() const¶ Arbitrary type const Eigen Nx3 array conversion.
- Throws:
std::invalid_argument – on type mismatch
std::invalid_argument – on dimensional shape mismatch
-
template<typename ...Args>
inline FieldView subview(Args... idx) const¶ Get a subview.
Operates similarly to numpy ndarray bracket operator, returning a sliced, potentially sparse subview
The following two snippets are functionally equivalent
std::vector<int> data(100*100*100); FieldView view(data.data(), fd_array<int>(100, 100, 100)); // get a slice of all elements in the first dimension with second // and third pinned to 10 and 20 respectively FieldView subview = view.subview(keep(), 10, 20);
import numpy as np arr = np.ndarray(shape=(100,100,100), dtype=np.int32) subview = arr[:,10,20]
-
template<typename ...Args>
inline FieldView reshape(Args... dims) const¶ Reshape field view to a different set of dimensions.
-
size_t bytes() const noexcept¶
Returns the number of allocated bytes in memory.
- Returns:
size in bytes
-
size_t size() const¶
Returns size in elements, or 1 if field is not an array.
- Returns:
size in elements
-
bool matches(const FieldDescriptor &d) const noexcept¶
returns true if FieldView matches descriptor
- Parameters:
d[in] descriptor to check
- Returns:
true if matched, otherwise false
-
const FieldDescriptor &desc() const¶
Get descriptor of the underlying memory.
- Returns:
-
const std::vector<size_t> &shape() const¶
Get shape of the stored array, if present.
shorthand for
desc().shape- Returns:
vector of dimensions
-
ChanFieldType tag() const¶
Get type tag, if applicable.
- Returns:
ChanFieldType
-
template<typename T>
inline void fill(const T &value)¶ Set all values in the FieldView to the provided value.
- Throws:
std::invalid_argument – if type T does not match the field type
std::invalid_argument – if the field has more than 4 dimensions
- Template Parameters:
T – value type
- Parameters:
value[in] value to fill with
-
FieldView(void *ptr, FieldDescriptor desc)¶