1#include "../include/face.h"
12 std::filesystem::path absolute_path = std::filesystem::current_path();
19 Eigen::MatrixXd tmp_faces =
78 Eigen::MatrixXd vol_mesh_vertices;
81 nlohmann::basic_json<>::value_type x_pc, y_pc, z_pc;
86 nlohmann::json incoming_data = nlohmann::json::parse(buffer);
89 x_pc = incoming_data[
"x"];
90 y_pc = incoming_data[
"y"];
91 z_pc = incoming_data[
"z"];
93 vol_mesh_vertices.resize(x_pc.size(), 3);
98 catch(nlohmann::json::parse_error& e)
106 for (
size_t i = 0; i < x_pc.size(); i++)
108 vol_mesh_vertices(i, 0) = x_pc[i];
109 vol_mesh_vertices(i, 1) = y_pc[i];
110 vol_mesh_vertices(i, 2) = z_pc[i];
115 vol_mesh_vertices.transpose()).transpose();
124 Eigen::Vector3d({x_cg, y_cg, z_cg});
146 struct sockaddr_in serv_addr;
148 if ((
m_socket = socket(AF_INET, SOCK_STREAM, 0)) < 0)
150 printf(
"\n Socket creation error \n");
153 serv_addr.sin_family = AF_INET;
159 printf(
"\nInvalid address/ Address not supported \n");
162 if (connect(
m_socket, (
struct sockaddr *)&serv_addr,
sizeof(serv_addr)) < 0)
164 printf(
"\nConnection Failed \n");
180 Eigen::MatrixXd t_mat = Eigen::MatrixXd(vert_num, offset.rows());
183 Eigen::VectorXd ones_vec = Eigen::VectorXd::Ones(vert_num);
185 for(
size_t i = 0; i < offset.rows(); i++)
187 t_mat.col(i) = offset(i) * ones_vec;
static Eigen::Matrix3d rotation(double phi, double theta, double psi)
Euler rotation matrix z-y'-x''.
Eigen::MatrixXd incoming_data_callback(void)
Read incoming data.
const int m_vertices_num
Number of vertices provided by the mediapipe. This is constant.
Eigen::MatrixXi m_surf_indices
The surface element indices of the incoming mesh.
Eigen::MatrixXd get_vertices(void)
Get face vertices.
int m_socket
Socket handle.
Eigen::Matrix3d m_rot_mat
Face rotation matrix.
Eigen::Matrix3d m_scale_mat
std::string m_vertices_connections_rel_filename
Relative name of vertices connection files.
Eigen::Vector3d m_face_offset
Eigen::MatrixXd translation_matrix(const Eigen::Vector3d &offset, size_t vert_num)
This function offset a set of vertices by a given offset.
std::string m_local_ip_address
Start tcp client at this ip adress (localhost).
Eigen::MatrixXd m_vol_mesh_vertices
Volume mesh data.
bool m_return_value
Termination flag for callback function.
void setup_tcp_communication(void)
Setup communication with python server.
std::future< Eigen::MatrixXd > m_future_fun
Future function handle.
std::filesystem::path m_vertices_connections_abs_path
Absolute name of vertices connection files.
static Eigen::MatrixXd load_matrix_data(std::string filename)
Load Eigen double matrix from csv file.