|
|
57bda0 |
|
|
|
57bda0 |
#include "raster.h"
|
|
|
57bda0 |
|
|
|
57bda0 |
|
|
|
57bda0 |
void Raster::touch(int index, Real value, Real x, Real y, Real dx, Real dy, TouchPointList &points) {
|
|
|
57bda0 |
dx = std::max(0.500001, dx);
|
|
|
57bda0 |
dy = std::max(0.500001, dy);
|
|
|
57bda0 |
int x0 = std::max(0, (int)ceil(x - dx));
|
|
|
57bda0 |
int y0 = std::max(0, (int)ceil(y - dy));
|
|
|
57bda0 |
int x1 = std::min(width, (int)ceil(x + dx));
|
|
|
57bda0 |
int y1 = std::min(height, (int)ceil(y + dy));
|
|
|
57bda0 |
dx = 1/dx;
|
|
|
57bda0 |
dy = 1/dy;
|
|
|
57bda0 |
|
|
|
57bda0 |
for(int iy = y0; iy < y1; ++iy) {
|
|
|
57bda0 |
for(int ix = x0; ix < x1; ++ix) {
|
|
|
57bda0 |
Real ddx = (x-ix)*dx;
|
|
|
57bda0 |
Real ddy = (y-iy)*dy;
|
|
|
57bda0 |
if (ddx + ddy <= 1.00001) {
|
|
|
57bda0 |
Real &pixel = (*this)[iy][ix];
|
|
|
57bda0 |
if (pixel > value) {
|
|
|
57bda0 |
points.push_back( TouchPoint(index, iy, ix, pixel, value) );
|
|
|
57bda0 |
pixel = value;
|
|
|
57bda0 |
}
|
|
|
57bda0 |
}
|
|
|
57bda0 |
}
|
|
|
57bda0 |
}
|
|
|
57bda0 |
}
|