//------------------------------------------------------------------------------ GroundTrackPlotPanel::GroundTrackPlotPanel(wxWindow *parent, const wxString &subscriberName) : GmatPanel(parent) { #if DEBUG_PANEL MessageInterface::ShowMessage("GroundTrackPlotPanel() entering...\n"); MessageInterface::ShowMessage("GroundTrackPlotPanel() subscriberName = " + std::string(subscriberName.c_str()) + "\n"); #endif Subscriber *subscriber = (Subscriber*) theGuiInterpreter->GetConfiguredObject(subscriberName.c_str()); mGroundTrackPlot = (GroundTrackPlot*)subscriber; // Set the pointer for the "Show Script" button mObject = mGroundTrackPlot; InitializeData(); Create(); Show(); // Listen for Spacecraft name change theGuiManager->AddToResourceUpdateListeners(this); }
HRESULT CTextObject::InitializeData(const FORMATETC* pFormatEtc, STGMEDIUM* pMedium, bool bGetDataHere) { if (pFormatEtc->lindex != -1) return DV_E_LINDEX; if (pFormatEtc->dwAspect != DVASPECT_CONTENT) return DV_E_DVASPECT; const void* pData; int nDataSize; switch (pFormatEtc->cfFormat) { case CF_TEXT: { PCSTR pszText = GetAnsiObjectText(); if (pszText == NULL) return E_OUTOFMEMORY; pData = pszText; nDataSize = (int)(strlen(pszText) + 1) * sizeof(CHAR); } break; case CF_UNICODETEXT: { PCWSTR pszText = GetWideObjectText(); if (pszText == NULL) return E_OUTOFMEMORY; pData = pszText; nDataSize = (int)(wcslen(pszText) + 1) * sizeof(WCHAR); } break; default: return DV_E_FORMATETC; } return (bGetDataHere ? InitializeDataHere(pMedium, pData, nDataSize) : InitializeData(pFormatEtc->tymed, pMedium, pData, nDataSize)); }
void NzTerrainNode::Initialize(nzTerrainNodeData *data, NzTerrainNode* parent, const NzPatch& parentPatch, nzNodeLocation location) { InitializeData(data,parent,location); m_patch = NzDynaTerrain::GetTerrainPatch(); m_patch->InitializeFromParent(m_nodeID,m_data,parentPatch); m_aabb = m_patch->GetAABB(); m_patch->UploadMesh(); }
int CComboColorPicker::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CComboBox::OnCreate(lpCreateStruct) == -1) return -1; InitializeData(); return 0; }
BOOL TransitionData::InitializeOutTransition(CString& strTransitionDataUUID) { if (InitializeData(TRANSITIONDATAOUT)) { strTransitionDataUUID = m_strUUID; m_eTransitionType = DISSOLVE; return TRUE; } return FALSE; }
void CriminisiInpainting::Initialize() { try { InitializeMask(); if(this->DebugImages) { Helpers::WriteImage<Mask>(this->CurrentMask, "Debug/Initialize.CurrentMask.mha"); } InitializeImage(); if(this->DebugImages) { Helpers::WriteImage<FloatVectorImageType>(this->CurrentImage, "Debug/Initialize.CurrentImage.mha"); } // Do this before we mask the image with the expanded mask ComputeIsophotes(); if(this->DebugImages) { Helpers::WriteImage<FloatVector2ImageType>(this->IsophoteImage, "Debug/Initialize.IsophoteImage.mha"); } InitializeData(); if(this->DebugImages) { Helpers::WriteImage<FloatScalarImageType>(this->DataImage, "Debug/Initialize.DataImage.mha"); } InitializePriority(); if(this->DebugImages) { Helpers::WriteImage<FloatScalarImageType>(this->PriorityImage, "Debug/Initialize.PriorityImage.mha"); } InitializeConfidence(); if(this->DebugImages) { Helpers::WriteImage<FloatScalarImageType>(this->ConfidenceImage, "Debug/Initialize.ConfidenceImage.mha"); } // Debugging outputs //WriteImage<TImage>(this->Image, "InitialImage.mhd"); //WriteImage<UnsignedCharImageType>(this->Mask, "InitialMask.mhd"); //WriteImage<FloatImageType>(this->ConfidenceImage, "InitialConfidence.mhd"); //WriteImage<VectorImageType>(this->IsophoteImage, "InitialIsophotes.mhd"); } catch( itk::ExceptionObject & err ) { std::cerr << "ExceptionObject caught in Initialize!" << std::endl; std::cerr << err << std::endl; exit(-1); } }
int main(int argc,char **argv) { PetscErrorCode ierr; /* used to check for functions returning nonzeros */ Vec x, f; /* solution, function */ Mat J; /* Jacobian matrix */ Tao tao; /* Tao solver context */ PetscInt i; /* iteration information */ PetscReal hist[100],resid[100]; PetscInt lits[100]; AppCtx user; /* user-defined work context */ PetscInitialize(&argc,&argv,(char *)0,help); /* Allocate vectors */ ierr = VecCreateSeq(MPI_COMM_SELF,NPARAMETERS,&x);CHKERRQ(ierr); ierr = VecCreateSeq(MPI_COMM_SELF,NOBSERVATIONS,&f);CHKERRQ(ierr); /* Create the Jacobian matrix. */ ierr = MatCreateSeqDense(MPI_COMM_SELF,NOBSERVATIONS,NPARAMETERS,NULL,&J);CHKERRQ(ierr); for (i=0;i<NOBSERVATIONS;i++) user.idm[i] = i; for (i=0;i<NPARAMETERS;i++) user.idn[i] = i; /* Create TAO solver and set desired solution method */ ierr = TaoCreate(PETSC_COMM_SELF,&tao);CHKERRQ(ierr); ierr = TaoSetType(tao,TAOPOUNDERS);CHKERRQ(ierr); /* Set the function and Jacobian routines. */ ierr = InitializeData(&user);CHKERRQ(ierr); ierr = FormStartingPoint(x);CHKERRQ(ierr); ierr = TaoSetInitialVector(tao,x);CHKERRQ(ierr); ierr = TaoSetSeparableObjectiveRoutine(tao,f,EvaluateFunction,(void*)&user);CHKERRQ(ierr); ierr = TaoSetJacobianRoutine(tao, J, J, EvaluateJacobian, (void*)&user);CHKERRQ(ierr); /* Check for any TAO command line arguments */ ierr = TaoSetFromOptions(tao);CHKERRQ(ierr); ierr = TaoSetConvergenceHistory(tao,hist,resid,0,lits,100,PETSC_TRUE);CHKERRQ(ierr); /* Perform the Solve */ ierr = TaoSolve(tao);CHKERRQ(ierr); ierr = TaoView(tao,PETSC_VIEWER_STDOUT_SELF);CHKERRQ(ierr); /* Free TAO data structures */ ierr = TaoDestroy(&tao);CHKERRQ(ierr); /* Free PETSc data structures */ ierr = VecDestroy(&x);CHKERRQ(ierr); ierr = VecDestroy(&f);CHKERRQ(ierr); ierr = MatDestroy(&J);CHKERRQ(ierr); PetscFinalize(); return 0; }
void CComboColorPicker::PreSubclassWindow() { InitializeData(); // set item height CDC *pDC = GetDC(); CSize sizeAutoText = pDC->GetTextExtent( CString( _T("default") ) ); SetItemHeight( 0, sizeAutoText.cy + 4 ); SetItemHeight( -1, sizeAutoText.cy + 4 ); CComboBox::PreSubclassWindow(); }
int main(int argc,char **argv) { PetscErrorCode ierr; /* used to check for functions returning nonzeros */ Vec x, f; /* solution, function */ Tao tao; /* Tao solver context */ AppCtx user; /* user-defined work context */ /* Initialize TAO and PETSc */ PetscInitialize(&argc,&argv,(char *)0,help); MPI_Comm_size(MPI_COMM_WORLD,&user.size); MPI_Comm_rank(MPI_COMM_WORLD,&user.rank); ierr = InitializeData(&user);CHKERRQ(ierr); /* Run optimization on rank 0 */ if (user.rank == 0) { /* Allocate vectors */ ierr = VecCreateSeq(PETSC_COMM_SELF,NPARAMETERS,&x);CHKERRQ(ierr); ierr = VecCreateSeq(PETSC_COMM_SELF,NOBSERVATIONS,&f);CHKERRQ(ierr); /* TAO code begins here */ /* Create TAO solver and set desired solution method */ ierr = TaoCreate(PETSC_COMM_SELF,&tao);CHKERRQ(ierr); ierr = TaoSetType(tao,TAOPOUNDERS);CHKERRQ(ierr); /* Set the function and Jacobian routines. */ ierr = FormStartingPoint(x);CHKERRQ(ierr); ierr = TaoSetInitialVector(tao,x);CHKERRQ(ierr); ierr = TaoSetSeparableObjectiveRoutine(tao,f,EvaluateFunction,(void*)&user);CHKERRQ(ierr); /* Check for any TAO command line arguments */ ierr = TaoSetFromOptions(tao);CHKERRQ(ierr); /* Perform the Solve */ ierr = TaoSolve(tao);CHKERRQ(ierr); /* Free TAO data structures */ ierr = TaoDestroy(&tao);CHKERRQ(ierr); /* Free PETSc data structures */ ierr = VecDestroy(&x);CHKERRQ(ierr); ierr = VecDestroy(&f);CHKERRQ(ierr); StopWorkers(&user); } else { TaskWorker(&user); } PetscFinalize(); return 0; }
// Performs Completion phase of EMV transaction // Source: VIS 1.4.0, ch 14, Figure 13-1. int Completion::completeTransaction(TERMINAL_RESPONSE *term_resp) { int res; byte cid = 0; byte cd = 0; CRYPTOGRAM_TYPE FinalDecision; bool AdviceNeeded = false; if ((res = InitializeData()) == SUCCESS) { cid = dob_CID.Data [0]; cd = cid >> 6; if (cd == AAC || cd == TC) res = complete_No2GAC(dob_CID.Data[0], &FinalDecision, &AdviceNeeded); else res = complete_2GAC(dob_CID.Data[0], &FinalDecision, &AdviceNeeded); }
BOOL CDlg_Options::OnInitDialog() { CDialog::OnInitDialog(); InitializeData (); FillPagesList (); GetDlgItem (IDC__DLGCAPTION)->ShowWindow (SW_HIDE); GetDlgItem (IDC__DLGFRAME)->ShowWindow (SW_HIDE); SetDlgItemText (IDCANCEL, LS (L_CANCEL)); return TRUE; }
UINT DexpotMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section) { if (InstanceCount == 0) { hWndRainmeterControl = FindWindow(_T("DummyRainWClass"), _T("Rainmeter control window")); hWndMessageWindow = CreateMessageWindow(); } InstanceCount++; if (!PluginRegistered && FindDexpotWindow()) { SendNotifyMessage(hWndDexpot, DEX_REGISTERPLUGIN, 0, (LPARAM) hWndMessageWindow); CurrentDesktop = (int) SendMessage(hWndDexpot, DEX_GETCURRENTDESKTOP, 0, 0); PluginRegistered = TRUE; } InitializeData(); DexpotMeasures.insert(this); return 0; }
//------------------------------------------------------------------------------ void GroundTrackPlotPanel::ObjectNameChanged(Gmat::ObjectType type, const wxString &oldName, const wxString &newName) { #ifdef DEBUG_RENAME MessageInterface::ShowMessage ("GroundTrackPlotPanel::ObjectNameChanged() type=%d, oldName=<%s>, " "newName=<%s>, mDataChanged=%d\n", type, oldName.c_str(), newName.c_str(), mDataChanged); #endif if (type != Gmat::SPACECRAFT) return; // Initialize GUI data and re-load from base InitializeData(); LoadData(); // We don't need to save data if object name changed from the resouce tree // while this panel is opened, since base code already has new name EnableUpdate(false); }
BOOL CDlg_Options::OnInitDialog() { CDialog::OnInitDialog(); InitializeData (); FillPagesList (); GetDlgItem (IDC__DLGCAPTION)->ShowWindow (SW_HIDE); GetDlgItem (IDC__DLGFRAME)->ShowWindow (SW_HIDE); SetDlgItemText (IDCANCEL, LS (L_CANCEL)); OSVERSIONINFO ver = {0}; ver.dwOSVersionInfoSize = sizeof (ver); GetVersionEx (&ver); if (ver.dwMajorVersion > 5) SetTimer (1, 300, NULL); return TRUE; }
void NzTerrainNode::Initialize(nzTerrainNodeData *data, NzTerrainNode* parent, nzNodeLocation location) { InitializeData(data,parent,location); CreatePatch(); }
int main(int argc,char **argv) { Userctx user; Vec p; PetscScalar *x_ptr; PetscErrorCode ierr; PetscMPIInt size; PetscInt i,numDataBuses; KSP ksp; PC pc; Tao tao; TaoConvergedReason reason; Vec lowerb,upperb; PetscViewer viewer; PetscScalar *proj_vec; //PetscLogDouble t0,t1; /* time the inversion process */ //ierr = PetscGetTime(&t0);CHKERRQ(ierr); ierr = PetscInitialize(&argc,&argv,"petscoptions",help);CHKERRQ(ierr); PetscFunctionBeginUser; ierr = MPI_Comm_size(PETSC_COMM_WORLD,&size);CHKERRQ(ierr); if (size > 1) SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_SUP,"Only for sequential runs"); ierr = ModelSetup(&user);CHKERRQ(ierr); /* hard code the data projection here - for now assume data at all buses */ ierr = VecCreateSeq(PETSC_COMM_WORLD,nbus,&user.proj);CHKERRQ(ierr); /*ierr = VecCreateSeq(PETSC_COMM_WORLD,4,&user.proj);CHKERRQ(ierr);*/ ierr = VecGetArray(user.proj,&proj_vec);CHKERRQ(ierr); for(i=0; i<nbus; i++) { proj_vec[i]=i; } srand( time(NULL) + rand () ); //VecView(user.proj, PETSC_VIEWER_STDOUT_WORLD); /* -- 2 5 6 8 */ /* -- proj_vec[0]=1; proj_vec[1]=4; proj_vec[2]=5; proj_vec[3]=7; */ ierr = VecRestoreArray(user.proj,&proj_vec);CHKERRQ(ierr); /* allocate/set the prior mean and its standard deviation */ ierr = PetscMalloc(3*sizeof(PetscScalar), &user.prior_mean); ierr = PetscMalloc(3*sizeof(PetscScalar), &user.prior_stddev); /*{23.64,6.4,3.01};*/ user.prior_mean[0] = 24.0; user.prior_mean[1] = 6.0; user.prior_mean[2] = 3.1; for(i=0; i<3; i++) user.prior_stddev[i] = user.prior_mean[i]*user.prior_noise; /* Create matrix to store solution */ if(user.saveSol) { ierr = MatCreateSeqDense(PETSC_COMM_SELF, user.neqs_pgrid+1, (PetscInt) round((user.tfinal-user.t0)/user.dt+1), NULL, &user.Sol); CHKERRQ(ierr); } printf("Num cols=%d\n", (PetscInt) round((user.tfinal-user.t0)/user.dt+1)); /* ********************************* * Generate/load observations **********************************/ ierr = VecGetSize(user.proj, &numDataBuses);CHKERRQ(ierr); /* Create matrix to save solutions at each time step */ ierr = MatCreateSeqDense(PETSC_COMM_SELF, 2*numDataBuses, //(PetscInt) round((user.tfinal-user.tdisturb)/user.data_dt)+1, (PetscInt) round((user.tfinal-user.trestore)/user.data_dt)+1, NULL, &user.obs); CHKERRQ(ierr); ierr = InitializeData(H0, &user, user.data_noise, user.data_dt);CHKERRQ(ierr); if(0==strlen(user.loadObsFile)) { /* save observations */ ierr = PetscViewerBinaryOpen(PETSC_COMM_SELF,"obs-perturbed.bin",FILE_MODE_WRITE,&viewer);CHKERRQ(ierr); ierr = MatView(user.obs,viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); printf("Observations generated.\n"); } if(user.saveSol) { ierr = PetscViewerBinaryOpen(PETSC_COMM_SELF,"out_pert.bin",FILE_MODE_WRITE,&viewer);CHKERRQ(ierr); ierr = MatView(user.Sol,viewer);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); ierr = MatDestroy(&user.Sol);CHKERRQ(ierr); CHKERRQ(ierr); } if(user.outputCov) { printf("The diagonal of the data noise covariance matrix (%g absolute noise) is:\n", user.data_noise); for(i=0; i<2*numDataBuses; i++) printf("%18.12f ", user.data_stddev[i]*user.data_stddev[i]); printf("\n"); printf("The prior mean is: "); for(i=0; i<3; i++) printf("%18.12f ", user.prior_mean[i]); printf("\n"); printf("The diagonal of the prior covariance matrix (%g relative noise) is:\n", user.prior_noise); for(i=0; i<3; i++) printf("%18.12f ", user.prior_stddev[i]*user.prior_stddev[i]); printf("\n"); goto finalize; } /* *************************************** * Optimization phase * ***************************************/ /* Create TAO solver and set desired solution method */ ierr = TaoCreate(PETSC_COMM_WORLD,&tao);CHKERRQ(ierr); ierr = TaoSetType(tao,TAOBLMVM);CHKERRQ(ierr); /* Optimization starts */ printf("Starting optimization...\n"); /* PetscScalar H_disturb[3]= {25.,6.4,3.01}; New inertia (after tdisturb) to be estimated */ /* Set initial solution guess */ ierr = VecCreateSeq(PETSC_COMM_WORLD,3,&p);CHKERRQ(ierr); ierr = VecGetArray(p,&x_ptr);CHKERRQ(ierr); //x_ptr[0] = H0[0]; x_ptr[1] = H0[1]; x_ptr[2] = H0[2]; x_ptr[0] = H0[0]*1.1; x_ptr[1] = H0[1]*1.1; x_ptr[2] = H0[2]*1.1; ierr = VecRestoreArray(p,&x_ptr);CHKERRQ(ierr); ierr = TaoSetInitialVector(tao,p);CHKERRQ(ierr); /* Set routine for function and gradient evaluation */ //ierr = TaoSetObjectiveRoutine(tao,FormFunction,(void *)&user);CHKERRQ(ierr); //ierr = TaoSetGradientRoutine(tao,TaoDefaultComputeGradient,(void *)&user);CHKERRQ(ierr); /* Sets the cost and gradient evaluation routine for minimization */ ierr = TaoSetObjectiveAndGradientRoutine(tao,FormFunctionGradient,&user);CHKERRQ(ierr); /* Set bounds for the optimization */ ierr = VecDuplicate(p,&lowerb);CHKERRQ(ierr); ierr = VecDuplicate(p,&upperb);CHKERRQ(ierr); ierr = VecGetArray(lowerb,&x_ptr);CHKERRQ(ierr); x_ptr[0] = 20.64; x_ptr[1] = 5.4; x_ptr[2] = 2.01; ierr = VecRestoreArray(lowerb,&x_ptr);CHKERRQ(ierr); ierr = VecGetArray(upperb,&x_ptr);CHKERRQ(ierr); x_ptr[0] = 25.64; x_ptr[1] = 7.4; x_ptr[2] = 4.01; ierr = VecRestoreArray(upperb,&x_ptr);CHKERRQ(ierr); ierr = TaoSetVariableBounds(tao,lowerb,upperb); /* Check for any TAO command line options */ ierr = TaoSetFromOptions(tao);CHKERRQ(ierr); ierr = TaoGetKSP(tao,&ksp);CHKERRQ(ierr); if (ksp) { ierr = KSPGetPC(ksp,&pc);CHKERRQ(ierr); ierr = PCSetType(pc,PCNONE);CHKERRQ(ierr); } //ierr = TaoSetTolerances(tao,1e-8,1e-6,1e-8,1e-6,1e-4); ierr = TaoSetTolerances(tao,1e-8,1e-8,1e-8,1e-8,1e-6); //ierr = TaoSetGradientTolerances(tao,1e-8, 1e-6, 1e-6); /* SOLVE the estimation problem */ ierr = TaoSolve(tao); CHKERRQ(ierr); /* Get information on termination */ printf("--- optimization done\n"); /* time the inversion process */ //ierr = PetscGetTime(&t1);CHKERRQ(ierr); //printf("elapsed_time %f seconds\n", t1 - t0); ierr = TaoGetConvergedReason(tao,&reason);CHKERRQ(ierr); if (reason <= 0){ ierr=PetscPrintf(MPI_COMM_WORLD, "Try another method! \n");CHKERRQ(ierr); } /*ierr = VecView(p,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);*/ ierr = VecGetArray(p,&x_ptr);CHKERRQ(ierr); printf("inertia-out: %.12f %.12f %.12f\n", x_ptr[0], x_ptr[1], x_ptr[2]); ierr = VecRestoreArray(p,&x_ptr);CHKERRQ(ierr); //ierr = EvaluateHessianFD(tao, p, &user);CHKERRQ(ierr); /* Free TAO data structures */ ierr = TaoDestroy(&tao);CHKERRQ(ierr); ierr = VecDestroy(&lowerb);CHKERRQ(ierr); ierr = VecDestroy(&upperb);CHKERRQ(ierr); finalize: ierr = MatDestroy(&user.obs);CHKERRQ(ierr); ierr = VecDestroy(&user.X0_disturb);CHKERRQ(ierr); ierr = PetscFree(user.data_stddev);CHKERRQ(ierr); PetscFree(user.prior_mean); PetscFree(user.prior_stddev); ierr = DMDestroy(&user.dmgen);CHKERRQ(ierr); ierr = DMDestroy(&user.dmnet);CHKERRQ(ierr); ierr = DMDestroy(&user.dmpgrid);CHKERRQ(ierr); ierr = ISDestroy(&user.is_diff);CHKERRQ(ierr); ierr = ISDestroy(&user.is_alg);CHKERRQ(ierr); ierr = MatDestroy(&user.J);CHKERRQ(ierr); ierr = MatDestroy(&user.Jacp);CHKERRQ(ierr); ierr = MatDestroy(&user.Ybus);CHKERRQ(ierr); ierr = VecDestroy(&user.V0);CHKERRQ(ierr); ierr = VecDestroy(&p);CHKERRQ(ierr); ierr = PetscFinalize(); return(0); }
STDMETHODIMP CTextObject::GetDataHere(FORMATETC* pFormatEtc, STGMEDIUM* pMedium) { if (pFormatEtc == NULL || pMedium == NULL) return E_INVALIDARG; return InitializeData(pFormatEtc, pMedium, true); }
int main(int argc, char *argv[]) { Entity et; int error, startupflags, i; char *restartname, name[128]; #ifdef PARALLEL const ParCommand end = EXIT; #endif InitVarTable(); #ifdef PARALLEL IsMaster(); if (master) { printf("MetPhoMod Rel. 2.2\n" SYSTEM " parallel Version - " DATE "\n\n"); #else printf("MetPhoMod Rel. 2.2\n" SYSTEM " sequential Version - " DATE "\n\n"); #endif if (argc > 1 && (!strcmp(argv[1], "-help") || !strcmp(argv[1], "-h"))) { McInterface::modmanager.Init1(); PrintHelp(argc - 2, argv + 2); exit (0); } if (argc > 1 && !strcmp(argv[1], "-genchem")) { if (argc != 3) goto instant_help; GenerateSpecialChem(argv[2]); exit (0); } startupflags = AnalizeOptions(&argc, argv, &restartname); if (argc != 2) { instant_help : printf("Usage : meteochem [-RESTART restart-file [-REOPEN]] [-noexcpt] [-syntax] \\\n" " [-nooutput] [-debug] [-sequential] inpfile\n" "or : meteochem (-h | -help) [keyword]\n" "or : meteochem -genchem chemfile\n"); return (1); } McInterface::modmanager.Init1(); if (startupflags & SYNTAX_ONLY) { if (ParseInput(argv[1])) { printf("Errors in Input-File\n"); return (1); } else { printf("the input-file seems to be OK!\n"); return (0); } } #ifdef PARALLEL if (startupflags & SEQUENTIAL) { parallel = FALSE; master = TRUE; leftest = rightest = TRUE; } } if (master) { #endif if (ParseInput(argv[1])) { fprintf(stderr, "Errors parsing Input-File. I don't start the calculation.\n"); return (1); } plausible = TRUE; if (!(startupflags & NOEXCPT)) InstallFpeHandler(); tinc = chemtinc = tincmax; actime = chemtime = tstart; #ifdef PARALLEL if (!parallel) printf("\n\n!!! Using sequential mode !!!\n\n"); else McInterface::modmanager.CheckIfReadyForParallel(); } InitializeWorkers(argv[0], startupflags & DEBUG_WORKERS); if (parallel && !master) { if (!(startupflags & NOEXCPT)) InstallFpeHandler(); McInterface::modmanager.Init1(); ReadDataFromMaster(); InitializeData(); plausible = TRUE; tinc = chemtinc = tincmax; actime = chemtime = tstart; } if (parallel && master) { printf("Sending Data to workers...\n"); SendDataToWorkers(); InitializeData(); } if (!parallel) #endif InitializeData(); for (et = maxentity; et--; ) if (g[et]) CalculateLayerAverage(g[et], pstat, avg+et*nz); else memset(avg+et*nz, 0, nz*sizeof(double)); CalcMeanHydrostaticPressure(); #ifdef PARALLEL if (!parallel || !master) { #endif SetAvgMountains(); SetBoundary(maxentity); /* CalcAllKm(); */ #ifdef PARALLEL } if (parallel && !master) { if (GetRestartName(name)) { if (!(ReadFullDump(name, (startupflags & REOPEN)) && actime <= tend)) { printf("Error : Restart-file not found\n"); plausible = FALSE; } } } else { if (parallel) SendRestartName((startupflags & RESTART) ? restartname : NULL); #endif if (startupflags & RESTART) { if (!ReadFullDump(restartname, (startupflags & REOPEN))) { printf("Error : Restart-file not found\n"); return (1); } } else if (startupflags & REOPEN) { printf("Error: -REOPEN can only be used together with -RESTART\n"); return (1); } #ifdef PARALLEL } if (master) { #endif if (!(startupflags & NO_OUTPUT)) { printf("Opening output-Files..."); if (OpenOutputFiles(argv[1], (startupflags & RESTART) && (startupflags & REOPEN))) { printf("\nExecution abortet\n"); exit (1); } CreateDomainFiles((startupflags & RESTART) && (startupflags & REOPEN)); } InstallSignalHandler(); printf("\n"); #ifdef PARALLEL if (parallel) printf("Starting calculation...\n"); } #else printf("Starting calculation...\n"); #endif #if PARALLEL if (!parallel || master) #endif if (!(startupflags & NO_OUTPUT)) { WriteOutData(tstart, FALSE); WriteToDomainFiles(tstart); } /* TestChemicals("Start"); */ #if PARALLEL if (parallel) if (master) MastersLoop(startupflags); else WorkersLoop(startupflags); else #endif SequentialLoop(startupflags); printf("Closing output-Files...\n"); if (plausible) printf("Calculation terminated successfully\n\n"); else { if (!(startupflags & NO_OUTPUT)) WriteOutData(actime, TRUE); printf("Calculation stopped because of inplausibilities!\n\n"); } if (!(startupflags & NO_OUTPUT)) { CloseOutputFiles(); CloseDomainFiles(); } #ifdef PARALLEL if (parallel) { pvm_initsend(PvmDataRaw); pvm_pkint((int *)&end, 1, 1); SendCommand(); pvm_exit(); } #endif return (0); }
void DexpotDesktopWallpaperMeasure::OnDesktopCountChanged(int NewCount) { InitializeData(); }
void DexpotDesktopWallpaperMeasure::OnDesktopConfigurationChanged() { InitializeData(); }
void DexpotDesktopNameMeasure::OnDesktopCountChanged(int NewCount) { InitializeData(); }
void DexpotDesktopNameMeasure::OnDesktopConfigurationChanged() { InitializeData(); }
int main(int argc,char **argv){ ProgData pdata; int exit_status = 0; SetupDefaultArgs(&pdata.args); if (!ParseArgs(argc, argv, &pdata.args)) { exit(1); } if (pdata.args.rescue_path != NULL) { exit(rmdRescue(pdata.args.rescue_path)); } if(XInitThreads ()==0){ fprintf(stderr,"Couldn't initialize thread support!\n"); exit(7); } if(pdata.args.display!=NULL){ pdata.dpy = XOpenDisplay(pdata.args.display); XSetErrorHandler(rmdErrorHandler); } else{ fprintf(stderr,"No display specified for connection!\n"); exit(8); } if (pdata.dpy == NULL) { fprintf(stderr, "Cannot connect to X server %s\n",pdata.args.display); exit(9); } else{ EncData enc_data; CacheData cache_data; #ifdef HAVE_LIBJACK JackData jdata; // Give jack access to program data, mainly for program state jdata.pdata = &pdata; pdata.jdata = &jdata; #endif // Query display specs pdata.specs.screen = DefaultScreen(pdata.dpy); pdata.specs.width = DisplayWidth(pdata.dpy, pdata.specs.screen); pdata.specs.height = DisplayHeight(pdata.dpy, pdata.specs.screen); pdata.specs.root = RootWindow(pdata.dpy, pdata.specs.screen); pdata.specs.visual = DefaultVisual(pdata.dpy, pdata.specs.screen); pdata.specs.gc = DefaultGC(pdata.dpy, pdata.specs.screen); pdata.specs.depth = DefaultDepth(pdata.dpy, pdata.specs.screen); if((pdata.specs.depth!=32)&& (pdata.specs.depth!=24)&& (pdata.specs.depth!=16)){ fprintf(stderr,"Only 32bpp,24bpp and 16bpp" " color depth modes are currently supported.\n"); exit(10); } if (!SetBRWindow(pdata.dpy, &pdata.brwin, &pdata.specs, &pdata.args)) exit(11); if( !pdata.args.nowmcheck && rmdWMIsCompositing( pdata.dpy, pdata.specs.screen ) ) { fprintf(stderr,"\nDetected compositing window manager.\n" "Reverting to full screen capture at every frame.\n" "To disable this check run with --no-wm-check\n" "(though that is not advised, since it will " "probably produce faulty results).\n\n"); pdata.args.full_shots=1; pdata.args.noshared=0; } QueryExtensions(pdata.dpy, &pdata.args, &pdata.damage_event, &pdata.damage_error, &pdata.shm_opcode); if((exit_status=InitializeData(&pdata,&enc_data,&cache_data))==0){ if(!strcmp(pdata.args.pause_shortcut, pdata.args.stop_shortcut)|| RegisterShortcut(pdata.dpy, pdata.specs.root, pdata.args.pause_shortcut, &(pdata.pause_key)) || RegisterShortcut(pdata.dpy, pdata.specs.root, pdata.args.stop_shortcut, &(pdata.stop_key))){ fprintf(stderr,"Invalid shortcut," " or shortcuts are the same!\n\n" "Using defaults.\n"); RegisterShortcut(pdata.dpy, pdata.specs.root, "Control+Mod1+p", &(pdata.pause_key)); RegisterShortcut(pdata.dpy, pdata.specs.root, "Control+Mod1+s", &(pdata.stop_key)); } //this is where the capturing happens. rmdThreads(&pdata); XCloseDisplay(pdata.dpy); fprintf(stderr,".\n"); //encode and then cleanup cache if(!pdata.args.encOnTheFly && !pdata.args.no_encode){ if (!pdata.aborted) { EncodeCache(&pdata); } fprintf(stderr,"Cleanning up cache...\n"); if(PurgeCache(pdata.cache_data,!pdata.args.nosound)) fprintf(stderr,"Some error occured " "while cleaning up cache!\n"); fprintf(stderr,"Done!!!\n"); } if (pdata.aborted && pdata.args.encOnTheFly) { if(remove(pdata.args.filename)){ perror("Error while removing file:\n"); return 1; } else{ fprintf(stderr,"SIGABRT received,file %s removed\n", pdata.args.filename); return 0; } } else fprintf(stderr,"Goodbye!\n"); CleanUp(); } } return exit_status; }
void LayerFCD::MakeAllLayers() { if (true) { LayerMRI* mri = m_mri_norm; if (m_layerSource) { mri->SetRefVolume(m_layerSource->GetSourceVolume()); } mri->SetName(GetName() + "_norm"); mri->SetFileName(m_fcd->mri_norm->fname); if ( mri->CreateFromMRIData((void*)m_fcd->mri_norm) ) { if (!m_layerSource) { m_layerSource = mri; InitializeData(); } } else { cerr << "Failed to create norm layer" << endl; delete mri; m_mri_norm = NULL; } } if (m_fcd->mri_flair) { LayerMRI* mri = m_mri_flair; if (m_layerSource) { mri->SetRefVolume(m_layerSource->GetSourceVolume()); } mri->SetName(GetName() + "_flair"); mri->SetFileName(m_fcd->mri_flair->fname); if ( !mri->CreateFromMRIData((void*)m_fcd->mri_flair) ) { delete m_mri_flair; m_mri_flair = NULL; } } else { delete m_mri_flair; m_mri_flair = NULL; } if (m_fcd->mri_t2) { LayerMRI* mri = m_mri_t2; if (m_layerSource) { mri->SetRefVolume(m_layerSource->GetSourceVolume()); } mri->SetName(GetName() + "_t2"); mri->SetFileName(m_fcd->mri_t2->fname); if ( !mri->CreateFromMRIData((void*)m_fcd->mri_t2) ) { delete m_mri_t2; m_mri_t2 = NULL; } } else { delete m_mri_t2; m_mri_t2 = NULL; } if (m_fcd->mri_aseg) { LayerMRI* mri = m_mri_aseg; if (m_layerSource) { mri->SetRefVolume(m_layerSource->GetSourceVolume()); } mri->SetName(GetName() + "_aseg"); mri->SetFileName(m_fcd->mri_aseg->fname); if ( mri->CreateFromMRIData((void*)m_fcd->mri_aseg) ) { mri->GetProperty()->SetColorMap(LayerPropertyMRI::LUT); mri->SetVisible(false); } else { delete m_mri_aseg; m_mri_aseg = NULL; } } else { delete m_mri_aseg; m_mri_aseg = NULL; } if (m_fcd->mri_thickness_difference) { LayerMRI* mri = m_mri_difference; if (m_layerSource) { mri->SetRefVolume(m_layerSource->GetSourceVolume()); } mri->SetName(GetName() + "_thickness_difference"); // mri->SetFileName(m_fcd->mri_thickness_increase->fname); if ( mri->CreateFromMRIData((void*)m_fcd->mri_thickness_difference) ) { mri->GetProperty()->SetColorMap(LayerPropertyMRI::Heat); } else { delete m_mri_difference; m_mri_difference = NULL; } } else { delete m_mri_difference; m_mri_difference = NULL; } if (m_fcd->mris_lh) { LayerSurface* surf = m_surf_lh; if (m_layerSource) { surf->SetRefVolume(m_layerSource); } surf->SetName(GetName() + "_lh"); if (!surf->CreateFromMRIS((void*)m_fcd->mris_lh)) { delete m_surf_lh; m_surf_lh = NULL; } } else { delete m_surf_lh; m_surf_lh = NULL; } if (m_fcd->mris_lh_pial) { LayerSurface* surf = m_surf_lh_pial; if (m_layerSource) { surf->SetRefVolume(m_layerSource); } surf->SetName(GetName() + "_lh.pial"); if (!surf->CreateFromMRIS((void*)m_fcd->mris_lh_pial)) { delete m_surf_lh_pial; m_surf_lh_pial = NULL; } else { surf->GetProperty()->SetEdgeColor(Qt::green); } } else { delete m_surf_lh_pial; m_surf_lh_pial = NULL; } if (m_fcd->mris_lh_sphere_d1) { LayerSurface* surf = m_surf_lh_sphere_d1; if (m_layerSource) { surf->SetRefVolume(m_layerSource); } surf->SetName(GetName() + "_lh.sphere.d1"); if (!surf->CreateFromMRIS((void*)m_fcd->mris_lh_sphere_d1)) { delete m_surf_lh_sphere_d1; m_surf_lh_sphere_d1 = NULL; } else { surf->GetProperty()->SetEdgeColor(Qt::red); surf->SetVisible(false); } } else { delete m_surf_lh_sphere_d1; m_surf_lh_sphere_d1 = NULL; } if (m_fcd->mris_rh) { LayerSurface* surf = m_surf_rh; if (m_layerSource) { surf->SetRefVolume(m_layerSource); } surf->SetName(GetName() + "_rh"); if (!surf->CreateFromMRIS((void*)m_fcd->mris_rh)) { delete m_surf_rh; m_surf_rh = NULL; } } else { delete m_surf_rh; m_surf_rh = NULL; } if (m_fcd->mris_rh_pial) { LayerSurface* surf = m_surf_rh_pial; if (m_layerSource) { surf->SetRefVolume(m_layerSource); } surf->SetName(GetName() + "_rh.pial"); if (!surf->CreateFromMRIS((void*)m_fcd->mris_rh_pial)) { delete m_surf_rh_pial; m_surf_rh_pial = NULL; } else { surf->GetProperty()->SetEdgeColor(Qt::green); } } else { delete m_surf_rh_pial; m_surf_rh_pial = NULL; } if (m_fcd->mris_rh_sphere_d1) { LayerSurface* surf = m_surf_rh_sphere_d1; if (m_layerSource) { surf->SetRefVolume(m_layerSource); } surf->SetName(GetName() + "_rh.sphere.d1"); if (!surf->CreateFromMRIS((void*)m_fcd->mris_rh_sphere_d1)) { delete m_surf_rh_sphere_d1; m_surf_rh_sphere_d1 = NULL; } else { surf->GetProperty()->SetEdgeColor(Qt::red); surf->SetVisible(false); } } else { delete m_surf_rh_sphere_d1; m_surf_rh_sphere_d1 = NULL; } }
LayerFCD::LayerFCD(LayerMRI* layerMRI, QObject *parent) : LayerVolumeBase(parent), m_fcd(NULL), m_mri_difference(NULL) { m_strTypeNames.push_back( "FCD" ); m_sPrimaryType = "FCD"; mProperty = new LayerPropertyFCD(this); for ( int i = 0; i < 3; i++ ) { m_dSlicePosition[i] = 0; m_sliceActor2D[i] = vtkSmartPointer<vtkImageActor>::New(); m_sliceActor3D[i] = vtkSmartPointer<vtkImageActor>::New(); m_sliceActor2D[i]->InterpolateOff(); m_sliceActor3D[i]->InterpolateOff(); } mProperty = new LayerPropertyFCD( this ); m_layerSource = layerMRI; if (m_layerSource) { InitializeData(); } LayerPropertyFCD* p = GetProperty(); connect( p, SIGNAL(ColorMapChanged()), this, SLOT(UpdateColorMap()) ); connect( p, SIGNAL(OpacityChanged(double)), this, SLOT(UpdateOpacity()) ); connect( p, SIGNAL(ThicknessThresholdChanged(double)), this, SLOT(Recompute())); connect( p, SIGNAL(SigmaChanged(double)), this, SLOT(Recompute())); connect( p, SIGNAL(MinAreaChanged(int)), this, SLOT(Recompute())); // pre allocate MRIs & surfaces m_mri_norm = new LayerMRI(NULL); m_mri_flair = new LayerMRI(NULL); m_mri_t2 = new LayerMRI(NULL); m_mri_aseg = new LayerMRI(NULL); m_mri_difference = new LayerMRI(NULL); connect(m_mri_norm, SIGNAL(destroyed()), this, SLOT(OnLayerDestroyed()), Qt::UniqueConnection); connect(m_mri_flair, SIGNAL(destroyed()), this, SLOT(OnLayerDestroyed()), Qt::UniqueConnection); connect(m_mri_t2, SIGNAL(destroyed()), this, SLOT(OnLayerDestroyed()), Qt::UniqueConnection); connect(m_mri_aseg, SIGNAL(destroyed()), this, SLOT(OnLayerDestroyed()), Qt::UniqueConnection); connect(m_mri_difference, SIGNAL(destroyed()), this, SLOT(OnLayerDestroyed()), Qt::UniqueConnection); m_surf_lh = new LayerSurface(NULL); m_surf_rh = new LayerSurface(NULL); connect(m_surf_lh, SIGNAL(destroyed()), this, SLOT(OnLayerDestroyed()), Qt::UniqueConnection); connect(m_surf_rh, SIGNAL(destroyed()), this, SLOT(OnLayerDestroyed()), Qt::UniqueConnection); m_surf_lh_pial = new LayerSurface(NULL); m_surf_rh_pial = new LayerSurface(NULL); connect(m_surf_lh_pial, SIGNAL(destroyed()), this, SLOT(OnLayerDestroyed()), Qt::UniqueConnection); connect(m_surf_rh_pial, SIGNAL(destroyed()), this, SLOT(OnLayerDestroyed()), Qt::UniqueConnection); m_surf_lh_sphere_d1 = new LayerSurface(NULL); m_surf_rh_sphere_d1 = new LayerSurface(NULL); connect(m_surf_lh_sphere_d1, SIGNAL(destroyed()), this, SLOT(OnLayerDestroyed()), Qt::UniqueConnection); connect(m_surf_rh_sphere_d1, SIGNAL(destroyed()), this, SLOT(OnLayerDestroyed()), Qt::UniqueConnection); m_worker = new LayerFCDWorkerThread(this); connect(m_worker, SIGNAL(started()), this, SIGNAL(StatusChanged())); connect(m_worker, SIGNAL(finished()), this, SIGNAL(StatusChanged())); connect(m_worker, SIGNAL(terminated()), this, SIGNAL(StatusChanged())); }
bool Deconvolution::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList) { StepResource pStep("Deconvolution Sharpening", "app", "619F3C8A-FB70-44E0-B211-B116E604EDDA"); if (pInArgList == NULL || pOutArgList == NULL) { return false; } Progress* pProgress = pInArgList->getPlugInArgValue<Progress>(Executable::ProgressArg()); RasterElement* pCube = pInArgList->getPlugInArgValue<RasterElement>(Executable::DataElementArg()); if (pCube == NULL) { std::string msg = "A raster cube must be specified."; pStep->finalize(Message::Failure, msg); if (pProgress != NULL) { pProgress->updateProgress(msg, 0, ERRORS); } return false; } RasterDataDescriptor* pDesc = static_cast<RasterDataDescriptor*>(pCube->getDataDescriptor()); VERIFY(pDesc != NULL); EncodingType ResultType = pDesc->getDataType(); if (pDesc->getDataType() == INT4SCOMPLEX) { ResultType = INT4SBYTES; } else if (pDesc->getDataType() == FLT8COMPLEX) { ResultType = FLT8BYTES; } FactoryResource<DataRequest> pRequest; pRequest->setInterleaveFormat(BSQ); DataAccessor pSrcAcc = pCube->getDataAccessor(pRequest.release()); ModelResource<RasterElement> pResultCube(RasterUtilities::createRasterElement(pCube->getName() + "_Deconvolution_Sharpening_Result", pDesc->getRowCount(), pDesc->getColumnCount(), ResultType)); if (pResultCube.get() == NULL) { std::string msg = "A raster cube could not be created."; pStep->finalize(Message::Failure, msg); if (pProgress != NULL) { pProgress->updateProgress(msg, 0, ERRORS); } return false; } FactoryResource<DataRequest> pResultRequest; pResultRequest->setWritable(true); DataAccessor pDestAcc = pResultCube->getDataAccessor(pResultRequest.release()); Service<DesktopServices> pDesktop; DeconvolutionDlg dlg(pDesktop->getMainWidget()); int stat = dlg.exec(); if (stat != QDialog::Accepted) { return true; } double minGrayValue; double maxGrayValue; double deltaValue = 0.0; int nFilterType = dlg.getCurrentFilterType(); int windowSize = dlg.getCurrentWindowSize(); double sigmaVal = dlg.getSigmaValue(); double gamaVal = dlg.getGamaValue(); windowSize = (windowSize-1)/2; if (NULL != pOriginalImage) { free(pOriginalImage); } pOriginalImage = (double *)malloc(sizeof(double)*pDesc->getRowCount()*pDesc->getColumnCount()); double *OrigData = (double *)malloc(sizeof(double)*pDesc->getRowCount()*pDesc->getColumnCount()); double *NewData = (double *)malloc(sizeof(double)*pDesc->getRowCount()*pDesc->getColumnCount()); double *ConvoData = (double *)malloc(sizeof(double)*pDesc->getRowCount()*pDesc->getColumnCount()); double *pTempData; InitializeData(pSrcAcc, pOriginalImage, OrigData, pDesc->getRowCount(), pDesc->getColumnCount(), pDesc->getDataType()); GetGrayScale(&minGrayValue, &maxGrayValue, pDesc->getDataType()); //Perform deconvolution iteratively for (int num = 0; num < MAX_ITERATION_NUMBER; num++) { if (pProgress != NULL) { pProgress->updateProgress("Deconvolution process", num*100/MAX_ITERATION_NUMBER, NORMAL); } if (isAborted()) { std::string msg = getName() + " has been aborted."; pStep->finalize(Message::Abort, msg); if (pProgress != NULL) { pProgress->updateProgress(msg, 0, ABORT); } free(OrigData); free(NewData); free(ConvoData); return false; } deltaValue = DeconvolutionFunc(OrigData, pOriginalImage, NewData, ConvoData, sigmaVal, gamaVal, windowSize, pDesc->getRowCount(), pDesc->getColumnCount(), nFilterType, maxGrayValue, minGrayValue); pTempData = OrigData; OrigData = NewData; NewData = pTempData; double errorRate = deltaValue/(maxGrayValue-minGrayValue); if (errorRate < CONVERGENCE_THRESHOLD) { break; } } free(NewData); free(ConvoData); //Output result unsigned int nCount = 0; for (int i = 0; i < pDesc->getRowCount(); i++) { for (int j = 0; j < pDesc->getColumnCount(); j++) { if (!pDestAcc.isValid()) { std::string msg = "Unable to access the cube data."; pStep->finalize(Message::Failure, msg); if (pProgress != NULL) { pProgress->updateProgress(msg, 0, ERRORS); } free(OrigData); return false; } pDestAcc->toPixel(i, j); switchOnEncoding(ResultType, restoreImageValue, pDestAcc->getColumn(), (OrigData+nCount)); nCount++; } } free(OrigData); if (!isBatch()) { Service<DesktopServices> pDesktop; SpatialDataWindow* pWindow = static_cast<SpatialDataWindow*>(pDesktop->createWindow(pResultCube->getName(), SPATIAL_DATA_WINDOW)); SpatialDataView* pView = (pWindow == NULL) ? NULL : pWindow->getSpatialDataView(); if (pView == NULL) { std::string msg = "Unable to create view."; pStep->finalize(Message::Failure, msg); if (pProgress != NULL) { pProgress->updateProgress(msg, 0, ERRORS); } return false; } pView->setPrimaryRasterElement(pResultCube.get()); pView->createLayer(RASTER, pResultCube.get()); } if (pProgress != NULL) { pProgress->updateProgress("Deconvolution enhancement is complete.", 100, NORMAL); } pOutArgList->setPlugInArgValue("Deconvolution enhancement Result", pResultCube.release()); pStep->finalize(); return true; }
void DexpotMeasure::OnDexpotStarted() { InitializeData(); }