60#define DONT_INTERSECT 0
64#define LERP(a, l, h) ((l) + (((h) - (l)) * (a)))
65#define EQUAL(a, b) (fabs((a) - (b)) < EPSILON)
66#define ISNODE(p, res) (fmod((double)p, (double)res) < EPSILON)
68#define SAME_SIGNS(a, b) ((a >= 0 && b >= 0) || (a < 0 && b < 0))
70static int drape_line_init(
int,
int);
71static Point3 *_gsdrape_get_segments(
geosurf *,
float *,
float *,
int *);
72static float dist_squared_2d(
float *,
float *);
81static Point3 *Vi, *Hi, *Di;
95static int drape_line_init(
int rows,
int cols)
141 float dir[2], yres, xres;
157 if (!((end[
Y] -
bgn[
Y]) / (end[
X] -
bgn[
X]) == yres / xres)) {
166 G_debug(5,
"_gsdrape_get_segments vi=%d, hi=%d, di=%d, num=%d",
vi,
hi,
di,
180static float dist_squared_2d(
float *
p1,
float *p2)
187 return (dx * dx + dy * dy);
200 static int first = 1;
205 if (0 > drape_line_init(
gs->rows,
gs->cols)) {
206 G_warning(
_(
"Unable to process vector map - out of memory"));
387 return (_gsdrape_get_segments(
gs,
bgn, end, num));
427 return (_gsdrape_get_segments(
gs,
bgn, end, num));
513 float xmax, ymin, ymax,
alpha;
525 if (
pt[
X] < 0.0 ||
pt[
Y] > ymax) {
530 if (
pt[
Y] < ymin ||
pt[
X] > xmax) {
549 if (
pt[
X] > 0.0 &&
pt[
Y] < ymax) {
586 else if (
pt[
X] == 0.0) {
608 else if (
pt[
Y] ==
gs->yrange) {
627 if (
pt[
X] > 0.0 &&
pt[
X] < xmax) {
643 else if (
pt[
X] == 0.0) {
700 if (
pt[
X] >= 0.0 &&
pt[
Y] <=
gs->yrange) {
751 big =
gs->yrange *
gs->yrange +
gs->xrange *
gs->xrange;
754 for (i = 0; i < num; i = cv +
ch +
cd) {
756 dv = dist_squared_2d(Vi[cv],
cpoint);
841 if (i == cv +
ch +
cd) {
842 G_debug(5,
"order_intersects(): stuck on %d",
cnum);
843 G_debug(5,
"order_intersects(): cv = %d, ch = %d, cd = %d", cv,
ch,
845 G_debug(5,
"order_intersects(): dv = %f, dh = %f, dd = %f",
dv,
dh,
922 yb =
gs->yrange - (yres * rows) -
EPSILON;
1078 float xres, yres,
xi,
yi, dx, dy;
1079 int diags, cols, rows, lower;
1086 diags = rows + cols;
1093 lower = ((end[
X] -
pt[
X]) / xres > (end[
Y] -
pt[
Y]) / yres);
1166 sqrt(dx * dx + dy * dy) /
sqrt(xres * xres + yres * yres);
1210 float x4,
float y4,
float *x,
float *y)
1221 c1 = x2 * y1 - x1 * y2;
1242 r1 = a2 * x1 +
b2 * y1 +
c2;
1243 r2 = a2 * x2 +
b2 * y2 +
c2;
1272 num = a2 *
c1 - a1 *
c2;
1338 v1[
X] =
p1[
X] - p3[
X];
1339 v1[
Y] =
p1[
Y] - p3[
Y];
1340 v1[
Z] =
p1[
Z] - p3[
Z];
1342 v2[
X] = p2[
X] - p3[
X];
1343 v2[
Y] = p2[
Y] - p3[
Y];
1344 v2[
Z] = p2[
Z] - p3[
Z];
1351 plane[
W] = -p3[
X] * norm[
X] - p3[
Y] * norm[
Y] - p3[
Z] * norm[
Z];
1366 c[
X] = (a[
Y] *
b[
Z]) - (a[
Z] *
b[
Y]);
1367 c[
Y] = (a[
Z] *
b[
X]) - (a[
X] *
b[
Z]);
1368 c[
Z] = (a[
X] *
b[
Y]) - (a[
Y] *
b[
X]);
void G_free(void *)
Free allocated memory.
void G_warning(const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf
int gs_point_is_masked(geosurf *, float *)
Check if point is masked.
float GS_P2distance(float *, float *)
Calculate distance in plane.
int gs_get_att_src(geosurf *, int)
Get attribute source.
void GS_v3eq(float *, float *)
Copy vector values.
typbuff * gs_get_att_typbuff(geosurf *, int, int)
Get attribute data buffer.
void GS_v2dir(float *, float *, float *)
Get a normalized direction from v1 to v2, store in v3 (2D)
#define UNUSED
A macro for an attribute, if attached to a variable, indicating that the variable is not used.
int P3toPlane(Point3 p1, Point3 p2, Point3 p3, float *plane)
Define plane.
Point3 * gsdrape_get_segments(geosurf *gs, float *bgn, float *end, int *num)
ADD.
int in_vregion(geosurf *gs, float *pt)
ADD.
int order_intersects(geosurf *gs, Point3 first, Point3 last, int vi, int hi, int di)
ADD.
int _viewcell_tri_interp(geosurf *gs, Point3 pt)
ADD.
int gsdrape_set_surface(geosurf *gs)
ADD.
void interp_first_last(geosurf *gs, float *bgn, float *end, Point3 f, Point3 l)
ADD.
int V3Cross(Point3 a, Point3 b, Point3 c)
Get cross product.
int viewcell_tri_interp(geosurf *gs, typbuff *buf, Point3 pt, int check_mask)
ADD.
int segs_intersect(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float *x, float *y)
Line intersect.
int get_horz_intersects(geosurf *gs, float *bgn, float *end, float *dir)
Get horizontal intersects.
int get_vert_intersects(geosurf *gs, float *bgn, float *end, float *dir)
ADD.
int get_diag_intersects(geosurf *gs, float *bgn, float *end, float *dir)
Get diagonal intersects.
int seg_intersect_vregion(geosurf *gs, float *bgn, float *end)
Check if segment intersect vector region.
Point3 * gsdrape_get_allsegments(geosurf *gs, float *bgn, float *end, int *num)
Get all segments.
int XY_intersect_plane(float *intersect, float *plane)
Check for intersection (point and plane)
int Point_on_plane(Point3 p1, Point3 p2, Point3 p3, Point3 unk)
Check if point is on plane.
#define GET_MAPATT(buff, offset, att)
OGSF header file (structures)
#define DRC2OFF(gs, drow, dcol)
#define VROW2DROW(gs, vrow)
#define VCOL2DCOL(gs, vcol)