16 std::vector<std::pair<SPoint3, double> >
_pts;
22 _pts.push_back(std::make_pair(pt, t));
25 return _pts.size() - 1;
27 void sort(std::vector<SPoint3> &spts, std::vector<double> &ts)
30 spts.reserve(
_pts.size());
32 ts.reserve(
_pts.size());
33 for(
int p =
_next[0]; p != -1; p =
_next[p + 1]) {
34 spts.push_back(
_pts[p].first);
35 ts.push_back(
_pts[p].second);
43 const SPoint3 &p3,
double t0,
double t3)
50 double d = std::max(
dot(d130, d130),
dot(d230, d230));
51 double l2 =
dot(d30, d30);
53 if(d < tol * tol * l2) {
return; }
58 SPoint3 p012((p01 + p12) * 0.5);
59 SPoint3 p123((p12 + p23) * 0.5);
60 SPoint3 p0123((p012 + p123) * 0.5);
61 double t0123 = 0.5 * (t0 + t3);
62 int newpos = discrete.
insertPoint(pos, p0123, t0123);
64 decasteljau(tol, discrete, pos, p0, p01, p012, p0123, t0, t0123);
65 decasteljau(tol, discrete, newpos, p0123, p123, p23, p3, t0123, t3);
69 const SPoint3 pt[4],
double t0,
double t3,
70 bool insertFirstPoint)
72 if(insertFirstPoint) pos = discrete.
insertPoint(pos, pt[0], t0);
74 decasteljau(tol, discrete, pos, pt[0], pt[1], pt[2], pt[3], t0, t3);
79 const SPoint3 pt[4],
double t0,
double t3,
80 bool insertFirstPoint)
82 SPoint3 bpt[4] = {
SPoint3((pt[0] + 4 * pt[1] + pt[2]) * (1. / 6.)),
83 SPoint3((2 * pt[1] + pt[2]) * (1. / 3.)),
84 SPoint3((pt[1] + 2 * pt[2]) * (1. / 3.)),
85 SPoint3((pt[1] + 4 * pt[2] + pt[3]) * (1. / 6.))};
90 const SPoint3 pt[4],
double t0,
double t3,
91 bool insertFirstPoint)
93 SPoint3 bpt[4] = {pt[1],
SPoint3((6 * pt[1] + pt[2] - pt[0]) * (1. / 6.)),
94 SPoint3((6 * pt[2] - pt[3] + pt[1]) * (1. / 6.)), pt[2]};
106 std::vector<double> &ts)
114 for(
int i = 0; i < NPt; ++i) {
116 ts[i] = i / (double)(NPt - 1);
122 int NbCurves = (
List_Nbr(
c->Control_Points) - 1) / 3;
123 for(
int iCurve = 0; iCurve < NbCurves; ++iCurve) {
124 double t1 = (iCurve) / (
double)(NbCurves);
125 double t2 = (iCurve + 1) / (
double)(NbCurves);
127 for(
int i = 0; i < 4; i++) { pt[i] =
curveGetPoint(
c, iCurve * 3 + i); }
134 bool periodic = (
c->end ==
c->beg);
135 int NbControlPoints =
List_Nbr(
c->Control_Points);
136 int NbCurves = NbControlPoints + (periodic ? -1 : 1);
138 for(
int iCurve = 0; iCurve < NbCurves; ++iCurve) {
139 double t1 = (iCurve) / (
double)(NbCurves);
140 double t2 = (iCurve + 1) / (
double)(NbCurves);
141 for(
int i = 0; i < 4; i++) {
144 k = (iCurve - 1 + i) % (NbControlPoints - 1);
145 if(k < 0) k += NbControlPoints - 1;
148 k = std::max(0, std::min(iCurve - 2 + i, NbControlPoints - 1));
157 int NbCurves =
List_Nbr(
c->Control_Points) - 1;
160 for(
int iCurve = 0; iCurve < NbCurves; ++iCurve) {
161 double t1 = (iCurve) / (
double)(NbCurves);
162 double t2 = (iCurve + 1) / (
double)(NbCurves);
169 pt[0] =
SPoint3(pt[1] * 2 - pt[2]);
173 if(iCurve == NbCurves - 1) {
177 pt[3] =
SPoint3(2 * pt[2] - pt[1]);
186 Msg::Error(
"discretizeCurve not implemented for curve type %d",
c->Typ);
188 discrete.
sort(pts, ts);
192 std::vector<double> &ts)