8 #include "GmshConfig.h"
20 void sortVertices(
const std::vector<MVertex *> &v, std::vector<char> &s)
24 if(v[0]->getNum() < v[1]->getNum() && v[0]->getNum() < v[2]->getNum()) {
29 else if(v[1]->getNum() < v[0]->getNum() &&
30 v[1]->getNum() < v[2]->getNum()) {
41 if(v[s[2]]->getNum() < v[s[1]]->getNum()) {
48 else if(v.size() == 4) {
50 MVertex * sorted[4] {v[0], v[1], v[2], v[3]};
51 std::sort(&sorted[0], &sorted[4],
compare);
53 for(
int i = 0; i < 4; ++i) {
55 std::distance(v.begin(), std::find(v.begin(), v.end(), sorted[i])));
60 std::vector<MVertex *> sorted = v;
61 std::sort(sorted.begin(), sorted.end(),
compare);
62 s.reserve(sorted.size());
63 for(std::size_t i = 0; i < sorted.size(); i++)
65 std::distance(v.begin(), std::find(v.begin(), v.end(), sorted[i])));
70 _v.reserve(v3 ? 4 : 3);
74 if(v3)
_v.push_back(v3);
81 for(std::size_t i = 0; i < v.size(); i++)
_v.push_back(v[i]);
89 if(
_v[
int(
_si[0])]->getNum() ==
_v[0]->getNum()) {
90 faceOrientationFlag[0] = 0;
91 if(
_v[
int(
_si[1])]->getNum() ==
_v[1]->getNum()) {
92 faceOrientationFlag[1] = 1;
95 faceOrientationFlag[1] = -1;
99 if(
_v[1]->getNum() ==
_v[
int(
_si[0])]->getNum()) {
100 faceOrientationFlag[0] = 1;
101 if(
_v[0]->getNum() ==
_v[
int(
_si[2])]->getNum()) {
102 faceOrientationFlag[1] = 1;
105 faceOrientationFlag[1] = -1;
109 faceOrientationFlag[0] = 2;
110 if(
_v[1]->getNum() ==
_v[
int(
_si[2])]->getNum()) {
111 faceOrientationFlag[1] = 1;
114 faceOrientationFlag[1] = -1;
121 for(
int i = 0; i < 4; i++) {
122 if(
_v[
int(
_si[0])]->getNum() ==
unsigned(
_v[i]->getNum())) {
c = i; }
124 int indexopposedVertex = 0;
126 case(0): indexopposedVertex = 3;
break;
127 case(1): indexopposedVertex = 2;
break;
128 case(2): indexopposedVertex = 1;
break;
129 case(3): indexopposedVertex = 0;
break;
131 int numVertexOpposed =
_v[indexopposedVertex]->getNum();
133 int axis1A =
_v[int(
_si[0])]->getNum();
135 if(
_v[
int(
_si[1])]->getNum() ==
unsigned(numVertexOpposed)) {
136 axis1B =
_v[int(
_si[2])]->getNum();
139 axis1B =
_v[int(
_si[1])]->getNum();
141 if(
unsigned(axis1A) ==
_v[0]->getNum()) {
142 if(
unsigned(axis1B) ==
_v[1]->getNum()) {
143 faceOrientationFlag[0] = 1;
144 faceOrientationFlag[1] = 1;
145 faceOrientationFlag[2] = 1;
148 faceOrientationFlag[0] = 1;
149 faceOrientationFlag[1] = 1;
150 faceOrientationFlag[2] = -1;
154 if(
unsigned(axis1A) ==
_v[1]->getNum()) {
155 if(
unsigned(axis1B) ==
_v[0]->getNum()) {
156 faceOrientationFlag[0] = -1;
157 faceOrientationFlag[1] = 1;
158 faceOrientationFlag[2] = 1;
161 faceOrientationFlag[0] = -1;
162 faceOrientationFlag[1] = 1;
163 faceOrientationFlag[2] = -1;
167 if(
unsigned(axis1A) ==
_v[2]->getNum()) {
168 if(
unsigned(axis1B) ==
_v[3]->getNum()) {
169 faceOrientationFlag[0] = 1;
170 faceOrientationFlag[1] = -1;
171 faceOrientationFlag[2] = 1;
174 faceOrientationFlag[0] = 1;
175 faceOrientationFlag[1] = -1;
176 faceOrientationFlag[2] = -1;
180 if(
unsigned(axis1B) ==
_v[2]->getNum()) {
181 faceOrientationFlag[0] = -1;
182 faceOrientationFlag[1] = -1;
183 faceOrientationFlag[2] = 1;
186 faceOrientationFlag[0] = -1;
187 faceOrientationFlag[1] = -1;
188 faceOrientationFlag[2] = -1;
197 SPoint3 p0 =
_v[0]->point(), p1 =
_v[1]->point(), p2 =
_v[2]->point();
199 if(
_v.size() == 3)
return a;
208 _v[1]->
z(),
_v[2]->x(),
_v[2]->y(),
_v[2]->
z(), n);
235 : _type(type), _order(order)
238 for(std::size_t i = 0; i < v.size(); i++)
_v[i] = v[i];
244 std::vector<MVertex *> vertices(
static_cast<std::size_t
>(
_order) + 1);
246 vertices[0] =
_v[num];
247 vertices[1] =
_v[(num + 1) % nCorner];
250 vertices[0] =
_v[(num + 1) % nCorner];
251 vertices[1] =
_v[num];
253 int start = nCorner + num * (
_order - 1);
254 int end = nCorner + (num + 1) * (
_order - 1);
257 for(
int i = start; i < end; ++i) vertices[++k] =
_v[i];
260 for(
int i = end - 1; i >= start; --i) vertices[++k] =
_v[i];
281 double x = 0, y = 0,
z = 0;
283 x +=
f[j] *
_v[j]->x();
284 y +=
f[j] *
_v[j]->y();
285 z +=
f[j] *
_v[j]->z();
292 if(num != 0 && num != 1) num = 0;
300 double dx = 0, dy = 0, dz = 0;
302 dx += sf[j][num] *
_v[j]->x();
303 dy += sf[j][num] *
_v[j]->y();
304 dz += sf[j][num] *
_v[j]->z();
317 double dx[2] = {0, 0}, dy[2] = {0, 0}, dz[2] = {0, 0};
319 for(
int k = 0; k < 1; ++k) {
320 dx[k] += sf[j][k] *
_v[j]->x();
321 dy[k] += sf[j][k] *
_v[j]->y();
322 dz[k] += sf[j][k] *
_v[j]->z();
341 double dx[2] = {0, 0}, dy[2] = {0, 0}, dz[2] = {0, 0};
343 for(
int k = 0; k < 2; ++k) {
344 dx[k] += sf[j][k] *
_v[j]->x();
345 dy[k] += sf[j][k] *
_v[j]->y();
346 dz[k] += sf[j][k] *
_v[j]->z();
366 double x = 0, y = 0,
z = 0;
367 double dx[2] = {0, 0}, dy[2] = {0, 0}, dz[2] = {0, 0};
369 x +=
f[j] *
_v[j]->x();
370 y +=
f[j] *
_v[j]->y();
371 z +=
f[j] *
_v[j]->z();
372 for(
int k = 0; k < 2; ++k) {
373 dx[k] += sf[j][k] *
_v[j]->x();
374 dy[k] += sf[j][k] *
_v[j]->y();
375 dz[k] += sf[j][k] *
_v[j]->z();
388 int start = nCorner + (
_order - 1) * nCorner;
389 for(
int i = start; i < (int)
_v.size(); ++i) {
394 for(
int j = 0; j < placement->
size2(); ++j) {
395 const double coeff = (*placement)(i - start, j);
396 v->
x() += coeff *
_v[j]->x();
397 v->
y() += coeff *
_v[j]->y();
398 v->
z() += coeff *
_v[j]->z();