ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
MessageUtils.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <map>
11 #include <tuple>
12 
18 
19 namespace zmq {
20 class message_t;
21 }
22 
23 namespace cloudViewer {
24 namespace io {
25 namespace rpc {
26 
27 namespace messages {
28 struct Array;
29 struct Status;
30 struct MeshData;
31 } // namespace messages
32 
46 std::shared_ptr<messages::Status> UnpackStatusFromReply(
47  const zmq::message_t& msg, size_t& offset, bool& ok);
48 
50 bool ReplyIsOKStatus(const zmq::message_t& msg);
51 
54 bool ReplyIsOKStatus(const zmq::message_t& msg, size_t& offset);
55 
57 std::string CreateSerializedRequestMessage(const std::string& msg_id);
58 
59 std::tuple<const void*, size_t> GetZMQMessageDataAndSize(
60  const zmq::message_t& msg);
61 
62 std::tuple<int32_t, std::string> GetStatusCodeAndStr(
63  const messages::Status& status);
64 
65 std::shared_ptr<zmq::message_t> CreateStatusOKMsg();
66 
72 std::shared_ptr<t::geometry::Geometry> MeshDataToGeometry(
73  const messages::MeshData& mesh_data);
74 
77 messages::MeshData GeometryToMeshData(const t::geometry::TriangleMesh& trimesh);
78 
81 messages::MeshData GeometryToMeshData(const t::geometry::PointCloud& pcd);
82 
85 messages::MeshData GeometryToMeshData(const t::geometry::LineSet& ls);
86 
91 std::tuple<std::string, double, std::shared_ptr<t::geometry::Geometry>>
92 DataBufferToMetaGeometry(std::string& data);
93 
94 } // namespace rpc
95 } // namespace io
96 } // namespace cloudViewer
int offset
::ccPointCloud PointCloud
Definition: PointCloud.h:19
std::shared_ptr< t::geometry::Geometry > MeshDataToGeometry(const messages::MeshData &mesh_data)
std::shared_ptr< zmq::message_t > CreateStatusOKMsg()
std::tuple< std::string, double, std::shared_ptr< t::geometry::Geometry > > DataBufferToMetaGeometry(std::string &data)
std::tuple< const void *, size_t > GetZMQMessageDataAndSize(const zmq::message_t &msg)
std::string CreateSerializedRequestMessage(const std::string &msg_id)
Creates a serialized Request message for testing purposes.
std::shared_ptr< messages::Status > UnpackStatusFromReply(const zmq::message_t &msg, size_t &offset, bool &ok)
bool ReplyIsOKStatus(const zmq::message_t &msg)
Convenience function for checking if the message is an OK.
messages::MeshData GeometryToMeshData(const t::geometry::TriangleMesh &trimesh)
std::tuple< int32_t, std::string > GetStatusCodeAndStr(const messages::Status &status)
Generic file read and write utility for python interface.