PostGIS  2.5.7dev-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 6470 of file lwgeom_topo.c.

6475 {
6476  const LWT_BE_IFACE *iface = topo->be_iface;
6477  /* this is arbitrary, could be taken as parameter */
6478  static const int placeholder_faceid = LWT_HOLES_FACE_PLACEHOLDER;
6479  LWT_EDGERING *ring;
6480 
6481  /* Get edge ring */
6482  ring = _lwt_BuildEdgeRing(topo, edges, edge, side);
6483 
6484  LWDEBUG(2, "Ring built, calling EdgeRingIsCCW");
6485 
6486  /* Compute winding (CW or CCW?) */
6487  int isccw = _lwt_EdgeRingIsCCW(ring);
6488 
6489  if ( isccw )
6490  {
6491  /* Create new face */
6492  LWT_ISO_FACE newface;
6493 
6494  LWDEBUGF(1, "Ring of edge %d is a shell (shell %d)", edge->edge_id * side, shells->size);
6495 
6496  newface.mbr = _lwt_EdgeRingGetBbox(ring);
6497 
6498  newface.face_id = -1;
6499  /* Insert the new face */
6500  int ret = lwt_be_insertFaces( topo, &newface, 1 );
6501  newface.mbr = NULL;
6502  if ( ret == -1 )
6503  {
6504  lwerror("Backend error: %s", lwt_be_lastErrorMessage(topo->be_iface));
6505  return -1;
6506  }
6507  if ( ret != 1 )
6508  {
6509  lwerror("Unexpected error: %d faces inserted when expecting 1", ret);
6510  return -1;
6511  }
6512  /* return new face_id */
6513  *registered = newface.face_id;
6514  LWT_EDGERING_ARRAY_PUSH(shells, ring);
6515 
6516  /* update ring edges set new face_id on resp. side to *registered */
6517  ret = _lwt_UpdateEdgeRingSideFace(topo, ring, *registered);
6518  if ( ret )
6519  {
6520  lwerror("Errors updating edgering side face: %s",
6521  lwt_be_lastErrorMessage(iface));
6522  return -1;
6523  }
6524 
6525  }
6526  else /* cw, so is an hole */
6527  {
6528  LWDEBUGF(1, "Ring of edge %d is a hole (hole %d)", edge->edge_id * side, holes->size);
6529  *registered = placeholder_faceid;
6530  LWT_EDGERING_ARRAY_PUSH(holes, ring);
6531  }
6532 
6533  return 0;
6534 }
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
const char * lwt_be_lastErrorMessage(const LWT_BE_IFACE *be)
Definition: lwgeom_topo.c:120
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:6259
static int _lwt_UpdateEdgeRingSideFace(LWT_TOPOLOGY *topo, LWT_EDGERING *ring, LWT_ELEMID face)
Definition: lwgeom_topo.c:6166
static int _lwt_EdgeRingIsCCW(LWT_EDGERING *ring)
Definition: lwgeom_topo.c:6339
#define LWT_HOLES_FACE_PLACEHOLDER
Definition: lwgeom_topo.c:6127
static GBOX * _lwt_EdgeRingGetBbox(LWT_EDGERING *ring)
Definition: lwgeom_topo.c:6416
static int lwt_be_insertFaces(LWT_TOPOLOGY *topo, LWT_ISO_FACE *face, int numelems)
Definition: lwgeom_topo.c:201
#define LWT_EDGERING_ARRAY_PUSH(a, r)
Definition: lwgeom_topo.c:6058
LWT_ELEMID edge_id
LWT_ELEMID face_id
const LWT_BE_IFACE * be_iface

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().

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