 |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
Go to the documentation of this file.
13 #include <msgpack.hpp>
30 std::memcpy(&b, &
a,
sizeof(uint8_t));
105 static std::string
MsgId() {
return "array"; }
111 const std::vector<int64_t>&
shape) {
113 arr.
type = TypeStr<T>();
115 arr.
data.ptr = (
const char*)ptr;
117 for (int64_t n :
shape) num *= n;
118 arr.
data.size = uint32_t(
sizeof(T) * num);
129 auto arr = messages::Array::FromPtr(
130 (scalar_t*)t.GetDataPtr(),
131 static_cast<std::vector<int64_t>>(t.GetShape()));
153 std::string& errstr)
const {
154 for (
auto rank : expected_ranks) {
155 if (
shape.size() ==
size_t(rank))
return true;
157 errstr +=
" expected rank to be in (";
158 for (
auto rank : expected_ranks) {
161 errstr += std::string(
")") +
" but got shape [";
162 for (
auto d :
shape) {
168 bool CheckRank(
const std::vector<int>& expected_ranks)
const {
177 std::string& errstr)
const {
178 if (!
CheckRank({int(expected_shape.size())}, errstr)) {
182 for (
size_t i = 0; i < expected_shape.size(); ++i) {
183 int64_t d_expected = expected_shape[i];
184 int64_t d =
shape[i];
185 if ((d_expected != -1 && d_expected != d) || d < 0) {
186 errstr +=
" expected shape [";
187 for (
auto d : expected_shape) {
194 errstr +=
"] but got [";
195 for (
auto d :
shape) {
204 bool CheckShape(
const std::vector<int64_t>& expected_shape)
const {
214 for (
auto d :
shape) n *= d;
215 if (0 == n ||
shape.empty()) {
216 errstr +=
" expected non empty array but got array with shape [";
217 for (
auto d :
shape) {
233 bool CheckType(
const std::vector<std::string>& expected_types,
234 std::string& errstr)
const {
235 for (
const auto& t : expected_types) {
236 if (t ==
type)
return true;
238 errstr +=
" expected array type to be one of (";
239 for (
const auto& t : expected_types) {
242 errstr +=
") but got " +
type;
245 bool CheckType(
const std::vector<std::string>& expected_types)
const {
256 static std::string
MsgId() {
return "mesh_data"; }
310 std::string tmp =
"invalid vertices array:";
313 if (!status) errstr += tmp;
320 std::string tmp =
"invalid faces array:";
344 tmp +=
" expected shape [?, >2] but got [" +
361 " invalid o3d_type. Expected 'PointCloud', 'TriangleMesh', "
362 "or 'LineSet' but got '" +
369 std::string tmp =
"invalid mesh_data message:";
372 if (!status) errstr += tmp;
392 static std::string
MsgId() {
return "set_mesh_data"; }
411 static std::string
MsgId() {
return "get_mesh_data"; }
427 static std::string
MsgId() {
return "camera_data"; }
435 std::array<double, 4>
R;
437 std::array<double, 3>
t;
459 static std::string
MsgId() {
return "set_camera_data"; }
479 static std::string
MsgId() {
return "set_time"; }
489 static std::string
MsgId() {
return "set_active_camera"; }
498 static std::string
MsgId() {
return "set_properties"; }
523 static std::string
MsgId() {
return "status"; }
529 return Status(1,
"unsupported msg_id");
532 return Status(2,
"error during unpacking");
535 return Status(3,
"error while processing message");
CameraData data
The data to be set.
Definition: Messages.h:471
Generic file read and write utility for python interface.
Definition: CloudViewerConfig.cpp:12
bool CheckFaces(std::string &errstr) const
Definition: Messages.h:317
MSGPACK_DEFINE_MAP(path, time, layer)
bool IsLittleEndian()
Definition: endian.h:58
static Array FromPtr(const T *const ptr, const std::vector< int64_t > &shape)
Definition: Messages.h:110
static std::string MsgId()
Definition: Messages.h:256
MSGPACK_DEFINE_MAP(path, time, layer, data)
int32_t time
Definition: Messages.h:481
void SetO3DTypeToPointCloud()
Definition: Messages.h:300
bool O3DTypeIsTriangleMesh() const
Definition: Messages.h:306
std::string o3d_type
Definition: Messages.h:262
std::string TypeStr< uint64_t >()
Definition: Messages.h:80
MSGPACK_DEFINE_MAP(msg_id)
std::string EndiannessStr()
Definition: Messages.h:24
static Status ErrorUnpackingFailed()
Definition: Messages.h:531
std::string TypeStr< double >()
Definition: Messages.h:48
int32_t time
The time associated with this data.
Definition: Messages.h:399
std::string str
string representation of the code
Definition: Messages.h:541
GetMeshData()
Definition: Messages.h:413
Status()
Definition: Messages.h:525
Tensor Contiguous() const
Definition: Tensor.cpp:772
static std::string MsgId()
Definition: Messages.h:105
std::string intrinsic_model
Definition: Messages.h:442
static Status ErrorUnsupportedMsgId()
Definition: Messages.h:528
std::map< std::string, Array > images
map of arrays that can be interpreted as camera images
Definition: Messages.h:450
static std::string MsgId()
Definition: Messages.h:523
Status(int code, const std::string &str)
Definition: Messages.h:526
static std::string MsgId()
Definition: Messages.h:498
std::array< double, 3 > t
translation
Definition: Messages.h:437
bool CheckShape(const std::vector< int64_t > &expected_shape, std::string &errstr) const
Definition: Messages.h:176
std::array< double, 4 > R
rotation R as quaternion [x,y,z,w]
Definition: Messages.h:435
int32_t time
The time for which to return the data.
Definition: Messages.h:418
static Array FromTensor(const core::Tensor &tensor)
Definition: Messages.h:125
std::string layer
The layer for which to return the data.
Definition: Messages.h:420
bool O3DTypeIsLineSet() const
Definition: Messages.h:305
MSGPACK_DEFINE_MAP(msg_id)
Array lines
Definition: Messages.h:287
Array vertices
shape must be [num_verts,3]
Definition: Messages.h:265
CameraData()
Definition: Messages.h:429
bool CheckVertices(std::string &errstr) const
Definition: Messages.h:308
const T * Ptr() const
Definition: Messages.h:146
std::string path
Path defining the location in the scene tree.
Definition: Messages.h:397
std::string path
Definition: Messages.h:490
bool CheckRank(const std::vector< int > &expected_ranks) const
Definition: Messages.h:168
std::string layer
The layer for this data.
Definition: Messages.h:401
SetTime()
Definition: Messages.h:480
bool CheckNonEmpty(std::string &errstr) const
Definition: Messages.h:212
std::map< std::string, Array > face_attributes
stores arbitrary attributes for each face
Definition: Messages.h:278
SetCameraData()
Definition: Messages.h:461
std::string TypeStr< float >()
Definition: Messages.h:44
MSGPACK_DEFINE_MAP(code, str)
std::string msg_id
Definition: Messages.h:509
Definition: Messages.h:391
std::map< std::string, Array > texture_maps
map of arrays that can be interpreted as textures
Definition: Messages.h:298
MSGPACK_DEFINE_MAP(R, t, intrinsic_model, intrinsic_parameters, width, height, images)
int height
Definition: Messages.h:447
SetMeshData()
Definition: Messages.h:394
Definition: Messages.h:508
static std::string MsgId()
Definition: Messages.h:489
bool CheckShape(const std::vector< int64_t > &expected_shape) const
Definition: Messages.h:204
std::map< std::string, float > material_scalar_attributes
Material scalar properties.
Definition: Messages.h:294
std::string path
Path defining the location in the scene tree.
Definition: Messages.h:464
static Status OK()
Definition: Messages.h:527
core::Tensor tensor_
Definition: Messages.h:139
Definition: Messages.h:522
std::vector< int64_t > shape
Definition: Messages.h:142
static std::string MsgId()
Definition: Messages.h:392
std::string TypeStr< uint32_t >()
Definition: Messages.h:76
std::string path
Path defining the location in the scene tree.
Definition: Messages.h:416
MeshData data
The data to be set.
Definition: Messages.h:404
MSGPACK_DEFINE_MAP(path, time, layer, data)
bool CheckO3DType(std::string &errstr) const
Definition: Messages.h:355
std::string TypeStr< int64_t >()
Definition: Messages.h:64
a[190]
Definition: essential_matrix_poly.h:19
int width
image dimensions in pixels
Definition: Messages.h:446
bool CheckRank(const std::vector< int > &expected_ranks, std::string &errstr) const
Definition: Messages.h:152
static std::string MsgId()
Definition: Messages.h:427
std::map< std::string, std::array< float, 4 > > material_vector_attributes
Material vector[4] properties.
Definition: Messages.h:296
Definition: Messages.h:478
struct for storing MeshData, e.g., PointClouds, TriangleMesh, ..
Definition: Messages.h:255
bool CheckType(const std::vector< std::string > &expected_types, std::string &errstr) const
Definition: Messages.h:233
Definition: Messages.h:458
void SetO3DTypeToLineSet()
Definition: Messages.h:301
std::string msg_id
Definition: Messages.h:516
MSGPACK_DEFINE_MAP(type, shape, data)
Definition: Messages.h:488
msgpack::type::raw_ref data
Definition: Messages.h:143
std::string type
Definition: Messages.h:141
std::string TypeStr< uint8_t >()
Definition: Messages.h:68
static Status ErrorProcessingMessage()
Definition: Messages.h:534
#define DISPATCH_DTYPE_TO_TEMPLATE(DTYPE,...)
Definition: Dispatch.h:31
int32_t time
The time for which to return the data.
Definition: Messages.h:466
Definition: Messages.h:497
struct for defining a "get_mesh_data" message, which requests mesh data.
Definition: Messages.h:410
Array faces
Definition: Messages.h:276
std::string TypeStr< int16_t >()
Definition: Messages.h:56
std::string TypeStr< uint16_t >()
Definition: Messages.h:72
Definition: Messages.h:104
static std::string MsgId()
Definition: Messages.h:479
bool CheckMessage(std::string &errstr) const
Definition: Messages.h:368
bool CheckNonEmpty() const
Definition: Messages.h:225
void SetO3DTypeToTriangleMesh()
Definition: Messages.h:302
std::string path
Definition: Messages.h:499
Definition: Messages.h:515
std::map< std::string, Array > vertex_attributes
Definition: Messages.h:268
std::string layer
The layer for which to return the data.
Definition: Messages.h:468
static std::string MsgId()
Definition: Messages.h:459
std::map< std::string, Array > line_attributes
stores arbitrary attributes for each line
Definition: Messages.h:289
bool O3DTypeIsPointCloud() const
Definition: Messages.h:304
bool CheckType(const std::vector< std::string > &expected_types) const
Definition: Messages.h:245
std::string material
Material for DrawableGeometry.
Definition: Messages.h:292
static std::string MsgId()
Definition: Messages.h:411
std::string to_string(const T &n)
Definition: Common.h:20
std::string TypeStr< int32_t >()
Definition: Messages.h:60
std::string TypeStr()
Definition: Messages.h:40
std::string TypeStr< int8_t >()
Definition: Messages.h:52
MSGPACK_DEFINE_MAP(o3d_type, vertices, vertex_attributes, faces, face_attributes, lines, line_attributes, material, material_scalar_attributes, material_vector_attributes, texture_maps)
std::vector< double > intrinsic_parameters
Definition: Messages.h:443
Tensor To(Dtype dtype, bool copy=false) const
Definition: Tensor.cpp:739
struct for storing camera data
Definition: Messages.h:426
int32_t code
return code. 0 means everything is OK.
Definition: Messages.h:539