/** * gts_edge_is_contact: * @e: a #GtsEdge. * * Returns: the number of sets of connected triangles sharing @e as a * contact edge. */ guint gts_edge_is_contact (GtsEdge * e) { GSList * i, * triangles; guint ncomponent = 0; g_return_val_if_fail (e != NULL, 0); triangles = gts_vertex_triangles (GTS_SEGMENT (e)->v1, NULL); i = triangles = gts_vertex_triangles (GTS_SEGMENT (e)->v2, triangles); while (i) { GTS_OBJECT (i->data)->reserved = i; i = i->next; } i = e->triangles; while (i) { GtsTriangle * t = i->data; if (GTS_OBJECT (t)->reserved) { GtsEdge * e1; GTS_OBJECT (t)->reserved = NULL; e1 = next_edge (t, NULL, e); triangle_next (e1, e); triangle_next (next_edge (t, e1, e), e); ncomponent++; } i = i->next; } g_slist_foreach (triangles, (GFunc) gts_object_reset_reserved, NULL); g_slist_free (triangles); return ncomponent; }
static PyObject* triangles(PygtsVertex *self, PyObject *args) { GSList *triangles, *t; PygtsTriangle *triangle; guint i,N; PyObject *tuple; SELF_CHECK triangles = gts_vertex_triangles(PYGTS_VERTEX_AS_GTS_VERTEX(self),NULL); N = g_slist_length(triangles); /* Create the tuple */ if( (tuple=PyTuple_New(N)) == NULL) { PyErr_SetString(PyExc_MemoryError,"could not create tuple"); return NULL; } /* Put PygtsVertex objects into the tuple */ t = triangles; for(i=0;i<N;i++) { if( (triangle = pygts_triangle_new(GTS_TRIANGLE(t->data))) == NULL ) { Py_DECREF(tuple); return NULL; } PyTuple_SET_ITEM(tuple, i, (PyObject*)triangle); t = g_slist_next(t); } return tuple; }
static void surface_hf_refine (GtsSurface * s, CostFunc cost_func, gpointer cost_data, GtsStopFunc stop_func, gpointer stop_data) { GtsEHeap * heap; gdouble top_cost; guint nv = 4; GtsListFace * f; gpointer data[3]; g_return_if_fail (s != NULL); g_return_if_fail (cost_func != NULL); g_return_if_fail (stop_func != NULL); data[0] = heap = gts_eheap_new (NULL, NULL); data[1] = cost_func; data[2] = cost_data; gts_surface_foreach_face (s, (GtsFunc) list_face_update, data); while ((f = gts_eheap_remove_top (heap, &top_cost)) && !(*stop_func) (- top_cost, nv, stop_data)) { GtsVertex * v = LIST_FACE (f)->best; GSList * t, * i; LIST_FACE (f)->heap = NULL; gts_delaunay_add_vertex_to_face (s, v, GTS_FACE (f)); i = t = gts_vertex_triangles (v, NULL); while (i) { list_face_update (i->data, data); i = i->next; } g_slist_free (t); nv++; } if (f) LIST_FACE (f)->heap = NULL; gts_eheap_foreach (heap, (GFunc) list_face_clear_heap, NULL); gts_eheap_destroy (heap); }