PostGIS  2.5.0beta1dev-r@@SVN_REVISION@@

◆ _lwt_UpdateEdgeRingSideFace()

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

Definition at line 6138 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().

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