std::ostream& rspfDtedInfo::print(std::ostream& out) const { if ( theFile.size() ) { std::string prefix = "dted."; rspfDtedVol vol(theFile, 0); rspfDtedHdr hdr(theFile, vol.stopOffset()); rspfDtedUhl uhl(theFile, hdr.stopOffset()); rspfDtedDsi dsi(theFile, uhl.stopOffset()); rspfDtedAcc acc(theFile, dsi.stopOffset()); if( vol.getErrorStatus() == rspfErrorCodes::RSPF_OK ) { vol.print(out, prefix); } if( hdr.getErrorStatus() == rspfErrorCodes::RSPF_OK ) { hdr.print(out, prefix); } if( uhl.getErrorStatus() == rspfErrorCodes::RSPF_OK ) { uhl.print(out, prefix); } if( dsi.getErrorStatus() == rspfErrorCodes::RSPF_OK ) { dsi.print(out, prefix); } if( acc.getErrorStatus() == rspfErrorCodes::RSPF_OK ) { acc.print(out, prefix); } } return out; }
void dsp_quick(NSLNSLnet *net) { int rr,qq,pp,nn,num,parts,flds,outnum=0; hop_ctrl_ds *hp=nsl_drv(hop_ctrl_ds); bio_ds *np=(&hp->nio); float val,hamap,hamai,ham; flds=np->fld_siz; num=dsi(np->flda,hop_tree_ds,size.part); parts=flds/num; for(rr=0;rr<num_pats;++rr) {hamap=(float)0.0; hamai=(float)0.0; for(pp=0;pp<parts;++pp) {for(qq=0;qq<num;++qq) {nn=pp*num+qq; val=(float)((quant)qua(np->flda+pp,hop_tree_ds,part[qq].output)) /((float)QSCALE); hamap+=diff((float)patsa[rr][nn],val); val=(float)1.0-val; hamai+=diff((float)patsa[rr][nn],val); val=(float)((quant)qua(np->fldb+pp,hop_tree_ds,part[qq].output)) /((float)QSCALE); hamap+=diff((float)patsb[rr][nn],val); val=(float)1.0-val; hamai+=diff((float)patsb[rr][nn],val); } } if(rr==0) ham=hamap; if(hamap<ham) {outnum=2*rr; ham=hamap;} if(hamai<ham) {outnum=2*rr+1; ham=hamai;} } fprintf(bam_logfp,"%d,%.3f,%d\n",curcc,ham,outnum); }
bool rspfDtedInfo::open(const rspfFilename& file) { bool result = false; // Test for extension, like dt0, dt1... rspfString ext = file.ext(); rspfRegExp regExp("^[d|D][t|T][0-9]"); if ( regExp.find( ext.c_str() ) ) { rspfDtedVol vol(file, 0); rspfDtedHdr hdr(file, vol.stopOffset()); rspfDtedUhl uhl(file, hdr.stopOffset()); rspfDtedDsi dsi(file, uhl.stopOffset()); rspfDtedAcc acc(file, dsi.stopOffset()); //--- // Check for errors. Must have uhl, dsi and acc records. vol and hdr // are for magnetic tape only; hence, may or may not be there. //--- if ( (uhl.getErrorStatus() == rspfErrorCodes::RSPF_OK) && (dsi.getErrorStatus() == rspfErrorCodes::RSPF_OK) && (acc.getErrorStatus() == rspfErrorCodes::RSPF_OK) ) { theFile = file; result = true; } else { theFile.clear(); } } return result; }
int hop_pattern(NSLNSLnet *net,va_list args) { int nn; hop_io_ds *hp=nsl_drv(hop_io_ds); nio_ds *np=(&hp->nio); np->xx=0; dsi(np->d0,hop_ctrl_ds,stable)=2; for(nn=0;nn<np->fld_siz;++nn) dsf(np->d0,hop_ctrl_ds,output[nn])=rndf(); return(0); }
//fill kf with data void kf::kfinit(){ if (init) { //load connection type int li=dsi("select data from setup where id=1"); if (ui->cbc->count()>li) {ui->cbc->setCurrentIndex(li);} init=false; //when debug to skip menu QTimer::singleShot(500,this,SLOT(kopen())); } }
// --- bool CBaseInfo::ReInit() { if ( m_curr ) { tDWORD en = DetectEnType( m_curr ); if ( m_en_type == ifAny ) m_en_type = en; else if ( m_en_type != en ) { if ( en == ifAny ) SetDWAttr( VE_PID_NODETYPE, en ); else if ( (en == ifIFace) && (m_en_type != ifPlugin) && (m_en_type != ifMethodParam) && (m_en_type != ifDataStructMember) ) { CFaceInfo ii(m_curr,false); switch( m_en_type ) { case ifType : StartHere(ii.FirstType()); break; case ifConstant : StartHere(ii.FirstConstant()); break; case ifErrCode : StartHere(ii.FirstErrCode()); break; case ifProperty : StartHere(ii.FirstProperty()); break; case ifPubMethod : StartHere(ii.FirstPubMethod()); break; case ifIntMethod : StartHere(ii.FirstIntMethod()); break; case ifDataStruct : StartHere(ii.FirstDataStruct()); break; case ifMsgClass : StartHere(ii.FirstMsgClass()); break; default : StartHere(0); m_en_type = ifAny; return false; } } else if ( (en==ifPubMethod) && (m_en_type==ifMethodParam) ) { CPubMethodInfo mi( m_curr, false ); StartHere( mi.FirstParam() ); } else if ( (en==ifIntMethod) && (m_en_type==ifMethodParam) ) { CIntMethodInfo mi( m_curr, false ); StartHere( mi.FirstParam() ); } else if ( (en==ifDataStruct) && (m_en_type==ifDataStructMember) ) { CDataStructInfo dsi( m_curr, false ); StartHere( dsi.FirstMember() ); } else { m_en_type = ifAny; StartHere( 0 ); } } tDWORD len = Name(0,0); if ( len ) { m_name = new char[len]; Name( m_name, len ); } else m_name = 0; } else m_name = 0; return true; }
/** * Same as {@code System.arraycopy(src, 0, dest, 0, length)}. * * @param src the source array. * @param srcSize the size of the source array. * @param dest the destination array. * @param destSize the size of the destination array. * @param length the number of array elements to be copied. */ void CryptoHelper::copyByteArray(const byte src[], size_t srcSize, byte dest[], size_t destSize, size_t copySize) { ASSERT(src); ASSERT(srcSize); ASSERT(dest); ASSERT(destSize); ASSERT(srcSize >= copySize); ASSERT(destSize >= copySize); if(!src) throw IllegalArgumentException("Source array cannot be nul"); if(!dest) throw IllegalArgumentException("Destination array cannot be nul"); try { // Will throw if ptr wraps. T* and size_t causing trouble on Linux SafeInt<size_t> ssi((size_t)src); ssi += srcSize; g_dummy = (void*)(size_t)ssi; SafeInt<size_t> dsi((size_t)dest); dsi += destSize; g_dummy = (void*)(size_t)dsi; } catch(const SafeIntException&) { throw IllegalArgumentException("Source or destination array pointer wrap"); } const size_t req = std::min(copySize, std::min(srcSize, destSize)); ASSERT(req > 0); ASSERT(req == copySize); if(req != copySize) throw IllegalArgumentException("Copy size exceeds source or destination size"); ESAPI_MS_NO_WARNING(4996); std::copy(src, src+req, dest); ESAPI_MS_DEF_WARNING(4996); }
rspfRefPtr<rspfProperty> rspfDtedInfo::getProperty( const rspfString& name)const { rspfRefPtr<rspfProperty> result = 0; //--- // Look through dted records. // Must have uhl, dsi and acc records. vol and hdr // are for magnetic tape only; hence, may or may not be there. //--- rspfDtedVol vol(theFile, 0); if( vol.getErrorStatus() == rspfErrorCodes::RSPF_OK ) { if (name == "dted_vol_record") { rspfContainerProperty* box = new rspfContainerProperty(); box->setName(name); std::vector<rspfString> list; vol.getPropertyNames(list); std::vector< rspfRefPtr<rspfProperty> > propList; std::vector<rspfString>::const_iterator i = list.begin(); while (i != list.end()) { rspfRefPtr<rspfProperty> prop = vol.getProperty( (*i) ); if (prop.valid()) { propList.push_back(prop); } ++i; } box->addChildren(propList); result = box; } } if (result.valid() == false) { rspfDtedHdr hdr(theFile, vol.stopOffset()); if( hdr.getErrorStatus() == rspfErrorCodes::RSPF_OK ) { if (name == "dted_hdr_record") { rspfContainerProperty* box = new rspfContainerProperty(); box->setName(name); std::vector<rspfString> list; hdr.getPropertyNames(list); std::vector< rspfRefPtr<rspfProperty> > propList; std::vector<rspfString>::const_iterator i = list.begin(); while (i != list.end()) { rspfRefPtr<rspfProperty> prop = hdr.getProperty( (*i) ); if (prop.valid()) { propList.push_back(prop); } ++i; } box->addChildren(propList); result = box; } } if (result.valid() == false) { rspfDtedUhl uhl(theFile, hdr.stopOffset()); if( uhl.getErrorStatus() == rspfErrorCodes::RSPF_OK ) { if (name == "dted_uhl_record") { rspfContainerProperty* box = new rspfContainerProperty(); box->setName(name); std::vector<rspfString> list; uhl.getPropertyNames(list); std::vector< rspfRefPtr<rspfProperty> > propList; std::vector<rspfString>::const_iterator i = list.begin(); while (i != list.end()) { rspfRefPtr<rspfProperty> prop = uhl.getProperty( (*i) ); if (prop.valid()) { propList.push_back(prop); } ++i; } box->addChildren(propList); result = box; } } if (result.valid() == false) { rspfDtedDsi dsi(theFile, uhl.stopOffset()); if( dsi.getErrorStatus() == rspfErrorCodes::RSPF_OK ) { if (name == "dted_dsi_record") { rspfContainerProperty* box = new rspfContainerProperty(); box->setName(name); std::vector<rspfString> list; dsi.getPropertyNames(list); std::vector< rspfRefPtr<rspfProperty> > propList; std::vector<rspfString>::const_iterator i = list.begin(); while (i != list.end()) { rspfRefPtr<rspfProperty> prop = dsi.getProperty( (*i) ); if (prop.valid()) { propList.push_back(prop); } ++i; } box->addChildren(propList); result = box; } } if (result.valid() == false) { rspfDtedAcc acc(theFile, dsi.stopOffset()); if( acc.getErrorStatus() == rspfErrorCodes::RSPF_OK ) { if (name == "dted_acc_record") { rspfContainerProperty* box = new rspfContainerProperty(); box->setName(name); std::vector<rspfString> list; acc.getPropertyNames(list); std::vector< rspfRefPtr<rspfProperty> > propList; rspfRefPtr<rspfProperty> prop = 0; std::vector<rspfString>::const_iterator i = list.begin(); while (i != list.end()) { rspfRefPtr<rspfProperty> prop = acc.getProperty( (*i) ); if (prop.valid()) { propList.push_back(prop); } ++i; } box->addChildren(propList); result = box; } } } } } } return result; }
ossimPlanetTextureLayerStateCode ossimPlanetDtedElevationDatabase::open(const std::string& location) { ossimElevManager::ConnectionStringVisitor visitor(location); ossimElevManager::instance()->accept(visitor); //std::cout << "DATABASE ==== " << (visitor.getElevationDatabase()?visitor.getElevationDatabase()->getConnectionString():"NOT FOUND") << std::endl; ossimFilename file(location); bool result = false; theLocation = ""; theExtents = new ossimPlanetExtents; ossim_uint32 count = 0; ossim_uint32 maxCount = 25; if(file.exists()) { if(file.isDir()) { ossimDirectory dir; if(dir.open(file)) { ossimFilename testFile; if(dir.getFirst(testFile)) { ++count; do { ossimRegExp eastern; ossimRegExp western; ossimRegExp easternUp; ossimRegExp westernUp; eastern.compile("e[0-9][0-9][0-9]"); western.compile("w[0-9][0-9][0-9]"); easternUp.compile("E[0-9][0-9][0-9]"); westernUp.compile("W[0-9][0-9][0-9]"); if(testFile.isDir()) { if(eastern.find(testFile.c_str())|| western.find(testFile.c_str())|| easternUp.find(testFile.c_str())|| westernUp.find(testFile.c_str())) { result = true; } if(result) { result = false; // now find a North South file ossimDirectory dirNS; dirNS.open(testFile); if(dirNS.getFirst(testFile)) { do { std::ifstream in; in.open(testFile.c_str(), std::ios::binary|std::ios::in); if(!in.fail()) { ossimDtedVol vol(in); ossimDtedHdr hdr(in); ossimDtedUhl uhl(in); ossimDtedDsi dsi(in); ossimDtedAcc acc(in); if(uhl.getErrorStatus() != ossimErrorCodes::OSSIM_ERROR) { double metersPerPixel = ossimGpt().metersPerDegree().y*uhl.latInterval(); dirtyExtents(); // make sure parents are marked as dirty if(fabs(metersPerPixel - (ossimGpt().metersPerDegree().y *(30.0/3600))) < .25) // 30 arc { setName("DTED0"); setDescription("DTED 1 kilometer elevation database"); theExtents->setMinMaxScale(metersPerPixel, metersPerPixel*std::pow(2.0, 6)); } else if(fabs(metersPerPixel - (ossimGpt().metersPerDegree().y *(3.0/3600))) < .25) // 3 arc { setName("DTED1"); setDescription("DTED 90 meter elevation database"); theExtents->setMinMaxScale(metersPerPixel, metersPerPixel*std::pow(2.0, 8)); } else if(fabs(metersPerPixel - (ossimGpt().metersPerDegree().y *(1.0/3600))) < .25) // 1 arc { setName("DTED2"); setDescription("DTED 30 meter elevation database"); theExtents->setMinMaxScale(metersPerPixel, metersPerPixel*std::pow(2.0, 10)); } else { setName("DTED"); setDescription("DTED elevation database"); theExtents->setMinMaxScale(metersPerPixel, metersPerPixel*std::pow(2.0, 12)); } result = true; } } }while(dirNS.getNext(testFile)&&(!result)); } } } }while(dir.getNext(testFile)&&(!result)&&(count < maxCount)); } } } } theOpenFlag = result; if(theOpenFlag) { theStateCode = ossimPlanetTextureLayer_VALID; theLocation = location; } else { theStateCode = ossimPlanetTextureLayer_NO_SOURCE_DATA; } return theStateCode; }
static void CB_MouseUp(s32 x,s32 y) { TRomSetState *pCurRomSetState=&RomSetState; if(isInsideRect(menurect11,x,y)==true) { } if(isInsideRect(menurect12,x,y)==true) { } if(isInsideRect(menurect13,x,y)==true) { } if(isInsideRect(menurect14,x,y)==true) { } if(isInsideRect(menurect16,x,y)==true) { if(pCurRomSetState->CheatState) { isPressRect16=false; DSIdx=dsi(); strcpy(CheatRomInfo.FullPathAlias,RomSetInfo.FullPathAlias); memcpy(&RomSetStateTmp,&RomSetState,sizeof(TRomSetState)); SetFlag(); { strcpy(pNDSAlis,CheatRomInfo.FullPathAlias); if(isHomeBrew() == true) { //do nothing } else {//商业ROM启动代码 //打开金手指窗口 if(isUserCheatDataExits()) { NDSCheatInfo *pInfo=FindSelectNDSCheatHeadInfo(); if(pInfo) { safefree(pInfo); isPressRect16=false; SetNextProc(ENP_Cheat,EPFE_CrossFade); } } else isPressRect16=true; } } } } if(isInsideRect(menurect00,x,y)==true) { isPressA=false; CloseRomData(); CB_CancelBtn_Click(NULL); } if(isInsideRect(menurect01,x,y)==true) { isPressB=false; CB_CancelBtn_Click(NULL); } }
static void CB_KeyPress(u32 VsyncCount,u32 Keys) { TRomSetState *pCurRomSetState=&RomSetState; if((Keys&KEY_A)!=0){ isPressA=true; CloseRomData(); CB_CancelBtn_Click(NULL); } if((Keys&KEY_B)!=0){ isPressB=true; CB_CancelBtn_Click(NULL); } if((Keys&(KEY_LEFT|KEY_RIGHT|KEY_UP|KEY_DOWN))!=0){ if((Keys&KEY_LEFT)!=0) { switch(ItemIdx) { case 0: { if(pCurRomSetState->SoftReset) pCurRomSetState->SoftReset=false; else pCurRomSetState->SoftReset=true; }break; case 1: { if(pCurRomSetState->RealtimeSave) pCurRomSetState->RealtimeSave=false; else pCurRomSetState->RealtimeSave=true; }break; case 2: { if(pCurRomSetState->GameGuide) pCurRomSetState->GameGuide=false; else pCurRomSetState->GameGuide=true; }break; case 3: { if(pCurRomSetState->CheatState) pCurRomSetState->CheatState=false; else pCurRomSetState->CheatState=true; }break; case 4: { if(pCurRomSetState->DownloadPlayState) pCurRomSetState->DownloadPlayState=false; else pCurRomSetState->DownloadPlayState=true; }break; case 5: { if(pCurRomSetState->SpeciaMode) pCurRomSetState->SpeciaMode=false; else pCurRomSetState->SpeciaMode=true; }break; default: break; } } if((Keys&KEY_RIGHT)!=0) { switch(ItemIdx) { case 0: { if(pCurRomSetState->SoftReset) pCurRomSetState->SoftReset=false; else pCurRomSetState->SoftReset=true; }break; case 1: { if(pCurRomSetState->RealtimeSave) pCurRomSetState->RealtimeSave=false; else pCurRomSetState->RealtimeSave=true; }break; case 2: { if(pCurRomSetState->GameGuide) pCurRomSetState->GameGuide=false; else pCurRomSetState->GameGuide=true; }break; case 3: { if(pCurRomSetState->CheatState) pCurRomSetState->CheatState=false; else pCurRomSetState->CheatState=true; }break; case 4: { if(pCurRomSetState->DownloadPlayState) pCurRomSetState->DownloadPlayState=false; else pCurRomSetState->DownloadPlayState=true; }break; case 5: { if(pCurRomSetState->SpeciaMode) pCurRomSetState->SpeciaMode=false; else pCurRomSetState->SpeciaMode=true; }break; default: break; } } if((Keys&KEY_DOWN)!=0) { if(ItemIdx==4) ItemIdx=5; if(ItemIdx==3) ItemIdx=4; if(ItemIdx==2) ItemIdx=3; if(ItemIdx==1) ItemIdx=2; if(ItemIdx==0) ItemIdx=1; } if((Keys&KEY_UP)!=0) { if(ItemIdx==1) ItemIdx=0; if(ItemIdx==2) ItemIdx=1; if(ItemIdx==3) ItemIdx=2; if(ItemIdx==4) ItemIdx=3; if(ItemIdx==5) ItemIdx=4; } } if((Keys&KEY_Y)!=0){ if(pCurRomSetState->CheatState) { isPressRect16=false; DSIdx=dsi(); strcpy(CheatRomInfo.FullPathAlias,RomSetInfo.FullPathAlias); memcpy(&RomSetStateTmp,&RomSetState,sizeof(TRomSetState)); SetFlag(); { strcpy(pNDSAlis,CheatRomInfo.FullPathAlias); if(isHomeBrew() == true) { //do nothing } else {//商业ROM启动代码 //打开金手指窗口 if(isUserCheatDataExits()) { NDSCheatInfo *pInfo=FindSelectNDSCheatHeadInfo(); if(pInfo) { safefree(pInfo); SetNextProc(ENP_Cheat,EPFE_CrossFade); } } } } } } }