11 #include "../../common/progress/TaskProgress.h" 30 std::size_t nVectorPoints =
m_dataset.size();
33 for (std::size_t i = 0; i<nVectorPoints; i++)
36 if ((pp3d.
getX() >= xMin) && (pp3d.
getX() < xMax) && (pp3d.
getY() >= yMin) && (pp3d.
getY() < yMax))
39 double nX = (pp3d.
getX() - xOrigem) / dnorm;
40 double nY = (pp3d.
getY() - yOrigem) / dnorm;
84 double rfsta2 = fi * fi * r / 4.;
86 static double c[4] = { 8.5733287401, 18.0590169730, 8.6347608925,
88 static double b[4] = { 9.5733223454, 25.6329561486, 21.0996530827,
90 double ce = 0.57721566;
92 static double u[10] = { 1.e+00, -.25e+00,
93 .055555555555556e+00, -.010416666666667e+00,
94 .166666666666667e-02, -2.31481481481482e-04,
95 2.83446712018141e-05, -3.10019841269841e-06,
96 3.06192435822065e-07, -2.75573192239859e-08 };
104 res = x * (u[0] + x * (u[1] + x * (u[2] + x * (u[3] + x * (u[4] + x *
105 (u[5] + x * (u[6] + x * (u[7] + x * (u[8] + x * u[9])))))))));
113 ea = c[3] + x * (c[2] + x * (c[1] + x * (c[0] + x)));
114 eb = b[3] + x * (b[2] + x * (b[1] + x * (b[0] + x)));
115 e1 = (ea / eb) / (x * exp(x));
117 res = e1 + ce + log(x);
127 for (i = 0; i<n; i++)
129 ip = indx[
static_cast<size_t>(i)];
130 sum = b[
static_cast<size_t>(ip)];
131 b[
static_cast<size_t>(ip)] = b[static_cast<size_t>(i)];
133 for (j = ii; j<i; j++)
134 sum -= a[static_cast<size_t>(i)][
static_cast<size_t>(j)] * b[static_cast<size_t>(j)];
137 b[
static_cast<size_t>(i)] = sum;
139 for (i = n - 1; i >= 0; i--)
141 sum = b[
static_cast<size_t>(i)];
142 for (j = i + 1; j<n; j++)
143 sum -= a[static_cast<size_t>(i)][
static_cast<size_t>(j)] * b[static_cast<size_t>(j)];
144 b[
static_cast<size_t>(i)] = sum / a[static_cast<size_t>(i)][
static_cast<size_t>(i)];
148 #define TINY 1.0e-20; 152 int i, imax = 0, j, k;
153 double big, dum, sum, temp;
154 std::vector<double> vv;
156 vv.resize(static_cast<size_t>(n));
158 for (i = 0; i<n; i++)
161 for (j = 0; j<n; j++)
162 if ((temp = fabs(a[static_cast<size_t>(i)][static_cast<size_t>(j)])) > big)
170 vv[
static_cast<size_t>(i)] = 1.0 / big;
172 for (j = 0; j<n; j++)
174 for (i = 0; i<j; i++)
176 sum = a[
static_cast<size_t>(i)][static_cast<size_t>(j)];
177 for (k = 0; k<i; k++)
178 sum -= a[static_cast<size_t>(i)][
static_cast<size_t>(k)] * a[static_cast<size_t>(k)][
static_cast<size_t>(j)];
179 a[
static_cast<size_t>(i)][static_cast<size_t>(j)] = sum;
182 for (i = j; i<n; i++)
184 sum = a[
static_cast<size_t>(i)][static_cast<size_t>(j)];
185 for (k = 0; k<j; k++)
186 sum -= a[static_cast<size_t>(i)][
static_cast<size_t>(k)] * a[static_cast<size_t>(k)][
static_cast<size_t>(j)];
187 a[
static_cast<size_t>(i)][static_cast<size_t>(j)] = sum;
188 if ((dum = vv[static_cast<size_t>(i)] * fabs(sum)) >= big)
196 for (k = 0; k<n; k++)
198 dum = a[
static_cast<size_t>(imax)][static_cast<size_t>(k)];
199 a[
static_cast<size_t>(imax)][static_cast<size_t>(k)] = a[
static_cast<size_t>(j)][static_cast<size_t>(k)];
200 a[
static_cast<size_t>(j)][static_cast<size_t>(k)] = dum;
203 vv[
static_cast<size_t>(imax)] = vv[static_cast<size_t>(j)];
205 indx[
static_cast<size_t>(j)] = imax;
206 if (a[static_cast<size_t>(j)][
static_cast<size_t>(j)] == 0.0)
207 a[
static_cast<size_t>(j)][static_cast<size_t>(j)] =
TINY;
210 dum = 1.0 / (a[
static_cast<size_t>(j)][static_cast<size_t>(j)]);
211 for (i = j + 1; i<n; i++)
212 a[static_cast<size_t>(i)][
static_cast<size_t>(j)] *= dum;
222 std::vector< std::vector <double> > &matrix,
223 std::vector<int> &indx,
double fi,
double rsm,
int KMAX2
233 std::vector<double>
A;
235 std::size_t i, i1, j, k, k1, k2, l, m;
239 std::size_t n1 = n_points + 1;
248 A.resize(static_cast<size_t>(KMAX2 + 2)*static_cast<size_t>(KMAX2 + 2) + 1);
251 for (k = 1; k <= n_points; k++)
263 for (k = 1; k <= n_points; k++)
273 for (l = k2; l <= n_points; l++)
296 for (k = 1; k <= n1; k++)
300 for (l = k2; l <= n1; l++)
302 m = (l - 1) * n1 + k;
304 amaxa =
amax1(A[m], amaxa);
308 for (i = 0; i <= n_points; i++) {
309 for (j = 0; j <= n_points; j++) {
315 if (
G_ludcmp(matrix, static_cast<int>(n_points + 1), indx, d) <= 0)
327 unsigned int nro_neighb;
334 std::unique_ptr<te::rst::Raster>
rst =
Initialize(
true, nro_neighb, rx1, ry2, NCols, NLines);
342 double ew_region = deltx /
static_cast<double>(nPartsX);
343 double ns_region = delty /
static_cast<double>(nPartsY);
348 double percentageDist = 0.5;
357 std::size_t nallPoints =
m_dataset.size();
359 double zmin = pp03d.
getZ();
360 double zmax = pp03d.
getZ();
361 for (std::size_t i = 1; i<nallPoints; i++)
368 int nsteps =
static_cast<int>(nPartsY*nPartsX + 1);
371 for (
int iy = 0; iy < nPartsY; iy++)
373 double begin_y = Y1 + (iy*ns_region);
374 double end_y = Y1 + ((iy + 1)*ns_region);
376 double disty = (end_y - begin_y) * percentageDist;
378 for (
int jx = 0; jx < nPartsX; jx++)
385 double begin_x = X1 + (jx*ew_region);
386 double end_x = X1 + ((jx + 1)*ew_region);
388 double distx = (end_x - begin_x) * percentageDist;
391 bool poucosPontos =
false;
394 double overlapDistX = distx*nOverlaping;
395 double overlapDistY = disty*nOverlaping;
397 setControlPoints(begin_x - overlapDistX, end_x + overlapDistX, begin_y - overlapDistY, end_y + overlapDistY, static_cast<int>(KMAX2), begin_x, begin_y, dnorm);
402 }
while (poucosPontos);
404 std::vector<int> indx;
405 std::vector< std::vector<double> > matrix;
406 std::vector<double>
b;
408 indx.resize(KMAX2 + 1);
409 for (
int ii = 0; ii < static_cast<int>(KMAX2) + 1; ++ii)
411 std::vector<double> maux;
412 maux.resize(KMAX2 + 1);
413 matrix.push_back(maux);
422 for (
int ii = 0; ii < static_cast<int>(KMAX2) + 1; ++ii)
423 matrix[static_cast<size_t>(ii)].clear();
429 for (std::size_t jj = 0; jj < n_points; jj++)
432 b[jj + 1] = pp3d.
getZ();
436 G_lubksb(matrix, static_cast<int>(n_points) + 1, indx, b);
441 for (
unsigned ii = 0; ii < matrix.size(); ++ii)
446 if (!
IL_grid_calc(begin_x, end_x, begin_y, end_y, zmin, zmax, static_cast<int>(KMAX2), b, fi, dnorm))
460 std::vector<double>&
b,
474 double h, xx, yy, r2, hz, zz, err, r;
477 for (mm = 1; mm <= n_points; mm++)
481 for (m = 1; m <= n_points; m++)
487 r2 = yy * yy + xx * xx;
496 zz = pp3dMM.
getZ() + zmin;
499 (ertot) += err * err;
515 double deltx = xMax - xMin;
516 double delty = yMax - yMin;
518 int n_rows =
static_cast<int>(delty / ns_res);
519 int n_cols =
static_cast<int>(deltx / ew_res);
523 int ngstc =
static_cast<int>((x_or - x1) / ew_res + 0.5);
524 int nszc = ngstc + n_cols;
525 int ngstr =
static_cast<int>((y2 - yMax) / ns_res + 0.5);
526 int nszr = ngstr + n_rows;
528 double stepix = ew_res / dnorm;
529 double stepiy = ns_res / dnorm;
531 std::vector<double> w2;
532 std::vector<double> w;
534 w.resize(static_cast<size_t>(KMAX2) + 9);
535 w2.resize(static_cast<size_t>(KMAX2) + 9);
539 for (
int k = ngstr; k <= nszr; k++)
541 double yg = (k - ngstr) * stepiy + stepiy / 2.;
542 for (
size_t m = 1; m <= n_points; m++)
545 double wm = yg - pp3d.
getY();
550 for (
int l = ngstc; l <= nszc; l++)
552 double xg = (l - ngstc) * stepix + stepix / 2.;
556 for (
size_t m = 1; m <= n_points; m++)
559 double xx = xg - pp3d.
getX();
560 double xx2 = xx * xx;
561 double r2 = xx2 + w2[m];
568 int row = nszr - contadory;
577 m_rst->
setValue(static_cast<unsigned int>(l), static_cast<unsigned int>(row), zz);
double m_nodatavalue
no data value
virtual void setValue(unsigned int c, unsigned int r, const double value, std::size_t b=0)
Sets the attribute value in a band of a cell.
int G_ludcmp(std::vector< std::vector< double > > &, int, std::vector< int > &, double &)
int IL_check_at_points_2d(std::vector< double > &b, double &ertot, double zmin, double dnorm, double fi)
void setControlPoints(double xMin, double xMax, double yMin, double yMax, int nMax, double xOrigem, double yOrigem, double dnorm)
std::unique_ptr< te::rst::Raster > Initialize(bool spline, unsigned int &nro_neighb, double &rx1, double &ry2, unsigned int &outputWidth, unsigned int &outputHeight)
bool IL_grid_calc(double xMin, double xMax, double yMin, double yMax, double zMin, double zMax, int KMAX2, std::vector< double > &b, double fi, double dnorm)
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
const double & getUpperRightX() const
It returns a constant refernce to the x coordinate of the upper right corner.
This class can be used to inform the progress of a task.
double amax1(double arg1, double arg2)
const double & getLowerLeftY() const
It returns a constant refernce to the y coordinate of the lower left corner.
double amin1(double arg1, double arg2)
double m_max
Output DTM limits.
const double & getUpperRightY() const
It returns a constant refernce to the x coordinate of the upper right corner.
void G_lubksb(std::vector< std::vector< double > > &a, int n, std::vector< int > &indx, std::vector< double > &b)
bool isActive() const
Verify if the task is active.
Utility functions for MNT support.
double IL_crst(double r, double fi)
const double & getY() const
It returns the Point y-coordinate value.
A point with x and y coordinate values.
std::vector< te::gm::Point > m_pointsRegion
Control Points of grid region.
unsigned int getNumberOfRows() const
Returns the raster number of rows.
static te::dt::DateTime d(2010, 8, 9, 15, 58, 39)
virtual ~SplineInterpolationGrassMitasova()
Destructor.
int IL_matrix_create(std::vector< std::vector< double > > &matrix, std::vector< int > &indx, double fi, double rsm, int KMAX2)
void pulse()
Calls setCurrentStep() function using getCurrentStep() + 1.
te::gm::Envelope m_env
Attribute used to restrict the area to generate the raster.
const double & getZ() const
It returns the Point z-coordinate value, if it has one or DoubleNotANumber otherwise.
std::vector< std::pair< te::gm::Coord2D, te::gm::Point > > m_dataset
void setX(const double &x)
It sets the Point x-coordinate value.
This file contains a class to calculate retangular grid from Samples using Spline Grass Mitasova Inte...
const double & getLowerLeftX() const
It returns a constant reference to the x coordinate of the lower left corner.
SplineInterpolationGrassMitasova(int minPoints=mitasovaMINPOINTS, double tension=mitasovaTENSION, double smooth=mitasovaSMOOTH)
Contructors.
void setY(const double &y)
It sets the Point y-coordinate value.
double m_resy
grid resolution in X and Y
const double & getX() const
It returns the Point x-coordinate value.
void setZ(const double &z)
It sets the Point z-coordinate value.
double m_tolerance
tolerance used to simplify lines