6 #include "GmshConfig.h"
13 #if defined(HAVE_MESH)
19 #define SQU(a) ((a) * (a))
36 static const int vv[6] = {2, 0, 1, 1, 0, 2};
38 SVector3 t1(x[1] - x[0], y[1] - y[0],
z[1] -
z[0]);
39 SVector3 t2(v2->
x() - x[0], v2->
y() - y[0], v2->
z() -
z[0]);
51 #if defined(HAVE_MESH)
55 return SPoint3(res[0], res[1], res[2]);
63 #if defined(HAVE_MESH)
68 double circum_radius = sqrt(dx * dx + dy * dy + dz * dz);
78 double dist[3], face_area = 0.;
80 for(
int i = 0; i < 4; i++) {
82 for(
int j = 0; j < 3; j++) {
88 sqrt((dist[0] + dist[1] + dist[2]) * (-dist[0] + dist[1] + dist[2]) *
89 (dist[0] - dist[1] + dist[2]) * (dist[0] + dist[1] - dist[2]));
91 return 3 * vol / face_area;
96 #if defined(HAVE_MESH)
106 #if defined(HAVE_MESH)
123 double mat[3][3], b[3], det;
128 sys3x3(mat, b, uvw, &det);
154 static double pp[4][3] = {{0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
155 static int ed[6][2] = {{0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 3}, {2, 3}};
156 int iEdge = num / numSubEdges;
157 int iSubEdge = num % numSubEdges;
159 int iVertex1 = ed[iEdge][0];
160 int iVertex2 = ed[iEdge][1];
161 double t1 = (double)iSubEdge / (
double)numSubEdges;
162 double u1 = pp[iVertex1][0] * (1. - t1) + pp[iVertex2][0] * t1;
163 double v1 = pp[iVertex1][1] * (1. - t1) + pp[iVertex2][1] * t1;
164 double w1 = pp[iVertex1][2] * (1. - t1) + pp[iVertex2][2] * t1;
166 double t2 = (double)(iSubEdge + 1) / (double)numSubEdges;
167 double u2 = pp[iVertex1][0] * (1. - t2) + pp[iVertex2][0] * t2;
168 double v2 = pp[iVertex1][1] * (1. - t2) + pp[iVertex2][1] * t2;
169 double w2 = pp[iVertex1][2] * (1. - t2) + pp[iVertex2][2] * t2;
172 tet->
pnt(u1, v1,
w1, pnt1);
173 tet->
pnt(u2, v2, w2, pnt2);
182 static const int f[6] = {0, 0, 0, 1, 2, 3};
217 static double pp[4][3] = {{0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
218 static int fak[4][3] = {{0, 2, 1}, {0, 1, 3}, {0, 3, 2}, {1, 2, 3}};
219 int iFace = num / (numSubEdges * numSubEdges);
220 int iSubFace = num % (numSubEdges * numSubEdges);
222 int iVertex1 = fak[iFace][0];
223 int iVertex2 = fak[iFace][1];
224 int iVertex3 = fak[iFace][2];
240 for(
int i = 0; i < numSubEdges; i++) {
241 int nbl = (numSubEdges - i - 1) * 2 + 1;
245 ix = nbl - (nbt - iSubFace);
250 const double d = 1. / numSubEdges;
253 double u1, v1, u2, v2, u3, v3;
257 u2 = (ix / 2 + 1) * d;
263 u1 = (ix / 2 + 1) * d;
265 u2 = (ix / 2 + 1) * d;
271 double U1 = pp[iVertex1][0] * (1. - u1 - v1) + pp[iVertex2][0] * u1 +
272 pp[iVertex3][0] * v1;
273 double U2 = pp[iVertex1][0] * (1. - u2 - v2) + pp[iVertex2][0] * u2 +
274 pp[iVertex3][0] * v2;
275 double U3 = pp[iVertex1][0] * (1. - u3 - v3) + pp[iVertex2][0] * u3 +
276 pp[iVertex3][0] * v3;
278 double V1 = pp[iVertex1][1] * (1. - u1 - v1) + pp[iVertex2][1] * u1 +
279 pp[iVertex3][1] * v1;
280 double V2 = pp[iVertex1][1] * (1. - u2 - v2) + pp[iVertex2][1] * u2 +
281 pp[iVertex3][1] * v2;
282 double V3 = pp[iVertex1][1] * (1. - u3 - v3) + pp[iVertex2][1] * u3 +
283 pp[iVertex3][1] * v3;
285 double W1 = pp[iVertex1][2] * (1. - u1 - v1) + pp[iVertex2][2] * u1 +
286 pp[iVertex3][2] * v1;
287 double W2 = pp[iVertex1][2] * (1. - u2 - v2) + pp[iVertex2][2] * u2 +
288 pp[iVertex3][2] * v2;
289 double W3 = pp[iVertex1][2] * (1. - u3 - v3) + pp[iVertex2][2] * u3 +
290 pp[iVertex3][2] * v3;
292 tet->
pnt(U1, V1, W1, pnt1);
293 tet->
pnt(U2, V2, W2, pnt2);
294 tet->
pnt(U3, V3, W3, pnt3);
306 SVector3 d1(x[1] - x[0], y[1] - y[0],
z[1] -
z[0]);
307 SVector3 d2(x[2] - x[0], y[2] - y[0],
z[2] -
z[0]);
341 for(ithFace = 0; ithFace < 4; ithFace++) {
352 indices.resize(ref.
size1());
353 for(
int i = 0; i < ref.
size1(); ++i) {
354 const double u = ref(i, 0);
355 const double v = ref(i, 1);
356 const double w = ref(i, 2);
357 for(
int j = 0; j < ref.
size1(); ++j) {
358 if(u == ref(j, 1) && v == ref(j, 0) && w == ref(j, 2)) {
379 std::vector<MVertex *> oldv(4 +
_vs.size());
384 for(
int i = 0; i < 4; ++i) {
_v[i] = oldv[indices[i]]; }
385 for(std::size_t i = 0; i <
_vs.size(); ++i) {
_vs[i] = oldv[indices[4 + i]]; }