void Notebook::selectPage(int n) { if(pages.size()>0 && n>=0 && n<(int)pages.size() && n!=selected) { NotebookPage *np; if(selected>=0) { np = (NotebookPage *)pages[selected]; if(event_handler) event_handler(this,NOTEBOOK_PAGE_HIDE,(intptr_t)np->page,np->tab.index,(intptr_t)np->tab.name); #ifdef USE_WIN32 np->page->hide(); #endif } #ifdef USE_GTK debug_output("Notebook::selectPage((index: %d)\n",n); np = (NotebookPage *)pages[n]; if(event_handler) event_handler(this,NOTEBOOK_PAGE_SHOW,(intptr_t)np->page,np->tab.index,(intptr_t)np->tab.name); gtk_notebook_set_current_page(GTK_NOTEBOOK(component),n); selected = n; #endif #ifdef USE_WIN32 if(type==WIDGET_NOTEBOOK) TabCtrl_SetCurSel((HWND)component,n); np = (NotebookPage *)pages[n]; debug_output("Notebook::selectPage(action: %d, tab: %s, width: %ld, height: %ld)\n",NOTEBOOK_PAGE_SHOW,np->tab.name,client.right-client.left,client.bottom-client.top); selected = n; ShowWindow((HWND)np->page->getComponent(),SW_SHOW); if(np->status==1) { makeLayout(client.left,client.top,client.right-client.left,client.bottom-client.top); np->page->move(); np->status = 0; } // BringWindowToTop((HWND)np->page->component); // InvalidateRect((HWND)np->page->component,0,false); // UpdateWindow((HWND)np->page->component); if(event_handler) event_handler(this,NOTEBOOK_PAGE_SHOW,(intptr_t)np->page,np->tab.index,(intptr_t)np->tab.name); #endif } }
inline bool encode(const char *data, uint32_t dataSize, const std::string& outFile, const std::string& pass, bool isOffice2013, const std::string& masterKey, int spinCount) { std::string encryptedPackage; ms::EncryptionInfo info; const cybozu::crypto::Cipher::Name cipherName = isOffice2013 ? cybozu::crypto::Cipher::N_AES256_CBC : cybozu::crypto::Cipher::N_AES128_CBC; const cybozu::crypto::Hash::Name hashName = isOffice2013 ? cybozu::crypto::Hash::N_SHA512 : cybozu::crypto::Hash::N_SHA1; encode_in(encryptedPackage, info, std::string(data, dataSize), cipherName, hashName, spinCount, pass, masterKey); const std::string encryptionInfoStr = info.addHeader(info.toXml(isOffice2013)); dprintf("encryptionInfoStr size=%d\n", (int)encryptionInfoStr.size()); ms::cfb::CompoundFile cfb; ms::makeDataSpace(cfb.dirs, encryptedPackage, encryptionInfoStr); std::string outData; makeLayout(outData, cfb); { std::ofstream ofs(outFile.c_str(), std::ios::binary); ofs.write(outData.c_str(), outData.size()); if (!ofs) throw cybozu::Exception("ms:encode:write") << outData; } return true; }
int main (int argc, char** argv) { #ifdef CH_MPI MPI_Init(&argc,&argv); #endif // Begin forever present scoping trick { const char* in_file = "plane.inputs"; if (argc > 1) { in_file = argv[1]; } // Parse input file ParmParse pp(0,NULL,NULL,in_file); Box domain; RealVect origin; Real dx; BaseIF* implicit; // Make geometry implicit = makeGeometry(domain,origin,dx); // Make grids DisjointBoxLayout grids; makeLayout(grids,domain); // Create ebislayout int nghost = 0; EBISLayout ebisl; makeEBISL(ebisl,grids,domain,nghost); // Make a LevelData int nComps = 1; IntVect ghost = IntVect::Unit; ghost *= nghost; RefCountedPtr<DataFactory<EBCellFAB> > rcpFactory(new EBCellFactory(ebisl)); LevelData<EBCellFAB> level(grids,nComps,ghost,*rcpFactory); // Put some data in the data holders fillData(level,origin,dx,*implicit); // Done with this object delete implicit; // Write the data and the EB out const char* basename = "plane"; char name[1000]; sprintf(name,"%s%dd.hdf5",basename,SpaceDim); #ifdef CH_USE_HDF5 writeEBLevelname(&level,name); #endif } // End scoping trick // Clean up EBIndexSpace* ebisPtr = Chombo_EBIS::instance(); ebisPtr->clear(); CH_TIMER_REPORT(); #ifdef CH_MPI MPI_Finalize(); #endif return 0; }
int checkIrregFabCopy(const Box& a_domain) { int eekflag = 0; int nvar = 1; Interval interv(0,0); int nghost= 0; IntVect ivgh= IntVect::Zero; Real tolerance = PolyGeom::getTolerance(); const EBIndexSpace* const ebisPtr = Chombo_EBIS::instance(); int numlevels = ebisPtr->numLevels(); Box levelDomain = a_domain; for (int ilev = 0; ilev < numlevels-1; ilev++) { DisjointBoxLayout dblOne, dblTwo; int maxsizeOne = 4; int maxsizeTwo = 2; makeLayout(dblOne, levelDomain, maxsizeOne); makeLayout(dblTwo, levelDomain, maxsizeTwo); EBISLayout ebislOne, ebislTwo; makeEBISL(ebislOne, dblOne, levelDomain, nghost); makeEBISL(ebislTwo, dblTwo, levelDomain, nghost); LayoutData<IntVectSet> ldIVSOne(dblOne); LayoutData<IntVectSet> ldIVSTwo(dblTwo); for (DataIterator dit = dblOne.dataIterator(); dit.ok(); ++dit) ldIVSOne[dit()] = IntVectSet(dblOne.get(dit())); for (DataIterator dit = dblTwo.dataIterator(); dit.ok(); ++dit) ldIVSTwo[dit()] = IntVectSet(dblTwo.get(dit())); BaseIVFactory<Real> factOne(ebislOne, ldIVSOne); BaseIVFactory<Real> factTwo(ebislTwo, ldIVSTwo); LevelData<BaseIVFAB<Real> > dataOne(dblOne, nvar, ivgh, factOne); LevelData<BaseIVFAB<Real> > dataTwo(dblTwo, nvar, ivgh, factTwo); for (DataIterator dit = dblOne.dataIterator(); dit.ok(); ++dit) dataOne[dit()].setVal(1); for (DataIterator dit = dblTwo.dataIterator(); dit.ok(); ++dit) dataTwo[dit()].setVal(2); //copy dataone into datatwo. then all datatwo should hold are ones dataOne.copyTo(interv, dataTwo, interv); Real rightVal = 1.0; for (DataIterator dit = dblTwo.dataIterator(); dit.ok(); ++dit) { const EBISBox& ebisBox = ebislTwo[dit()]; const IntVectSet& ivs = ldIVSTwo[dit()]; const BaseIVFAB<Real>& fab = dataTwo[dit()]; for (VoFIterator vofit(ivs, ebisBox.getEBGraph()); vofit.ok(); ++vofit) { Real thisVal = fab(vofit(), 0); if (Abs(thisVal - rightVal) > tolerance) { eekflag = 3; return eekflag; } } } levelDomain.coarsen(2); } return eekflag; }
int main(int argc, char** argv) { #ifdef CH_MPI MPI_Init(&argc, &argv); #endif //begin forever present scoping trick { const char* in_file = "ramp.inputs"; //parse input file ParmParse pp(0,NULL,NULL,in_file); int eekflag = 0; //define the geometry object. //need the new and delete because of //strong construction //make the gometry. this makes the first Chombo_EBIS Box domain; Real dx; RealVect origin; int upDir; int indepVar; Real startPt; Real slope; //and defines it using a geometryservice eekflag = makeGeometry(domain, dx, origin, upDir, indepVar, startPt, slope); if (eekflag != 0) { pout() << "non zero eek detected = " << eekflag << endl; MayDay::Error("problem in makeGeometry"); } //make grids DisjointBoxLayout grids; eekflag = makeLayout(grids, domain); if (eekflag != 0) { pout() << "non zero eek detected = " << eekflag << endl; MayDay::Error("problem in makeLayouts"); } ///create ebislayout int nghost = 2; EBISLayout ebisl; eekflag = makeEBISL(ebisl, grids, domain, nghost); if (eekflag != 0) { pout() << "non zero eek detected = " << eekflag << endl; MayDay::Error("problem in makeEBISL"); } //check everything i can think of on finest level eekflag = checkEBISL(ebisl, grids, domain, dx, origin, upDir, indepVar, startPt, slope); if (eekflag != 0) { pout() << "non zero eek detected = " << eekflag << endl; MayDay::Error("problem in checkEBISL"); } pout() << "ramp test passed" << endl; }//end scoping trick EBIndexSpace* ebisPtr = Chombo_EBIS::instance(); ebisPtr->clear(); #ifdef CH_MPI MPI_Finalize(); #endif return 0; }
int main (int argc, char** argv) { #ifdef CH_MPI MPI_Init(&argc,&argv); #endif // begin forever present scoping trick { const char* in_file = "impFuncTest.inputs"; // parse input file ParmParse pp(0,NULL,NULL,in_file); RealVect center; Real radius; bool insideRegular; RealVect origin; Real dx; Box domain; int eekflag = 0; // make geometry eekflag = makeGeometry(domain, dx, origin, center, radius, insideRegular); if (eekflag != 0) { pout() << "non zero eek detected = " << eekflag << endl; MayDay::Error("problem in makeGeometry"); } // make grids DisjointBoxLayout grids; eekflag = makeLayout(grids,domain); if (eekflag != 0) { pout() << "non zero eek detected = " << eekflag << endl; MayDay::Error("problem in makeLayouts"); } // create ebislayout int nghost = 2; EBISLayout ebisl; eekflag = makeEBISL(ebisl,grids,domain,nghost); // make a LevelData int nComps = 2; IntVect ghost = IntVect::Unit; ghost *= nghost; RefCountedPtr<DataFactory<EBCellFAB> > rcpFactory(new EBCellFactory(ebisl)); LevelData<EBCellFAB> level(grids,nComps,ghost,*rcpFactory); // writeEBLevelname(&level,"level.hdf5"); if (eekflag != 0) { pout() << "non zero eek detected = " << eekflag << endl; MayDay::Error("problem in makeEBISL"); } // check volume and surface area of approximate sphere eekflag = checkEBISL(ebisl, grids, domain, dx, origin, radius, center, insideRegular); if (eekflag != 0) { pout() << "non zero eek detected = " << eekflag << endl; MayDay::Error("problem in checkEBISL"); } pout() << "implicit function test passed" << endl; } // end scoping trick CH_XD::EBIndexSpace* ebisPtr = Chombo_EBIS::instance(); ebisPtr->clear(); #ifdef CH_MPI MPI_Finalize(); #endif return 0; }
int main(int argc, char** argv) { #ifdef CH_MPI MPI_Init(&argc, &argv); #endif int eekflag = 0; {//begin forever present scoping trick const char* in_file = "ramp.inputs"; //parse input file ParmParse pp(0,NULL,NULL,in_file); //define the geometry object. //need the new and delete because of //strong construction //make the gometry. this makes the first Chombo_EBIS Box domainFine, domainCoar; Real dxFine, dxCoar; //and defines it using a geometryservice eekflag = makeGeometry(domainFine, dxFine); CH_assert(eekflag == 0); domainCoar = coarsen(domainFine, 2); dxCoar = 2.0*dxFine; //make grids DisjointBoxLayout gridsFine, gridsCoar; eekflag = makeLayout(gridsFine, domainFine); CH_assert(eekflag == 0); coarsen(gridsCoar, gridsFine, 2); ///create ebislayout int nghost = 2; EBISLayout ebislFine, ebislCoar; eekflag = makeEBISL(ebislFine, gridsFine, domainFine, nghost); if (eekflag != 0) return eekflag; eekflag = makeEBISL(ebislCoar, gridsCoar, domainCoar, nghost); if (eekflag != 0) return eekflag; int nvar = 1; EBCellFactory ebcellfactFine(ebislFine); EBCellFactory ebcellfactCoar(ebislCoar); IntVect ivghost = nghost*IntVect::Unit; LevelData<EBCellFAB> errorFine(gridsFine, nvar, ivghost,ebcellfactFine); LevelData<EBCellFAB> errorCoar(gridsCoar, nvar, ivghost,ebcellfactCoar); eekflag = getError(errorFine,ebislFine, gridsFine, domainFine, dxFine); if (eekflag != 0) return eekflag; eekflag = getError(errorCoar,ebislCoar, gridsCoar, domainCoar, dxCoar); if (eekflag != 0) return eekflag; eekflag = compareError(errorFine, ebislFine, gridsFine, domainFine, errorCoar, ebislCoar, gridsCoar, domainCoar); if (eekflag != 0) return eekflag; }//end omnipresent scoping trick EBIndexSpace* ebisPtr = Chombo_EBIS::instance(); ebisPtr->clear(); if (eekflag == 0) { pout() << "aggpwlfpTest passed" << endl; } #ifdef CH_MPI MPI_Finalize(); #endif return eekflag; }