PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ lw_dist3d_poly_tri()

int lw_dist3d_poly_tri ( const LWPOLY poly,
const LWTRIANGLE tri,
DISTPTS3D dl 
)

polygon to triangle calculation

Definition at line 911 of file measures3d.c.

912 {
913  PLANE3D plane1, plane2;
914  int planedef1, planedef2;
915 
916  if (dl->mode == DIST_MAX)
917  return lw_dist3d_ptarray_ptarray(poly->rings[0], tri->points, dl);
918 
919  planedef1 = define_plane(poly->rings[0], &plane1);
920  planedef2 = define_plane(tri->points, &plane2);
921 
922  if (!planedef1 || !planedef2)
923  {
924  /* Neither define a plane: Return distance line to line */
925  if (!planedef1 && !planedef2)
926  return lw_dist3d_ptarray_ptarray(poly->rings[0], tri->points, dl);
927 
928  /* Only tri defines a plane: Return distance from line (poly) to tri */
929  else if (!planedef1)
930  return lw_dist3d_ptarray_tri(poly->rings[0], tri, &plane2, dl);
931 
932  /* Only poly defines a plane: Return distance from line (tri) to poly */
933  else
934  return lw_dist3d_ptarray_poly(tri->points, poly, &plane1, dl);
935  }
936 
937  /* What we do here is to compare the boundary of one polygon with the other polygon
938  and then take the second boundary comparing with the first polygon */
939  dl->twisted = 1;
940  if (!lw_dist3d_ptarray_tri(poly->rings[0], tri, &plane2, dl))
941  return LW_FALSE;
942  if (dl->distance < dl->tolerance) /* Just check if the answer already is given*/
943  return LW_TRUE;
944 
945  dl->twisted = -1; /* because we switch the order of geometries we switch "twisted" to -1 which will give the
946  right order of points in shortest line. */
947  return lw_dist3d_ptarray_poly(tri->points, poly, &plane1, dl);
948 }
#define LW_FALSE
Definition: liblwgeom.h:94
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:93
int lw_dist3d_ptarray_ptarray(const POINTARRAY *l1, const POINTARRAY *l2, DISTPTS3D *dl)
Finds all combinations of segments between two pointarrays.
Definition: measures3d.c:1122
int define_plane(const POINTARRAY *pa, PLANE3D *pl)
Definition: measures3d.c:1491
int lw_dist3d_ptarray_poly(const POINTARRAY *pa, const LWPOLY *poly, PLANE3D *plane, DISTPTS3D *dl)
Computes pointarray to polygon distance.
Definition: measures3d.c:1333
int lw_dist3d_ptarray_tri(const POINTARRAY *pa, const LWTRIANGLE *tri, PLANE3D *plane, DISTPTS3D *dl)
Computes pointarray to triangle distance.
Definition: measures3d.c:1413
#define DIST_MAX
Definition: measures.h:43
int twisted
Definition: measures3d.h:45
double distance
Definition: measures3d.h:40
int mode
Definition: measures3d.h:43
double tolerance
Definition: measures3d.h:47
POINTARRAY ** rings
Definition: liblwgeom.h:519
POINTARRAY * points
Definition: liblwgeom.h:495

References define_plane(), DIST_MAX, DISTPTS3D::distance, lw_dist3d_ptarray_poly(), lw_dist3d_ptarray_ptarray(), lw_dist3d_ptarray_tri(), LW_FALSE, LW_TRUE, DISTPTS3D::mode, LWTRIANGLE::points, LWPOLY::rings, DISTPTS3D::tolerance, and DISTPTS3D::twisted.

Referenced by lw_dist3d_distribute_bruteforce().

Here is the call graph for this function:
Here is the caller graph for this function: