Esempio n. 1
0
int		main(int argc, char **argv)
{
	t_fillit	*linear;
	t_info		l;
	char		*map;

	if (argc != 2)
	{
		write(1, "usage: ./fillit file\n", 21);
		return (0);
	}
	if (!check(argv[1]) || open(argv[1], O_RDONLY) == -1)
	{
		write(1, "error\n", 6);
		return (0);
	}
	linear = full_it(argv[1], &l);
	min_map(&l);
	map = generate_map(l.min);
	while (resolve(&linear, &l, &map) != 1)
	{
		l.min++;
		ft_strdel(&map);
		map = generate_map((&l)->min);
	}
	return (0);
}
Esempio n. 2
0
HeightMapNode* HeightMap::createQuadTree(const std::vector<std::vector<double> >& map,
                            unsigned int mx_min, unsigned int my_min,
                            unsigned int mx_max, unsigned int my_max, double resolution) {

    double max_height = 0;
    for(unsigned int mx = mx_min; mx < mx_max; ++mx) {
        for(unsigned int my = my_min; my < my_max; ++my) {
            max_height = std::max(max_height, map[mx][my]);
        }
    }

    if (max_height == 0) {
        return 0;
    }

    Vector3 min_map((double)mx_min * resolution,
                    (double)my_min * resolution, 0);
    Vector3 max_map((double)mx_max * resolution,
                    (double)my_max * resolution, max_height);

    HeightMapNode* n = new HeightMapNode(Box(min_map, max_map));

    if (mx_max - mx_min == 1 || my_max - my_min == 1) {
        assert(mx_max - mx_min == 1 && my_max - my_min == 1);
        n->occupied_ = true;
        return n;
    } else {
        n->occupied_ = false;

        unsigned int cx = (mx_max + mx_min) / 2;
        unsigned int cy = (my_max + my_min) / 2;

        n->children_[0] = createQuadTree(map, mx_min, my_min, cx, cy, resolution);
        n->children_[1] = createQuadTree(map, cx , my_min, mx_max, cy, resolution);
        n->children_[2] = createQuadTree(map, mx_min, cy , cx, my_max, resolution);
        n->children_[3] = createQuadTree(map, cx , cy , mx_max, my_max, resolution);

    }

    return n;
}