Exemple #1
0
	 size_t insert_point(const uvector &p, 
			     const uvector &n = uvector(),
			     const Color &c = Color())
	 {
	    _points.push_back(p);
	    if (_flags & MESH_NORMAL)
	       _normals.push_back(n);
	    if (_flags & MESH_COLOR)
	       _colors.push_back(c);
	    return _points.size() - 1;
	 }
Exemple #2
0
void nemo_main()
{
    stream instr, outstr;
    real   mscale, pscale, xscale, tsnap, escale, dscale;
    vector rscale, vscale, ascale;
    string times;
    int i, nbody, bits, nrscale, nvscale, nascale, kscale;
    Body *btab = NULL, *bp;
    bool Qmass, Qphase, Qacc, Qpot, Qkey, Qaux, Qeps, Qdens;

    nrscale = nemoinpr(getparam("rscale"),rscale,NDIM);     /* RSCALE */
    if (nrscale==1) 
    	for (i=1; i<NDIM; i++)
    	   rscale[i] = rscale[0];
    else if (nrscale!=NDIM)
    	error("keyword rscale needs either 1 or %d numbers", NDIM);
    			

    nvscale = nemoinpr(getparam("vscale"),vscale,NDIM);     /* VSCALE */
    if (nvscale==1)
    	for (i=1; i<NDIM; i++)
    	   vscale[i] = vscale[0];
    else if (nvscale!=NDIM)
    	error("keyword vscale needs either 1 or %d numbers", NDIM);    

    nascale = nemoinpr(getparam("ascale"),ascale,NDIM);     /* ASCALE */
    if (nascale==1)
    	for (i=1; i<NDIM; i++)
    	   ascale[i] = ascale[0];
    else if (nascale!=NDIM)
    	error("keyword ascale needs either 1 or %d numbers", NDIM);    

    mscale = getdparam("mscale");
    pscale = getdparam("pscale");
    xscale = getdparam("xscale");
    dscale = getdparam("dscale");
    escale = getdparam("escale");
    kscale = getiparam("kscale");
    times = getparam("times");

    instr = stropen(getparam("in"), "r");   /* open files */
    outstr = stropen(getparam("out"), "w");

    get_history(instr);
    put_history(outstr);		
    for (;;) {
    	get_history(instr);		/* skip over stuff we can forget */
        if (!get_tag_ok(instr, SnapShotTag))
		break;			/* done with work in loop */
        get_snap(instr, &btab, &nbody, &tsnap, &bits);
        if ((bits & MassBit) == 0 && (bits & PhaseSpaceBit) == 0) {
	    continue;       /* just skip it's probably a diagnostics */
        }

        if ((bits & TimeBit) == 0)
	    tsnap = 0.0;
        else if (!streq(times,"all") && !within(tsnap, times, TIMEFUZZ))
            continue;
        dprintf (1,"Scaling snapshot at time= %f bits=0x%x\n",tsnap,bits);

        Qmass  = MassBit & bits        && !uscalar(mscale);
        Qphase = PhaseSpaceBit & bits  &&(!uvector(rscale) || !uvector(vscale));
        Qacc   = AccelerationBit & bits&& !uvector(ascale);
        Qpot   = PotentialBit & bits   && !uscalar(pscale);
        Qaux   = AuxBit & bits         && !uscalar(xscale);
        Qkey   = KeyBit & bits         && (kscale!=1);
        Qdens  = DensBit & bits        && !uscalar(dscale);
        Qeps   = EpsBit & bits         && !uscalar(escale);

        dprintf(1,"Scaling: ");
        if (Qmass)  dprintf(1," mass");
        if (Qphase) dprintf(1," phase");
        if (Qacc)   dprintf(1," acc");
        if (Qpot)   dprintf(1," pot");
        if (Qaux)   dprintf(1," aux");
        if (Qkey)   dprintf(1," key");
        if (Qdens)  dprintf(1," dens");
        if (Qeps)   dprintf(1," eps");
        dprintf(1,"\n");

        if (Qmass || Qphase || Qacc || Qpot || Qaux || Qkey || Qdens || Qeps) {
            for (bp = btab; bp < btab+nbody; bp++) {
                if(Qmass) Mass(bp) *= mscale;
                if(Qphase) {
                    SMULVV(Pos(bp),rscale);
                    SMULVV(Vel(bp),vscale);
	        }
                if(Qpot) Phi(bp) *= pscale;
                if(Qacc) {
                    SMULVV(Acc(bp),ascale);
                }
                if(Qaux) Aux(bp) *= xscale;
                if(Qkey) Key(bp) *= kscale;
		if(Qdens) Dens(bp) *= dscale;
		if(Qeps) Eps(bp) *= escale;
            }
        } else {
            warning("No scaling applied to snapshot");
	}

        put_snap(outstr, &btab, &nbody, &tsnap, &bits);
    }
}