22 static void minmax(
int n,
double *X,
double *Y,
double *Z,
double *min,
31 for(
int i = 1; i < n; i++) {
32 min[0] = (X[i] < min[0]) ? X[i] : min[0];
33 min[1] = (Y[i] < min[1]) ? Y[i] : min[1];
34 min[2] = (Z[i] < min[2]) ? Z[i] : min[2];
35 max[0] = (X[i] > max[0]) ? X[i] : max[0];
36 max[1] = (Y[i] > max[1]) ? Y[i] : max[1];
37 max[2] = (Z[i] > max[2]) ? Z[i] : max[2];
53 max[0] = bb.
max().
x();
54 max[1] = bb.
max().
y();
55 max[2] = bb.
max().
z();
56 min[0] = bb.
min().
x();
57 min[1] = bb.
min().
y();
58 min[2] = bb.
min().
z();
61 static void centroid(
int n,
double *X,
double *Y,
double *Z,
double *
c)
63 const double oc = 1. / (double)n;
67 for(
int i = 1; i < n; i++) {
77 static void pntBB(
void *a,
double *min,
double *max)
79 double *X = (
double *)a, *Y = &X[1], *Z = &X[2];
80 minmax(1, X, Y, Z, min, max);
83 static void linBB(
void *a,
double *min,
double *max)
85 double *X = (
double *)a, *Y = &X[2], *Z = &X[4];
86 minmax(2, X, Y, Z, min, max);
89 static void triBB(
void *a,
double *min,
double *max)
91 double *X = (
double *)a, *Y = &X[3], *Z = &X[6];
92 minmax(3, X, Y, Z, min, max);
95 static void quaBB(
void *a,
double *min,
double *max)
97 double *X = (
double *)a, *Y = &X[4], *Z = &X[8];
98 minmax(4, X, Y, Z, min, max);
101 static void tetBB(
void *a,
double *min,
double *max)
103 double *X = (
double *)a, *Y = &X[4], *Z = &X[8];
104 minmax(4, X, Y, Z, min, max);
107 static void hexBB(
void *a,
double *min,
double *max)
109 double *X = (
double *)a, *Y = &X[8], *Z = &X[16];
110 minmax(8, X, Y, Z, min, max);
113 static void priBB(
void *a,
double *min,
double *max)
115 double *X = (
double *)a, *Y = &X[6], *Z = &X[12];
116 minmax(6, X, Y, Z, min, max);
119 static void pyrBB(
void *a,
double *min,
double *max)
121 double *X = (
double *)a, *Y = &X[5], *Z = &X[10];
122 minmax(5, X, Y, Z, min, max);
125 static int pntInEle(
void *a,
double *x) {
return 1; }
129 double *X = (
double *)a, *Y = &X[2], *Z = &X[4], uvw[3];
132 return lin.
isInside(uvw[0], uvw[1], uvw[2]);
137 double *X = (
double *)a, *Y = &X[3], *Z = &X[6], uvw[3];
140 return tri.
isInside(uvw[0], uvw[1], uvw[2]);
145 double *X = (
double *)a, *Y = &X[4], *Z = &X[8], uvw[3];
148 return qua.
isInside(uvw[0], uvw[1], uvw[2]);
153 double *X = (
double *)a, *Y = &X[4], *Z = &X[8], uvw[3];
156 return tet.
isInside(uvw[0], uvw[1], uvw[2]);
161 double *X = (
double *)a, *Y = &X[8], *Z = &X[16], uvw[3];
164 return hex.
isInside(uvw[0], uvw[1], uvw[2]);
169 double *X = (
double *)a, *Y = &X[6], *Z = &X[12], uvw[3];
172 return pri.
isInside(uvw[0], uvw[1], uvw[2]);
177 double *X = (
double *)a, *Y = &X[5], *Z = &X[10], uvw[3];
180 return pyr.
isInside(uvw[0], uvw[1], uvw[2]);
185 double *X = (
double *)a, *Y = &X[1], *Z = &X[2];
191 double *X = (
double *)a, *Y = &X[2], *Z = &X[4];
197 double *X = (
double *)a, *Y = &X[3], *Z = &X[6];
203 double *X = (
double *)a, *Y = &X[4], *Z = &X[8];
209 double *X = (
double *)a, *Y = &X[4], *Z = &X[8];
215 double *X = (
double *)a, *Y = &X[8], *Z = &X[16];
221 double *X = (
double *)a, *Y = &X[6], *Z = &X[12];
227 double *X = (
double *)a, *Y = &X[5], *Z = &X[10];
233 for(std::size_t i = 0; i < l.size(); i += nbelm)
Octree_Insert(&l[i], o);
291 Msg::Error(
"Cannot create octree for non-adapted high-order list-based "
293 Msg::Error(
"to select 'Adapt visualization grid' first");
310 double min[3] = {bbmin.
x(), bbmin.
y(), bbmin.
z()};
311 double size[3] = {bbmax.x() - bbmin.
x(), bbmax.y() - bbmin.
y(),
312 bbmax.z() - bbmin.
z()};
313 const int maxElePerBucket = 100;
422 double *qx,
double *qy,
double *qz)
424 if(qn && qx && qy && qz) {
425 std::vector<void *> v;
431 for(std::size_t i = 0; i < v.size(); i++) {
432 double *X = (
double *)v[i], *Y = &X[qn], *Z = &X[2 * qn];
434 for(
int j = 0; j < qn; j++) {
435 ok &= (fabs(X[j] - qx[j]) < eps && fabs(Y[j] - qy[j]) < eps &&
436 fabs(Z[j] - qz[j]) < eps);
441 if(v.size())
return v[0];
450 double *qy,
double *qz,
int dim)
453 if(qn && qx && qy && qz) {
458 for(std::size_t i = 0; i < elements.size(); i++) {
461 for(
int j = 0; j < qn; j++) {
462 MVertex *v = elements[i]->getVertex(j);
464 (std::abs(v->
x() - qx[j]) < eps && std::abs(v->
y() - qy[j]) < eps &&
465 std::abs(v->
z() - qz[j]) < eps);
467 if(ok)
return elements[i];
470 if(elements.size())
return elements[0];
480 double P[3],
int step,
double *values,
481 double *elementSize,
bool grad)
483 if(!in)
return false;
485 double *X = (
double *)in, *Y = &X[nbNod], *Z = &X[2 * nbNod],
486 *V = &X[3 * nbNod], U[3];
495 for(
int j = 0; j < nbComp; j++) {
497 values[nbComp * i + j] = e->
interpolate(&V[nbNod * nbComp * i + j],
498 U[0], U[1], U[2], nbComp);
502 &values[3 * (nbComp * i + j)], nbComp);
508 for(
int j = 0; j < nbComp; j++) {
510 values[j] = e->
interpolate(&V[nbNod * nbComp * step + j], U[0], U[1],
515 &values[3 * j], nbComp);
526 double *values,
double *elementSize,
bool grad)
528 if(!in)
return false;
540 dataIndex[i] = e->
getNum();
548 if(timestep < 0 || step == timestep) {
550 for(
int comp = 0; comp < nbComp; comp++)
552 nodeval[nod * nbComp + comp]);
554 for(
int comp = 0; comp < nbComp; comp++) {
556 double val = e->
interpolate(&nodeval[comp], U[0], U[1], U[2], nbComp);
558 values[nbComp * step + comp] = val;
565 &values[3 * (nbComp * step + comp)], nbComp);
568 &values[3 * comp], nbComp);
574 if(elementSize) *elementSize = e->
maxEdge();
579 int step,
double *size,
int qn,
double *qx,
580 double *qy,
double *qz,
bool grad,
int dim)
582 double P[3] = {x, y,
z};
583 int mult = grad ? 3 : 1;
591 for(
int i = 0; i < numSteps *
mult; i++) { values[i] = 0.; }
594 for(
int i = 0; i <
mult; i++) values[i] = 0.;
599 3, 4, 1, P, step, values, size, grad))
602 3, 8, 1, P, step, values, size, grad))
605 3, 6, 1, P, step, values, size, grad))
608 3, 5, 1, P, step, values, size, grad))
611 2, 3, 1, P, step, values, size, grad))
614 2, 4, 1, P, step, values, size, grad))
617 1, 2, 1, P, step, values, size, grad))
620 0, 1, 1, P, step, values, size, grad))
627 if(
_getValue(e, 1, P, step, values, size, grad)) {
return true; }
635 int step,
double *size,
int qn,
double *qx,
636 double *qy,
double *qz,
bool grad,
int dim)
638 double P[3] = {x, y,
z};
639 int mult = grad ? 3 : 1;
647 for(
int i = 0; i < 3 * numSteps *
mult; i++) values[i] = 0.;
650 for(
int i = 0; i < 3 *
mult; i++) values[i] = 0.;
655 3, 4, 3, P, step, values, size, grad))
658 3, 8, 3, P, step, values, size, grad))
661 3, 6, 3, P, step, values, size, grad))
664 3, 5, 3, P, step, values, size, grad))
667 2, 3, 3, P, step, values, size, grad))
670 2, 4, 3, P, step, values, size, grad))
673 1, 2, 3, P, step, values, size, grad))
676 0, 1, 3, P, step, values, size, grad))
683 if(
_getValue(e, 3, P, step, values, size, grad)) {
return true; }
691 int step,
double *size,
int qn,
double *qx,
692 double *qy,
double *qz,
bool grad,
int dim)
694 double P[3] = {x, y,
z};
695 int mult = grad ? 3 : 1;
703 for(
int i = 0; i < 9 * numSteps *
mult; i++) values[i] = 0.;
706 for(
int i = 0; i < 9 *
mult; i++) values[i] = 0.;
711 3, 4, 9, P, step, values, size, grad))
714 3, 8, 9, P, step, values, size, grad))
717 3, 6, 9, P, step, values, size, grad))
720 3, 5, 9, P, step, values, size, grad))
723 2, 3, 9, P, step, values, size, grad))
726 2, 4, 9, P, step, values, size, grad))
729 1, 2, 9, P, step, values, size, grad))
732 0, 1, 9, P, step, values, size, grad))
739 if(
_getValue(e, 9, P, step, values, size, grad)) {
return true; }