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

also transfer vector arrays

(we should design a small container atop the va to store the additional
info we need to transfer: min/max, bbox, timeval)
parent c141c2d7
Branches
Tags
No related merge requests found
...@@ -53,7 +53,7 @@ int GmshDaemon(std::string socket) ...@@ -53,7 +53,7 @@ int GmshDaemon(std::string socket)
view->getOptions()->intervalsType = PViewOptions::Iso; view->getOptions()->intervalsType = PViewOptions::Iso;
view->fillVertexArrays(); view->fillVertexArrays();
int len; int len;
char *ss = view->va_triangles->toChar(view->getNum(), len); char *ss = view->va_triangles->toChar(view->getNum(), 3, len);
client.SendMessage(GmshSocket::GMSH_VERTEX_ARRAY, len, ss); client.SendMessage(GmshSocket::GMSH_VERTEX_ARRAY, len, ss);
delete [] ss; delete [] ss;
} }
......
...@@ -217,7 +217,7 @@ int VertexArray::getMemoryUsage() ...@@ -217,7 +217,7 @@ int VertexArray::getMemoryUsage()
return bytes / 1024 / 1024; return bytes / 1024 / 1024;
} }
char *VertexArray::toChar(int num, int &len) char *VertexArray::toChar(int num, int type, int &len)
{ {
int vn = _vertices.size(), nn = _normals.size(), cn = _colors.size(); int vn = _vertices.size(), nn = _normals.size(), cn = _colors.size();
int vs = vn * sizeof(float), ns = nn * sizeof(char), cs = cn * sizeof(unsigned char); int vs = vn * sizeof(float), ns = nn * sizeof(char), cs = cn * sizeof(unsigned char);
...@@ -227,7 +227,7 @@ char *VertexArray::toChar(int num, int &len) ...@@ -227,7 +227,7 @@ char *VertexArray::toChar(int num, int &len)
char *data = new char[len]; char *data = new char[len];
int index = 0; int index = 0;
memcpy(&data[index], &num, is); index += is; memcpy(&data[index], &num, is); index += is;
memcpy(&data[index], &_numVerticesPerElement, is); index += is; memcpy(&data[index], &type, is); index += is;
memcpy(&data[index], &vn, is); index += is; memcpy(&data[index], &vn, is); index += is;
memcpy(&data[index], &_vertices[0], vs); index += vs; memcpy(&data[index], &_vertices[0], vs); index += vs;
memcpy(&data[index], &nn, is); index += is; memcpy(&data[index], &nn, is); index += is;
...@@ -246,12 +246,7 @@ void VertexArray::fromChar(const char *data, bool swap) ...@@ -246,12 +246,7 @@ void VertexArray::fromChar(const char *data, bool swap)
int is = sizeof(int), index = 0; int is = sizeof(int), index = 0;
int num; memcpy(&num, &data[index], is); index += is; int num; memcpy(&num, &data[index], is); index += is;
int tmp; memcpy(&tmp, &data[index], is); index += is; int type; memcpy(&type, &data[index], is); index += is;
if(tmp != _numVerticesPerElement){
Msg::Error("Incompatible raw data for vertex array (%d != %d)",
tmp, _numVerticesPerElement);
return;
}
int vn; memcpy(&vn, &data[index], is); index += is; int vn; memcpy(&vn, &data[index], is); index += is;
_vertices.resize(vn); int vs = vn * sizeof(float); _vertices.resize(vn); int vs = vn * sizeof(float);
......
...@@ -163,7 +163,7 @@ class VertexArray{ ...@@ -163,7 +163,7 @@ class VertexArray{
int getMemoryUsage(); int getMemoryUsage();
// serialize the vertex array into a string (for sending over the // serialize the vertex array into a string (for sending over the
// network) // network)
char *toChar(int num, int &len); char *toChar(int num, int type, int &len);
void fromChar(const char *data, bool swap=false); void fromChar(const char *data, bool swap=false);
}; };
......
...@@ -1126,6 +1126,11 @@ void PView::fillVertexArray(int length, const char *bytes) ...@@ -1126,6 +1126,11 @@ void PView::fillVertexArray(int length, const char *bytes)
int num; memcpy(&num, &bytes[0], is); int num; memcpy(&num, &bytes[0], is);
int type; memcpy(&type, &bytes[is], is); int type; memcpy(&type, &bytes[is], is);
// we should also serialize the following info
// min, max
// time value
// bounding box
Msg::Info("Filling vertex array (type %d) in view num %d", type, num); Msg::Info("Filling vertex array (type %d) in view num %d", type, num);
PView *view; PView *view;
...@@ -1153,6 +1158,11 @@ void PView::fillVertexArray(int length, const char *bytes) ...@@ -1153,6 +1158,11 @@ void PView::fillVertexArray(int length, const char *bytes)
view->va_triangles = new VertexArray(3, 100); view->va_triangles = new VertexArray(3, 100);
view->va_triangles->fromChar(bytes); view->va_triangles->fromChar(bytes);
break; break;
case 4:
if(view->va_vectors) delete view->va_vectors;
view->va_vectors = new VertexArray(2, 100);
view->va_vectors->fromChar(bytes);
break;
default: default:
Msg::Error("Cannot fill vertex array of type %d", type); Msg::Error("Cannot fill vertex array of type %d", type);
return; return;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment