PostGIS  2.5.0dev-r@@SVN_REVISION@@
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 6672 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().

6677 {
6678  const LWT_BE_IFACE *iface = topo->be_iface;
6679  /* this is arbitrary, could be taken as parameter */
6680  static const int placeholder_faceid = LWT_HOLES_FACE_PLACEHOLDER;
6681  LWT_EDGERING *ring;
6682 
6683  /* Get edge ring */
6684  ring = _lwt_BuildEdgeRing(topo, edges, edge, side);
6685 
6686  LWDEBUG(2, "Ring built, calling EdgeRingIsCCW");
6687 
6688  /* Compute winding (CW or CCW?) */
6689  int isccw = _lwt_EdgeRingIsCCW(ring);
6690 
6691  if ( isccw )
6692  {
6693  /* Create new face */
6694  LWT_ISO_FACE newface;
6695 
6696  LWDEBUGF(1, "Ring of edge %d is a shell (shell %d)", edge->edge_id * side, shells->size);
6697 
6698  newface.mbr = _lwt_EdgeRingGetBbox(ring);
6699 
6700  newface.face_id = -1;
6701  /* Insert the new face */
6702  int ret = lwt_be_insertFaces( topo, &newface, 1 );
6703  newface.mbr = NULL;
6704  if ( ret == -1 )
6705  {
6706  lwerror("Backend error: %s", lwt_be_lastErrorMessage(topo->be_iface));
6707  return -1;
6708  }
6709  if ( ret != 1 )
6710  {
6711  lwerror("Unexpected error: %d faces inserted when expecting 1", ret);
6712  return -1;
6713  }
6714  /* return new face_id */
6715  *registered = newface.face_id;
6716  LWT_EDGERING_ARRAY_PUSH(shells, ring);
6717 
6718  /* update ring edges set new face_id on resp. side to *registered */
6719  ret = _lwt_UpdateEdgeRingSideFace(topo, ring, *registered);
6720  if ( ret )
6721  {
6722  lwerror("Errors updating edgering side face: %s",
6723  lwt_be_lastErrorMessage(iface));
6724  return -1;
6725  }
6726 
6727  }
6728  else /* cw, so is an hole */
6729  {
6730  LWDEBUGF(1, "Ring of edge %d is a hole (hole %d)", edge->edge_id * side, holes->size);
6731  *registered = placeholder_faceid;
6732  LWT_EDGERING_ARRAY_PUSH(holes, ring);
6733  }
6734 
6735  return 0;
6736 }
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:6329
static GBOX * _lwt_EdgeRingGetBbox(LWT_EDGERING *ring)
Definition: lwgeom_topo.c:6618
#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:6368
static LWT_EDGERING * _lwt_BuildEdgeRing(LWT_TOPOLOGY *topo, LWT_ISO_EDGE_TABLE *edges, LWT_ISO_EDGE *edge, int side)
Definition: lwgeom_topo.c:6461
const LWT_BE_IFACE * be_iface
static int _lwt_EdgeRingIsCCW(LWT_EDGERING *ring)
Definition: lwgeom_topo.c:6541
LWT_ELEMID face_id
LWT_ELEMID edge_id
#define LWT_EDGERING_ARRAY_PUSH(a, r)
Definition: lwgeom_topo.c:6260
#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: