18 : _numVerticesPerElement(numVerticesPerElement)
22 double memv = (nb * 3. *
sizeof(float)) / 1024. / 1024.;
26 nb = memmax / (3. *
sizeof(float)) * 1024 * 1024;
27 Msg::Debug(
"Reduce preallocation of vertex array (%d -> %d)", old, nb);
36 int bytes =
_vertices.size() *
sizeof(float) +
38 _colors.size() *
sizeof(
unsigned char);
39 return (
double)bytes / 1024. / 1024.;
51 #if defined(HAVE_VISUDEV)
82 unsigned int *col,
MElement *ele,
bool unique,
bool boundary)
85 unsigned char r[100], g[100], b[100], a[100];
87 for(
int i = 0; i < npe; i++){
93 add(x, y,
z, n, r, g, b, a, ele, unique, boundary);
96 add(x, y,
z, n,
nullptr,
nullptr,
nullptr,
nullptr, ele, unique, boundary);
100 unsigned char *g,
unsigned char *b,
unsigned char *a,
101 MElement *ele,
bool unique,
bool boundary)
105 if(boundary && npe == 3){
121 for(
int i = 0; i < npe; i++)
130 for(
int i = 0; i < npe; i++){
132 if(n)
_addNormal((
float)n[i].x(), (
float)n[i].y(), (
float)n[i].
z());
133 if(r && g && b && a)
_addColor(r[i], g[i], b[i], a[i]);
142 for(; it !=
_data3.end(); it++){
143 for(
int i = 0; i < 3; i++){
146 _addColor(it->r(i), it->g(i), it->b(i), it->a(i));
169 double cg1[3] = { 0., 0., 0. }, cg2[3] = { 0., 0., 0.};
171 cg1[0] += e1.
v[3 * i];
172 cg1[1] += e1.
v[3 * i + 1];
173 cg1[2] += e1.
v[3 * i + 2];
174 cg2[0] += e2.
v[3 * i];
175 cg2[1] += e2.
v[3 * i + 1];
176 cg2[2] += e2.
v[3 * i + 2];
199 std::vector<AlphaElement> elements;
201 for(
int i = 0; i < n; i++){
204 unsigned char *cp =
_colors.empty() ? nullptr : &
_colors[4 * npe * i];
209 std::vector<float> sortedVertices;
210 std::vector<normal_type> sortedNormals;
211 std::vector<unsigned char> sortedColors;
212 sortedVertices.reserve(
_vertices.size());
213 sortedNormals.reserve(
_normals.size());
214 sortedColors.reserve(
_colors.size());
216 for(
int i = 0; i < n; i++){
217 for(
int j = 0; j < npe; j++){
218 for(
int k = 0; k < 3; k++)
219 sortedVertices.push_back(elements[i].v[3 * j + k]);
221 for(
int k = 0; k < 3; k++)
222 sortedNormals.push_back(elements[i].n[3 * j + k]);
224 for(
int k = 0; k < 4; k++)
225 sortedColors.push_back(elements[i].c[4 * j + k]);
235 double min,
double max,
int numsteps,
double time,
239 int vs = vn *
sizeof(float),
241 cs = cn *
sizeof(
unsigned char);
242 int is =
sizeof(int), ds =
sizeof(
double);
243 int ss = name.size();
244 double xmin = bbox.
min().
x(), ymin = bbox.
min().
y(), zmin = bbox.
min().
z();
245 double xmax = bbox.
max().
x(), ymax = bbox.
max().
y(), zmax = bbox.
max().
z();
247 len = ss + 7 * is + 9 * ds + vs + ns + cs;
248 char *bytes =
new char[len];
250 memcpy(&bytes[index], &num, is); index += is;
251 memcpy(&bytes[index], &ss, is); index += is;
252 memcpy(&bytes[index], name.c_str(), ss); index += ss;
253 memcpy(&bytes[index], &type, is); index += is;
254 memcpy(&bytes[index], &min, ds); index += ds;
255 memcpy(&bytes[index], &max, ds); index += ds;
256 memcpy(&bytes[index], &numsteps, is); index += is;
257 memcpy(&bytes[index], &time, ds); index += ds;
258 memcpy(&bytes[index], &xmin, ds); index += ds;
259 memcpy(&bytes[index], &ymin, ds); index += ds;
260 memcpy(&bytes[index], &zmin, ds); index += ds;
261 memcpy(&bytes[index], &xmax, ds); index += ds;
262 memcpy(&bytes[index], &ymax, ds); index += ds;
263 memcpy(&bytes[index], &zmax, ds); index += ds;
264 memcpy(&bytes[index], &vn, is); index += is;
265 if(vs){ memcpy(&bytes[index], &
_vertices[0], vs); index += vs; }
266 memcpy(&bytes[index], &nn, is); index += is;
267 if(ns){ memcpy(&bytes[index], &
_normals[0], ns); index += ns; }
268 memcpy(&bytes[index], &cn, is); index += is;
269 if(cs){ memcpy(&bytes[index], &
_colors[0], cs); }
274 std::string &name,
int &tag,
int &type,
275 double &min,
double &max,
int &numSteps,
double &time,
276 double &xmin,
double &ymin,
double &zmin,
277 double &xmax,
double &ymax,
double &zmax)
279 int is =
sizeof(int), ds =
sizeof(
double);
281 if(
length < 4 * is + 9 * ds){
287 Msg::Error(
"Should swap bytes in vertex array--not implemented yet");
292 memcpy(&tag, &bytes[index], is); index += is;
293 int ss; memcpy(&ss, &bytes[index], is); index += is;
295 std::vector<char> n(ss);
296 memcpy(&n[0], &bytes[index], ss); index += ss;
297 for(std::size_t i = 0; i < n.size(); i++) name += n[i];
299 memcpy(&type, &bytes[index], is); index += is;
300 memcpy(&min, &bytes[index], ds); index += ds;
301 memcpy(&max, &bytes[index], ds); index += ds;
302 memcpy(&numSteps, &bytes[index], is); index += is;
303 memcpy(&time, &bytes[index], ds); index += ds;
304 memcpy(&xmin, &bytes[index], ds); index += ds;
305 memcpy(&ymin, &bytes[index], ds); index += ds;
306 memcpy(&zmin, &bytes[index], ds); index += ds;
307 memcpy(&xmax, &bytes[index], ds); index += ds;
308 memcpy(&ymax, &bytes[index], ds); index += ds;
309 memcpy(&zmax, &bytes[index], ds); index += ds;
316 int tag, type, numSteps;
317 double min, max, time, xmin, ymin, zmin, xmax, ymax, zmax;
319 numSteps, time, xmin, ymin, zmin, xmax, ymax, zmax);
322 int is =
sizeof(int);
323 int vn; memcpy(&vn, &bytes[index], is); index += is;
325 _vertices.resize(vn);
int vs = vn *
sizeof(float);
326 memcpy(&
_vertices[0], &bytes[index], vs); index += vs;
329 int nn; memcpy(&nn, &bytes[index], is); index += is;
333 memcpy(&
_normals[0], &bytes[index], ns); index += ns;
336 int cn; memcpy(&cn, &bytes[index], is); index += is;
338 _colors.resize(cn);
int cs = cn *
sizeof(
unsigned char);
339 memcpy(&
_colors[0], &bytes[index], cs);