Skip to content
Snippets Groups Projects
Commit 96da7177 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

remote stuff now mostly functional

parent cd9b9aca
No related branches found
No related tags found
No related merge requests found
......@@ -12,9 +12,11 @@
#include "PViewOptions.h"
#include "PViewData.h"
#include "VertexArray.h"
#include "Context.h"
static void computeAndSendVertexArrays(GmshClient &client)
{
CTX::instance()->terminal = 1; // debug
client.Info("Sending vertex arrays");
for(unsigned int i = 0; i < PView::list.size(); i++){
PView *p = PView::list[i];
......@@ -23,7 +25,7 @@ static void computeAndSendVertexArrays(GmshClient &client)
VertexArray *va[4] =
{p->va_points, p->va_lines, p->va_triangles, p->va_vectors};
for(int type = 0; type < 4; type++){
if(va[type] && va[type]->getNumVertices()){
if(va[type]){
int len;
char *str = va[type]->toChar
(p->getNum(), type + 1, data->getMin(), data->getMax(),
......@@ -79,6 +81,7 @@ int GmshDaemon(std::string socket)
break;
}
else if(type == GmshSocket::GMSH_VERTEX_ARRAY){
ParseString(msg);
computeAndSendVertexArrays(client);
}
else if(type == GmshSocket::GMSH_MERGE_FILE){
......@@ -87,7 +90,6 @@ int GmshDaemon(std::string socket)
}
else if(type == GmshSocket::GMSH_PARSE_STRING){
ParseString(msg);
computeAndSendVertexArrays(client);
}
else if(type == GmshSocket::GMSH_SPEED_TEST){
client.Info("Sending huge array");
......
......@@ -241,11 +241,11 @@ char *VertexArray::toChar(int num, int type, double min, double max, double time
memcpy(&bytes[index], &ymax, ds); index += ds;
memcpy(&bytes[index], &zmax, ds); index += ds;
memcpy(&bytes[index], &vn, is); index += is;
memcpy(&bytes[index], &_vertices[0], vs); index += vs;
if(vs){ memcpy(&bytes[index], &_vertices[0], vs); index += vs; }
memcpy(&bytes[index], &nn, is); index += is;
memcpy(&bytes[index], &_normals[0], ns); index += ns;
if(ns){ memcpy(&bytes[index], &_normals[0], ns); index += ns; }
memcpy(&bytes[index], &cn, is); index += is;
memcpy(&bytes[index], &_colors[0], cs); index += cs;
if(cs){ memcpy(&bytes[index], &_colors[0], cs); index += cs; }
return bytes;
}
......@@ -270,14 +270,20 @@ void VertexArray::fromChar(const char *bytes)
double zmax; memcpy(&zmax, &bytes[index], ds); index += ds;
int vn; memcpy(&vn, &bytes[index], is); index += is;
if(vn){
_vertices.resize(vn); int vs = vn * sizeof(float);
memcpy(&_vertices[0], &bytes[index], vs); index += vs;
}
int nn; memcpy(&nn, &bytes[index], is); index += is;
if(nn){
_normals.resize(nn); int ns = nn * sizeof(char);
memcpy(&_normals[0], &bytes[index], ns); index += ns;
}
int cn; memcpy(&cn, &bytes[index], is); index += is;
if(cn){
_colors.resize(cn); int cs = cn * sizeof(unsigned char);
memcpy(&_colors[0], &bytes[index], cs); index += cs;
}
}
......@@ -71,8 +71,7 @@ class PViewDataRemote : public PViewData {
// FIXME: until we rewrite the option code and allow nice serialization ;-)
PrintOptions(0, GMSH_FULLRC, 0, 0, fileName.c_str());
std::string options = ConvertFileToString(fileName);
server->SendString(GmshSocket::GMSH_PARSE_STRING, options.c_str());
server->SendString(GmshSocket::GMSH_VERTEX_ARRAY, "Send the vertex arrays!");
server->SendString(GmshSocket::GMSH_VERTEX_ARRAY, options.c_str());
return 1;
}
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment