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