PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ lw_dist3d_poly_tri()

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

polygon to triangle calculation

Definition at line 874 of file measures3d.c.

875 {
876  PLANE3D plane1, plane2;
877  int planedef1, planedef2;
878 
879  if (dl->mode == DIST_MAX)
880  return lw_dist3d_ptarray_ptarray(poly->rings[0], tri->points, dl);
881 
882  planedef1 = define_plane(poly->rings[0], &plane1);
883  planedef2 = define_plane(tri->points, &plane2);
884 
885  if (!planedef1 || !planedef2)
886  {
887  /* Neither define a plane: Return distance line to line */
888  if (!planedef1 && !planedef2)
889  return lw_dist3d_ptarray_ptarray(poly->rings[0], tri->points, dl);
890 
891  /* Only tri defines a plane: Return distance from line (poly) to tri */
892  else if (!planedef1)
893  return lw_dist3d_ptarray_tri(poly->rings[0], tri, &plane2, dl);
894 
895  /* Only poly defines a plane: Return distance from line (tri) to poly */
896  else
897  return lw_dist3d_ptarray_poly(tri->points, poly, &plane1, dl);
898  }
899 
900  /* What we do here is to compare the boundary of one polygon with the other polygon
901  and then take the second boundary comparing with the first polygon */
902  dl->twisted = 1;
903  if (!lw_dist3d_ptarray_tri(poly->rings[0], tri, &plane2, dl))
904  return LW_FALSE;
905  if (dl->distance < dl->tolerance) /* Just check if the answer already is given*/
906  return LW_TRUE;
907 
908  dl->twisted = -1; /* because we switch the order of geometries we switch "twisted" to -1 which will give the
909  right order of points in shortest line. */
910  return lw_dist3d_ptarray_poly(tri->points, poly, &plane1, dl);
911 }
#define LW_FALSE
Definition: liblwgeom.h:94
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:93
int define_plane(POINTARRAY *pa, PLANE3D *pl)
Definition: measures3d.c:1448
int lw_dist3d_ptarray_tri(POINTARRAY *pa, LWTRIANGLE *tri, PLANE3D *plane, DISTPTS3D *dl)
Computes pointarray to triangle distance.
Definition: measures3d.c:1370
int lw_dist3d_ptarray_poly(POINTARRAY *pa, LWPOLY *poly, PLANE3D *plane, DISTPTS3D *dl)
Computes pointarray to polygon distance.
Definition: measures3d.c:1290
int lw_dist3d_ptarray_ptarray(POINTARRAY *l1, POINTARRAY *l2, DISTPTS3D *dl)
Finds all combinations of segments between two pointarrays.
Definition: measures3d.c:1085
#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: