29 std::vector<double> lc(n), u_lc(n);
30 for (
int i = 0; i < n; ++i)
34 u_lc[i] = i * 1. / (n - 1);
138 std::ostringstream sstream;
143 sstream <<
"Control points: ";
152 info += sstream.str();
172 np = (int)(0.99 + (n - 1) * a / (2 * M_PI));
214 int NbCurves = NbControlPoints + (
periodic ? -1 : 1);
215 int iCurve = (int)floor(epar * (
double)NbCurves);
216 if (iCurve >= NbCurves)
217 iCurve = NbCurves - 1;
220 double t1 = (double)(iCurve) / (double)(NbCurves);
221 double t2 = (double)(iCurve + 1) / (double)(NbCurves);
222 double t = (epar - t1) / (t2 - t1);
224 for (
int j = 0; j < 4; j++)
226 int k = iCurve - (
periodic ? 1 : 2) + j;
228 k =
periodic ? k + NbControlPoints - 1 : 0;
229 if (k >= NbControlPoints)
230 k =
periodic ? k - NbControlPoints + 1 : NbControlPoints - 1;
239 int i = (int)((
double)(N - 1) * epar);
244 double t1 = (double)(i) / (double)(N - 1);
245 double t2 = (double)(i + 1) / (double)(N - 1);
246 double t = (epar - t1) / (t2 - t1);
285 Msg::Error(
"Unknown curve type in reparamOnFace");
293 for (
int i = 0; i < 4; i++)
297 if (C[0]->Num ==
_c->
Num)
299 U = (epar - C[0]->
ubeg) / (C[0]->uend - C[0]->ubeg);
302 else if (C[0]->Num == -
_c->
Num)
304 U = (C[0]->
uend - epar - C[0]->
ubeg) / (C[0]->uend - C[0]->ubeg);
307 else if (C[1]->Num ==
_c->
Num)
309 V = (epar - C[1]->
ubeg) / (C[1]->uend - C[1]->ubeg);
312 else if (C[1]->Num == -
_c->
Num)
314 V = (C[1]->
uend - epar - C[1]->
ubeg) / (C[1]->uend - C[1]->ubeg);
317 else if (C[2]->Num ==
_c->
Num)
319 U = 1 - (epar - C[2]->
ubeg) / (C[2]->uend - C[2]->ubeg);
322 else if (C[2]->Num == -
_c->
Num)
324 U = 1 - (C[2]->
uend - epar - C[2]->
ubeg) / (C[2]->uend - C[2]->ubeg);
327 else if (C[3]->Num ==
_c->
Num)
329 V = 1 - (epar - C[3]->
ubeg) / (C[3]->uend - C[3]->ubeg);
332 else if (C[3]->Num == -
_c->
Num)
334 V = 1 - (C[3]->
uend - epar - C[3]->
ubeg) / (C[3]->uend - C[3]->ubeg);
347 for (
int i = 0; i < 3; i++)
352 if (C[0]->Num ==
_c->
Num)
354 U = (epar - C[0]->
ubeg) / (C[0]->uend - C[0]->ubeg);
357 else if (C[0]->Num == -
_c->
Num)
359 U = (C[0]->
uend - epar - C[0]->
ubeg) / (C[0]->uend - C[0]->ubeg);
362 else if (C[1]->Num ==
_c->
Num)
364 V = (epar - C[1]->
ubeg) / (C[1]->uend - C[1]->ubeg);
367 else if (C[1]->Num == -
_c->
Num)
369 V = (C[1]->
uend - epar - C[1]->
ubeg) / (C[1]->uend - C[1]->ubeg);
372 else if (C[2]->Num ==
_c->
Num)
374 U = 1 - (epar - C[2]->
ubeg) / (C[2]->uend - C[2]->ubeg);
377 else if (C[2]->Num == -
_c->
Num)
379 U = 1 - (C[2]->
uend - epar - C[2]->
ubeg) / (C[2]->uend - C[2]->ubeg);
395 if (C[0]->Num ==
_c->
Num)
397 U = (epar - C[0]->
ubeg) / (C[0]->uend - C[0]->ubeg);
400 else if (C[0]->Num == -
_c->
Num)
402 U = (C[0]->
uend - epar - C[0]->
ubeg) / (C[0]->uend - C[0]->ubeg);
405 else if (C[1]->Num ==
_c->
Num)
407 V = (epar - C[1]->
ubeg) / (C[1]->uend - C[1]->ubeg);
410 else if (C[1]->Num == -
_c->
Num)
412 V = (C[1]->
uend - epar - C[1]->
ubeg) / (C[1]->uend - C[1]->ubeg);
415 else if (C[2]->Num ==
_c->
Num)
417 U = 1 - (epar - C[2]->
ubeg) / (C[2]->uend - C[2]->ubeg);
420 else if (C[2]->Num == -
_c->
Num)
422 U = 1 - (C[2]->
uend - epar - C[2]->
ubeg) / (C[2]->uend - C[2]->ubeg);
446 fprintf(fp,
"Line(%d) = ",
_c->
Num);
450 fprintf(fp,
"Circle(%d) = ",
_c->
Num);
454 fprintf(fp,
"Ellipse(%d) = ",
_c->
Num);
457 fprintf(fp,
"Nurbs(%d) = {",
_c->
Num);
463 fprintf(fp,
"%d", v->
Num);
465 fprintf(fp,
", %d", v->
Num);
470 fprintf(fp,
" Knots {");
474 fprintf(fp,
"%.16g",
_c->
k[j]);
476 fprintf(fp,
", %.16g",
_c->
k[j]);
481 fprintf(fp,
" Order %d;\n",
_c->
degre);
484 fprintf(fp,
"Spline(%d) = ",
_c->
Num);
487 fprintf(fp,
"BSpline(%d) = ",
_c->
Num);
490 fprintf(fp,
"Bezier(%d) = ",
_c->
Num);
501 fprintf(fp,
", %d", v->
Num);
503 fprintf(fp,
"{%d", v->
Num);
511 fprintf(fp,
"Transfinite Line {%d} = %d",
tag() * (
meshAttributes.typeTransfinite > 0 ? 1 : -1),
516 fprintf(fp,
" Using Progression ");
518 fprintf(fp,
" Using Bump ");
520 fprintf(fp,
" Using Beta ");
522 fprintf(fp,
" Using Sizemap ");
529 fprintf(fp,
"Reverse Line {%d};\n",
tag());
548 for (
int i = 0; i < NPt; ++i)
551 ts[i] = i / (double)(NPt - 1);
558 for (
int iCurve = 0; iCurve < NbCurves; ++iCurve)
560 double t1 = (iCurve) / (
double)(NbCurves);
561 double t2 = (iCurve + 1) / (
double)(NbCurves);
563 for (
int i = 0; i < 4; i++)
567 std::vector<double> lts;
568 std::vector<SPoint3> lpts;
569 decasteljau(tol, pt[0], pt[1], pt[2], pt[3], lpts, lts);
570 for (
size_t i = (iCurve == 0 ? 0 : 1); i < lpts.size(); ++i)
572 pts.push_back(lpts[i]);
573 ts.push_back(t1 + lts[i] * (t2 - t1));
582 int NbCurves = NbControlPoints + (
periodic ? -1 : 1);
584 for (
int iCurve = 0; iCurve < NbCurves; ++iCurve)
586 double t1 = (iCurve) / (
double)(NbCurves);
587 double t2 = (iCurve + 1) / (
double)(NbCurves);
588 for (
int i = 0; i < 4; i++)
593 k = (iCurve - 1 + i) % (NbControlPoints - 1);
595 k += NbControlPoints - 1;
599 k = std::max(0, std::min(iCurve - 2 + i, NbControlPoints - 1));
603 SPoint3 bpt[4] = {(pt[0] + pt[1] * 4 + pt[2]) * (1. / 6.), (pt[1] * 2 + pt[2]) * (1. / 3.),
604 (pt[1] + pt[2] * 2) * (1. / 3.), (pt[1] + pt[2] * 4 + pt[3]) * (1. / 6.)};
605 std::vector<double> lts;
606 std::vector<SPoint3> lpts;
607 decasteljau(tol, bpt[0], bpt[1], bpt[2], bpt[3], lpts, lts);
608 for (
size_t i = (iCurve == 0 ? 0 : 1); i < lpts.size(); ++i)
610 pts.push_back(lpts[i]);
611 ts.push_back(t1 + lts[i] * (t2 - t1));
620 for (
int iCurve = 0; iCurve < NbCurves; ++iCurve)
622 double t1 = (iCurve) / (
double)(NbCurves);
623 double t2 = (iCurve + 1) / (
double)(NbCurves);
631 pt[0] =
SPoint3(pt[1] * 2 - pt[2]);
635 if (iCurve == NbCurves - 1)
640 pt[3] =
SPoint3(2 * pt[2] - pt[1]);
644 SPoint3 bpt[4] = {pt[1], (pt[1] * 6 + pt[2] - pt[0]) * (1. / 6.), (pt[2] * 6 - pt[3] + pt[1]) * (1. / 6.),
646 std::vector<double> lts;
647 std::vector<SPoint3> lpts;
648 decasteljau(tol, bpt[0], bpt[1], bpt[2], bpt[3], lpts, lts);
649 for (
size_t i = (iCurve == 0 ? 0 : 1); i < lpts.size(); ++i)
651 pts.push_back(lpts[i]);
652 ts.push_back(t1 + lts[i] * (t2 - t1));