6 #include "GmshConfig.h"
13 #if defined(HAVE_MESH)
36 static const int vv[3] = {2, 0, 1};
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 double p1[3] = {
_v[0]->
x(),
_v[0]->
y(),
_v[0]->
z()};
52 double p2[3] = {
_v[1]->
x(),
_v[1]->
y(),
_v[1]->
z()};
53 double p3[3] = {
_v[2]->
x(),
_v[2]->
y(),
_v[2]->
z()};
56 return SPoint3(res[0], res[1], res[2]);
72 double dist[3], k = 0.;
73 for(
int i = 0; i < 3; i++) {
79 std::sqrt(k * (k - dist[0]) * (k - dist[1]) * (k - dist[2]));
86 double dist[3], k = 0.0;
87 for(
int i = 0; i < 3; i++) {
93 std::sqrt(k * (k - dist[0]) * (k - dist[1]) * (k - dist[2]));
94 return dist[0] * dist[1] * dist[2] / (4 * area);
99 #if defined(HAVE_MESH)
108 #if defined(HAVE_MESH)
117 #if defined(HAVE_MESH)
138 const double O[3] = {
_v[0]->
x(),
_v[0]->
y(),
_v[0]->
z()};
140 const double d[3] = {xyz[0] -
O[0], xyz[1] -
O[1], xyz[2] -
O[2]};
141 const double d1[3] = {
_v[1]->
x() -
O[0],
_v[1]->
y() -
O[1],
143 const double d2[3] = {
_v[2]->
x() -
O[0],
_v[2]->
y() -
O[1],
146 const double Jxy = d1[0] * d2[1] - d1[1] * d2[0];
147 const double Jxz = d1[0] * d2[2] - d1[2] * d2[0];
148 const double Jyz = d1[1] * d2[2] - d1[2] * d2[1];
150 if((std::abs(Jxy) > std::abs(Jxz)) && (std::abs(Jxy) > std::abs(Jyz))) {
151 uvw[0] = (d[0] * d2[1] - d[1] * d2[0]) / Jxy;
152 uvw[1] = (d[1] * d1[0] - d[0] * d1[1]) / Jxy;
154 else if(std::abs(Jxz) > std::abs(Jyz)) {
155 uvw[0] = (d[0] * d2[2] - d[2] * d2[0]) / Jxz;
156 uvw[1] = (d[2] * d1[0] - d[0] * d1[2]) / Jxz;
159 uvw[0] = (d[1] * d2[2] - d[2] * d2[1]) / Jyz;
160 uvw[1] = (d[2] * d1[1] - d[1] * d1[2]) / Jyz;
191 if(num < numSubEdges) {
193 t->
pnt((
double)num / numSubEdges, 0., 0., pnt1);
194 t->
pnt((
double)(num + 1) / numSubEdges, 0., 0, pnt2);
203 if(num < 2 * numSubEdges) {
206 t->
pnt(1. - (
double)num / numSubEdges, (
double)num / numSubEdges, 0, pnt1);
207 t->
pnt(1. - (
double)(num + 1) / numSubEdges,
208 (
double)(num + 1) / numSubEdges, 0, pnt2);
219 num -= 2 * numSubEdges;
220 t->
pnt(0, (
double)num / numSubEdges, 0, pnt1);
221 t->
pnt(0, (
double)(num + 1) / numSubEdges, 0, pnt2);
260 return curved ? std::pow(
CTX::instance()->mesh.numSubEdges, 2) : 1;
264 return curved ? std::pow(
CTX::instance()->mesh.numSubEdges, 2) : 1;
275 for(
int i = 0; i < numSubEdges; i++) {
276 int nbl = (numSubEdges - i - 1) * 2 + 1;
280 ix = nbl - (nbt - num);
285 const double d = 1. / numSubEdges;
288 double J1[3][3], J2[3][3], J3[3][3];
290 t->
pnt(ix / 2 * d, iy * d, 0, pnt1);
291 t->
pnt((ix / 2 + 1) * d, iy * d, 0, pnt2);
292 t->
pnt(ix / 2 * d, (iy + 1) * d, 0, pnt3);
298 t->
pnt((ix / 2 + 1) * d, iy * d, 0, pnt1);
299 t->
pnt((ix / 2 + 1) * d, (iy + 1) * d, 0, pnt2);
300 t->
pnt(ix / 2 * d, (iy + 1) * d, 0, pnt3);
302 t->
getJacobian((ix / 2 + 1) * d, (iy + 1) * d, 0, J2);
306 SVector3 d1(J1[0][0], J1[0][1], J1[0][2]);
307 SVector3 d2(J1[1][0], J1[1][1], J1[1][2]);
312 SVector3 d1(J2[0][0], J2[0][1], J2[0][2]);
313 SVector3 d2(J2[1][0], J2[1][1], J2[1][2]);
318 SVector3 d1(J3[0][0], J3[0][1], J3[0][2]);
319 SVector3 d2(J3[1][0], J3[1][1], J3[1][2]);
366 int npts =
_order - 1, base = 0;
367 auto begin =
_vs.begin() + base;
370 std::reverse(begin, begin + 3 * npts);
374 _vs[base + 1] =
_vs[base + 2];
378 begin =
_vs.begin() + base + 3;
384 if(rot == 0 && !
swap)
return;
387 std::memcpy(tmp,
_v, 3 *
sizeof(
MVertex *));
389 for(
int i = 0; i < 3; i++)
_v[i] = tmp[(3 - i + rot) % 3];
391 for(
int i = 0; i < 3; i++)
_v[i] = tmp[(3 + i - rot) % 3];
396 if(rot == 0 && !
swap)
return;
402 for(
int i = 0; i < 3; i++)
_vs[i] = tmp[(5 + rot - i) % 3];
404 for(
int i = 0; i < 3; i++)
_vs[i] = tmp[(3 - rot + i) % 3];
407 std::map<TupleReorientation, IndicesReoriented>
411 void _getIndicesReorientedTri(
int order,
int rot,
bool swap,
416 indices.resize(ref.
size1());
417 for(
int i = 0; i < ref.
size1(); ++i) {
418 double u = ref(i, 0);
419 double v = ref(i, 1);
438 for(
int j = 0; j < ref.
size1(); ++j) {
439 if(u == ref(j, 0) && v == ref(j, 1)) {
450 if(rot == 0 && !
swap)
return;
456 _getIndicesReorientedTri(
_order, rot,
swap, indices);
464 std::vector<MVertex *> oldv(3 +
_vs.size());
469 for(
int i = 0; i < 3; ++i) {
_v[i] = oldv[indices[i]]; }
470 for(std::size_t i = 0; i <
_vs.size(); ++i) {
_vs[i] = oldv[indices[3 + i]]; }
475 const bool swap = sign == -1;
479 for(
int i = 0; i < 3; i++) vertices[i] =
_v[(3 - i + rot) % 3];
481 for(
int i = 0; i < 3; i++) vertices[i] =
_v[(3 + i - rot) % 3];
488 const bool swap = sign == -1;
492 for(
int i = 0; i < 3; i++) {
493 vertices[i] =
_v[(3 - i + rot) % 3];
494 vertices[3 + i] =
_vs[(5 - i + rot) % 3];
498 for(
int i = 0; i < 3; i++) {
499 vertices[i] =
_v[(3 + i - rot) % 3];
500 vertices[3 + i] =
_vs[(3 + i - rot) % 3];
508 const bool swap = sign == -1;
514 _getIndicesReorientedTri(
_order, rot,
swap, indices);