GRASS Programmer's Manual  6.4.2(2012)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gs_query.c File Reference

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

#include <math.h>
#include <grass/gis.h>
#include <grass/gstypes.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)
int gs_los_intersect (int surfid, float **los, float *point)
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

#define BACKFACE   -1

Definition at line 35 of file gs_query.c.

Referenced by RayCvxPolyhedronInt().

#define FRONTFACE   1

Definition at line 34 of file gs_query.c.

Referenced by gs_setlos_enterdata(), and RayCvxPolyhedronInt().

#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().

#define MISSED   0

Definition at line 33 of file gs_query.c.

Referenced by gs_setlos_enterdata(), and RayCvxPolyhedronInt().


Function Documentation

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(), gui_modules.psmap_dialogs::s, gui_modules.psmap_dialogs::w, X, and Y.

Referenced by gs_setlos_enterdata().

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:
surfidsurface id
losshould be in surf-world coordinates
[out]pointintersect point (real)
Returns:
0 on failure
1 on success

Definition at line 191 of file gs_query.c.

References b, FROM, 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().

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:
surfidsurface id
losshould be in surf-world coordinates
[out]pointintersect point (real)
Returns:
0 on failure
1 on success

Definition at line 52 of file gs_query.c.

References b, FROM, 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().

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 FROM, 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().

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 nunber of the face hit is returned.

Parameters:
org,dirorigin and direction of ray
tmaxmaximum useful distance along ray
phdrnlist of planes in convex polyhedron
ph_numnumber of planes in convex polyhedron
[out]tresultdistance of intersection along ray
[out]pnnumber 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, and MISSED.

Referenced by gs_setlos_enterdata().