3977{
3978 uint64_t i, nedges, nfaces, fields;
3982 int nedge_left = 0;
3984 int nedge_right = 0;
3986 int nnode = 0;
3991 int fnode_edges = 0;
3992
3993 int lnode_edges = 0;
3994
3995
3996
3998
3999 i = 1;
4001 if (!edge)
4002 {
4003 LWDEBUGF(1,
"lwt_be_getEdgeById returned NULL and set i=%llu", i);
4004 if (i == UINT64_MAX)
4005 {
4007 return -1;
4008 }
4009 else if (i == 0)
4010 {
4012 return -1;
4013 }
4014 else
4015 {
4017 "Backend coding error: getEdgeById callback returned NULL "
4018 "but numelements output parameter has value %" PRIu64 " "
4019 "(expected 0 or 1)",
4020 i);
4021 return -1;
4022 }
4023 }
4024
4027 {
4029 return -1;
4030 }
4031
4032 LWDEBUG(1,
"Updating next_{right,left}_face of ring edges...");
4033
4034
4035
4036 nedges = 0;
4039 {
4040 node_ids[nedges++] = edge->
end_node;
4041 }
4046 if (nedges == UINT64_MAX)
4047 {
4049 return -1;
4050 }
4051 nedge_left = nedge_right = 0;
4052 for ( i=0; i<nedges; ++i )
4053 {
4055 if ( e->
edge_id == edge_id )
continue;
4057 {
4058 ++fnode_edges;
4059 }
4061 {
4062 ++lnode_edges;
4063 }
4065 {
4069 }
4071 {
4075 }
4076
4078 {
4082 }
4084 {
4088 }
4089 }
4090
4091 if ( nedge_left )
4092 {
4093 LWDEBUGF(1,
"updating %d 'next_left' edges", nedge_left);
4094
4097 {
4101 return -1;
4102 }
4103 }
4104 if ( nedge_right )
4105 {
4106 LWDEBUGF(1,
"updating %d 'next_right' edges", nedge_right);
4107
4110 {
4114 return -1;
4115 }
4116 }
4117 LWDEBUGF(1,
"releasing %llu updateable edges in %p", nedges, upd_edge);
4119
4120
4121
4123
4124
4126 {
4128 }
4129 else
4130 {
4131
4133 {
4134 floodface = 0;
4135 LWDEBUG(1,
"floodface is universe");
4136 }
4137 else
4138 {
4139
4140
4143
4146 nfaces = 2;
4149 if (nfaces == UINT64_MAX)
4150 {
4152 return -1;
4153 }
4156 for ( i=0; i<nfaces; ++i )
4157 {
4158 if ( faces[i].face_id == edge->
face_left )
4159 {
4160 if ( ! box1 ) box1 = faces[i].
mbr;
4161 else
4162 {
4166 lwerror(
"corrupted topology: more than 1 face have face_id=%"
4168 return -1;
4169 }
4170 }
4171 else if ( faces[i].face_id == edge->
face_right )
4172 {
4173 if ( ! box2 ) box2 = faces[i].
mbr;
4174 else
4175 {
4179 lwerror(
"corrupted topology: more than 1 face have face_id=%"
4181 return -1;
4182 }
4183 }
4184 else
4185 {
4189 lwerror(
"Backend coding error: getFaceById returned face "
4191 return -1;
4192 }
4193 }
4194 if ( ! box1 ) {
4198 lwerror(
"corrupted topology: no face have face_id=%"
4201 return -1;
4202 }
4203 if ( ! box2 ) {
4207 lwerror(
"corrupted topology: no face have face_id=%"
4210 return -1;
4211 }
4214 if ( modFace )
4215 {
4220 {
4223 return -1;
4224 }
4226 {
4228 lwerror(
"Unexpected error: %" PRIu64
" faces updated when expecting 1", i);
4229 return -1;
4230 }
4231 }
4232 else
4233 {
4234
4239 {
4242 return -1;
4243 }
4245 {
4247 lwerror(
"Unexpected error: %d faces inserted when expecting 1",
result);
4248 return -1;
4249 }
4251 }
4252 }
4253
4254
4255
4256
4258 {
4260 {
4263 return -1;
4264 }
4266 {
4269 return -1;
4270 }
4271 }
4272
4274 {
4276 {
4279 return -1;
4280 }
4282 {
4285 return -1;
4286 }
4287 }
4288
4289
4292 floodface) )
4293 {
4296 return -1;
4297 }
4298 }
4299
4300
4303 {
4306 return -1;
4307 }
4308
4309
4310
4311
4312 if ( ! fnode_edges )
4313 {
4316 ++nnode;
4317 }
4319 {
4322 ++nnode;
4323 }
4324 if ( nnode )
4325 {
4328 {
4331 return -1;
4332 }
4333 }
4334
4336
4337 {
4339 int nids = 0;
4346 {
4349 return -1;
4350 }
4351 }
4352
4354 return modFace ? floodface : newface.
face_id;
4355}
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