4094{
4095 uint64_t i, nedges, nfaces, fields;
4099 int nedge_left = 0;
4101 int nedge_right = 0;
4103 int nnode = 0;
4108 int fnode_edges = 0;
4109
4110 int lnode_edges = 0;
4111
4112
4113
4115
4116 i = 1;
4118 if (!edge)
4119 {
4120 LWDEBUGF(1,
"lwt_be_getEdgeById returned NULL and set i=%llu", i);
4121 if (i == UINT64_MAX)
4122 {
4124 return -1;
4125 }
4126 else if (i == 0)
4127 {
4129 return -1;
4130 }
4131 else
4132 {
4134 "Backend coding error: getEdgeById callback returned NULL "
4135 "but numelements output parameter has value %" PRIu64 " "
4136 "(expected 0 or 1)",
4137 i);
4138 return -1;
4139 }
4140 }
4141
4144 {
4146 return -1;
4147 }
4148
4149 LWDEBUG(1,
"Updating next_{right,left}_face of ring edges...");
4150
4151
4152
4153 nedges = 0;
4156 {
4157 node_ids[nedges++] = edge->
end_node;
4158 }
4163 if (nedges == UINT64_MAX)
4164 {
4166 return -1;
4167 }
4168 nedge_left = nedge_right = 0;
4169 for ( i=0; i<nedges; ++i )
4170 {
4172 if ( e->
edge_id == edge_id )
continue;
4174 {
4175 ++fnode_edges;
4176 }
4178 {
4179 ++lnode_edges;
4180 }
4182 {
4186 }
4188 {
4192 }
4193
4195 {
4199 }
4201 {
4205 }
4206 }
4207
4208 if ( nedge_left )
4209 {
4210 LWDEBUGF(1,
"updating %d 'next_left' edges", nedge_left);
4211
4214 {
4218 return -1;
4219 }
4220 }
4221 if ( nedge_right )
4222 {
4223 LWDEBUGF(1,
"updating %d 'next_right' edges", nedge_right);
4224
4227 {
4231 return -1;
4232 }
4233 }
4234 LWDEBUGF(1,
"releasing %llu updateable edges in %p", nedges, upd_edge);
4236
4237
4238
4240
4241
4243 {
4245 }
4246 else
4247 {
4248
4250 {
4251 floodface = 0;
4252 LWDEBUG(1,
"floodface is universe");
4253 }
4254 else
4255 {
4256
4257
4260
4263 nfaces = 2;
4266 if (nfaces == UINT64_MAX)
4267 {
4269 return -1;
4270 }
4273 for ( i=0; i<nfaces; ++i )
4274 {
4275 if ( faces[i].face_id == edge->
face_left )
4276 {
4277 if ( ! box1 ) box1 = faces[i].
mbr;
4278 else
4279 {
4283 lwerror(
"corrupted topology: more than 1 face have face_id=%"
4285 return -1;
4286 }
4287 }
4288 else if ( faces[i].face_id == edge->
face_right )
4289 {
4290 if ( ! box2 ) box2 = faces[i].
mbr;
4291 else
4292 {
4296 lwerror(
"corrupted topology: more than 1 face have face_id=%"
4298 return -1;
4299 }
4300 }
4301 else
4302 {
4306 lwerror(
"Backend coding error: getFaceById returned face "
4308 return -1;
4309 }
4310 }
4311 if ( ! box1 ) {
4315 lwerror(
"corrupted topology: no face have face_id=%"
4318 return -1;
4319 }
4320 if ( ! box2 ) {
4324 lwerror(
"corrupted topology: no face have face_id=%"
4327 return -1;
4328 }
4331 if ( modFace )
4332 {
4337 {
4340 return -1;
4341 }
4343 {
4345 lwerror(
"Unexpected error: %" PRIu64
" faces updated when expecting 1", i);
4346 return -1;
4347 }
4348 }
4349 else
4350 {
4351
4356 {
4359 return -1;
4360 }
4362 {
4364 lwerror(
"Unexpected error: %d faces inserted when expecting 1",
result);
4365 return -1;
4366 }
4368 }
4369 }
4370
4371
4372
4373
4375 {
4377 {
4380 return -1;
4381 }
4383 {
4386 return -1;
4387 }
4388 }
4389
4391 {
4393 {
4396 return -1;
4397 }
4399 {
4402 return -1;
4403 }
4404 }
4405
4406
4409 floodface) )
4410 {
4413 return -1;
4414 }
4415 }
4416
4417
4420 {
4423 return -1;
4424 }
4425
4426
4427
4428
4429 if ( ! fnode_edges )
4430 {
4433 ++nnode;
4434 }
4436 {
4439 ++nnode;
4440 }
4441 if ( nnode )
4442 {
4445 {
4448 return -1;
4449 }
4450 }
4451
4453
4454 {
4456 int nids = 0;
4463 {
4466 return -1;
4467 }
4468 }
4469
4471 return modFace ? floodface : newface.
face_id;
4472}
char result[OUT_DOUBLE_BUFFER_SIZE]
int gbox_merge(const GBOX *new_box, GBOX *merge_box)
Update the merged GBOX to be large enough to include itself and the new box.
LWT_INT64 LWT_ELEMID
Identifier of topology element.
#define LWT_COL_EDGE_START_NODE
#define LWT_COL_EDGE_NEXT_RIGHT
#define LWT_COL_NODE_CONTAINING_FACE
#define LWT_COL_EDGE_EDGE_ID
Edge fields.
#define LWT_COL_EDGE_END_NODE
#define LWT_COL_EDGE_NEXT_LEFT
#define PGTOPO_BE_ERROR()
#define LWDEBUG(level, msg)
#define LWDEBUGF(level, msg,...)
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
static uint64_t lwt_be_updateFacesById(LWT_TOPOLOGY *topo, const LWT_ISO_FACE *faces, uint64_t numfaces)
static int lwt_be_deleteFacesById(const LWT_TOPOLOGY *topo, const LWT_ELEMID *ids, uint64_t numelems)
static int lwt_be_checkTopoGeomRemEdge(LWT_TOPOLOGY *topo, LWT_ELEMID edge_id, LWT_ELEMID face_left, LWT_ELEMID face_right)
static int _lwt_UpdateEdgeFaceRef(LWT_TOPOLOGY *topo, LWT_ELEMID of, LWT_ELEMID nf)
LWT_ISO_EDGE * lwt_be_getEdgeById(LWT_TOPOLOGY *topo, const LWT_ELEMID *ids, uint64_t *numelems, int fields)
void _lwt_release_faces(LWT_ISO_FACE *faces, int num_faces)
static int lwt_be_updateNodesById(LWT_TOPOLOGY *topo, const LWT_ISO_NODE *nodes, int numnodes, int upd_fields)
static int lwt_be_updateTopoGeomFaceHeal(LWT_TOPOLOGY *topo, LWT_ELEMID face1, LWT_ELEMID face2, LWT_ELEMID newface)
static LWT_ISO_FACE * lwt_be_getFaceById(LWT_TOPOLOGY *topo, const LWT_ELEMID *ids, uint64_t *numelems, int fields)
int lwt_be_deleteEdges(LWT_TOPOLOGY *topo, const LWT_ISO_EDGE *sel_edge, int sel_fields)
static int _lwt_UpdateNodeFaceRef(LWT_TOPOLOGY *topo, LWT_ELEMID of, LWT_ELEMID nf)
void _lwt_release_edges(LWT_ISO_EDGE *edges, int num_edges)
int lwt_be_updateEdgesById(LWT_TOPOLOGY *topo, const LWT_ISO_EDGE *edges, int numedges, int upd_fields)
LWT_ISO_EDGE * lwt_be_getEdgeByNode(LWT_TOPOLOGY *topo, const LWT_ELEMID *ids, uint64_t *numelems, int fields)
const char * lwt_be_lastErrorMessage(const LWT_BE_IFACE *be)
int lwt_be_insertFaces(LWT_TOPOLOGY *topo, LWT_ISO_FACE *face, uint64_t numelems)
LWT_ELEMID containing_face
const LWT_BE_IFACE * be_iface