PostGIS  3.0.0dev-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 6441 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().

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