Open3D (C++ API)  0.11.0
Public Member Functions | Static Public Member Functions | Data Fields
open3d::io::rpc::messages::Array Struct Reference

#include <Messages.h>

Public Member Functions

template<class T >
const T * Ptr ()
 
 MSGPACK_DEFINE_MAP (type, shape, data)
 

Static Public Member Functions

static std::string MsgId ()
 
template<class T >
static Array FromPtr (const T *const ptr, const std::vector< int64_t > &shape)
 

Data Fields

std::string type
 
std::vector< int64_t > shape
 
msgpack::type::raw_ref data
 

Detailed Description

Array structure inspired by msgpack_numpy but not directly compatible because they use bin-type for the map keys and we must use string. This structure does not have ownership of the data.

The following code can be used in python to create a compatible dict

def numpy_to_Array(arr): if isinstance(arr, np.ndarray): return {'type': arr.dtype.str, 'shape': arr.shape, 'data': arr.tobytes()} raise Exception('object is not a numpy array')

This codes converts the dict back to numpy.ndarray

def Array_to_numpy(dic): return np.frombuffer(dic['data'], dtype=np.dtype(dic['type'])).reshape(dic['shape'])

Member Function Documentation

◆ FromPtr()

template<class T >
static Array open3d::io::rpc::messages::Array::FromPtr ( const T *const  ptr,
const std::vector< int64_t > &  shape 
)
inlinestatic

◆ MsgId()

static std::string open3d::io::rpc::messages::Array::MsgId ( )
inlinestatic

◆ MSGPACK_DEFINE_MAP()

open3d::io::rpc::messages::Array::MSGPACK_DEFINE_MAP ( type  ,
shape  ,
data   
)

◆ Ptr()

template<class T >
const T* open3d::io::rpc::messages::Array::Ptr ( )
inline

Field Documentation

◆ data

msgpack::type::raw_ref open3d::io::rpc::messages::Array::data

◆ shape

std::vector<int64_t> open3d::io::rpc::messages::Array::shape

◆ type

std::string open3d::io::rpc::messages::Array::type

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