GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-d6dec75dd4
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. More...
 
#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. More...
 
int gs_los_intersect (int surfid, float **los, float *point)
 Crude method of intersecting line of sight with closest part of surface. More...
 
int RayCvxPolyhedronInt (Point3 org, Point3 dir, double tmax, Point4 *phdrn, int ph_num, double *tresult, int *pn)
 Ray-Convex Polyhedron Intersection Test. More...
 
void gs_get_databounds_planes (Point4 *planes)
 Get data bounds for plane. More...
 
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.

◆ FRONTFACE

#define FRONTFACE   1

Definition at line 34 of file gs_query.c.

◆ 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.

◆ MISSED

#define MISSED   0

Definition at line 33 of file gs_query.c.

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.

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

Definition at line 192 of file gs_query.c.

◆ 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
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.

◆ 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 FROM, FRONTFACE, GS_distance(), gs_get_databounds_planes(), GS_v3add(), GS_v3dir(), GS_v3mult(), gsd_get_cplanes(), MISSED, RayCvxPolyhedronInt(), and TO.

◆ 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,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, DOT3, FRONTFACE, HUGE_VAL, MISSED, t, and W.

Referenced by gs_setlos_enterdata().