9 #include "GmshConfig.h"
20 #if defined(HAVE_MESH)
24 #if defined(HAVE_PARSER)
34 return abs(q->
Num) - abs(w->
Num);
43 Msg::Error(
"Cannot compare position of null points");
51 if(q->
Pos.
X - w->
Pos.
X > eps)
return 1;
52 if(q->
Pos.
X - w->
Pos.
X < -eps)
return -1;
53 if(q->
Pos.
Y - w->
Pos.
Y > eps)
return 1;
54 if(q->
Pos.
Y - w->
Pos.
Y < -eps)
return -1;
55 if(q->
Pos.
Z - w->
Pos.
Z > eps)
return 1;
56 if(q->
Pos.
Z - w->
Pos.
Z < -eps)
return -1;
148 std::max(
GModel::current()->getGEOInternals()->getMaxPhysicalTag(), Num));
150 for(
int i = 0; i <
List_Nbr(intlist); i++) {
174 -1, std::max(
GModel::current()->getGEOInternals()->getMaxTag(-1), Num));
175 for(
int i = 0; i <
List_Nbr(intlist); i++) {
199 -2, std::max(
GModel::current()->getGEOInternals()->getMaxTag(-2), Num));
200 for(
int i = 0; i <
List_Nbr(intlist); i++) {
236 for(
int i = 1; i < NN; i++) {
239 c->geometry =
nullptr;
247 (NN == 3 || NN == 4)) {
273 double dir12[3], dir32[3], dir42[3] = {0., 0., 0.};
297 if(
norm3(n) < 1.e-15) { isValid =
false; }
300 if((fabs(n[0]) < 1.e-5 && fabs(n[1]) < 1.e-5 && fabs(n[2]) < 1.e-5)) {
306 n[0] =
c->Circle.n[0];
307 n[1] =
c->Circle.n[1];
308 n[2] =
c->Circle.n[2];
315 mat[2][0] =
c->Circle.invmat[0][2] = n[0];
316 mat[2][1] =
c->Circle.invmat[1][2] = n[1];
317 mat[2][2] =
c->Circle.invmat[2][2] = n[2];
318 mat[1][0] =
c->Circle.invmat[0][1] = m[0];
319 mat[1][1] =
c->Circle.invmat[1][1] = m[1];
320 mat[1][2] =
c->Circle.invmat[2][1] = m[2];
321 mat[0][0] =
c->Circle.invmat[0][0] = dir12[0];
322 mat[0][1] =
c->Circle.invmat[1][0] = dir12[1];
323 mat[0][2] =
c->Circle.invmat[2][0] = dir12[2];
326 if(n[0] == 0.0 && n[1] == 0.0) {
327 mat[2][0] =
c->Circle.invmat[0][2] = 0;
328 mat[2][1] =
c->Circle.invmat[1][2] = 0;
329 mat[2][2] =
c->Circle.invmat[2][2] = 1;
330 mat[1][0] =
c->Circle.invmat[0][1] = 0;
331 mat[1][1] =
c->Circle.invmat[1][1] = 1;
332 mat[1][2] =
c->Circle.invmat[2][1] = 0;
333 mat[0][0] =
c->Circle.invmat[0][0] = 1;
334 mat[0][1] =
c->Circle.invmat[1][0] = 0;
335 mat[0][2] =
c->Circle.invmat[2][0] = 0;
345 Msg::Error(
"Zero radius in circle or ellipse with tag %d",
c->Num);
348 else if(!v[3] && fabs((R - R2) / (R + R2)) > 0.1) {
350 Msg::Error(
"Control points of circle with tag %d are not cocircular: "
351 "R1=%g, R2=%g, n=[%g,%g,%g]",
352 c->Num, R, R2, n[0], n[1], n[2]);
363 double x1 = v0.
Pos.
X * cos(A4) + v0.
Pos.
Y * sin(A4);
364 double y1 = -v0.
Pos.
X * sin(A4) + v0.
Pos.
Y * cos(A4);
365 double x3 = v2.
Pos.
X * cos(A4) + v2.
Pos.
Y * sin(A4);
366 double y3 = -v2.
Pos.
X * sin(A4) + v2.
Pos.
Y * cos(A4);
367 double sys[2][2], rhs[2], sol[2];
375 if(sol[0] <= 0 || sol[1] <= 0) {
376 Msg::Error(
"Ellipse with tag %d is wrong",
c->Num);
382 f1 = sqrt(1. / sol[0]);
383 f2 = sqrt(1. / sol[1]);
388 A1 = -
myasin(y1 / f2) + A4 + M_PI;
390 A1 =
myasin(y1 / f2) + A4;
392 A3 = -
myasin(y3 / f2) + A4 + M_PI;
394 A3 =
myasin(y3 / f2) + A4;
405 if(A1 >= A3) A3 += 2 * M_PI;
411 if(!
CTX::instance()->expertMode &&
c->Num > 0 && A3 - A1 > 1.01 * M_PI) {
412 Msg::Error(
"Circle or ellipse arc %d greater than Pi (angle=%g)",
c->Num,
415 "(If you understand what this implies, you can disable this error");
417 "message by selecting `Enable expert mode' in the option dialog.");
418 Msg::Error(
"Otherwise, please subdivide the arc in smaller pieces.)");
435 for(
int i = 1; i < NN; i++) {
446 int p1,
int p2,
double u1,
double u2,
bool &ok)
449 double matcr[4][4] = {{-0.5, 1.5, -1.5, 0.5},
450 {1.0, -2.5, 2.0, -0.5},
451 {-0.5, 0.0, 0.5, 0.0},
452 {0.0, 1.0, 0.0, 0.0}};
453 double matbs[4][4] = {
454 {-1, 3, -3, 1}, {3, -6, 3, 0}, {-3, 0, 3, 0}, {1, 4, 1, 0}};
455 double matbez[4][4] = {
456 {-1, 3, -3, 1}, {3, -6, 3, 0}, {-3, 3, 0, 0}, {1, 0, 0, 0}};
482 for(
int i = 0; i < 4; i++)
483 for(
int j = 0; j < 4; j++) pC->
mat[i][j] = matcr[i][j];
486 for(
int i = 0; i < 4; i++)
487 for(
int j = 0; j < 4; j++) pC->
mat[i][j] = matbs[i][j] / 6.0;
490 for(
int i = 0; i < 4; i++)
491 for(
int j = 0; j < 4; j++) pC->
mat[i][j] = matbez[i][j];
499 double kmin = .0, kmax = 1.;
504 for(
int i = 0; i <
List_Nbr(Knots); i++) {
515 for(
int j = 0; j <
List_Nbr(Liste); j++) {
522 Msg::Error(
"Unknown control point %d in GEO curve %d", iPnt, pC->
Num);
540 Msg::Error(
"Unknown control point %d in GEO curve %d", p1, pC->
Num);
548 Msg::Error(
"Unknown control point %d in GEO curve %d", p2, pC->
Num);
558 Msg::Warning(
"Start point %d and end point %d of GEO line %d are closer "
559 "than the geometrical tolerance, at position (%g, %g, %g)",
571 if(pC->
k)
delete[] pC->
k;
650 int (*fcmp)(
const void *a,
const void *b))
667 for(i = 0; i <
List_Nbr(List1Prime); i++) {
780 if(!v)
return nullptr;
790 if(!gv)
return nullptr;
801 return abs(q->
Num) - abs(w->
Num);
815 for(
int i = 0; i < 4; i++)
816 for(
int j = 0; j < 4; j++) cc->
mat[i][j] =
c->mat[i][j];
837 for(
int i = 0; i <
List_Nbr(
c->Control_Points); i++) {
881 "Only automatic transfinite surface specifications can be copied");
916 for(std::size_t i = 0; i <
edges.size(); i++) {
917 if(!
edges[i]->degenerate(0)) {
920 source[newc->
Num] =
edges[i]->tag();
935 "Only automatic transfinite volume specifications can be copied");
961 for(
int i = 0; i <
List_Nbr(Curves); i++) {
964 for(
int j = 0; j <
List_Nbr(
c->Control_Points); j++) {
986 for(
int i = 0; i <
List_Nbr(Surfs); i++) {
1007 for(
int k = 0; k <
List_Nbr(
c->Control_Points); k++) {
1012 if(
c->beg) vv.insert(
c->beg->Num);
1013 if(
c->end) vv.insert(
c->end->Num);
1014 for(
auto it = vv.begin(); it != vv.end(); it++)
DeletePoint(*it);
1023 for(
int i = 0; i <
List_Nbr(Vols); i++) {
1043 std::set<int> cc, vv;
1048 for(
int k = 0; k <
List_Nbr(
c->Control_Points); k++) {
1053 if(
c->beg) vv.insert(
c->beg->Num);
1054 if(
c->end) vv.insert(
c->end->Num);
1056 for(
auto it = cc.begin(); it != cc.end(); it++) {
1060 for(
auto it = vv.begin(); it != vv.end(); it++)
DeletePoint(*it);
1076 std::set<int> ss, cc, vv;
1085 for(
int k = 0; k <
List_Nbr(
c->Control_Points); k++) {
1090 if(
c->beg) vv.insert(
c->beg->Num);
1091 if(
c->end) vv.insert(
c->end->Num);
1094 for(
auto it = ss.begin(); it != ss.end(); it++)
DeleteSurface(*it);
1095 for(
auto it = cc.begin(); it != cc.end(); it++) {
1099 for(
auto it = vv.begin(); it != vv.end(); it++)
DeletePoint(*it);
1151 CreateCurve(-
c->Num,
c->Typ, 1,
nullptr,
nullptr, -1, -1, 0., 1., ok);
1157 Vertex *e1, *e2, *e3, *e4;
1172 newc->
k =
new float[
c->degre +
List_Nbr(
c->Control_Points) + 1];
1173 for(
int i = 0; i <
c->degre +
List_Nbr(
c->Control_Points) + 1; i++)
1174 newc->
k[
c->degre +
List_Nbr(
c->Control_Points) - i] =
c->k[i];
1191 newc->
ubeg = 1. -
c->uend;
1192 newc->
uend = 1. -
c->ubeg;
1219 for(
int i = 0; i <
List_Nbr(temp); i++) {
1237 for(
int i = 0; i <
List_Nbr(temp); i++) {
1252 for(
int i = 0; i < 4; i++) {
1253 for(
int j = 0; j < 4; j++) { matrix[i][j] = (i == j) ? 1.0 : 0.0; }
1255 for(
int i = 0; i < 3; i++) matrix[i][3] = T[i];
1261 double p = (A * A + B * B + C * C);
1263 double F = -2.0 / p;
1264 matrix[0][0] = 1. + A * A *
F;
1265 matrix[0][1] = A * B *
F;
1266 matrix[0][2] = A * C *
F;
1267 matrix[0][3] = A *
D *
F;
1268 matrix[1][0] = A * B *
F;
1269 matrix[1][1] = 1. + B * B *
F;
1270 matrix[1][2] = B * C *
F;
1271 matrix[1][3] = B *
D *
F;
1272 matrix[2][0] = A * C *
F;
1273 matrix[2][1] = B * C *
F;
1274 matrix[2][2] = 1. + C * C *
F;
1275 matrix[2][3] = C *
D *
F;
1276 matrix[3][0] = B * C *
F;
1288 matrix[0][3] = T[0] * (1.0 - A);
1292 matrix[1][3] = T[1] * (1.0 - B);
1296 matrix[2][3] = T[2] * (1.0 - C);
1318 double t1[3], t2[3];
1327 else if(Axe[1] != 0.0) {
1344 double rot[3][3], plan[3][3], invplan[3][3];
1345 plan[0][0] = Axe[0];
1346 plan[0][1] = Axe[1];
1347 plan[0][2] = Axe[2];
1354 rot[2][2] = cos(alpha);
1355 rot[2][1] = sin(alpha);
1357 rot[1][2] = -sin(alpha);
1358 rot[1][1] = cos(alpha);
1364 for(i = 0; i < 3; i++)
1365 for(j = 0; j < 3; j++) invplan[i][j] = plan[j][i];
1366 double interm[3][3];
1367 for(i = 0; i < 3; i++)
1368 for(j = 0; j < 3; j++) {
1370 for(k = 0; k < 3; k++) interm[i][j] += invplan[i][k] * rot[k][j];
1372 for(i = 0; i < 4; i++)
1373 for(j = 0; j < 4; j++) matrix[i][j] = 0.0;
1374 for(i = 0; i < 3; i++)
1375 for(j = 0; j < 3; j++) {
1376 for(k = 0; k < 3; k++) matrix[i][j] += interm[i][k] * plan[k][j];
1381 static void vecmat4x4(
double mat[4][4],
double vec[4],
double res[4])
1383 for(
int i = 0; i < 4; i++) {
1385 for(
int j = 0; j < 4; j++) { res[i] += mat[i][j] * vec[j]; }
1391 double pos[4], vec[4];
1418 if(!
c->beg || !
c->end) {
1419 Msg::Error(
"Cannot transform curve with no begin/end points");
1426 for(
int i = 0; i <
List_Nbr(
c->Control_Points); i++) {
1464 for(
int i = 0; i <
List_Nbr(shapes); i++) {
1473 Msg::Error(
"Unknown GEO point with tag %d",
O.Num);
1490 Msg::Error(
"Unknown GEO curve with tag %d",
O.Num);
1501 Msg::Error(
"Unknown GEO surface with tag %d",
O.Num);
1510 Msg::Error(
"Unknown GEO volume with tag %d",
O.Num);
1515 Msg::Error(
"Impossible to transform entity %d (of type %d)",
O.Num,
1530 for(
int i = 0; i <
List_Nbr(All); i++) {
1533 for(
int j = 0; j <
List_Nbr(
c->Control_Points); j++) {
1551 double T[3], matrix[4][4];
1564 bool DilatShapes(
double X,
double Y,
double Z,
double A,
double B,
double C,
1567 double T[3], matrix[4][4];
1581 double Pz,
double alpha,
List_T *shapes)
1583 double A[3], T[3], matrix[4][4];
1610 double matrix[4][4];
1624 if(std::abs(v1->
Num) < std::abs(v2->
Num))
return true;
1651 return c1->Num - c2->
Num;
1654 if(
c1->Typ != c2->
Typ) {
1662 return c1->Typ - c2->
Typ;
1669 if(!
c1->beg || !c2->
beg)
return 1;
1671 if(comp)
return comp;
1672 if(!
c1->end || !c2->
end)
return 1;
1674 if(comp)
return comp;
1677 for(
int i = 0; i <
List_Nbr(
c1->Control_Points); i++) {
1682 if(comp)
return comp;
1693 if(comp)
return comp;
1707 return s1->
Num - s2->
Num;
1759 std::map<MVertex *, Vertex *> v2V;
1760 std::vector<MVertex *> used, unused;
1762 for(
int i = 0; i <
List_Nbr(tmp); i++) {
1769 unused.push_back(v);
1776 for(
int i = 0; i <
List_Nbr(tmp); i++) {
1780 c->beg = v2V[pos.
find(
c->beg->Pos.X,
c->beg->Pos.Y,
c->beg->Pos.Z)];
1781 c->end = v2V[pos.
find(
c->end->Pos.X,
c->end->Pos.Y,
c->end->Pos.Z)];
1784 for(
int j = 0; j <
List_Nbr(
c->Control_Points); j++) {
1794 c->Extrude->geo.Source =
1802 for(
int i = 0; i <
List_Nbr(tmp); i++) {
1817 for(
int i = 0; i <
List_Nbr(tmp); i++) {
1848 for(std::size_t i = 0; i < unused.size(); i++) {
1849 Vertex *V = v2V[unused[i]];
1854 for(std::size_t i = 0; i < used.size(); i++) {
delete used[i]; }
1856 Msg::Info(
"Done new Coherence (removed %d additional points)", start - end);
1870 Vertex *v, *v2, **pv, **pv2;
1875 Tree_T *allNonDuplicatedPoints =
1882 for(
int i = 0; i <
List_Nbr(All); i++) {
1891 auto m_it = v_report->find(v->
Num);
1892 if(m_it != v_report->end()) {
1894 if(v_rep) m_it->second = (*v_rep)->Num;
1908 Msg::Debug(
"Removed %d duplicate points", start - end);
1915 bool success =
true;
1919 for(
int i = 0; i <
List_Nbr(All); i++) {
1922 if(
c->beg && !
Tree_Query(allNonDuplicatedPoints, &
c->beg)) {
1923 Msg::Debug(
"Could not replace point %d in old Coherence",
c->beg->Num);
1928 if(
c->end && !
Tree_Query(allNonDuplicatedPoints, &
c->end)) {
1929 Msg::Debug(
"Could not replace point %d in old Coherence",
c->end->Num);
1935 for(
int j = 0; j <
List_Nbr(
c->Control_Points); j++) {
1938 Msg::Debug(
"Could not replace point %d in old Coherence", (*pv)->Num);
1948 v2 =
FindPoint(std::abs(
c->Extrude->geo.Source), points2delete);
1951 Msg::Debug(
"Could not replace point %d in old Coherence", v2->
Num);
1957 c->Extrude->geo.Source = (*pv2)->Num;
1965 for(
int i = 0; i <
List_Nbr(All); i++) {
1971 Msg::Debug(
"Could not replace point %d in old Coherence", (*pv)->Num);
1984 for(
int i = 0; i <
List_Nbr(All); i++) {
1990 Msg::Debug(
"Could not replace point %d in old Coherence", (*pv)->Num);
2010 v2 =
FindPoint(std::abs(num), points2delete);
2013 Msg::Debug(
"Could not replace point %d in old Coherence", v2->
Num);
2026 for(
int i = 0; i <
List_Nbr(tmp); i++)
2041 Tree_T *allNonDuplicatedCurves =
2048 for(
int i = 0; i <
List_Nbr(All); i++) {
2054 Msg::Error(
"Unknown GEO curve with tag %d", -
c->Num);
2057 for(
int i = 0; i <
List_Nbr(tmp); i++)
2070 Msg::Error(
"Unknown GEO curve with tag %d", -
c->Num);
2078 auto m_it = c_report->find(
c->Num);
2079 if(m_it != c_report->end()) {
2081 if(c_rep) m_it->second = (*c_rep)->Num;
2083 m_it = c_report->find(c2->
Num);
2084 if(m_it != c_report->end()) {
2087 if(c_rep_neg) m_it->second = (*c_rep_neg)->Num;
2099 for(
int i = 0; i <
List_Nbr(tmp); i++)
2108 Msg::Debug(
"Removed %d duplicate curves", start - end);
2117 for(
int i = 0; i <
List_Nbr(All); i++) {
2121 c2 =
FindCurve(std::abs(
c->Extrude->geo.Source), curves2delete);
2124 Msg::Error(
"Could not replace GEO curve with tag %d in Coherence",
2127 c->Extrude->geo.Source = (*pc2)->Num;
2135 for(
int i = 0; i <
List_Nbr(All); i++) {
2141 Msg::Error(
"Could not replace GEO curve with tag %d in Coherence",
2152 c2 =
FindCurve(std::abs(num), curves2delete);
2155 Msg::Error(
"Could not replace GEO curve with tag %d in Coherence",
2166 Msg::Error(
"Could not replace GEO curve with tag %d in Coherence",
2184 c2 =
FindCurve(std::abs(num), curves2delete);
2187 Msg::Error(
"Could not replace GEO curve with tag %d in Coherence",
2197 for(
int i = 0; i <
List_Nbr(tmp); i++)
2220 for(
int i = 0; i <
List_Nbr(All); i++) {
2227 for(
int j = 0; j <
List_Nbr(ll); j++) {
2230 if(!
c->degenerate()) {
2236 Msg::Info(
"Coherence: surface %d goes from %d to %d bounding curves",
2244 for(
int i = 0; i <
List_Nbr(All); i++) {
2247 if(
c->degenerate()) {
2258 for(
int k = 0; k <
List_Nbr(Vols); k++) {
2261 std::set<int> unique;
2263 for(
int j = 0; j < N; j++) {
2266 auto it = unique.find(-s->
Num);
2267 if(it == unique.end())
2268 unique.insert(s->
Num);
2272 if(N - unique.size())
2273 Msg::Info(
"Coherence: removing %d seams on volume %d", N - unique.size(),
2280 for(
int j = 0; j <
List_Nbr(ll); j++) {
2283 if(unique.find(s->
Num) != unique.end()) {
2291 Msg::Info(
"Coherence: volume %d is removed (degenerated)", v->
Num);
2301 for(
int i = 0; i <
List_Nbr(All); i++) {
2303 std::set<int> unique;
2306 for(
int j = 0; j < N; j++) {
2309 auto it = unique.find(-
c->Num);
2310 if(it == unique.end())
2311 unique.insert(
c->Num);
2316 if(N - unique.size())
2317 Msg::Info(
"Coherence: removing %d seams on surface %d", N - unique.size(),
2324 for(
int j = 0; j <
List_Nbr(ll); j++) {
2327 if(unique.find(
c->Num) != unique.end()) {
2335 Msg::Info(
"Coherence: surface %d is removed (degenerated)", s->
Num);
2337 for(
int k = 0; k <
List_Nbr(Vols); k++) {
2344 for(
int j = 0; j <
List_Nbr(ll); j++) {
2362 for(
int i = 0; i < N; i++) {
2365 if(!
c->degenerate()) Nd++;
2375 Tree_T *allNonDuplicatedSurfaces =
2382 for(
int i = 0; i <
List_Nbr(All); i++) {
2393 auto m_it = (*s_report).find(s->
Num);
2394 if(m_it != s_report->end()) {
2397 if(s_rep) m_it->second = (*s_rep)->Num;
2409 for(
int i = 0; i <
List_Nbr(tmp); i++)
2418 Msg::Debug(
"Removed %d duplicate surfaces", start - end);
2427 for(
int i = 0; i <
List_Nbr(All); i++) {
2434 Msg::Error(
"Could not replace surface %d in Coherence", s2->
Num);
2444 for(
int i = 0; i <
List_Nbr(All); i++) {
2450 Msg::Error(
"Could not replace surface %d in Coherence", (*ps)->Num);
2460 Msg::Error(
"Could not replace surface %d in Coherence", s2->
Num);
2470 Msg::Error(
"Could not replace surface %d in Coherence", s2->
Num);
2490 Msg::Error(
"Could not replace surface %d in Coherence", s2->
Num);
2499 for(
int i = 0; i <
List_Nbr(tmp); i++)
2509 std::map<int, int> *vertex_report =
nullptr;
2510 std::map<int, int> *curve_report =
nullptr;
2511 std::map<int, int> *surface_report =
nullptr;
2512 if(report.size() >= 1 && report[0].size()) vertex_report = &(report[0]);
2513 if(report.size() >= 2 && report[1].size()) curve_report = &(report[1]);
2514 if(report.size() >= 3 && report[2].size()) surface_report = &(report[2]);
2529 std::vector<std::map<int, int> > report;
2544 double matrix[4][4];
2548 T[0] = -e->
geo.
pt[0];
2549 T[1] = -e->
geo.
pt[1];
2550 T[2] = -e->
geo.
pt[2];
2570 int ExtrudePoint(
int type,
int ip,
double T0,
double T1,
double T2,
double A0,
2571 double A1,
double A2,
double X0,
double X1,
double X2,
2572 double alpha,
Curve **pc,
Curve **prc,
int final,
2575 double matrix[4][4], T[3], Ax[3], d;
2577 *pc = *prc =
nullptr;
2592 if(!found && !gv)
return 0;
2615 c->Extrude->fill(type, T0, T1, T2, A0, A1, A2, X0, X1, X2, alpha);
2616 c->Extrude->geo.Source = pv->
Num;
2617 if(e)
c->Extrude->mesh = e->
mesh;
2630 c->Extrude->fill(type, T0, T1, T2, A0, A1, A2, X0, X1, X2, alpha);
2631 c->Extrude->geo.Source = pv->
Num;
2632 if(e)
c->Extrude->mesh = e->
mesh;
2636 if(gv)
c->begByTag = gv->
tag();
2663 c->Extrude->fill(type, T0, T1, T2, A0, A1, A2, X0, X1, X2, alpha);
2664 c->Extrude->geo.Source = pv->
Num;
2665 if(e)
c->Extrude->mesh = e->
mesh;
2673 T[0] = pv->
Pos.
X - X0;
2674 T[1] = pv->
Pos.
Y - X1;
2675 T[2] = pv->
Pos.
Z - X2;
2677 newp->
Pos.
X = X0 + d * Ax[0];
2678 newp->
Pos.
Y = X1 + d * Ax[1];
2679 newp->
Pos.
Z = X2 + d * Ax[2];
2693 c->Extrude->fill(type, T0, T1, T2, A0, A1, A2, X0, X1, X2, alpha);
2694 c->Extrude->geo.Source = pv->
Num;
2695 if(e)
c->Extrude->mesh = e->
mesh;
2728 default:
Msg::Error(
"Unknown extrusion type");
return pv->
Num;
2739 int chap_num = chapeau->
Num;
2740 int body_num =
c->Num;
2743 std::vector<std::map<int, int> > report(3);
2744 report[0][chap_num] = chap_num;
2745 report[1][body_num] = body_num;
2747 auto m_it = report[0].find(chap_num);
2748 if(m_it != report[0].end())
2749 chap_num = report[0][chap_num];
2752 if(report[1][body_num] != body_num) *pc = *prc =
nullptr;
2757 int ExtrudeCurve(
int type,
int ic,
double T0,
double T1,
double T2,
double A0,
2758 double A1,
double A2,
double X0,
double X1,
double X2,
2761 double matrix[4][4], T[3], Ax[3];
2767 GEdge *ge =
nullptr;
2774 if((!pc || !revpc) && !ge) {
return 0; }
2777 if(!pc->
beg || !pc->
end) {
2778 Msg::Error(
"Cannot extrude curve with no begin or end point");
2782 Msg::Warning(
"Extrusion of periodic curves is not supported with the "
2789 Msg::Info(
"Skipping boundary layer extrusion of degenerate curve %d",
2795 Msg::Error(
"Cannot extrude curve with no begin or end point");
2802 Curve *chapeau =
nullptr;
2809 chapeau->
Extrude->
fill(type, T0, T1, T2, A0, A1, A2, X0, X1, X2, alpha);
2906 Curve *CurveBeg, *CurveEnd, *ReverseBeg, *ReverseEnd;
2907 ExtrudePoint(type, ibeg, T0, T1, T2, A0, A1, A2, X0, X1, X2, alpha,
2908 &CurveBeg, &ReverseBeg, 0, e);
2909 ExtrudePoint(type, iend, T0, T1, T2, A0, A1, A2, X0, X1, X2, alpha,
2910 &CurveEnd, &ReverseEnd, 0, e);
2912 if(!CurveBeg && !CurveEnd) {
return ic; }
2922 else if(!CurveBeg || !CurveEnd)
2930 s->
Extrude->
fill(type, T0, T1, T2, A0, A1, A2, X0, X1, X2, alpha);
2942 else if(!CurveEnd) {
2968 int chap_num = chapeau->
Num;
2969 int body_num = s->
Num;
2972 std::vector<std::map<int, int> > report(3);
2973 report[1][chap_num] = chap_num;
2974 report[2][body_num] = body_num;
2976 auto m_it = report[1].find(chap_num);
2977 if(m_it != report[1].end())
2978 chap_num = report[1][chap_num];
2981 if(report[2][body_num] != body_num) *ps =
nullptr;
2988 double A1,
double A2,
double X0,
double X1,
double X2,
2998 GFace *gf =
nullptr;
3004 if(!ps && !gf)
return 0;
3009 std::map<int, int> source;
3015 chapeau->
Extrude->
fill(type, T0, T1, T2, A0, A1, A2, X0, X1, X2, alpha);
3023 c->Extrude->fill(type, T0, T1, T2, A0, A1, A2, X0, X1, X2, alpha);
3032 c2num = source[
c->Num];
3034 c->Extrude->geo.Source = c2num;
3035 if(e)
c->Extrude->mesh = e->
mesh;
3039 Msg::Error(
"Unknown GEO curve with tag %d", -
c->Num);
3040 return ps ? ps->
Num : gf->
tag();
3043 revc->
Extrude->
fill(type, T0, T1, T2, A0, A1, A2, X0, X1, X2, alpha);
3045 if(e)
c->Extrude->mesh = e->
mesh;
3062 v->
Extrude->
fill(type, T0, T1, T2, A0, A1, A2, X0, X1, X2, alpha);
3070 int tag = gf->
tag();
3080 else numg = gf->
edges().size();
3082 for(
int i = 0; i < numg; i++) {
3090 cnum = gf->
edges()[i]->tag();
3092 if(i < (
int)ori.size() && ori[i] < 0) cnum *= -1;
3095 ExtrudeCurve(type, cnum, T0, T1, T2, A0, A1, A2, X0, X1, X2, alpha, &s, 0,
3107 double matrix[4][4], T[3], Ax[3];
3134 for(
int i = 0; i <
List_Nbr(
c->Control_Points); i++) {
3187 default:
Msg::Error(
"Unknown extrusion type");
break;
3203 int chap_num = chapeau->
Num;
3206 std::vector<std::map<int, int> > report(3);
3207 report[2][chap_num] = chap_num;
3209 auto m_it = (report[2]).find(chap_num);
3210 if(m_it != report[2].end())
3211 chap_num = report[2][chap_num];
3222 double A0,
double A1,
double A2,
double X0,
double X1,
3225 for(
int i = 0; i <
List_Nbr(list_in); i++) {
3228 switch(shape.
Type) {
3230 Curve *pc =
nullptr, *prc =
nullptr;
3232 top.
Num =
ExtrudePoint(type, shape.
Num, T0, T1, T2, A0, A1, A2, X0, X1,
3233 X2, alpha, &pc, &prc, 1, e);
3254 top.
Num =
ExtrudeCurve(type, shape.
Num, T0, T1, T2, A0, A1, A2, X0, X1,
3255 X2, alpha, &ps, 1, e);
3268 if(abs(
c->Num) != shape.
Num && abs(
c->Num) != top.
Num) {
3284 top.
Num =
ExtrudeSurface(type, shape.
Num, T0, T1, T2, A0, A1, A2, X0, X1,
3299 if(abs(s->
Num) != shape.
Num && abs(s->
Num) != top.
Num) {
3310 Msg::Error(
"Impossible to extrude entity %d (of type %d)", shape.
Num,
3331 res(0) = (
c.Pos.X - ps->
p->
Pos.
X) * du.
Pos.
X +
3334 res(1) = (
c.Pos.X - ps->
p->
Pos.
X) * dv.
Pos.
X +
3351 if(d2 < 1.e-12)
return true;
3360 if(success && x(0) >= UMIN && x(0) <= UMAX && x(1) >= VMIN &&
3367 "ProjectPoint (%g,%g,%g) On Surface %d converged after %d iterations",
3371 x(0) = UMIN + (UMAX - UMIN) * ((rand() % 10000) / 10000.);
3372 x(1) = VMIN + (VMAX - VMIN) * ((rand() % 10000) / 10000.);
3373 if(ITER++ > 100)
break;
3377 double uok = 0.5, vok = 0.5;
3378 double dmin = 1.e22;
3379 for(
int i = 0; i < NSAMPLES; i++) {
3380 const double U = i / (double)(NSAMPLES - 1);
3381 for(
int j = 0; j < NSAMPLES; j++) {
3382 const double V = j / (double)(NSAMPLES - 1);
3398 Msg::Info(
"Brute force method used for projection of point (%g %g %g) on "
3412 Curve *cnew =
nullptr;
3416 cnew =
CreateCurve(
id,
c->Typ, 1, nodes,
nullptr, -1, -1, 0., 1., ok);
3419 cnew =
CreateCurve(
id,
c->Typ, 3, nodes,
nullptr, -1, -1, 0., 1., ok);
3422 cnew =
CreateCurve(
id,
c->Typ, 2, nodes,
nullptr, -1, -1, 0., 1., ok);
3425 Msg::Error(
"Cannot split a curve with type %i",
c->Typ);
3437 Msg::Error(
"Unknown curve %i to split", line_id);
3445 Msg::Error(
"Cannot split curve %i with type %i", line_id,
c->Typ);
3448 std::set<int> v_break;
3449 for(
int i = 0; i <
List_Nbr(vertices_id); i++) {
3454 bool is_periodic = (
c->beg ==
c->end);
3455 bool first_periodic =
true;
3456 bool last_periodic =
false;
3461 for(
int i = 0; i <
List_Nbr(
c->Control_Points); i++) {
3464 if(v_break.find(pv->
Num) != v_break.end() &&
List_Nbr(new_list) > 1) {
3465 if(last_periodic)
break;
3466 if(!(is_periodic && first_periodic)) {
3471 first_periodic =
false;
3475 if(i == (
List_Nbr(
c->Control_Points) - 1) && is_periodic &&
3478 last_periodic =
true;
3490 for(
int i = 0; i <
List_Nbr(curves); i++) {
3497 for(
int i = 0; i <
List_Nbr(Surfs); i++) {
3501 Curve *surface_curve;
3503 if(surface_curve->
Num ==
c->Num) {
3508 else if(surface_curve->
Num == -
c->Num) {
3565 Msg::Error(
"Unknown surface %d", surface_id);
3568 for(
int i = 0; i <
List_Nbr(curve_ids); i++) {
3590 Msg::Error(
"Unknown curve %d", (
int)curve_id);
3607 for(
int i = 0; i < nbEdges; i++) {
3613 Msg::Debug(
"Aborting curve loop sort for discrete curve: "
3614 "let's hope you know what you're doing ;-)");
3620 Msg::Debug(
"Unknown curve %d, aborting curve loop sort: "
3621 "let's hope you know what you're doing ;-)",
3637 for(
int i = 0; i <
List_Nbr(temp); i++) {
3639 if(reorient &&
c1->end == c2->
end) {
3647 if(
c1->end == c2->
beg) {
3654 "Starting subloop %d in curve loop %d (are you sure about this?)",
3682 for(
int i = 0; i < nbLoop; i++) {
3686 std::vector<int> fromModel;
3688 Msg::Error(
"Unknown curve loop %d in GEO surface %d", iLoop, s->
Num);
3696 if((i == 0 && iLoop > 0) ||
3697 (i != 0 && iLoop < 0)) {
3701 if(i != 0) ic *= -1;
3703 fromModel.push_back(ic);
3712 if(i != 0) ic *= -1;
3714 fromModel.push_back(ic);
3719 for(std::size_t j = 0; j < fromModel.size(); j++) {
3739 for(
int i = 0; i <
List_Nbr(loops); i++) {
3757 if(i > 0) tmp *= -1;
3764 Msg::Error(
"Unknown surface %d in GEO volume %d", is, v->
Num);
3780 tag = std::max(tag,
GModel::current()->getOCCInternals()->getMaxTag(0) + 1);
3792 tag = std::max(tag,
GModel::current()->getOCCInternals()->getMaxTag(1) + 1);
3805 std::max(tag,
GModel::current()->getOCCInternals()->getMaxTag(-1) + 1);
3817 tag = std::max(tag,
GModel::current()->getOCCInternals()->getMaxTag(2) + 1);
3830 std::max(tag,
GModel::current()->getOCCInternals()->getMaxTag(-2) + 1);
3842 tag = std::max(tag,
GModel::current()->getOCCInternals()->getMaxTag(3) + 1);
3849 for(
int dim = -2; dim <= 3; dim++) {
3852 std::max(tag,
GModel::current()->getGEOInternals()->getMaxTag(dim) + 1);
3857 for(
int dim = -2; dim <= 3; dim++) {
3868 #if defined(HAVE_MESH)