Skip to content
Snippets Groups Projects
Commit c71908ea authored by Tom Fischer's avatar Tom Fischer
Browse files

[GL] Raster: Rm unused fct. getRasterFromSurface.

parent a57b4268
No related branches found
No related tags found
No related merge requests found
......@@ -55,41 +55,6 @@ Raster::~Raster()
delete [] _raster_data;
}
Raster* Raster::getRasterFromSurface(Surface const& sfc, double cell_size, double no_data_val)
{
MathLib::Point3d const& ll(sfc.getAABB().getMinPoint());
MathLib::Point3d const& ur(sfc.getAABB().getMaxPoint());
const std::size_t n_cols = static_cast<std::size_t>(std::abs(ur[0]-ll[0]) / cell_size)+1;
const std::size_t n_rows = static_cast<std::size_t>(std::abs(ur[1]-ll[1]) / cell_size)+1;
const std::size_t n_triangles(sfc.getNumberOfTriangles());
auto* z_vals(new double[n_cols * n_rows]);
std::size_t k(0);
for (std::size_t r(0); r < n_cols; r++) {
for (std::size_t c(0); c < n_rows; c++) {
GeoLib::Point const test_pnt = { ll[0] + r*cell_size, ll[1] + c*cell_size, 0};
for (k=0; k<n_triangles; k++) {
if (sfc[k]->containsPoint2D(test_pnt)) {
GeoLib::Triangle const * const tri (sfc[k]);
// compute coefficients c0, c1, c2 for the plane f(x,y) = c0 x + c1 y + c2
double coeff[3] = {0.0, 0.0, 0.0};
GeoLib::getPlaneCoefficients(*tri, coeff);
z_vals[r*n_rows+c] = coeff[0] * test_pnt[0] + coeff[1] * test_pnt[1] + coeff[2];
break;
}
}
if (k==n_triangles) {
z_vals[r*n_rows+c] = no_data_val;
}
}
}
RasterHeader header = { std::size_t(n_cols), std::size_t(n_rows), 1,
MathLib::Point3d(ll), cell_size, static_cast<double>(-9999) };
return new Raster(header, z_vals, z_vals+n_cols*n_rows);
}
double Raster::getValueAtPoint(const MathLib::Point3d &pnt) const
{
if (pnt[0]>=_header.origin[0] && pnt[0]<(_header.origin[0]+(_header.cell_size*_header.n_cols)) &&
......
......@@ -97,9 +97,6 @@ public:
~Raster();
/// Creates a Raster based on a GeoLib::Surface
static Raster* getRasterFromSurface(Surface const& sfc, double cell_size, double no_data_val = -9999);
private:
void setCellSize(double cell_size);
void setNoDataVal (double no_data_val);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment