Esempio n. 1
0
/* simplify mesh by half edge removal
 *
 * algorithm is:
 * find vertex where all facets have the same normal
 * search each vertex of each attached facet for one where all its facets have teh same normal
 * merge second vertex into first
 */
bool
simplify_mesh(struct mesh *mesh)
{
    unsigned int vloop = 0;
    unsigned int vtx1;

    /* ensure index tables are up to date */
    assert(mesh->v != NULL);

    dump_mesh_simplify_init(mesh);

    while (vloop < mesh->vcount) {
        /* find a candidate edge */
        if (is_candidate(mesh, vloop) &&
            find_adjacent(mesh, vloop, &vtx1)) {

            /* collapse verticies */
            merge_edge(mesh, vloop, vtx1);

            /* do *not* advance past this vertex as we may have just modified
             * it!
             */
        } else {
            vloop++;
        }
    }

    dump_mesh_simplify_fini(mesh);

    verify_mesh(mesh);

    return true;
}
Esempio n. 2
0
/* Process a key event while the keypad is up. */
void
keypad_key(int k, ucs4_t u)
{
	if (!(menu_is_up & KEYPAD_IS_UP))
	    return;

	switch (k) {

#if defined(NCURSES_MOUSE_VERSION) /*[*/
	case MK_MOUSE: {
		MEVENT m;
		size_t i;

		if (getmouse(&m) != OK)
			return;
		if (!(m.bstate & (BUTTON1_PRESSED || BUTTON1_RELEASED)))
			return;
		/* Find it. */
		for (i = 0; i < NUM_SENSE; i++) {
			if (m.x >= sens[i].ul_x && m.y >= sens[i].ul_y &&
			    m.x <= sens[i].lr_x && m.y <= sens[i].lr_y) {
				push_macro(sens[i].callback, false);
				break;
			}
		}
		pop_up_keypad(false);
		break;
	    }
#endif /*]*/

	case MK_UP:
		find_adjacent(0, -1);
		break;

	case MK_DOWN:
		find_adjacent(0, 1);
		break;

	case MK_LEFT:
		find_adjacent(-1, 0);
		break;

	case MK_RIGHT:
		find_adjacent(1, 0);
		break;

	case MK_HOME:
		/* Find the first entry. */
		current_sens = &sens[0];
		break;

	case MK_END:
		/* Find the last entry. */
		current_sens = &sens[NUM_SENSE - 1];
		break;

	case MK_ENTER:
		push_macro(current_sens->callback, false);
		pop_up_keypad(false);
		break;

	case MK_NONE:
		switch (u) {
		case '\r':
		case '\n':
			push_macro(current_sens->callback, false);
			break;
		default:
			break;
		}
		pop_up_keypad(false);
		break;

	default:
	case MK_OTHER:
		pop_up_keypad(false);
		break;
	}

	screen_changed = true;
}