PostGIS  2.5.2dev-r@@SVN_REVISION@@

◆ _lwt_RegisterFaceOnEdgeSide()

static int _lwt_RegisterFaceOnEdgeSide ( LWT_TOPOLOGY topo,
LWT_ISO_EDGE edge,
int  side,
LWT_ISO_EDGE_TABLE edges,
LWT_EDGERING_ARRAY holes,
LWT_EDGERING_ARRAY shells,
LWT_ELEMID registered 
)
static

Definition at line 6442 of file lwgeom_topo.c.

References _lwt_BuildEdgeRing(), _lwt_EdgeRingGetBbox(), _lwt_EdgeRingIsCCW(), _lwt_UpdateEdgeRingSideFace(), LWT_TOPOLOGY_T::be_iface, LWT_ISO_EDGE::edge_id, LWT_ISO_FACE::face_id, LWDEBUG, LWDEBUGF, lwerror(), lwt_be_insertFaces(), lwt_be_lastErrorMessage(), LWT_EDGERING_ARRAY_PUSH, LWT_HOLES_FACE_PLACEHOLDER, LWT_ISO_FACE::mbr, and LWT_EDGERING_ARRAY_T::size.

Referenced by lwt_Polygonize().

6447 {
6448  const LWT_BE_IFACE *iface = topo->be_iface;
6449  /* this is arbitrary, could be taken as parameter */
6450  static const int placeholder_faceid = LWT_HOLES_FACE_PLACEHOLDER;
6451  LWT_EDGERING *ring;
6452 
6453  /* Get edge ring */
6454  ring = _lwt_BuildEdgeRing(topo, edges, edge, side);
6455 
6456  LWDEBUG(2, "Ring built, calling EdgeRingIsCCW");
6457 
6458  /* Compute winding (CW or CCW?) */
6459  int isccw = _lwt_EdgeRingIsCCW(ring);
6460 
6461  if ( isccw )
6462  {
6463  /* Create new face */
6464  LWT_ISO_FACE newface;
6465 
6466  LWDEBUGF(1, "Ring of edge %d is a shell (shell %d)", edge->edge_id * side, shells->size);
6467 
6468  newface.mbr = _lwt_EdgeRingGetBbox(ring);
6469 
6470  newface.face_id = -1;
6471  /* Insert the new face */
6472  int ret = lwt_be_insertFaces( topo, &newface, 1 );
6473  newface.mbr = NULL;
6474  if ( ret == -1 )
6475  {
6476  lwerror("Backend error: %s", lwt_be_lastErrorMessage(topo->be_iface));
6477  return -1;
6478  }
6479  if ( ret != 1 )
6480  {
6481  lwerror("Unexpected error: %d faces inserted when expecting 1", ret);
6482  return -1;
6483  }
6484  /* return new face_id */
6485  *registered = newface.face_id;
6486  LWT_EDGERING_ARRAY_PUSH(shells, ring);
6487 
6488  /* update ring edges set new face_id on resp. side to *registered */
6489  ret = _lwt_UpdateEdgeRingSideFace(topo, ring, *registered);
6490  if ( ret )
6491  {
6492  lwerror("Errors updating edgering side face: %s",
6493  lwt_be_lastErrorMessage(iface));
6494  return -1;
6495  }
6496 
6497  }
6498  else /* cw, so is an hole */
6499  {
6500  LWDEBUGF(1, "Ring of edge %d is a hole (hole %d)", edge->edge_id * side, holes->size);
6501  *registered = placeholder_faceid;
6502  LWT_EDGERING_ARRAY_PUSH(holes, ring);
6503  }
6504 
6505  return 0;
6506 }
static int lwt_be_insertFaces(LWT_TOPOLOGY *topo, LWT_ISO_FACE *face, int numelems)
Definition: lwgeom_topo.c:201
#define LWT_HOLES_FACE_PLACEHOLDER
Definition: lwgeom_topo.c:6099
static GBOX * _lwt_EdgeRingGetBbox(LWT_EDGERING *ring)
Definition: lwgeom_topo.c:6388
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
static int _lwt_UpdateEdgeRingSideFace(LWT_TOPOLOGY *topo, LWT_EDGERING *ring, LWT_ELEMID face)
Definition: lwgeom_topo.c:6138
const LWT_BE_IFACE * be_iface
static int _lwt_EdgeRingIsCCW(LWT_EDGERING *ring)
Definition: lwgeom_topo.c:6311
LWT_ELEMID face_id
LWT_ELEMID edge_id
static LWT_EDGERING * _lwt_BuildEdgeRing(__attribute__((__unused__)) LWT_TOPOLOGY *topo, LWT_ISO_EDGE_TABLE *edges, LWT_ISO_EDGE *edge, int side)
Definition: lwgeom_topo.c:6231
#define LWT_EDGERING_ARRAY_PUSH(a, r)
Definition: lwgeom_topo.c:6030
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
const char * lwt_be_lastErrorMessage(const LWT_BE_IFACE *be)
Definition: lwgeom_topo.c:120
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
Here is the call graph for this function:
Here is the caller graph for this function: