EXP int CALL srwlPropagRadMultiE(SRWLStokes* pStokes, SRWLWfr* pWfr0, SRWLOptC* pOpt, double* precPar, int (*pExtFunc)(int action, SRWLStokes* pStokesInst)) { if((pStokes == 0) || (pWfr0 == 0) || (pOpt == 0) || (precPar == 0)) return SRWL_INCORRECT_PARAM_FOR_WFR_PROP; int locErNo = 0; try { srTSRWRadStructAccessData wfr(pWfr0); srTCompositeOptElem optCont(*pOpt); //to continue //if(locErNo = optCont.CheckRadStructForPropagation(&wfr)) return locErNo; //if(locErNo = optCont.PropagateRadiationGuided(wfr)) return locErNo; //wfr.OutSRWRadPtrs(*pWfr); UtiWarnCheck(); } catch(int erNo) { return erNo; } return 0; }
EXP int CALL srwlSetRepresElecField(SRWLWfr* pWfr, char repr) { if(pWfr == 0) return SRWL_INCORRECT_PARAM_FOR_CHANGE_REP; char reprCoordOrAng=0, reprFreqOrTime=0; if((repr == 'c') || (repr == 'C') || (repr == 'a') || (repr == 'A')) reprCoordOrAng = repr; if((repr == 'f') || (repr == 'F') || (repr == 't') || (repr == 'T')) reprFreqOrTime = repr; if((!reprCoordOrAng) && (!reprFreqOrTime)) return SRWL_INCORRECT_PARAM_FOR_CHANGE_REP; try { srTSRWRadStructAccessData wfr(pWfr); int locErNo = 0; if(reprCoordOrAng) locErNo = wfr.SetRepresCA(reprCoordOrAng); //set Coordinate or Angular representation else if(reprFreqOrTime) locErNo = wfr.SetRepresFT(reprFreqOrTime); //set Frequency or Time representation if(locErNo) return locErNo; wfr.OutSRWRadPtrs(*pWfr); UtiWarnCheck(); } catch(int erNo) { return erNo; } return 0; }
EXP int CALL srwlCalcIntFromElecField(char* pInt, SRWLWfr* pWfr, char polar, char intType, char depType, double e, double x, double y) { if((pWfr == 0) || (pInt == 0)) return SRWL_INCORRECT_PARAM_FOR_INT_EXTR; try { srTSRWRadStructAccessData wfr(pWfr); CHGenObj hWfr(&wfr, true); srTRadGenManip radGenManip(hWfr); //Re-defining intType //from SRWL convention: 0- Single-Elec. Intensity; 1- Multi-Elec. Intensity; 2- Single-Elec. Flux; 3- Multi-Elec. Flux; 4- Single-Elec. Rad. Phase; 5- Re(E); 6- Im(E) //to old SRW convention: 0- Single-Elec. Intensity; 1- Multi-Elec. Intensity; 2- Single-Elec. Rad. Phase; 3- Re(E); 4- Single-Elec. Flux; 5- Multi-Elec. Flux; 6- Im(E) if(intType == 2) intType = 4; else if(intType == 3) intType = 5; else if(intType == 4) intType = 2; else if(intType == 5) intType = 3; radGenManip.ExtractRadiation((int)polar, (int)intType, (int)depType, wfr.Pres, e, x, y, pInt); //wfr.OutSRWRadPtrs(*pWfr); //not necessary? UtiWarnCheck(); } catch(int erNo) { return erNo; } return 0; }
EXP int CALL srwlCalcElecFieldGaussian(SRWLWfr* pWfr, SRWLGsnBm* pGsnBm, double* precPar) { if((pWfr == 0) || (pGsnBm == 0)) return SRWL_INCORRECT_PARAM_FOR_GAUS_BEAM_COMP; int locErNo = 0; try { double arMom1[] = {pGsnBm->x, pGsnBm->xp, pGsnBm->y, pGsnBm->yp}; srTGsnBeam GsnBm(-1, pGsnBm->polar, pGsnBm->sigX, pGsnBm->mx, pGsnBm->sigY, pGsnBm->my, pGsnBm->sigT, 1, arMom1, pGsnBm->z, pGsnBm->repRate, pGsnBm->pulseEn, pGsnBm->avgPhotEn); srTSRWRadStructAccessData wfr(pWfr, &GsnBm, precPar); //ATTENTION: this may request for changing numbers of points in the wavefront mesh srTWfrSmp auxSmp; wfr.SetObsParamFromWfr(auxSmp); GsnBm.ComputeElectricField(&auxSmp, &wfr); wfr.OutSRWRadPtrs(*pWfr); UtiWarnCheck(); } catch(int erNo) { locErNo = erNo; //return erNo; } return locErNo; }
void DocReader::ReadIntoBufferIgnoringBitsInDeletedList(int iOffset, int iByteCount, void* pBuf, int iBufSize) { _ASSERT(iBufSize>=iByteCount); WordFileReader wfr(m_sfr, "WordDocument", iOffset, iByteCount); wfr.Read(pBuf, iByteCount); ByteRemover br((char*)pBuf, iByteCount, iOffset, m_vecDeletedBits); br.Process((char*)pBuf, iBufSize); }
EXP int CALL srwlResizeElecField(SRWLWfr* pWfr, char type, double* par) { if((pWfr == 0) || (par == 0)) return SRWL_INCORRECT_PARAM_FOR_RESIZE; bool isCorA = (type == 'c') || (type == 'C') || (type == 'a') || (type == 'A'); bool isForT = (type == 'f') || (type == 'F') || (type == 't') || (type == 'T'); if(!(isCorA || isForT)) return SRWL_INCORRECT_PARAM_FOR_RESIZE; //if((type != 'c') && (type != 'C') && (type != 'a') && (type != 'A') && (type != 'f') && (type != 'F') && (type != 't') && (type != 'T')) return SRWL_INCORRECT_PARAM_FOR_RESIZE; //if((type != 'c') && (type != 'C') && (type != 'a') && (type != 'A') /*&& (type != 'f') && (type != 'F') && (type != 't') && (type != 'T')*/) return SRWL_INCORRECT_PARAM_FOR_RESIZE; //resizing vs photon energy / time yet to be implemented! try { int locErNo = 0; srTGenOptElem GenOptElem; srTSRWRadStructAccessData wfr(pWfr); srTRadResize resPar; //resPar.UseOtherSideFFT = (char)par[0]; resPar.useOtherSideFFT((int)par[0]); if(isCorA) { resPar.pxm = (double)par[1]; //horizontal range resPar.pxd = (double)par[2]; //horizontal resolution resPar.pzm = (double)par[3]; //vertical range resPar.pzd = (double)par[4]; //vertical resolution if(locErNo = GenOptElem.RadResizeGen(wfr, resPar)) return locErNo; //to make it static or put it into srTSRWRadStructAccessData eventually? } else if(isForT) { resPar.pem = (double)par[1]; //photon energy / time range resPar.ped = (double)par[2]; //photon energy / time resolution if(locErNo = GenOptElem.RadResizeGenE(wfr, resPar)) return locErNo; //to make it static or put it into srTSRWRadStructAccessData eventually? } wfr.OutSRWRadPtrs(*pWfr); UtiWarnCheck(); } catch(int erNo) { return erNo; } return 0; }
EXP int CALL srwlPropagElecField(SRWLWfr* pWfr, SRWLOptC* pOpt) { if((pWfr == 0) || (pOpt == 0)) return SRWL_INCORRECT_PARAM_FOR_WFR_PROP; int locErNo = 0; try { srTCompositeOptElem optCont(*pOpt); srTSRWRadStructAccessData wfr(pWfr); if(locErNo = optCont.CheckRadStructForPropagation(&wfr)) return locErNo; if(locErNo = optCont.PropagateRadiationGuided(wfr)) return locErNo; wfr.OutSRWRadPtrs(*pWfr); UtiWarnCheck(); } catch(int erNo) { return erNo; } return 0; }
EXP int CALL srwlCalcElecFieldSR(SRWLWfr* pWfr, SRWLPrtTrj* pTrj, SRWLMagFldC* pMagFld, double* precPar, int nPrecPar) { if((pWfr == 0) || (precPar == 0)) return SRWL_INCORRECT_PARAM_FOR_SR_COMP; bool trjIsDefined = true; if(pTrj == 0) trjIsDefined = false; else if((((pTrj->arX == 0) || (pTrj->arXp == 0)) && ((pTrj->arY == 0) || (pTrj->arYp == 0))) || (pTrj->np <= 0)) trjIsDefined = false; bool fldIsDefined = true; if(pMagFld == 0) fldIsDefined = false; else if((pMagFld->arMagFld == 0) || (pMagFld->arMagFldTypes == 0) || (pMagFld->nElem <= 0)) fldIsDefined = false; if((!trjIsDefined) && (!fldIsDefined)) return SRWL_INCORRECT_PARAM_FOR_SR_COMP; int locErNo = 0; try { if(!trjIsDefined) { pTrj = new SRWLPrtTrj(); int npTraj = 100000; if((nPrecPar <= 0) || (nPrecPar > 4)) npTraj = (int)precPar[4]; pTrj->arX = new double[npTraj]; pTrj->arXp = new double[npTraj]; pTrj->arY = new double[npTraj]; pTrj->arYp = new double[npTraj]; pTrj->arZ = new double[npTraj]; //required? pTrj->arZp = new double[npTraj]; //required? pTrj->partInitCond = pWfr->partBeam.partStatMom1; pTrj->np = npTraj; double sStartInt = 0.; //longitudinal position to start integration if((nPrecPar <= 0) || (nPrecPar > 2)) sStartInt = precPar[2]; double sEndInt = 0.; //longitudinal position to end integration if((nPrecPar <= 0) || (nPrecPar > 3)) sEndInt = precPar[3]; //pTrj->ctStart = precPar[2] - pTrj->partInitCond.z; //precPar[2]; //OC_GIANLUCA //pTrj->ctEnd = precPar[3] - pTrj->partInitCond.z;//precPar[3]; //OC_GIANLUCA //processing of the case pTrj->ctStart >= pTrj->ctEnd takes place in srwlCalcPartTraj pTrj->ctStart = sStartInt - pTrj->partInitCond.z; //precPar[2]; //OC_GIANLUCA pTrj->ctEnd = sEndInt - pTrj->partInitCond.z;//precPar[3]; //OC_GIANLUCA double* precParForTrj = 0; //assume default for the moment; to update later (?) if(locErNo = srwlCalcPartTraj(pTrj, pMagFld, precParForTrj)) throw locErNo; } else pWfr->partBeam.partStatMom1 = pTrj->partInitCond; srTTrjDat trjData(pTrj); //this calculates interpolating structure required for SR calculation trjData.EbmDat.SetCurrentAndMom2(pWfr->partBeam.Iavg, pWfr->partBeam.arStatMom2, 21); srTSRWRadStructAccessData wfr(pWfr, &trjData, precPar); //ATTENTION: this may request for changing numbers of points in the wavefront mesh srTWfrSmp auxSmp; wfr.SetObsParamFromWfr(auxSmp); //precPar = array('d', [meth, relPrec, zStartInteg, zEndInteg, npTraj, 0, sampFactNxNyForProp]) char calcTerminTerms = 1; //by default do calculate two terminating terms if((nPrecPar <= 0) || (nPrecPar > 5)) calcTerminTerms = (char)precPar[5]; //srTParPrecElecFld precElecFld((int)precPar[0], precPar[1], precPar[2], precPar[3], precPar[6]); //srTParPrecElecFld(int In_IntegMethNo, double In_RelPrecOrStep, double In_sStartInt, double In_sEndInt, double In_NxNzOversamplingFactor, bool In_ShowProgrIndic = true, char In_CalcTerminTerms = 1) srTParPrecElecFld precElecFld((int)precPar[0], precPar[1], precPar[2], precPar[3], precPar[6], false, calcTerminTerms); srTRadInt RadInt; RadInt.ComputeElectricFieldFreqDomain(&trjData, &auxSmp, &precElecFld, &wfr, 0); wfr.OutSRWRadPtrs(*pWfr); UtiWarnCheck(); } catch(int erNo) { locErNo = erNo; //return erNo; } if(!trjIsDefined) { if(pTrj->arX != 0) { delete[] pTrj->arX; pTrj->arX = 0;} if(pTrj->arXp != 0) { delete[] pTrj->arXp; pTrj->arXp = 0;} if(pTrj->arY != 0) { delete[] pTrj->arY; pTrj->arY = 0;} if(pTrj->arYp != 0) { delete[] pTrj->arYp; pTrj->arYp = 0;} if(pTrj->arZ != 0) { delete[] pTrj->arZ; pTrj->arZ = 0;} if(pTrj->arZp != 0) { delete[] pTrj->arZp; pTrj->arZp = 0;} delete pTrj; } return locErNo; }