r575: no message
[ctsim.git] / src / threadrecon.cpp
index e53daacb2458f53faa63a3f062496b1432ee755c..159e9d43975749c2e1ad154c54203150e236238e 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2001 Kevin Rosenberg
 **
-**  $Id: threadrecon.cpp,v 1.3 2001/02/22 18:22:40 kevin Exp $
+**  $Id: threadrecon.cpp,v 1.5 2001/02/23 03:28:26 kevin Exp $
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License (version 2) as
@@ -70,20 +70,17 @@ ThreadedReconstructor::ThreadedReconstructor (ProjectionFileView* pProjView,
   int iExtraViews = m_iTotalViews % m_iNumThreads;
   
   m_vecpChildImageFile.reserve (m_iNumThreads);
-  m_vecpReconstructor.reserve (m_iNumThreads);
   m_vecpThread.reserve (m_iNumThreads);
   
   for (unsigned int iProc = 0; iProc < m_iNumThreads; iProc++) {
     m_vecpChildImageFile[iProc] = new ImageFile (iImageNX, iImageNY);
-    m_vecpReconstructor[iProc] = new Reconstructor (m_pProjView->GetDocument()->getProjections(), *m_vecpChildImageFile[iProc],
-      pszFilterName, dFilterParam, pszFilterMethod, iZeropad, pszFilterGenerationName, 
-      pszInterpName, iInterpParam, pszBackprojectName, Trace::TRACE_NONE);
     
     int iStartView = iProc * iBaseViews;
     int iNumViews = iBaseViews;
     if (iProc < iExtraViews)
       ++iNumViews;
-    m_vecpThread[iProc] = new ReconstructionThread (this, m_vecpReconstructor[iProc], iProc, iStartView, iNumViews);
+      m_vecpThread[iProc] = new ReconstructionThread (this, pProjView, m_vecpChildImageFile[iProc], iProc, iStartView, iNumViews,
+      pszFilterName, dFilterParam, pszFilterMethod, iZeropad, pszFilterGenerationName, pszInterpName, iInterpParam, pszBackprojectName);
     if (m_vecpThread[iProc]->Create () != wxTHREAD_NO_ERROR) {
       m_bFail = true;
       break;
@@ -102,8 +99,11 @@ ThreadedReconstructor::start()
   m_pProjView->GetDocument()->addReconstructor (this);
   if (! theApp->getUseBackgroundTasks())
     m_pDialogProgress = new wxProgressDialog (_T("Filtered Backprojection"), _T("Reconstruction Progress"), m_iTotalViews, m_pProjView->getFrame(), wxPD_CAN_ABORT | wxPD_AUTO_HIDE);
-  else
-    m_pGauge = theApp->getBackgroundManager()->addTask (this, m_iTotalViews, m_pProjView->GetFrame()->GetTitle());
+  else {
+    std::string strLabel ("Reconstructing ");
+    strLabel += m_pProjView->GetFrame()->GetTitle();
+    m_pGauge = theApp->getBackgroundManager()->addTask (this, m_iTotalViews, strLabel.c_str());
+  }
   
   m_iRunning = m_iNumThreads;
   m_iViewsDone = 0;
@@ -144,12 +144,7 @@ ThreadedReconstructor::cleanUp()
     for (i = 0; i < m_iNumThreads; i++) {
       delete m_vecpChildImageFile[i];
       m_vecpChildImageFile[i] = NULL;
-    }
-    for (i = 0; i < m_iNumThreads; i++) {
-      delete m_vecpReconstructor[i];
-      m_vecpReconstructor[i] = NULL;
-    }
-    
+    }    
     
     m_iNumThreads = 0;
     m_iRunning = 0;
@@ -169,7 +164,7 @@ ThreadedReconstructor::onDone()
 {
   wxCriticalSection doneSection;
   doneSection.Enter();
-
+  
   m_pProjView->GetDocument()->removeReconstructor (this);
   ImageFileDocument* pReconDoc = theApp->newImageDoc();
   if (! pReconDoc) {
@@ -177,12 +172,7 @@ ThreadedReconstructor::onDone()
     doneSection.Leave();
     return;
   }
-  
-  for (int i = 0; i < m_iNumThreads; i++) {
-    delete m_vecpReconstructor[i];
-    m_vecpReconstructor[i] = NULL;
-  }
-  
+    
   ImageFile* pImageFile = getImageFile();
   pReconDoc->setImageFile (pImageFile);
   if (theApp->getAskDeleteNewDocs())
@@ -282,18 +272,25 @@ ThreadedReconstructor::~ThreadedReconstructor()
 }
 
 
-ReconstructionThread::ReconstructionThread (ThreadedReconstructor* pSupervisor, 
-                                            Reconstructor* pReconstructor, int iThread, int iStartView, int iNumViews)
-                                            : m_pSupervisor(pSupervisor), m_pReconstructor(pReconstructor), 
+ReconstructionThread::ReconstructionThread 
+(ThreadedReconstructor* pSupervisor, ProjectionFileView* pProjView, ImageFile* pImageFile, int iThread, int iStartView, int iNumViews, 
+                                            const char* pszFilterName, double dFilterParam, const char* pszFilterMethod, 
+                                            int iZeropad, const char* pszFilterGenerationName, const char* pszInterpName, int iInterpParam,
+                                            const char* pszBackprojectName)
+                                            : m_pSupervisor(pSupervisor), 
                                             m_iStartView(iStartView), m_iNumViews(iNumViews), m_iThread(iThread), 
                                             wxThread(wxTHREAD_DETACHED)
 {
+  m_pReconstructor = new Reconstructor (pProjView->GetDocument()->getProjections(), 
+    *pImageFile, pszFilterName, dFilterParam, pszFilterMethod, iZeropad, pszFilterGenerationName, 
+    pszInterpName, iInterpParam, pszBackprojectName, Trace::TRACE_NONE);
 }
 
 wxThread::ExitCode
 ReconstructionThread::Entry ()
 {
   wxCommandEvent eventProgress (wxEVT_COMMAND_MENU_SELECTED, RECONSTRUCTION_THREAD_EVENT);
+
   for (int iView = 0; iView < m_iNumViews; iView++) {
     if (TestDestroy()) {
       wxString msg;
@@ -307,6 +304,7 @@ ReconstructionThread::Entry ()
     eventProgress.SetInt (RTHREAD_UNIT_COMPLETE);
     wxPostEvent (m_pSupervisor, eventProgress);
   }
+  m_pReconstructor->postProcessing();
   
   eventProgress.SetInt (m_iThread); // Send back thread# that has finished
   wxPostEvent (m_pSupervisor, eventProgress);
@@ -317,4 +315,5 @@ ReconstructionThread::Entry ()
 void
 ReconstructionThread::OnExit ()
 {
+   delete m_pReconstructor;
 }