28 static void saturate(
int nb,
double **val,
double vmin,
double vmax,
int i0 = 0,
29 int i1 = 1,
int i2 = 2,
int i3 = 3,
int i4 = 4,
int i5 = 5,
30 int i6 = 6,
int i7 = 7)
32 int id[8] = {i0, i1, i2, i3, i4, i5, i6, i7};
33 for(
int i = 0; i < nb; i++) {
34 if(val[
id[i]][0] > vmax)
36 else if(val[
id[i]][0] < vmin)
42 double min,
double max)
45 if(v < min && v > 1e-15) {
47 for(
int iComp = 0; iComp < numComp2; ++iComp) val2[iComp] *=
f;
53 if(v > max && v > 1e-15) {
55 for(
int iComp = 0; iComp < numComp2; ++iComp) val2[iComp] *=
f;
66 SVector3 t1(xyz[i1][0] - xyz[i0][0], xyz[i1][1] - xyz[i0][1],
67 xyz[i1][2] - xyz[i0][2]);
68 SVector3 t2(xyz[i2][0] - xyz[i0][0], xyz[i2][1] - xyz[i0][1],
69 xyz[i2][2] - xyz[i0][2]);
84 n[0] = (v - opt->
tmpMin) / (d ? d : 1.);
90 double *v,
SVector3 n[2],
bool computeNormal)
100 n[0][0] = (v[0] - opt->
tmpMin) / (d ? d : 1.);
101 n[1][0] = (v[1] - opt->
tmpMin) / (d ? d : 1.);
105 n[0][0] = n[1][0] = 1.;
108 else if(computeNormal) {
112 else if(bb.
min().
y() == bb.
max().
y())
114 else if(bb.
min().
x() == bb.
max().
x())
118 SVector3 t(x[1] - x[0], y[1] - y[0],
z[1] -
z[0]);
134 int numNodes,
int numComp,
double **val,
135 int &numComp2,
double **val2)
141 for(
int i = 0; i < numNodes; i++)
142 for(
int j = 0; j < numComp; j++) val2[i][j] = val[i][j];
146 if(index < 0 || index >= (
int)
PView::list.size())
return false;
156 for(
int i = 0; i < numNodes; i++)
157 for(
int j = 0; j < numComp2; j++)
177 double **vals,
double **xyz)
182 std::vector<double> values(14, 0.), res(3);
183 for(
int k = 0; k < numNodes; k++) {
184 for(
int i = 0; i < 3; i++) values[i] = xyz[k][i];
185 for(
int i = 0; i < std::min(numComp, 9); i++) values[3 + i] = vals[k][i];
189 for(
int i = 0; i < 3; i++) xyz[k][i] += opt->
genRaiseFactor * res[i];
194 int numComp,
double **xyz,
double **val)
199 double barycenter[3] = {0., 0., 0.};
200 for(
int i = 0; i < numNodes; i++)
201 for(
int j = 0; j < 3; j++) barycenter[j] += xyz[i][j];
202 for(
int j = 0; j < 3; j++) barycenter[j] /= (
double)numNodes;
203 for(
int i = 0; i < numNodes; i++)
204 for(
int j = 0; j < 3; j++)
205 xyz[i][j] = barycenter[j] + opt->
explode * (xyz[i][j] - barycenter[j]);
213 for(
int i = 0; i < numNodes; i++) {
214 double old[3] = {xyz[i][0], xyz[i][1], xyz[i][2]};
215 for(
int j = 0; j < 3; j++) {
217 for(
int k = 0; k < 3; k++) xyz[i][j] += opt->
transform[j][k] * old[k];
223 for(
int i = 0; i < numNodes; i++)
224 for(
int j = 0; j < 3; j++) xyz[i][j] += opt->
offset[j];
228 for(
int i = 0; i < numNodes; i++) {
230 for(
int j = 0; j < 3; j++) xyz[i][j] += opt->
raise[j] * v;
239 double x[2] = {xyz[0][0], xyz[1][0]};
240 double y[2] = {xyz[0][1], xyz[1][1]};
241 double z[2] = {xyz[0][2], xyz[1][2]};
243 SVector3 t(x[1] - x[0], y[1] - y[0],
z[1] -
z[0]);
249 for(
int i = 0; i < numNodes; i++) {
251 for(
int j = 0; j < 3; j++) xyz[i][j] += n[j] * opt->
normalRaise * v;
256 for(
int i = 0; i < numNodes; i++) {
257 for(
int j = 0; j < 3; j++)
264 double **val2 =
new double *[numNodes];
265 for(
int i = 0; i < numNodes; i++) val2[i] =
new double[9];
267 numComp, val, numComp2, val2);
269 for(
int i = 0; i < numNodes; i++)
delete[] val2[i];
285 for(
int i = 1; i < numNodes; i++) {
301 if(dim == 3 &&
CTX::instance()->clipOnlyDrawIntersectingVolume && d) {
316 bool pre,
int i0 = 0)
320 p->
va_points->
add(&xyz[i0][0], &xyz[i0][1], &xyz[i0][2], &n, &color,
nullptr,
325 int i0 = 0,
bool unique =
false)
334 if(val[i0][0] >= vmin && val[i0][0] <= vmax) {
336 val[i0][0], vmin, vmax,
false,
339 p->
va_points->
add(&xyz[i0][0], &xyz[i0][1], &xyz[i0][2], &n, &col,
nullptr,
345 int i0 = 0,
int i1 = 1)
349 const int in[2] = {i0, i1};
351 double x[2], y[2],
z[2];
352 for(
int i = 0; i < 2; i++) {
353 x[i] = xyz[in[i]][0];
354 y[i] = xyz[in[i]][1];
355 z[i] = xyz[in[i]][2];
364 int i0 = 0,
int i1 = 1,
bool unique =
false)
381 double x[2] = {xyz[i0][0], xyz[i1][0]};
382 double y[2] = {xyz[i0][1], xyz[i1][1]};
383 double z[2] = {xyz[i0][2], xyz[i1][2]};
384 double v[2] = {val[i0][0], val[i1][0]};
389 if(val[i0][0] >= vmin && val[i0][0] <= vmax && val[i1][0] >= vmin &&
390 val[i1][0] <= vmax) {
392 for(
int i = 0; i < 2; i++) col[i] = opt->
getColor(v[i], vmin, vmax);
396 double x2[2], y2[2], z2[2], v2[2];
397 int nb =
CutLine(x, y,
z, v, vmin, vmax, x2, y2, z2, v2);
400 for(
int i = 0; i < 2; i++) col[i] = opt->
getColor(v2[i], vmin, vmax);
401 p->
va_lines->
add(x2, y2, z2, n, col,
nullptr, unique);
407 for(
int k = 0; k < opt->
nbIso; k++) {
408 if(vmin == vmax) k = opt->
nbIso / 2;
411 double x2[2], y2[2], z2[2], v2[2];
412 int nb =
CutLine(x, y,
z, v, min, max, x2, y2, z2, v2);
415 unsigned int col[2] = {color, color};
418 p->
va_lines->
add(x2, y2, z2, n, col,
nullptr, unique);
420 if(vmin == vmax)
break;
425 for(
int k = 0; k < opt->
nbIso; k++) {
426 if(vmin == vmax) k = opt->
nbIso / 2;
428 double x2[1], y2[1], z2[1];
429 int nb =
IsoLine(x, y,
z, v, iso, x2, y2, z2);
433 p->
va_points->
add(x2, y2, z2, &n, &color,
nullptr, unique);
435 if(vmin == vmax)
break;
441 bool pre,
int i0 = 0,
int i1 = 1,
int i2 = 2)
445 const int il[3][2] = {{i0, i1}, {i1, i2}, {i2, i0}};
449 for(
int i = 0; i < 3; i++) {
450 double x[2] = {xyz[il[i][0]][0], xyz[il[i][1]][0]};
451 double y[2] = {xyz[il[i][0]][1], xyz[il[i][1]][1]};
452 double z[2] = {xyz[il[i][0]][2], xyz[il[i][1]][2]};
454 unsigned int col[2] = {color, color};
456 for(
int j = 0; j < 2; j++) {
458 p->
normals->
add(x[j], y[j],
z[j], n[j][0], n[j][1], n[j][2]);
460 p->
normals->
get(x[j], y[j],
z[j], n[j][0], n[j][1], n[j][2]);
464 if(!pre) p->
va_lines->
add(x, y,
z, n, col,
nullptr,
true);
469 int i0 = 0,
int i1 = 1,
int i2 = 2,
470 bool unique =
false,
bool skin =
false)
474 const int il[3][2] = {{i0, i1}, {i1, i2}, {i2, i0}};
478 for(
int i = 0; i < 3; i++)
487 double x[3] = {xyz[i0][0], xyz[i1][0], xyz[i2][0]};
488 double y[3] = {xyz[i0][1], xyz[i1][1], xyz[i2][1]};
489 double z[3] = {xyz[i0][2], xyz[i1][2], xyz[i2][2]};
490 double v[3] = {val[i0][0], val[i1][0], val[i2][0]};
495 if(val[i0][0] >= vmin && val[i0][0] <= vmax && val[i1][0] >= vmin &&
496 val[i1][0] <= vmax && val[i2][0] >= vmin && val[i2][0] <= vmax) {
499 for(
int i = 0; i < 3; i++) {
502 p->
normals->
add(x[i], y[i],
z[i], n[i][0], n[i][1], n[i][2]);
504 p->
normals->
get(x[i], y[i],
z[i], n[i][0], n[i][1], n[i][2]);
506 col[i] = opt->
getColor(v[i], vmin, vmax);
511 double x2[10], y2[10], z2[10], v2[10];
512 int nb =
CutTriangle(x, y,
z, v, vmin, vmax, x2, y2, z2, v2);
514 for(
int j = 2; j < nb; j++) {
515 double x3[3] = {x2[0], x2[j - 1], x2[j]};
516 double y3[3] = {y2[0], y2[j - 1], y2[j]};
517 double z3[3] = {z2[0], z2[j - 1], z2[j]};
518 double v3[3] = {v2[0], v2[j - 1], v2[j]};
521 for(
int i = 0; i < 3; i++) {
524 p->
normals->
add(x3[i], y3[i], z3[i], n[i][0], n[i][1], n[i][2]);
526 p->
normals->
get(x3[i], y3[i], z3[i], n[i][0], n[i][1], n[i][2]);
528 col[i] = opt->
getColor(v3[i], vmin, vmax);
538 for(
int k = 0; k < opt->
nbIso; k++) {
539 if(vmin == vmax) k = opt->
nbIso / 2;
542 double x2[10], y2[10], z2[10], v2[10];
543 int nb =
CutTriangle(x, y,
z, v, min, max, x2, y2, z2, v2);
546 unsigned int col[3] = {color, color, color};
547 for(
int j = 2; j < nb; j++) {
548 double x3[3] = {x2[0], x2[j - 1], x2[j]};
549 double y3[3] = {y2[0], y2[j - 1], y2[j]};
550 double z3[3] = {z2[0], z2[j - 1], z2[j]};
553 for(
int i = 0; i < 3; i++) {
555 p->
normals->
add(x3[i], y3[i], z3[i], n[i][0], n[i][1], n[i][2]);
557 p->
normals->
get(x3[i], y3[i], z3[i], n[i][0], n[i][1], n[i][2]);
564 if(vmin == vmax)
break;
569 for(
int k = 0; k < opt->
nbIso; k++) {
570 if(vmin == vmax) k = opt->
nbIso / 2;
572 double x2[3], y2[3], z2[3];
576 unsigned int col[2] = {color, color};
579 for(
int i = 0; i < 2; i++) {
581 p->
normals->
add(x2[i], y2[i], z2[i], n[i][0], n[i][1], n[i][2]);
583 p->
normals->
get(x2[i], y2[i], z2[i], n[i][0], n[i][1], n[i][2]);
586 double v[2] = {iso, iso};
588 if(!pre) p->
va_lines->
add(x2, y2, z2, n, col,
nullptr, unique);
590 if(vmin == vmax)
break;
596 bool pre,
int i0 = 0,
int i1 = 1,
int i2 = 2,
601 const int il[4][2] = {{i0, i1}, {i1, i2}, {i2, i3}, {i3, i0}};
605 for(
int i = 0; i < 4; i++) {
606 double x[2] = {xyz[il[i][0]][0], xyz[il[i][1]][0]};
607 double y[2] = {xyz[il[i][0]][1], xyz[il[i][1]][1]};
608 double z[2] = {xyz[il[i][0]][2], xyz[il[i][1]][2]};
610 unsigned int col[2] = {color, color};
612 for(
int j = 0; j < 2; j++) {
614 p->
normals->
add(x[j], y[j],
z[j], n[j][0], n[j][1], n[j][2]);
616 p->
normals->
get(x[j], y[j],
z[j], n[j][0], n[j][1], n[j][2]);
620 if(!pre) p->
va_lines->
add(x, y,
z, n, col,
nullptr,
true);
625 int i0 = 0,
int i1 = 1,
int i2 = 2,
int i3 = 3,
630 const int il[4][2] = {{i0, i1}, {i1, i2}, {i2, i3}, {i3, i0}};
631 const int it[2][3] = {{i0, i1, i2}, {i0, i2, i3}};
635 for(
int i = 0; i < 4; i++)
641 for(
int i = 0; i < 2; i++)
646 bool pre,
int numNodes)
648 for(
int i = 0; i < numNodes / 3; i++)
658 const int il[3][2] = {{0, 1}, {1, 2}, {2, 0}};
659 std::map<MEdge, int, MEdgeLessThan>
edges;
660 std::vector<MVertex *> verts;
661 verts.reserve(numNodes);
662 for(
int i = 0; i < numNodes; i++)
663 verts.push_back(
new MVertex(xyz[i][0], xyz[i][1], xyz[i][2]));
664 for(
int i = 0; i < numNodes / 3; i++) {
665 for(
int j = 0; j < 3; j++) {
666 MEdge ed(verts[3 * i + il[j][0]], verts[3 * i + il[j][1]]);
667 std::map<MEdge, int, MEdgeLessThan>::iterator ite;
668 for(ite =
edges.begin(); ite !=
edges.end(); ite++)
669 if((*ite).first == ed)
break;
670 if(ite ==
edges.end())
671 edges[ed] = 100 * i + j;
678 for(
auto ite =
edges.begin(); ite !=
edges.end(); ite++) {
679 int i = (int)(*ite).second / 100;
680 int j = (*ite).second % 100;
682 addScalarLine(p, xyz, val, pre, 3 * i + il[j][0], 3 * i + il[j][0],
687 for(
int i = 0; i < numNodes; i++)
delete verts[i];
691 for(
int i = 0; i < numNodes / 3; i++)
698 const int it[4][3] = {{0, 2, 1}, {0, 1, 3}, {0, 3, 2}, {3, 1, 2}};
699 for(
int i = 0; i < 4; i++)
704 int i0 = 0,
int i1 = 1,
int i2 = 2,
int i3 = 3)
708 const int it[4][3] = {{i0, i2, i1}, {i0, i1, i3}, {i0, i3, i2}, {i3, i1, i2}};
714 for(
int i = 0; i < 4; i++)
724 double x[4] = {xyz[i0][0], xyz[i1][0], xyz[i2][0], xyz[i3][0]};
725 double y[4] = {xyz[i0][1], xyz[i1][1], xyz[i2][1], xyz[i3][1]};
726 double z[4] = {xyz[i0][2], xyz[i1][2], xyz[i2][2], xyz[i3][2]};
727 double v[4] = {val[i0][0], val[i1][0], val[i2][0], val[i3][0]};
730 for(
int k = 0; k < opt->
nbIso; k++) {
731 if(vmin == vmax) k = opt->
nbIso / 2;
733 double x2[6], y2[6], z2[6], nn[3];
734 int nb =
IsoSimplex(x, y,
z, v, iso, x2, y2, z2, nn);
737 unsigned int col[3] = {color, color, color};
738 for(
int j = 2; j < nb; j++) {
739 double x3[3] = {x2[0], x2[j - 1], x2[j]};
740 double y3[3] = {y2[0], y2[j - 1], y2[j]};
741 double z3[3] = {z2[0], z2[j - 1], z2[j]};
743 for(
int i = 0; i < 3; i++) {
749 p->
normals->
add(x3[i], y3[i], z3[i], n[i][0], n[i][1], n[i][2]);
751 p->
normals->
get(x3[i], y3[i], z3[i], n[i][0], n[i][1], n[i][2]);
758 if(vmin == vmax)
break;
766 const int iq[6][4] = {{0, 3, 2, 1}, {0, 1, 5, 4}, {0, 4, 7, 3},
767 {1, 2, 6, 5}, {2, 3, 7, 6}, {4, 5, 6, 7}};
769 for(
int i = 0; i < 6; i++)
778 const int iq[6][4] = {{0, 3, 2, 1}, {0, 1, 5, 4}, {0, 4, 7, 3},
779 {1, 2, 6, 5}, {2, 3, 7, 6}, {4, 5, 6, 7}};
780 const int is[6][4] = {{0, 1, 3, 7}, {0, 4, 1, 7}, {1, 4, 5, 7},
781 {1, 2, 3, 7}, {1, 6, 2, 7}, {1, 5, 6, 7}};
785 for(
int i = 0; i < 6; i++)
792 for(
int i = 0; i < 6; i++)
800 const int iq[3][4] = {{0, 1, 4, 3}, {0, 3, 5, 2}, {1, 2, 5, 4}};
801 const int it[2][3] = {{0, 2, 1}, {3, 4, 5}};
803 for(
int i = 0; i < 3; i++)
806 for(
int i = 0; i < 2; i++)
813 const int iq[3][4] = {{0, 1, 4, 3}, {0, 3, 5, 2}, {1, 2, 5, 4}};
814 const int it[2][3] = {{0, 2, 1}, {3, 4, 5}};
815 const int is[3][4] = {{0, 1, 2, 4}, {0, 4, 2, 5}, {0, 3, 4, 5}};
819 for(
int i = 0; i < 3; i++)
822 for(
int i = 0; i < 2; i++)
828 for(
int i = 0; i < 3; i++)
836 const int it[4][3] = {{0, 1, 4}, {3, 0, 4}, {1, 2, 4}, {2, 3, 4}};
839 for(
int i = 0; i < 4; i++)
847 const int it[4][3] = {{0, 1, 4}, {3, 0, 4}, {1, 2, 4}, {2, 3, 4}};
848 const int is[2][4] = {{0, 1, 3, 4}, {1, 2, 3, 4}};
853 for(
int i = 0; i < 4; i++)
859 for(
int i = 0; i < 2; i++)
871 int i0 = 0,
int i1 = 1,
int i2 = 2,
int i3 = 3,
878 bool pre,
int numNodes)
881 const int it[4][3] = {{0, 2, 1}, {0, 1, 3}, {0, 3, 2}, {3, 1, 2}};
882 std::map<MFace, int, MFaceLessThan> triFaces;
883 std::vector<MVertex *> verts;
884 verts.reserve(numNodes);
885 for(
int i = 0; i < numNodes; i++)
886 verts.push_back(
new MVertex(xyz[i][0], xyz[i][1], xyz[i][2]));
887 for(
int i = 0; i < numNodes / 4; i++) {
888 for(
int j = 0; j < 4; j++) {
889 MFace f(verts[4 * i + it[j][0]], verts[4 * i + it[j][1]],
890 verts[4 * i + it[j][2]]);
891 std::map<MFace, int, MFaceLessThan>::iterator ite;
892 for(ite = triFaces.begin(); ite != triFaces.end(); ite++)
893 if((*ite).first ==
f)
break;
894 if(ite == triFaces.end())
895 triFaces[
f] = 100 * i + j;
900 for(
auto ite = triFaces.begin(); ite != triFaces.end(); ite++) {
901 int i = (int)(*ite).second / 100;
902 int j = (*ite).second % 100;
907 for(
int i = 0; i < numNodes; i++)
delete verts[i];
917 for(
int i = 0; i < numNodes / 4; i++)
952 bool pre,
int numNodes)
970 int type,
double **xyz,
double **val,
bool pre)
977 double **val2 =
new double *[numNodes];
978 for(
int i = 0; i < numNodes; i++) val2[i] =
new double[9];
983 for(
int i = 0; i < numNodes; i++)
997 for(
int ts = 0; ts < opt->
timeStep; ts++) {
1000 double xyz0[3], dxyz[3][2] = {{0., 0.}, {0., 0.}, {0., 0.}};
1001 data->
getNode(ts, ient, iele, 0, xyz0[0], xyz0[1], xyz0[2]);
1002 for(
int j = 0; j < 3; j++) {
1004 if(comp >= 0 && comp < numComp) {
1005 data->
getValue(ts, ient, iele, 0, comp, dxyz[j][0]);
1006 data->
getValue(ts + 1, ient, iele, 0, comp, dxyz[j][1]);
1009 unsigned int col[2];
1011 for(
int i = 0; i < 2; i++) {
1012 norm[i] = sqrt(dxyz[0][i] * dxyz[0][i] + dxyz[1][i] * dxyz[1][i] +
1013 dxyz[2][i] * dxyz[2][i]);
1016 for(
int j = 0; j < 3; j++) {
1022 p->
va_lines->
add(dxyz[0], dxyz[1], dxyz[2], n, col,
nullptr,
false);
1025 for(
int i = 0; i < numNodes; i++)
delete[] val2[i];
1031 for(
int i = 0; i < numNodes; i++)
delete[] val2[i];
1037 for(
int i = 0; i < numNodes; i++) {
1042 if(v2 >= opt->
externalMin && v2 <= opt->externalMax) {
1043 unsigned int color = opt->
getColor(
1046 unsigned int col[2] = {color, color};
1048 for(
int j = 0; j < 3; j++) {
1049 dxyz[j][0] = xyz[i][j];
1050 dxyz[j][1] = val[i][j];
1052 p->
va_vectors->
add(dxyz[0], dxyz[1], dxyz[2],
nullptr, col,
nullptr,
1062 double d[3] = {0., 0., 0.};
1064 for(
int i = 0; i < numNodes; i++) {
1065 pc +=
SPoint3(xyz[i][0], xyz[i][1], xyz[i][2]);
1070 for(
int j = 0; j < 3; j++) d[j] += val[i][j];
1072 pc /= (double)numNodes;
1073 v2 /= (double)numNodes;
1075 for(
int i = 0; i < 3; i++) d[i] *= v2;
1080 v2 <= opt->externalMax * (1. + 1.e-15)) {
1081 unsigned int color = opt->
getColor(
1084 unsigned int col[2] = {color, color};
1086 for(
int i = 0; i < 3; i++) {
1090 p->
va_vectors->
add(dxyz[0], dxyz[1], dxyz[2],
nullptr, col,
nullptr,
1094 for(
int i = 0; i < numNodes; i++)
delete[] val2[i];
1099 double *x2,
SPoint3 &xx,
double val)
1101 unsigned int color = opt->
getColor(
1105 SVector3 a(x1[0] - x0[0], x1[1] - x0[1], x1[2] - x0[2]);
1106 SVector3 b(x2[0] - x0[0], x2[1] - x0[1], x2[2] - x0[2]);
1107 SVector3 c(xx.
x() - x0[0], xx.
y() - x0[1], xx.
z() - x0[2]);
1109 unsigned int col[3] = {color, color, color};
1112 double XX[3] = {x0[0], x1[0], x2[0]};
1113 double YY[3] = {x0[1], x1[1], x2[1]};
1114 double ZZ[3] = {x0[2], x1[2], x2[2]};
1119 double XX[3] = {x1[0], x0[0], x2[0]};
1120 double YY[3] = {x1[1], x0[1], x2[1]};
1121 double ZZ[3] = {x1[2], x0[2], x2[2]};
1128 int type,
double **xyz,
double **val,
bool pre)
1136 for(
int i = 0; i < numNodes; i++) val[i][0] =
ComputeVonMises(val[i]);
1142 for(
int i = 0; i < numNodes; i++) {
1143 double d0[3], d1[3], d2[3];
1144 double nrm = sqrt(val[i][0] * val[i][0] + val[i][1] * val[i][1] +
1145 val[i][2] * val[i][2]);
1147 for(
int j = 0; j < 3; j++) {
1152 double x = xyz[i][0];
1153 double y = xyz[i][1];
1154 double z = xyz[i][2];
1157 double x0[3] = {x + d0[0] + d1[0] + d2[0], y + d0[1] + d1[1] + d2[1],
1158 z + d0[2] + d1[2] + d2[2]};
1159 double x1[3] = {x - d0[0] + d1[0] + d2[0], y - d0[1] + d1[1] + d2[1],
1160 z - d0[2] + d1[2] + d2[2]};
1161 double x2[3] = {x - d0[0] - d1[0] + d2[0], y - d0[1] - d1[1] + d2[1],
1162 z - d0[2] - d1[2] + d2[2]};
1163 double x3[3] = {x + d0[0] - d1[0] + d2[0], y + d0[1] - d1[1] + d2[1],
1164 z + d0[2] - d1[2] + d2[2]};
1166 double x4[3] = {x + d0[0] + d1[0] - d2[0], y + d0[1] + d1[1] - d2[1],
1167 z + d0[2] + d1[2] - d2[2]};
1168 double x5[3] = {x - d0[0] + d1[0] - d2[0], y - d0[1] + d1[1] - d2[1],
1169 z - d0[2] + d1[2] - d2[2]};
1170 double x6[3] = {x - d0[0] - d1[0] - d2[0], y - d0[1] - d1[1] - d2[1],
1171 z - d0[2] - d1[2] - d2[2]};
1172 double x7[3] = {x + d0[0] - d1[0] - d2[0], y + d0[1] - d1[1] - d2[1],
1173 z + d0[2] - d1[2] - d2[2]};
1195 double vval[3][4] = {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}};
1196 for(
int i = 0; i < numNodes; i++) {
1197 for(
int j = 0; j < 3; j++) {
1198 tensor(j, 0) = val[i][0 + j * 3];
1199 tensor(j, 1) = val[i][1 + j * 3];
1200 tensor(j, 2) = val[i][2 + j * 3];
1202 tensor.
eig(
S, imS, leftV, rightV,
false);
1203 for(
int k = 0; k < 3; k++) {
1204 vval[k][0] = xyz[i][k];
1205 for(
int j = 0; j < 3; j++) { vval[k][j + 1] = rightV(k, j) *
S(j); }
1207 double lmax = std::max(
S(0), std::max(
S(1),
S(2)));
1208 unsigned int color = opt->
getColor(
1211 unsigned int col[4] = {color, color, color, color};
1212 p->
va_ellipses->
add(vval[0], vval[1], vval[2],
nullptr, col,
nullptr,
1217 double vval[3][4] = {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}};
1218 for(
int i = 0; i < numNodes; i++) {
1219 for(
int j = 0; j < 3; j++) {
1220 tensor(j, 0) = val[i][0 + j * 3];
1221 tensor(j, 1) = val[i][1 + j * 3];
1222 tensor(j, 2) = val[i][2 + j * 3];
1224 tensor.
eig(
S, imS, leftV, rightV,
false);
1225 for(
int j = 0; j < 3; j++) {
1226 vval[0][j + 1] += rightV(0, j) *
S(j) / numNodes;
1227 vval[1][j + 1] += rightV(1, j) *
S(j) / numNodes;
1228 vval[2][j + 1] += rightV(2, j) *
S(j) / numNodes;
1230 vval[0][0] += xyz[i][0] / numNodes;
1231 vval[1][0] += xyz[i][1] / numNodes;
1232 vval[2][0] += xyz[i][2] / numNodes;
1234 double lmax = std::max(
S(0), std::max(
S(1),
S(2)));
1235 unsigned int color = opt->
getColor(
1238 unsigned int col[4] = {color, color, color, color};
1239 p->
va_ellipses->
add(vval[0], vval[1], vval[2],
nullptr, col,
nullptr,
1244 double **vval[3] = {
new double *[numNodes],
new double *[numNodes],
1245 new double *[numNodes]};
1246 for(
int i = 0; i < 3; i++)
1247 for(
int j = 0; j < numNodes; j++) vval[i][j] =
new double[3];
1248 for(
int i = 0; i < numNodes; i++) {
1249 for(
int j = 0; j < 3; j++) {
1250 tensor(j, 0) = val[i][0 + j * 3];
1251 tensor(j, 1) = val[i][1 + j * 3];
1252 tensor(j, 2) = val[i][2 + j * 3];
1254 tensor.
eig(
S, imS, leftV, rightV,
1261 for(
int j = 0; j < 3; j++) {
1262 vval[0][i][j] = rightV(j, 0) *
S(0);
1263 vval[1][i][j] = rightV(j, 1) *
S(1);
1264 vval[2][i][j] = rightV(j, 2) *
S(2);
1276 for(
int i = 0; i < 3; i++) {
1277 for(
int j = 0; j < numNodes; j++)
delete[] vval[i][j];
1285 static int numNodesError = 0, numCompError = 0;
1294 double **xyz =
new double *[NMAX];
1295 double **val =
new double *[NMAX];
1296 for(
int i = 0; i < NMAX; i++) {
1297 xyz[i] =
new double[3];
1298 val[i] =
new double[9];
1311 if(numNodes > NMAX) {
1312 for(
int j = 0; j < NMAX; j++) {
1319 xyz =
new double *[NMAX];
1320 val =
new double *[NMAX];
1321 for(
int j = 0; j < NMAX; j++) {
1322 xyz[j] =
new double[3];
1323 val[j] =
new double[9];
1328 if(numNodesError != numNodes) {
1329 numNodesError = numNodes;
1331 "Fields with %d nodes per element cannot be displayed: "
1332 "either force the field type or select 'Adapt visualization "
1333 "grid' if the field is high-order",
1341 if(numCompError != numComp) {
1342 numCompError = numComp;
1344 "Fields with %d components cannot be displayed: "
1345 "either force the field type or select 'Adapt visualization "
1346 "grid' if the field is high-order",
1351 for(
int j = 0; j < numNodes; j++) {
1357 if(comp >= 0 && comp < numComp)
1364 for(
int k = 0; k < numComp; k++)
1373 for(
int j = 0; j < numNodes; j++)
1381 for(
int j = 0; j < numNodes; j++) {
1382 double *x2 =
new double[3];
1383 double **xyz2 = &x2;
1384 double *v2 =
new double[9];
1385 double **val2 = &v2;
1386 xyz2[0][0] = xyz[j][0];
1387 xyz2[0][1] = xyz[j][1];
1388 xyz2[0][2] = xyz[j][2];
1389 for(
int k = 0; k < numComp; k++) val2[0][k] = val[j][k];
1395 preprocessNormalsOnly);
1398 preprocessNormalsOnly);
1407 preprocessNormalsOnly);
1410 preprocessNormalsOnly);
1414 for(
int j = 0; j < NMAX; j++) {
1433 if(opt->
clip & (1 <<
clip))
return (
int)sqrt((
double)num);
1443 return heuristic + 10000;
1450 return heuristic + 10000;
1467 heuristic = (tets + prisms + pyrs + hexas + polyhs) / 10;
1469 heuristic = (tris + 2 * quads + 3 * polygs + 6 * tets + 8 * prisms +
1470 6 * pyrs + 2 * trihs + 12 * hexas + 10 * polyhs);
1472 heuristic = (tris + 2 * quads + 3 * polygs + 6 * tets + 8 * prisms +
1473 6 * pyrs + 2 * trihs + 12 * hexas + 10 * polyhs) *
1476 return heuristic + 10000;
1484 return heuristic + 1000;
1492 return heuristic + 1000;
1510 std::string fileName =
1555 "%d vertices in vertex arrays (%g Mb)",
1575 const char *bytes,
int swap)
1578 int tag, type, numSteps;
1579 double min, max, time, xmin, ymin, zmin, xmax, ymax, zmax;
1581 numSteps, time, xmin, ymin, zmin, xmax, ymax,
1585 Msg::Debug(
"Filling vertex array (type %d) in view tag %d", type, tag);
1591 Msg::Info(
"View tag %d does not exist: creating new view", tag);
1594 data->
setName(name +
" (remote)");
1595 p =
new PView(data, tag);
1636 default:
Msg::Error(
"Cannot fill vertex array of type %d", type);
return;