PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ _lwt_UpdateEdgeRingSideFace()

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

Definition at line 6166 of file lwgeom_topo.c.

6168 {
6169  LWT_ISO_EDGE *forward_edges = NULL;
6170  int forward_edges_count = 0;
6171  LWT_ISO_EDGE *backward_edges = NULL;
6172  int backward_edges_count = 0;
6173  int i, ret;
6174 
6175  /* Make a list of forward_edges and backward_edges */
6176 
6177  forward_edges = lwalloc(sizeof(LWT_ISO_EDGE) * ring->size);
6178  forward_edges_count = 0;
6179  backward_edges = lwalloc(sizeof(LWT_ISO_EDGE) * ring->size);
6180  backward_edges_count = 0;
6181 
6182  for ( i=0; i<ring->size; ++i )
6183  {
6184  LWT_EDGERING_ELEM *elem = ring->elems[i];
6185  LWT_ISO_EDGE *edge = elem->edge;
6186  LWT_ELEMID id = edge->edge_id;
6187  if ( elem->left )
6188  {
6189  LWDEBUGF(3, "Forward edge %d is %d", forward_edges_count, id);
6190  forward_edges[forward_edges_count].edge_id = id;
6191  forward_edges[forward_edges_count++].face_left = face;
6192  edge->face_left = face;
6193  }
6194  else
6195  {
6196  LWDEBUGF(3, "Backward edge %d is %d", forward_edges_count, id);
6197  backward_edges[backward_edges_count].edge_id = id;
6198  backward_edges[backward_edges_count++].face_right = face;
6199  edge->face_right = face;
6200  }
6201  }
6202 
6203  /* Update forward edges */
6204  if ( forward_edges_count )
6205  {
6206  ret = lwt_be_updateEdgesById(topo, forward_edges,
6207  forward_edges_count,
6209  if ( ret == -1 )
6210  {
6211  lwfree( forward_edges );
6212  lwfree( backward_edges );
6213  lwerror("Backend error: %s", lwt_be_lastErrorMessage(topo->be_iface));
6214  return -1;
6215  }
6216  if ( ret != forward_edges_count )
6217  {
6218  lwfree( forward_edges );
6219  lwfree( backward_edges );
6220  lwerror("Unexpected error: %d edges updated when expecting %d (forward)",
6221  ret, forward_edges_count);
6222  return -1;
6223  }
6224  }
6225 
6226  /* Update backward edges */
6227  if ( backward_edges_count )
6228  {
6229  ret = lwt_be_updateEdgesById(topo, backward_edges,
6230  backward_edges_count,
6232  if ( ret == -1 )
6233  {
6234  lwfree( forward_edges );
6235  lwfree( backward_edges );
6236  lwerror("Backend error: %s", lwt_be_lastErrorMessage(topo->be_iface));
6237  return -1;
6238  }
6239  if ( ret != backward_edges_count )
6240  {
6241  lwfree( forward_edges );
6242  lwfree( backward_edges );
6243  lwerror("Unexpected error: %d edges updated when expecting %d (backward)",
6244  ret, backward_edges_count);
6245  return -1;
6246  }
6247  }
6248 
6249  lwfree( forward_edges );
6250  lwfree( backward_edges );
6251 
6252  return 0;
6253 }
void lwfree(void *mem)
Definition: lwutil.c:244
void * lwalloc(size_t size)
Definition: lwutil.c:229
#define LWT_COL_EDGE_FACE_RIGHT
LWT_INT64 LWT_ELEMID
Identifier of topology element.
#define LWT_COL_EDGE_FACE_LEFT
#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 int lwt_be_updateEdgesById(LWT_TOPOLOGY *topo, const LWT_ISO_EDGE *edges, int numedges, int upd_fields)
Definition: lwgeom_topo.c:306
LWT_ISO_EDGE * edge
Definition: lwgeom_topo.c:5979
LWT_EDGERING_ELEM ** elems
Definition: lwgeom_topo.c:5989
LWT_ELEMID face_right
LWT_ELEMID face_left
LWT_ELEMID edge_id
const LWT_BE_IFACE * be_iface

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

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