r575: no message
[ctsim.git] / src / threadrecon.cpp
index f973c68a1498fc6ec59ade44c586348a768a685a..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.4 2001/02/23 02:06:02 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;
@@ -147,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;
@@ -172,7 +164,7 @@ ThreadedReconstructor::onDone()
 {
   wxCriticalSection doneSection;
   doneSection.Enter();
-
+  
   m_pProjView->GetDocument()->removeReconstructor (this);
   ImageFileDocument* pReconDoc = theApp->newImageDoc();
   if (! pReconDoc) {
@@ -180,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())
@@ -285,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;
@@ -321,4 +315,5 @@ ReconstructionThread::Entry ()
 void
 ReconstructionThread::OnExit ()
 {
+   delete m_pReconstructor;
 }