PostGIS  3.0.6dev-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 877 of file measures3d.c.

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

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: