r589: Added threaded rasterizer
[ctsim.git] / src / threadrecon.cpp
index 75861c492f3f6a8adb7cbab7fe5a1e9396e94383..2cd9dd1bda33475e1bbe711cb119d952d58440b6 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2001 Kevin Rosenberg
 **
-**  $Id: threadrecon.cpp,v 1.10 2001/02/25 08:00:57 kevin Exp $
+**  $Id: threadrecon.cpp,v 1.14 2001/02/27 03:59:30 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
@@ -65,13 +65,13 @@ ReconstructorSupervisorThread::ReconstructorSupervisorThread (ProjectionFileView
 wxThread::ExitCode
 ReconstructorSupervisorThread::Entry()
 {
-  ReconstructorSupervisor reconSupervisor (m_pProjView, m_iNX, m_iNY, 
+  ReconstructorSupervisor reconSupervisor (this, m_pProjView, m_iNX, m_iNY, 
    m_strFilterName.c_str(), m_dFilterParam, m_strFilterMethod.c_str(), m_iZeropad, m_strFilterGenerationName.c_str(), 
    m_strInterpName.c_str(), m_iInterpParam, m_strBackprojectName.c_str(), m_strLabel.c_str());
 
   reconSupervisor.start();
   while (! reconSupervisor.isDone() && ! reconSupervisor.fail()) {
-    Sleep(50);
+    Sleep(100);
     Yield();
   }
   if (reconSupervisor.fail())
@@ -84,9 +84,9 @@ ReconstructorSupervisorThread::Entry()
     wxPostEvent( theApp->getMainFrame(), eventLog ); // send log event
   }
 
-  while (reconSupervisor.anyWorkersRunning()) {
+  while (! reconSupervisor.workersDeleted()) {
     Sleep(50);
-    reconSupervisor.ProcessPendingEvents ();
+    reconSupervisor.ProcessPendingEvents();
   }
 
   return reinterpret_cast<wxThread::ExitCode>(0);
@@ -104,7 +104,7 @@ ReconstructorSupervisorThread::OnExit()
 //
 /////////////////////////////////////////////////////////////////////
 
-ReconstructorSupervisor::ReconstructorSupervisor (ProjectionFileView* pProjView, 
+ReconstructorSupervisor::ReconstructorSupervisor (SupervisorThread* pThread, ProjectionFileView* pProjView, 
   int iImageNX, int iImageNY, const char* pszFilterName, double dFilterParam, const char* pszFilterMethod, 
   int iZeropad, const char* pszFilterGenerationName, const char* pszInterpName, int iInterpParam,
   const char* pszBackprojectName, const char* const pszLabel)
@@ -113,11 +113,11 @@ ReconstructorSupervisor::ReconstructorSupervisor (ProjectionFileView* pProjView,
       m_pszFilterName(pszFilterName), m_dFilterParam(dFilterParam), m_pszFilterMethod(pszFilterMethod),
       m_iZeropad(iZeropad), m_pszFilterGenerationName(pszFilterGenerationName), m_pszInterpName(pszInterpName),
       m_iInterpParam(iInterpParam), m_pszBackprojectName(pszBackprojectName), m_pszLabel(pszLabel), 
-      BackgroundSupervisor (pProjView->GetFrame(), pProjView->GetDocument(), "Reconstructing", pProjView->GetDocument()->getProjections().nView())
+      BackgroundSupervisor (pThread, pProjView->GetFrame(), pProjView->GetDocument(), "Reconstructing", pProjView->GetDocument()->getProjections().nView())
 {
   m_vecpChildImageFile.reserve (getNumWorkers());
   for (unsigned int iThread = 0; iThread < getNumWorkers(); iThread++) {
-    m_vecpChildImageFile[iThread] = new ImageFile (iImageNX, iImageNY);    
+    m_vecpChildImageFile[iThread] = new ImageFile (m_iImageNX, m_iImageNY);    
   }
 
 }
@@ -127,8 +127,7 @@ ReconstructorSupervisor::~ReconstructorSupervisor()
   for (int i = 0; i < getNumWorkers(); i++) {
       delete m_vecpChildImageFile[i];
       m_vecpChildImageFile[i] = NULL;
-    }    
-
+    }
 }
 
 BackgroundWorkerThread*
@@ -197,6 +196,7 @@ ReconstructorSupervisor::getImageFile()
 //
 /////////////////////////////////////////////////////////////////////
 
+void
 ReconstructorWorker::SetParameters (ProjectionFileView* pProjView, ImageFile* pImageFile, 
  const char* pszFilterName, double dFilterParam, const char* pszFilterMethod, int iZeropad,
  const char* pszFilterGenerationName, const char* pszInterpName, int iInterpParam,