// FIXME: Not very efficient
bool t_spectra::is_minimal_candidate (const t_candidate & candidate,
                                      const t_spectra_filter * filter) const {
    if (!is_candidate(candidate, filter))
        return false;

    t_candidate tmp = candidate;
    BOOST_FOREACH(t_component_id c, candidate) {
        tmp.erase(c);

        if (is_candidate(tmp, filter))
            return false;

        tmp.insert(c);
    }
Beispiel #2
0
int
main()
{
    int i, j, nd;
    int prod, cand, max = 0;
    char numstr[32];

    /*
     * We stop the loop at 9999 since any number after that multiplied by
     * atleast 1 and 2 and concatenated will results in more than 9 digits.
     */
    for (i = 1; i < 10000; i++) {
        memset(numstr, 0, 32);
        nd = 0;
        for (j = 1; j < 10; j++) {
            prod = i * j;
            nd += num_digits(prod);
            sprintf(numstr, "%s%d", numstr, prod);
            if (nd >= 9) {
                break;
            }
        }
        if (nd == 9) {
            cand = atoi(numstr);
            if (is_candidate(cand) && cand > max) {
                max = cand;
            }
        }
    }
    printf("%d\n", max);

    return (0);
}
Beispiel #3
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;
}
Beispiel #4
0
int
main()
{
	int i;
	for (i = 1; ; i++) {
		if (is_candidate(i)) {
			printf("%d\n", i);
			break;
		}
	}
	return (0);
}
Beispiel #5
0
/** find an adjacent vertex suitabile for removal.
 */
static bool
find_adjacent(struct mesh *mesh, unsigned int ivtx, unsigned int *avtx)
{
    unsigned int floop; /* facet loop */
    unsigned int vloop; /* vertex within facets */
    struct vertex *vtx; /* initial vertex */
    unsigned int civtx; /* candidate vertex index */
    struct vertex *cvtx; /* candidate vertex */

    vtx = vertex_from_index(mesh, ivtx);

    /* examine each facet attached to starting vertex */
    for (floop = 0; floop < vtx->fcount; floop++) {
        /* check each vertex of this facet has */
        for (vloop = 0; vloop < 3; vloop++) {
            civtx = vtx->facets[floop]->i[vloop];

            if (civtx == ivtx) {
                continue; /* skip starting vertex */
            }

            if (!is_candidate(mesh, civtx)) {
                continue; /* skip non candidate verticies */
            }

            cvtx = vertex_from_index(mesh, civtx);

            /* cannot merge edge verticies if it makes the mesh too
             * complicated to represent
             */
            if (((vtx->fcount + cvtx->fcount) - 2) > mesh->vertex_fcount) {
                continue;
            }

            if (!check_move_ok(mesh, civtx, ivtx)) {
                continue;
            }

            /* found something suitable */
            *avtx = civtx;
            return true;



        }
    }
    return false; /* no match */
}