예제 #1
0
파일: init.c 프로젝트: NegMozzie/42
void		init(t_env *env, char **av, int ac)
{
	env->color = NULL;
	env->pixel = NULL;
	env->coeff = NULL;
	env->t = NULL;
	env->fract = NULL;
	if ((init_args(env, av, ac)))
		ft_exit(env, "Wrong arg !");
	if (!(img_init(env)))
		ft_exit(env, "Unable to init mlx.");
	if (!(env->color = rgbmap()))
		ft_exit(env, "Unable to creat rgbmap");
	if (!(env->pixel = pixelmap()))
		ft_exit(env, "Unable to create pixelmap");
	if (!(env->coeff = coeffmap()))
		ft_exit(env, "Unable to create coeffmap");
	if (!(env->t = threadmap(env)))
		ft_exit(env, "Unable to create threadmap");
}
예제 #2
0
/*------------------------------------------------------------------------------
  Main program.
*/
int main(int argc, char *argv[])
{
    int ifile, nadj, nfiles, npoly, npolys, res_max_temp,i;
    char scheme_temp;
    polygon **polys;
    polys=polys_global;

    /* default output format */
    fmt.out = keywords[POLYGON];
    /* default is to renumber output polygons with pixel numbers as id numbers */
    fmt.newid = 'p';

    /* parse arguments */
    parse_args(argc, argv);

    /* at least one input and output filename required as arguments */
    if (argc - optind < 2) {
	if (optind > 1 || argc - optind == 1) {
	    fprintf(stderr, "%s requires at least 2 arguments: polygon_infile and polygon_outfile\n", argv[0]);
	    usage();
	    exit(1);
	} else {
	    usage();
	    exit(0);
	}
    }

    msg("---------------- pixelmap ----------------\n");

    /* tolerance angle for multiple intersections */
    if (mtol != 0.) {
	scale(&mtol, munit, 's');
	munit = 's';
	msg("multiple intersections closer than %Lg%c will be treated as coincident\n", mtol, munit);
	scale(&mtol, munit, 'r');
	munit = 'r';
    }

    /* save res_max as defined on command line rather than using value from file*/
    /* value of scheme in file will override scheme defined on command line */
    res_max_temp=res_max;
    scheme_temp=scheme;

    /* advise data format */
    advise_fmt(&fmt);

    /* read polygons */
    npoly = 0;
    nfiles = argc - 1 - optind;
    for (ifile = optind; ifile < optind + nfiles; ifile++) {
	npolys = rdmask(argv[ifile], &fmt, NPOLYSMAX - npoly, &polys[npoly]);
	if (npolys == -1) exit(1);
	npoly += npolys;
    }
    if (nfiles >= 2) {
        msg("total of %d polygons read\n", npoly);
    }
    if (npoly == 0) {
	msg("STOP\n");
	exit(0);
    }
    
    res_max=res_max_temp;
    msg("pixelization scheme %c, making map at resolution %d\n", scheme, res_max);
    
    if (snapped==0 || balkanized==0) {
      fprintf(stderr, "Error: input polygons must be snapped and balkanized before using pixelmap.\n");
      fprintf(stderr, "If your polygons are already snapped and balkanized, add the 'snapped' and\n'balkanized' keywords at the beginning of each of your input polygon files.\n");
      exit(1);
    }

    /* pixelmap polygons */
    nadj = pixelmap(&npoly, polys);
    if (nadj == -1) exit(1);

    ifile = argc - 1;
    npoly = wrmask(argv[ifile], &fmt, npoly, polys);
    if (npoly == -1) exit(1);
 
    for(i=0;i<npoly;i++){
      free_poly(polys[i]);
    }

    return(0);
}