ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cloudViewer::io::rpc Namespace Reference

Namespaces

 messages
 

Classes

class  BufferConnection
 Implements a connection writing to a buffer. More...
 
class  Connection
 
class  ConnectionBase
 Base class for all connections. More...
 
class  DummyMessageProcessor
 
class  DummyReceiver
 
class  MessageProcessorBase
 
class  ZMQReceiver
 Class for the server side receiving requests from a client. More...
 

Functions

std::shared_ptr< messages::StatusUnpackStatusFromReply (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. More...
 
bool ReplyIsOKStatus (const zmq::message_t &msg, size_t &offset)
 
std::string CreateSerializedRequestMessage (const std::string &msg_id)
 Creates a serialized Request message for testing purposes. More...
 
std::tuple< const void *, size_t > GetZMQMessageDataAndSize (const zmq::message_t &msg)
 
std::tuple< int32_t, std::string > GetStatusCodeAndStr (const messages::Status &status)
 
std::shared_ptr< zmq::message_t > CreateStatusOKMsg ()
 
static core::Tensor ArrayToTensor (const messages::Array &array)
 
static std::map< std::string, messages::ArrayTensorMapToArrayMap (const t::geometry::TensorMap &tensor_map)
 Converts a TensorMap to an Array map. More...
 
static Material GetMaterialFromMeshData (const messages::MeshData &mesh_data, std::string &errstr)
 
std::shared_ptr< t::geometry::GeometryMeshDataToGeometry (const messages::MeshData &mesh_data)
 
static void AddMaterialToMeshData (messages::MeshData &mesh_data, const Material &material)
 
messages::MeshData GeometryToMeshData (const t::geometry::TriangleMesh &trimesh)
 
messages::MeshData GeometryToMeshData (const t::geometry::PointCloud &pcd)
 
messages::MeshData GeometryToMeshData (const t::geometry::LineSet &ls)
 
std::tuple< std::string, double, std::shared_ptr< t::geometry::Geometry > > DataBufferToMetaGeometry (std::string &data)
 
bool SetPointCloud (const ccPointCloud &pcd, const std::string &path, int time, const std::string &layer, std::shared_ptr< ConnectionBase > connection)
 
bool SetTriangleMesh (const ccMesh &mesh, const std::string &path, int time, const std::string &layer, std::shared_ptr< ConnectionBase > connection)
 
bool SetTriangleMesh (const t::geometry::TriangleMesh &mesh, const std::string &path, int time, const std::string &layer, std::shared_ptr< ConnectionBase > connection)
 
bool SetMeshData (const std::string &path, int time, const std::string &layer, const core::Tensor &vertices, const std::map< std::string, core::Tensor > &vertex_attributes, const core::Tensor &faces, const std::map< std::string, core::Tensor > &face_attributes, const core::Tensor &lines, const std::map< std::string, core::Tensor > &line_attributes, const std::string &material, const std::map< std::string, float > &material_scalar_attributes, const std::map< std::string, std::array< float, 4 >> &material_vector_attributes, const std::map< std::string, t::geometry::Image > &texture_maps, const std::string &o3d_type, std::shared_ptr< ConnectionBase > connection)
 
bool SetLegacyCamera (const camera::PinholeCameraParameters &camera, const std::string &path, int time, const std::string &layer, std::shared_ptr< ConnectionBase > connection)
 
bool SetTime (int time, std::shared_ptr< ConnectionBase > connection)
 
bool SetActiveCamera (const std::string &path, std::shared_ptr< ConnectionBase > connection)
 
std::shared_ptr< zmq::context_t > GetZMQContext ()
 Returns the zeromq context for this process. More...
 
void DestroyZMQContext ()
 

Function Documentation

◆ AddMaterialToMeshData()

◆ ArrayToTensor()

static core::Tensor cloudViewer::io::rpc::ArrayToTensor ( const messages::Array array)
static

◆ CreateSerializedRequestMessage()

std::string cloudViewer::io::rpc::CreateSerializedRequestMessage ( const std::string &  msg_id)

Creates a serialized Request message for testing purposes.

Definition at line 67 of file MessageUtils.cpp.

◆ CreateStatusOKMsg()

std::shared_ptr< zmq::message_t > cloudViewer::io::rpc::CreateStatusOKMsg ( )

◆ DataBufferToMetaGeometry()

std::tuple< std::string, double, std::shared_ptr< t::geometry::Geometry > > cloudViewer::io::rpc::DataBufferToMetaGeometry ( std::string &  data)

This function returns the geometry, the path and the time stored in a SetMeshData message. data must contain the Request header message followed by the SetMeshData message. The function returns a null pointer for the geometry if not successful.

Definition at line 341 of file MessageUtils.cpp.

References cloudViewer::io::rpc::messages::SetMeshData::data, LogWarning, MeshDataToGeometry(), cloudViewer::io::rpc::messages::Request::msg_id, offset, cloudViewer::io::rpc::messages::SetMeshData::path, result, and cloudViewer::io::rpc::messages::SetMeshData::time.

Referenced by cloudViewer::io::pybind_rpc().

◆ DestroyZMQContext()

void cloudViewer::io::rpc::DestroyZMQContext ( )

Destroys the zeromq context for this process. On windows this needs to be called manually for a clean shutdown of the process.

Definition at line 30 of file ZMQContext.cpp.

Referenced by cloudViewer::io::pybind_rpc().

◆ GeometryToMeshData() [1/3]

◆ GeometryToMeshData() [2/3]

◆ GeometryToMeshData() [3/3]

◆ GetMaterialFromMeshData()

◆ GetStatusCodeAndStr()

std::tuple< int32_t, std::string > cloudViewer::io::rpc::GetStatusCodeAndStr ( const messages::Status status)

◆ GetZMQContext()

std::shared_ptr< zmq::context_t > cloudViewer::io::rpc::GetZMQContext ( )

Returns the zeromq context for this process.

Definition at line 22 of file ZMQContext.cpp.

◆ GetZMQMessageDataAndSize()

std::tuple< const void *, size_t > cloudViewer::io::rpc::GetZMQMessageDataAndSize ( const zmq::message_t &  msg)

Definition at line 74 of file MessageUtils.cpp.

◆ MeshDataToGeometry()

◆ ReplyIsOKStatus() [1/2]

bool cloudViewer::io::rpc::ReplyIsOKStatus ( const zmq::message_t &  msg)

Convenience function for checking if the message is an OK.

Definition at line 53 of file MessageUtils.cpp.

References offset, and ReplyIsOKStatus().

Referenced by SetActiveCamera(), SetLegacyCamera(), SetMeshData(), SetPointCloud(), SetTime(), and SetTriangleMesh().

◆ ReplyIsOKStatus() [2/2]

bool cloudViewer::io::rpc::ReplyIsOKStatus ( const zmq::message_t &  msg,
size_t &  offset 
)

Convenience function for checking if the message is an OK.

Parameters
offset
See also
UnpackStatusFromReply

Definition at line 58 of file MessageUtils.cpp.

References offset, and UnpackStatusFromReply().

Referenced by ReplyIsOKStatus().

◆ SetActiveCamera()

bool cloudViewer::io::rpc::SetActiveCamera ( const std::string &  path,
std::shared_ptr< ConnectionBase connection = std::shared_ptr< ConnectionBase >() 
)

Sets the object with the specified path as the active camera.

Parameters
pathPath descriptor defining a location in the scene tree. E.g., 'mygroup/mycam'.
connectionThe connection object used for sending the data. If nullptr a default connection object will be used.

Definition at line 427 of file RemoteFunctions.cpp.

References cloudViewer::io::rpc::messages::SetActiveCamera::MsgId(), cloudViewer::io::rpc::messages::SetActiveCamera::path, cloudViewer::t::geometry::path, and ReplyIsOKStatus().

Referenced by cloudViewer::io::pybind_rpc().

◆ SetLegacyCamera()

bool cloudViewer::io::rpc::SetLegacyCamera ( const camera::PinholeCameraParameters camera,
const std::string &  path = "",
int  time = 0,
const std::string &  layer = "",
std::shared_ptr< ConnectionBase connection = std::shared_ptr< ConnectionBase >() 
)

Function for sending Camera data.

Parameters
cameraThe PinholeCameraParameters object.
pathPath descriptor defining a location in the scene tree. E.g., 'mygroup/mycam'.
timeThe time point associated with the object.
layerThe layer for this object.
connectionThe connection object used for sending the data. If nullptr a default connection object will be used.

Definition at line 353 of file RemoteFunctions.cpp.

References cloudViewer::io::rpc::messages::SetCameraData::data, cloudViewer::camera::PinholeCameraParameters::extrinsic_, cloudViewer::camera::PinholeCameraIntrinsic::GetSkew(), cloudViewer::io::rpc::messages::CameraData::height, cloudViewer::camera::PinholeCameraIntrinsic::height_, cloudViewer::camera::PinholeCameraParameters::intrinsic_, cloudViewer::camera::PinholeCameraIntrinsic::intrinsic_matrix_, cloudViewer::io::rpc::messages::CameraData::intrinsic_model, cloudViewer::io::rpc::messages::CameraData::intrinsic_parameters, cloudViewer::camera::PinholeCameraIntrinsic::IsValid(), cloudViewer::io::rpc::messages::SetCameraData::layer, LogWarning, cloudViewer::io::rpc::messages::SetCameraData::MsgId(), cloudViewer::io::rpc::messages::SetCameraData::path, cloudViewer::t::geometry::path, cloudViewer::io::rpc::messages::CameraData::R, ReplyIsOKStatus(), cloudViewer::io::rpc::messages::CameraData::t, cloudViewer::io::rpc::messages::SetCameraData::time, cloudViewer::io::rpc::messages::CameraData::width, and cloudViewer::camera::PinholeCameraIntrinsic::width_.

Referenced by cloudViewer::io::pybind_rpc().

◆ SetMeshData()

bool cloudViewer::io::rpc::SetMeshData ( const std::string &  path = "",
int  time = 0,
const std::string &  layer = "",
const core::Tensor vertices = core::Tensor({0}, core::Float32),
const std::map< std::string, core::Tensor > &  vertex_attributes = std::map< std::string, core::Tensor >(),
const core::Tensor faces = core::Tensor({0}, core::Int32),
const std::map< std::string, core::Tensor > &  face_attributes = std::map< std::string, core::Tensor >(),
const core::Tensor lines = core::Tensor({0}, core::Int32),
const std::map< std::string, core::Tensor > &  line_attributes = std::map< std::string, core::Tensor >(),
const std::string &  material = "",
const std::map< std::string, float > &  material_scalar_attributes = std::map< std::string, float >(),
const std::map< std::string, std::array< float, 4 >> &  material_vector_attributes = std::map< std::string, std::array< float, 4 >>(),
const std::map< std::string, t::geometry::Image > &  texture_maps = std::map< std::string, t::geometry::Image >(),
const std::string &  o3d_type = "",
std::shared_ptr< ConnectionBase connection = std::shared_ptr< ConnectionBase >() 
)

Function for sending general mesh data.

Parameters
pathPath descriptor defining a location in the scene tree. E.g., 'mygroup/mypoints'.
timeThe time point associated with the object.
layerThe layer for this object.
verticesTensor with vertices of shape [N,3]
vertex_attributesMap with Tensors storing vertex attributes. The first dim of each attribute must match the number of vertices.
facesTensor with vertex indices defining the faces. The Tensor is of rank 1 or 2. A rank 2 Tensor with shape [num_faces,n] defines num_faces n-gons. If the rank is 1 then polys of different lengths are stored sequentially. Each polygon is stored as a sequence 'n i1 i2 ... in' with n>=3. The type of the array must be int32_t or int64_t
face_attributesMap with Tensors storing face attributes. The first dim of each attribute must match the number of faces.
linesTensor with vertex indices defining the lines. The Tensor is of rank 1 or 2. A rank 2 Tensor with shape [num_lines,n] defines num_lines linestrips. If the rank is 1 then linestrips of different lengths are stored sequentially. Each linestrips is stored as a sequence 'n i1 i2 ... in' with n>=2. The type of the array must be int32_t or int64_t
line_attributesMap with Tensors storing line attributes. The first dim of each attribute must match the number of lines.
materialBasic material model for rendering a DrawableGeometry (e.g. defaultLit or defaultUnlit). Must be non-empty if any material attributes or texture maps are provided.
material_scalar_attributesMap of material scalar attributes for a DrawableGeometry Material (e.g. "point_size", "line_width" or "base_reflectance")
material_vector_attributesMap of material 4-vector attributes for a DrawableGeometry Material (e.g. "base_color" or "absorption_color")
texture_mapsMap of t::geometry::Image for storing textures.
o3d_typeThe type of the geometry. This is one of "PointCloud", "LineSet", "TriangleMesh". This argument should be specified for partial data that has no primary key data, e.g., a triangle mesh without vertices but with other attribute tensors.
connectionThe connection object used for sending the data. If nullptr a default connection object will be used.

Definition at line 202 of file RemoteFunctions.cpp.

References cloudViewer::io::rpc::messages::MeshData::CheckMessage(), cloudViewer::io::rpc::messages::SetMeshData::data, cloudViewer::io::rpc::messages::MeshData::face_attributes, cloudViewer::io::rpc::messages::MeshData::faces, cloudViewer::core::Float32, cloudViewer::core::Float64, cloudViewer::core::Tensor::GetDtype(), cloudViewer::core::Tensor::GetShape(), cloudViewer::core::Int32, cloudViewer::core::Int64, cloudViewer::io::rpc::messages::SetMeshData::layer, cloudViewer::io::rpc::messages::MeshData::line_attributes, cloudViewer::io::rpc::messages::MeshData::lines, LogError, cloudViewer::io::rpc::messages::MeshData::material, cloudViewer::io::rpc::messages::MeshData::material_scalar_attributes, cloudViewer::io::rpc::messages::MeshData::material_vector_attributes, cloudViewer::io::rpc::messages::SetMeshData::MsgId(), cloudViewer::core::Tensor::NumDims(), cloudViewer::core::Tensor::NumElements(), cloudViewer::io::rpc::messages::MeshData::o3d_type, cloudViewer::io::rpc::messages::SetMeshData::path, cloudViewer::t::geometry::path, ReplyIsOKStatus(), cloudViewer::io::rpc::messages::MeshData::texture_maps, cloudViewer::io::rpc::messages::SetMeshData::time, cloudViewer::core::Dtype::ToString(), cloudViewer::io::rpc::messages::MeshData::vertex_attributes, and cloudViewer::io::rpc::messages::MeshData::vertices.

Referenced by cloudViewer::io::pybind_rpc(), and SetTriangleMesh().

◆ SetPointCloud()

bool cloudViewer::io::rpc::SetPointCloud ( const ccPointCloud pcd,
const std::string &  path = "",
int  time = 0,
const std::string &  layer = "",
std::shared_ptr< ConnectionBase connection = std::shared_ptr< ConnectionBase >() 
)

◆ SetTime()

bool cloudViewer::io::rpc::SetTime ( int  time,
std::shared_ptr< ConnectionBase connection = std::shared_ptr< ConnectionBase >() 
)

Sets the time in the external visualizer.

Parameters
timeThe time value
connectionThe connection object used for sending the data. If nullptr a default connection object will be used.

Definition at line 410 of file RemoteFunctions.cpp.

References cloudViewer::io::rpc::messages::SetTime::MsgId(), ReplyIsOKStatus(), and cloudViewer::io::rpc::messages::SetTime::time.

Referenced by cloudViewer::io::pybind_rpc().

◆ SetTriangleMesh() [1/2]

bool cloudViewer::io::rpc::SetTriangleMesh ( const ccMesh mesh,
const std::string &  path = "",
int  time = 0,
const std::string &  layer = "",
std::shared_ptr< ConnectionBase connection = std::shared_ptr< ConnectionBase >() 
)

Function for sending a TriangleMesh.

Parameters
meshThe TriangleMesh object.
pathPath descriptor defining a location in the scene tree. E.g., 'mygroup/mypoints'.
timeThe time point associated with the object.
layerThe layer for this object.
connectionThe connection object used for sending the data. If nullptr a default connection object will be used.

Definition at line 71 of file RemoteFunctions.cpp.

References cloudViewer::io::rpc::messages::SetMeshData::data, cloudViewer::io::rpc::messages::MeshData::face_attributes, cloudViewer::io::rpc::messages::MeshData::faces, ccMesh::getAssociatedCloud(), ccPointCloud::getPointColors(), ccPointCloud::getPointNormalsPtr(), cloudViewer::PointCloudTpl< T >::getPoints(), ccMesh::getTriangleNormalsPtr(), ccMesh::getTrianglesPtr(), ccMesh::hasColors(), ccMesh::hasNormals(), ccMesh::hasTextures(), cloudViewer::GenericMesh::hasTriangles(), ccMesh::hasTriangleUvs(), ccMesh::hasTriNormals(), image, cloudViewer::io::rpc::messages::SetMeshData::layer, LogInfo, cloudViewer::io::rpc::messages::SetMeshData::MsgId(), normals, cloudViewer::io::rpc::messages::SetMeshData::path, cloudViewer::t::geometry::path, ReplyIsOKStatus(), cloudViewer::io::rpc::messages::MeshData::texture_maps, ccMesh::textures_, cloudViewer::io::rpc::messages::SetMeshData::time, patch::to_string(), ccHObjectCaster::ToPointCloud(), ccMesh::triangle_uvs_, cloudViewer::io::rpc::messages::MeshData::vertex_attributes, and cloudViewer::io::rpc::messages::MeshData::vertices.

Referenced by cloudViewer::io::pybind_rpc().

◆ SetTriangleMesh() [2/2]

bool cloudViewer::io::rpc::SetTriangleMesh ( const t::geometry::TriangleMesh mesh,
const std::string &  path = "",
int  time = 0,
const std::string &  layer = "",
std::shared_ptr< ConnectionBase connection = std::shared_ptr< ConnectionBase >() 
)

Function for sending a TriangleMesh.

Parameters
meshThe TriangleMesh object.
pathPath descriptor defining a location in the scene tree. E.g., 'mygroup/mypoints'.
timeThe time point associated with the object.
layerThe layer for this object.
connectionThe connection object used for sending the data. If nullptr a default connection object will be used.

Definition at line 161 of file RemoteFunctions.cpp.

References cloudViewer::t::geometry::DrawableGeometry::GetMaterial(), cloudViewer::visualization::rendering::Material::GetMaterialName(), cloudViewer::t::geometry::TriangleMesh::GetTriangleAttr(), cloudViewer::t::geometry::TriangleMesh::GetTriangleIndices(), cloudViewer::t::geometry::TriangleMesh::GetVertexAttr(), cloudViewer::t::geometry::TriangleMesh::GetVertexPositions(), cloudViewer::t::geometry::DrawableGeometry::HasMaterial(), cloudViewer::io::rpc::messages::MeshData::o3d_type, cloudViewer::t::geometry::path, SetMeshData(), and cloudViewer::io::rpc::messages::MeshData::SetO3DTypeToTriangleMesh().

◆ TensorMapToArrayMap()

static std::map<std::string, messages::Array> cloudViewer::io::rpc::TensorMapToArrayMap ( const t::geometry::TensorMap tensor_map)
static

Converts a TensorMap to an Array map.

Definition at line 131 of file MessageUtils.cpp.

References result.

Referenced by GeometryToMeshData().

◆ UnpackStatusFromReply()

std::shared_ptr< messages::Status > cloudViewer::io::rpc::UnpackStatusFromReply ( const zmq::message_t &  msg,
size_t &  offset,
bool &  ok 
)

Helper function for unpacking the Status message from a reply.

Parameters
msgThe message that contains the Reply and the Status messages.
offsetByte offset into the message. Defines where to start parsing the message. The offset will be updated and will point to the first byte after the parse messages. If unpacking fails offset will be set to the end of the message.
okOutput variable which will be set to true if the unpacking was successful.
Returns
The extracted Status message object. Check ok to see if the returned object is valid.

Definition at line 24 of file MessageUtils.cpp.

References LogDebug, cloudViewer::io::rpc::messages::Reply::msg_id, cloudViewer::io::rpc::messages::Status::MsgId(), and offset.

Referenced by ReplyIsOKStatus().