Ejemplo n.º 1
0
void ber_kamera_zpruhledni_poly(EDIT_MESH_POLY * p_poly, BOD * p_cam,
                                BOD * p_stred)
{
    TEXT_KOORD *p_koord;
    BOD dir;
    int v, in, pl;

    vektor_sub(p_stred, p_cam, &dir);
    in = obb_intersect_line_dist(&p_poly->obb, p_cam, &dir);
    pl = intersect_poly(p_poly, p_cam, &dir);

    if (in && pl) {
        p_poly->kflag |= (KONT_UPLOAD | KONT_DRAW_CAMERA);

        p_koord = p_poly->p_koord;
        for (v = 0; v < p_poly->facenum; v++, p_koord++) {
            if (p_koord->da > PRUHL_ALFA)
                p_koord->da = PRUHL_ALFA;
        }
    }
    else {
        p_poly->kflag &= ~KONT_DRAW_CAMERA;
        if (p_poly->m1flag & MAT_PRUHLEDNY || p_poly->m2flag & MAT2_MASKA) {
            ber_reset_poly(p_poly->p_koord, p_poly->facenum);
            p_poly->k2flag |= KONT_UPLOAD;
        }
    }

}
Ejemplo n.º 2
0
/*------------------------------------------------------------------------------
  Main program.
*/
int main(int argc, char *argv[])
{
    int ifile, ipoly, nfiles, npoly, npolys, i;
    polygon **polys;
    polys=polys_global;

    /* default output format */
    fmt.out = keywords[POLYGON];

    /* 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("---------------- poly2poly ----------------\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';
    }

    /* weight limits */
    if (is_weight_min && is_weight_max) {
	/* min <= max */
	if (weight_min <= weight_max) {
	    msg("will keep only polygons with weights inside [%Lg, %Lg]\n", weight_min, weight_max);
	/* min > max */
	} else {
	    msg("will keep only polygons with weights >= %Lg or <= %Lg\n", weight_min, weight_max);
	    msg("         (only polygons with weights outside (%Lg, %Lg))\n", weight_max, weight_min);
	}
    } else if (is_weight_min) {
	msg("will keep only polygons with weights >= %Lg\n", weight_min);
    } else if (is_weight_max) {
	msg("will keep only polygons with weights <= %Lg\n", weight_max);
    }
    /* area limits */
    if (is_area_min && is_area_max) {
	/* min <= max */
	if (area_min < area_max) {
	    msg("will keep only polygons with areas inside [%Lg, %Lg]\n", area_min, area_max);
	/* min > max */
	} else {
	    msg("will keep only polygons with areas >= %Lg or <= %Lg\n", area_min, area_max);
	    msg("         (only polygons with areas outside (%Lg, %Lg))\n", area_max, area_min);
	}
    } else if (is_area_min) {
	msg("will keep only polygons with areas >= %Lg\n", area_min);
    } else if (is_area_max) {
	msg("will keep only polygons with areas <= %Lg\n", area_max);
    }
    /* id limits */
    if (is_id_min && is_id_max) {
	/* min <= max */
	if (id_min < id_max) {
	    msg("will keep only polygons with ids inside [%lld, %lld]\n", id_min, id_max);
	/* min > max */
	} else {
	    msg("will keep only polygons with ids >= %lld or <= %lld\n", id_min, id_max);
	    msg("         (only polygons with ids outside (%lld, %lld))\n", id_max, id_min);
	}
    } else if (is_id_min) {
	msg("will keep only polygons with areas >= %lld\n", id_min);
    } else if (is_id_max) {
	msg("will keep only polygons with areas <= %lld\n", id_max);
    }
    /* pixel limits */
    if (is_pixel_min && is_pixel_max) {
	/* min <= max */
	if (pixel_min < pixel_max) {
	    msg("will keep only polygons with pixel numbers inside [%d, %d]\n", pixel_min, pixel_max);
	/* min > max */
	} else {
	    msg("will keep only polygons with pixel numbers >= %d or <= %d\n", pixel_min, pixel_max);
	    msg("         (only polygons with pixel numbers outside (%d, %d))\n", pixel_max, pixel_min);
	}
    } else if (is_pixel_min) {
	msg("will keep only polygons with pixel numbers >= %d\n", pixel_min);
    } else if (is_pixel_max) {
	msg("will keep only polygons with pixel numbers <= %d\n", pixel_max);
    }

    /* 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);
	/* intersect polygons of infile1 with those of subsequent infiles */
	if (ifile > optind && intersect) {
	    npoly = intersect_poly(npoly, polys, npolys, &polys[npoly], mtol);
	    if (npoly == -1) exit(1);
	/* increment number of polygons */
	} else {
	    npoly += npolys;
	}
    }
    if (nfiles >= 2 && !intersect) {
        msg("total of %d polygons read\n", npoly);
    }
    if (npoly == 0) {
	msg("STOP\n");
	exit(0);
    }

    /* apply new id numbers to output polygons */
    if (fmt.newid == 'n') {
	for (ipoly = 0; ipoly < npoly; ipoly++) {
	  polys[ipoly]->id = (long long)ipoly+fmt.idstart;
	}
    }

    if (fmt.newid == 'p') {
      for (ipoly = 0; ipoly < npoly; ipoly++) {
	polys[ipoly]->id = (long long)polys[ipoly]->pixel;
      }
    }

    /* write polygons */
    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);
}