Loading...
Searching...
No Matches
gs_query.c File Reference

OGSF library - query (lower level functions). More...

`#include <math.h>`
`#include <grass/gis.h>`
`#include <grass/ogsf.h>`
Include dependency graph for gs_query.c:

Go to the source code of this file.

## Macros

#define | HUGE_VAL 1.7976931348623157e+308
| Values needed for Ray-Convex Polyhedron Intersection Test below originally by Eric Haines, erich.nosp@m.@eye.nosp@m..com.
#define | MISSED 0
#define | FRONTFACE 1
#define | BACKFACE -1

## Functions

int | gs_los_intersect1 (int surfid, float(*los)[3], float *point)
| Crude method of intersecting line of sight with closest part of surface.
int | gs_los_intersect (int surfid, float **los, float *point)
| Crude method of intersecting line of sight with closest part of surface.
int | RayCvxPolyhedronInt (Point3 org, Point3 dir, double tmax, Point4 *phdrn, int ph_num, double *tresult, int *pn)
| Ray-Convex Polyhedron Intersection Test.
void | gs_get_databounds_planes (Point4 *planes)
| Get data bounds for plane.
int | gs_setlos_enterdata (Point3 *los)

## Detailed Description

OGSF library - query (lower level functions).

GRASS OpenGL gsurf OGSF Library

(C) 1999-2008 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
  Bill Brown USACERL (January 1994)
  Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)

Definition in file gs_query.c.

## Macro Definition Documentation

## BACKFACE

#define BACKFACE -1

Definition at line 35 of file gs_query.c.

Referenced by RayCvxPolyhedronInt().

## FRONTFACE

#define FRONTFACE 1

Definition at line 34 of file gs_query.c.

Referenced by gs_setlos_enterdata(), and RayCvxPolyhedronInt().

## HUGE_VAL

#define HUGE_VAL 1.7976931348623157e+308

Values needed for Ray-Convex Polyhedron Intersection Test below originally by Eric Haines, erich.nosp@m.@eye.nosp@m..com.

Definition at line 29 of file gs_query.c.

Referenced by I_cluster_assign(), I_cluster_reassign(), and RayCvxPolyhedronInt().

## MISSED

#define MISSED 0

Definition at line 33 of file gs_query.c.

Referenced by gs_setlos_enterdata(), and RayCvxPolyhedronInt().

## Function Documentation

## gs_get_databounds_planes()

void gs_get_databounds_planes | ( | Point4 * | planes | ) |

Get data bounds for plane.

Parameters

  [out] | planes |

Definition at line 469 of file gs_query.c.

References b, gs_get_xrange(), gs_get_yrange(), GS_get_zrange(), t, X, and Y.

Referenced by gs_setlos_enterdata().

## gs_los_intersect()

int gs_los_intersect | ( | int | surfid,
|  | float ** | los,
|  | float * | point )

Crude method of intersecting line of sight with closest part of surface.

This version uses the shadow of the los projected down to the surface to generate a line_on_surf, then follows each point in that line until the los intersects it.

Parameters

  | surfid | surface id
  | los | should be in surf-world coordinates
  [out] | point | intersect point (real)

Returns
  0 on failure
  1 on success

Definition at line 192 of file gs_query.c.

References b, G_debug(), gs_get_att_typbuff(), gs_get_surf(), GS_v3dir(), GS_v3eq(), gsdrape_get_allsegments(), NULL, segs_intersect(), viewcell_tri_interp(), X, and Y.

Referenced by GS_get_selected_point_on_surface().

## gs_los_intersect1()

int gs_los_intersect1 | ( | int | surfid,
|  | float(*) | los[3],
|  | float * | point )

Crude method of intersecting line of sight with closest part of surface.

Uses los vector to determine the point of first intersection which is returned in point. Returns 0 if los doesn't intersect.

Parameters

  | surfid | surface id
  | los | should be in surf-world coordinates
  [out] | point | intersect point (real)

Returns
  0 on failure
  1 on success

Definition at line 52 of file gs_query.c.

References b, G_debug(), GS_distance(), gs_get_att_typbuff(), gs_get_surf(), GS_v3dir(), NULL, viewcell_tri_interp(), X, and Y.

Referenced by GS_get_selected_point_on_surface().

## gs_setlos_enterdata()

int gs_setlos_enterdata | ( | Point3 * | los | ) |

Gets all current cutting planes & data bounding planes

Intersects los with resulting convex polyhedron, then replaces los[FROM] with first point on ray inside data.

Parameters

  [out] | los |

Returns
  0 on failure
  1 on success

Definition at line 529 of file gs_query.c.

References FRONTFACE, GS_distance(), gs_get_databounds_planes(), GS_v3add(), GS_v3dir(), GS_v3mult(), gsd_get_cplanes(), MISSED, and RayCvxPolyhedronInt().

Referenced by GS_get_selected_point_on_surface().

## RayCvxPolyhedronInt()

int RayCvxPolyhedronInt | ( | Point3 | org,
|  | Point3 | dir,
|  | double | tmax,
|  | Point4 * | phdrn,
|  | int | ph_num,
|  | double * | tresult,
|  | int * | pn )

Ray-Convex Polyhedron Intersection Test.

Originally by Eric Haines, erich.nosp@m.@eye.nosp@m..com

This test checks the ray against each face of a polyhedron, checking whether the set of intersection points found for each ray-plane intersection overlaps the previous intersection results. If there is no overlap (i.e. no line segment along the ray that is inside the polyhedron), then the ray misses and returns 0; else 1 is returned if the ray is entering the polyhedron, -1 if the ray originates inside the polyhedron. If there is an intersection, the distance and the number of the face hit is returned.

Parameters

  | org,dir | origin and direction of ray
  | tmax | maximum useful distance along ray
  | phdrn | list of planes in convex polyhedron
  | ph_num | number of planes in convex polyhedron
  [out] | tresult | distance of intersection along ray
  [out] | pn | number of face hit (0 to ph_num-1)

Returns
  FACE code

Definition at line 384 of file gs_query.c.

References BACKFACE, FRONTFACE, HUGE_VAL, MISSED, and t.

Referenced by gs_setlos_enterdata().