PostGIS  3.0.0dev-r@@SVN_REVISION@@

◆ _lwt_UpdateEdgeRingSideFace()

static int _lwt_UpdateEdgeRingSideFace ( LWT_TOPOLOGY topo,
LWT_EDGERING ring,
LWT_ELEMID  face 
)
static

Definition at line 6137 of file lwgeom_topo.c.

References LWT_TOPOLOGY_T::be_iface, LWT_EDGERING_ELEM_T::edge, LWT_ISO_EDGE::edge_id, LWT_EDGERING_T::elems, LWT_ISO_EDGE::face_left, LWT_ISO_EDGE::face_right, LWT_EDGERING_ELEM_T::left, lwalloc(), LWDEBUGF, lwerror(), lwfree(), lwt_be_lastErrorMessage(), lwt_be_updateEdgesById(), LWT_COL_EDGE_FACE_LEFT, LWT_COL_EDGE_FACE_RIGHT, and LWT_EDGERING_T::size.

Referenced by _lwt_RegisterFaceOnEdgeSide(), and lwt_Polygonize().

6139 {
6140  LWT_ISO_EDGE *forward_edges = NULL;
6141  int forward_edges_count = 0;
6142  LWT_ISO_EDGE *backward_edges = NULL;
6143  int backward_edges_count = 0;
6144  int i, ret;
6145 
6146  /* Make a list of forward_edges and backward_edges */
6147 
6148  forward_edges = lwalloc(sizeof(LWT_ISO_EDGE) * ring->size);
6149  forward_edges_count = 0;
6150  backward_edges = lwalloc(sizeof(LWT_ISO_EDGE) * ring->size);
6151  backward_edges_count = 0;
6152 
6153  for ( i=0; i<ring->size; ++i )
6154  {
6155  LWT_EDGERING_ELEM *elem = ring->elems[i];
6156  LWT_ISO_EDGE *edge = elem->edge;
6157  LWT_ELEMID id = edge->edge_id;
6158  if ( elem->left )
6159  {
6160  LWDEBUGF(3, "Forward edge %d is %d", forward_edges_count, id);
6161  forward_edges[forward_edges_count].edge_id = id;
6162  forward_edges[forward_edges_count++].face_left = face;
6163  edge->face_left = face;
6164  }
6165  else
6166  {
6167  LWDEBUGF(3, "Backward edge %d is %d", forward_edges_count, id);
6168  backward_edges[backward_edges_count].edge_id = id;
6169  backward_edges[backward_edges_count++].face_right = face;
6170  edge->face_right = face;
6171  }
6172  }
6173 
6174  /* Update forward edges */
6175  if ( forward_edges_count )
6176  {
6177  ret = lwt_be_updateEdgesById(topo, forward_edges,
6178  forward_edges_count,
6180  if ( ret == -1 )
6181  {
6182  lwfree( forward_edges );
6183  lwfree( backward_edges );
6184  lwerror("Backend error: %s", lwt_be_lastErrorMessage(topo->be_iface));
6185  return -1;
6186  }
6187  if ( ret != forward_edges_count )
6188  {
6189  lwfree( forward_edges );
6190  lwfree( backward_edges );
6191  lwerror("Unexpected error: %d edges updated when expecting %d (forward)",
6192  ret, forward_edges_count);
6193  return -1;
6194  }
6195  }
6196 
6197  /* Update backward edges */
6198  if ( backward_edges_count )
6199  {
6200  ret = lwt_be_updateEdgesById(topo, backward_edges,
6201  backward_edges_count,
6203  if ( ret == -1 )
6204  {
6205  lwfree( forward_edges );
6206  lwfree( backward_edges );
6207  lwerror("Backend error: %s", lwt_be_lastErrorMessage(topo->be_iface));
6208  return -1;
6209  }
6210  if ( ret != backward_edges_count )
6211  {
6212  lwfree( forward_edges );
6213  lwfree( backward_edges );
6214  lwerror("Unexpected error: %d edges updated when expecting %d (backward)",
6215  ret, backward_edges_count);
6216  return -1;
6217  }
6218  }
6219 
6220  lwfree( forward_edges );
6221  lwfree( backward_edges );
6222 
6223  return 0;
6224 }
LWT_ELEMID face_left
#define LWT_COL_EDGE_FACE_LEFT
static int lwt_be_updateEdgesById(LWT_TOPOLOGY *topo, const LWT_ISO_EDGE *edges, int numedges, int upd_fields)
Definition: lwgeom_topo.c:305
void lwfree(void *mem)
Definition: lwutil.c:242
#define LWT_COL_EDGE_FACE_RIGHT
LWT_ISO_EDGE * edge
Definition: lwgeom_topo.c:5950
const LWT_BE_IFACE * be_iface
LWT_ELEMID face_right
LWT_ELEMID edge_id
LWT_EDGERING_ELEM ** elems
Definition: lwgeom_topo.c:5960
LWT_INT64 LWT_ELEMID
Identifier of topology element.
void * lwalloc(size_t size)
Definition: lwutil.c:227
#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: