Esempio n. 1
0
BMEdge *bmesh_disk_faceedge_find_next(BMEdge *e, BMVert *v)
{
	BMEdge *searchedge = NULL;
	searchedge = bmesh_disk_edge_next(e, v);
	do {
		if (searchedge->l && bmesh_radial_facevert_count(searchedge->l, v)) {
			return searchedge;
		}
	} while ((searchedge = bmesh_disk_edge_next(searchedge, v)) != e);
	return e;
}
Esempio n. 2
0
BMEdge *bmesh_disk_faceedge_find_next(const BMEdge *e, const BMVert *v)
{
	BMEdge *e_find = NULL;
	e_find = bmesh_disk_edge_next(e, v);
	do {
		if (e_find->l && bmesh_radial_facevert_count(e_find->l, v)) {
			return e_find;
		}
	} while ((e_find = bmesh_disk_edge_next(e_find, v)) != e);
	return (BMEdge *)e;
}
Esempio n. 3
0
int bmesh_disk_count(const BMVert *v)
{
	if (v->e) {
		BMEdge *e_first, *e_iter;
		int count = 0;

		e_iter = e_first = v->e;

		do {
			if (!e_iter) {
				return 0;
			}

			if (count >= (1 << 20)) {
				printf("bmesh error: infinite loop in disk cycle!\n");
				return 0;
			}
			count++;
		} while ((e_iter = bmesh_disk_edge_next(e_iter, v)) != e_first);
		return count;
	}
	else {
		return 0;
	}
}
Esempio n. 4
0
void  *bmiter__edge_of_vert_step(BMIter *iter)
{
	BMEdge *current = iter->e_next;

	if (iter->e_next)
		iter->e_next = bmesh_disk_edge_next(iter->e_next, iter->vdata);
	
	if (iter->e_next == iter->e_first) iter->e_next = NULL;

	return current;
}
Esempio n. 5
0
void  *bmiter__edge_of_vert_step(BMIter *iter)
{
	BMEdge *current = iter->nextedge;

	if (iter->nextedge)
		iter->nextedge = bmesh_disk_edge_next(iter->nextedge, iter->vdata);
	
	if (iter->nextedge == iter->firstedge) iter->nextedge = NULL;

	return current;
}
/**
 * \brief FIND FIRST FACE EDGE
 *
 * Finds the first edge in a vertices
 * Disk cycle that has one of this
 * vert's loops attached
 * to it.
 */
BMEdge *bmesh_disk_faceedge_find_first(const BMEdge *e, const BMVert *v)
{
	const BMEdge *e_find = e;
	do {
		if (e_find->l && bmesh_radial_facevert_check(e_find->l, v)) {
			return (BMEdge *)e_find;
		}
	} while ((e_find = bmesh_disk_edge_next(e_find, v)) != e);

	return NULL;
}
int bmesh_disk_count(const BMVert *v)
{
	int count = 0;
	if (v->e) {
		BMEdge *e_first, *e_iter;
		e_iter = e_first = v->e;
		do {
			count++;
		} while ((e_iter = bmesh_disk_edge_next(e_iter, v)) != e_first);
	}
	return count;
}
int bmesh_disk_count_ex(const BMVert *v, const int count_max)
{
	int count = 0;
	if (v->e) {
		BMEdge *e_first, *e_iter;
		e_iter = e_first = v->e;
		do {
			count++;
			if (count == count_max) {
				break;
			}
		} while ((e_iter = bmesh_disk_edge_next(e_iter, v)) != e_first);
	}
	return count;
}
Esempio n. 9
0
BMEdge *bmesh_disk_edge_exists(const BMVert *v1, const BMVert *v2)
{
	BMEdge *e_iter, *e_first;
	
	if (v1->e) {
		e_first = e_iter = v1->e;

		do {
			if (bmesh_verts_in_edge(v1, v2, e_iter)) {
				return e_iter;
			}
		} while ((e_iter = bmesh_disk_edge_next(e_iter, v1)) != e_first);
	}
	
	return NULL;
}
/**
 * \brief DISK COUNT FACE VERT
 *
 * Counts the number of loop users
 * for this vertex. Note that this is
 * equivalent to counting the number of
 * faces incident upon this vertex
 */
int bmesh_disk_facevert_count(const BMVert *v)
{
	/* is there an edge on this vert at all */
	int count = 0;
	if (v->e) {
		BMEdge *e_first, *e_iter;

		/* first, loop around edge */
		e_first = e_iter = v->e;
		do {
			if (e_iter->l) {
				count += bmesh_radial_facevert_count(e_iter->l, v);
			}
		} while ((e_iter = bmesh_disk_edge_next(e_iter, v)) != e_first);
	}
	return count;
}
Esempio n. 11
0
bool bmesh_disk_validate(int len, BMEdge *e, BMVert *v)
{
	BMEdge *e_iter;

	if (!BM_vert_in_edge(e, v))
		return false;
	if (bmesh_disk_count(v) != len || len == 0)
		return false;

	e_iter = e;
	do {
		if (len != 1 && bmesh_disk_edge_prev(e_iter, v) == e_iter) {
			return false;
		}
	} while ((e_iter = bmesh_disk_edge_next(e_iter, v)) != e);

	return true;
}
Esempio n. 12
0
/**
 * Given an array of edges,
 * order them using the winding defined by \a v1 & \a v2
 * into \a edges_sort & \a verts_sort.
 *
 * All arrays must be \a len long.
 */
static bool bm_edges_sort_winding(
        BMVert *v1, BMVert *v2,
        BMEdge **edges, const int len,
        BMEdge **edges_sort, BMVert **verts_sort)
{
	BMEdge *e_iter, *e_first;
	BMVert *v_iter;
	int i;

	/* all flags _must_ be cleared on exit! */
	for (i = 0; i < len; i++) {
		BM_ELEM_API_FLAG_ENABLE(edges[i], _FLAG_MF);
		BM_ELEM_API_FLAG_ENABLE(edges[i]->v1, _FLAG_MV);
		BM_ELEM_API_FLAG_ENABLE(edges[i]->v2, _FLAG_MV);
	}

	/* find first edge */
	i = 0;
	v_iter = v1;
	e_iter = e_first = v1->e;
	do {
		if (BM_ELEM_API_FLAG_TEST(e_iter, _FLAG_MF) &&
		    (BM_edge_other_vert(e_iter, v_iter) == v2))
		{
			i = 1;
			break;
		}
	} while ((e_iter = bmesh_disk_edge_next(e_iter, v_iter)) != e_first);
	if (i == 0) {
		goto error;
	}

	i = 0;
	do {
		/* entering loop will always succeed */
		if (BM_ELEM_API_FLAG_TEST(e_iter, _FLAG_MF)) {
			if (UNLIKELY(BM_ELEM_API_FLAG_TEST(v_iter, _FLAG_MV) == false)) {
				/* vert is in loop multiple times */
				goto error;
			}

			BM_ELEM_API_FLAG_DISABLE(e_iter, _FLAG_MF);
			edges_sort[i] = e_iter;

			BM_ELEM_API_FLAG_DISABLE(v_iter, _FLAG_MV);
			verts_sort[i] = v_iter;

			i += 1;

			/* walk onto the next vertex */
			v_iter = BM_edge_other_vert(e_iter, v_iter);
			if (i == len) {
				if (UNLIKELY(v_iter != verts_sort[0])) {
					goto error;
				}
				break;
			}

			e_first = e_iter;
		}
	} while ((e_iter = bmesh_disk_edge_next(e_iter, v_iter)) != e_first);

	if (i == len) {
		return true;
	}

error:
	for (i = 0; i < len; i++) {
		BM_ELEM_API_FLAG_DISABLE(edges[i], _FLAG_MF);
		BM_ELEM_API_FLAG_DISABLE(edges[i]->v1, _FLAG_MV);
		BM_ELEM_API_FLAG_DISABLE(edges[i]->v2, _FLAG_MV);
	}

	return false;
}