r591: Added Center-Detector length to scanning and reconstruction
[ctsim.git] / src / views.cpp
index fdfbc9f6dde82fd16e1d9576f4f5d87894a77454..74458f2d08189292e25ef4b330ae28e10302f2ee 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (c) 1983-2001 Kevin Rosenberg
 **
-**  $Id: views.cpp,v 1.121 2001/02/27 03:59:30 kevin Exp $
+**  $Id: views.cpp,v 1.122 2001/03/01 07:30:49 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
@@ -1825,13 +1825,15 @@ PhantomFileView::PhantomFileView()
 #if defined(DEBUG) || defined(_DEBUG)
   m_iDefaultNDet = 165;
   m_iDefaultNView = 180;
+  m_iDefaultNSample = 1;
 #else
   m_iDefaultNDet = 367;
   m_iDefaultNView = 320;
-#endif
   m_iDefaultNSample = 2;
+#endif
   m_dDefaultRotation = 1;
   m_dDefaultFocalLength = 2;
+  m_dDefaultCenterDetectorLength = 2;
   m_dDefaultViewRatio = 1;
   m_dDefaultScanRatio = 1;
   m_iDefaultGeometry = Scanner::GEOMETRY_PARALLEL;
@@ -1877,8 +1879,8 @@ PhantomFileView::OnProjections (wxCommandEvent& event)
 {
   DialogGetProjectionParameters dialogProjection (getFrameForChild(), 
     m_iDefaultNDet, m_iDefaultNView, m_iDefaultNSample, m_dDefaultRotation, 
-    m_dDefaultFocalLength, m_dDefaultViewRatio, m_dDefaultScanRatio, m_iDefaultGeometry
-    m_iDefaultTrace);
+    m_dDefaultFocalLength, m_dDefaultCenterDetectorLength, m_dDefaultViewRatio, m_dDefaultScanRatio
+    m_iDefaultGeometry, m_iDefaultTrace);
   int retVal = dialogProjection.ShowModal();
   if (retVal != wxID_OK) 
     return;
@@ -1889,6 +1891,7 @@ PhantomFileView::OnProjections (wxCommandEvent& event)
   m_iDefaultTrace = dialogProjection.getTrace();
   m_dDefaultRotation = dialogProjection.getRotAngle();
   m_dDefaultFocalLength = dialogProjection.getFocalLengthRatio();
+  m_dDefaultCenterDetectorLength = dialogProjection.getCenterDetectorLengthRatio();
   m_dDefaultViewRatio = dialogProjection.getViewRatio();
   m_dDefaultScanRatio = dialogProjection.getScanRatio();
   wxString sGeometry = dialogProjection.getGeometry();
@@ -1901,7 +1904,7 @@ PhantomFileView::OnProjections (wxCommandEvent& event)
   
   const Phantom& rPhantom = GetDocument()->getPhantom();
   Scanner theScanner (rPhantom, sGeometry.c_str(), m_iDefaultNDet, m_iDefaultNView, m_iDefaultNSample, 
-    dRotationRadians, m_dDefaultFocalLength, m_dDefaultViewRatio, m_dDefaultScanRatio);
+    dRotationRadians, m_dDefaultFocalLength, m_dDefaultCenterDetectorLength, m_dDefaultViewRatio, m_dDefaultScanRatio);
   if (theScanner.fail()) {
     wxString msg = "Failed making scanner\n";
     msg += theScanner.failMessage().c_str();
@@ -1914,6 +1917,7 @@ PhantomFileView::OnProjections (wxCommandEvent& event)
   os << "Projections for " << rPhantom.name() << ": nDet=" << m_iDefaultNDet 
     << ", nView=" << m_iDefaultNView << ", nSamples=" << m_iDefaultNSample 
     << ", RotAngle=" << m_dDefaultRotation << ", FocalLengthRatio=" << m_dDefaultFocalLength 
+    << ", CenterDetectorLengthRatio=" << m_dDefaultCenterDetectorLength
     << ", ViewRatio=" << m_dDefaultViewRatio << ", ScanRatio=" << m_dDefaultScanRatio 
     << ", Geometry=" << sGeometry.c_str() << ", FanBeamAngle=" << 
     convertRadiansToDegrees (theScanner.fanBeamAngle());
@@ -1941,7 +1945,7 @@ PhantomFileView::OnProjections (wxCommandEvent& event)
     if (theApp->getUseBackgroundTasks() || theApp->getNumberCPU() > 1) {
       ProjectorSupervisorThread* pProjector = new ProjectorSupervisorThread (this, m_iDefaultNDet,
         m_iDefaultNView, sGeometry.c_str(), m_iDefaultNSample, dRotationRadians,
-        m_dDefaultFocalLength, m_dDefaultViewRatio, m_dDefaultScanRatio, os.str().c_str());
+        m_dDefaultFocalLength, m_dDefaultCenterDetectorLength, m_dDefaultViewRatio, m_dDefaultScanRatio, os.str().c_str());
       if (pProjector->Create() != wxTHREAD_NO_ERROR) {
         sys_error (ERR_SEVERE, "Error creating projector thread");
         delete pProjector;
@@ -2427,14 +2431,14 @@ ProjectionFileView::OnReconstructFBP (wxCommandEvent& event)
   os << "Reconstruct " << rProj.getFilename() << ": xSize=" << m_iDefaultNX << ", ySize=" << m_iDefaultNY << ", Filter=" << optFilterName.c_str() << ", FilterParam=" << m_dDefaultFilterParam << ", FilterMethod=" << optFilterMethodName.c_str() << ", FilterGeneration=" << optFilterGenerationName.c_str() << ", Zeropad=" << m_iDefaultZeropad << ", Interpolation=" << optInterpName.c_str() << ", InterpolationParam=" << m_iDefaultInterpParam << ", Backprojection=" << optBackprojectName.c_str();
   
   Timer timerRecon;
-  ImageFile rImageFile;
+  ImageFile* pImageFile = NULL;
   if (m_iDefaultTrace > Trace::TRACE_CONSOLE) {
-    rImageFile.setArraySize (m_iDefaultNX, m_iDefaultNY);
-    Reconstructor* pReconstructor = new Reconstructor (rProj, rImageFile, optFilterName.c_str(), 
+    pImageFile = new ImageFile (m_iDefaultNX, m_iDefaultNY);
+    Reconstructor* pReconstructor = new Reconstructor (rProj, *pImageFile, optFilterName.c_str(), 
       m_dDefaultFilterParam, optFilterMethodName.c_str(), m_iDefaultZeropad, optFilterGenerationName.c_str(), 
       optInterpName.c_str(), m_iDefaultInterpParam, optBackprojectName.c_str(), m_iDefaultTrace);
     
-    ReconstructDialog* pDlgReconstruct = new ReconstructDialog (*pReconstructor, rProj, rImageFile, m_iDefaultTrace, getFrameForChild());
+    ReconstructDialog* pDlgReconstruct = new ReconstructDialog (*pReconstructor, rProj, *pImageFile, m_iDefaultTrace, getFrameForChild());
     for (int iView = 0; iView < rProj.nView(); iView++) {
       ::wxYield();
       if (pDlgReconstruct->isCancelled() || ! pDlgReconstruct->reconstructView (iView, true)) {
@@ -2467,8 +2471,8 @@ ProjectionFileView::OnReconstructFBP (wxCommandEvent& event)
       pReconstructor->Run();
       return;
     } else {
-      rImageFile.setArraySize (m_iDefaultNX, m_iDefaultNY);
-      Reconstructor* pReconstructor = new Reconstructor (rProj, rImageFile, optFilterName.c_str(), 
+      pImageFile = new ImageFile (m_iDefaultNX, m_iDefaultNY);
+      Reconstructor* pReconstructor = new Reconstructor (rProj, *pImageFile, optFilterName.c_str(), 
         m_dDefaultFilterParam, optFilterMethodName.c_str(), m_iDefaultZeropad, optFilterGenerationName.c_str(), 
         optInterpName.c_str(), m_iDefaultInterpParam, optBackprojectName.c_str(), m_iDefaultTrace);
       
@@ -2482,11 +2486,6 @@ ProjectionFileView::OnReconstructFBP (wxCommandEvent& event)
       }
       pReconstructor->postProcessing();
       delete pReconstructor;
-      ImageFileDocument* pReconDoc = theApp->newImageDoc();
-      if (! pReconDoc) {
-        sys_error (ERR_SEVERE, "Unable to create image file");
-        return;
-      }
     }
   }
   ImageFileDocument* pReconDoc = theApp->newImageDoc();
@@ -2494,7 +2493,7 @@ ProjectionFileView::OnReconstructFBP (wxCommandEvent& event)
     sys_error (ERR_SEVERE, "Unable to create image file");
     return;
   }
-  pReconDoc->setImageFile (&rImageFile);
+  pReconDoc->setImageFile (pImageFile);
   if (theApp->getAskDeleteNewDocs())
     pReconDoc->Modify (true);
   pReconDoc->UpdateAllViews (this);
@@ -2504,8 +2503,8 @@ ProjectionFileView::OnReconstructFBP (wxCommandEvent& event)
     rasterView->getFrame()->Show(true);
   }
   *theApp->getLog() << os.str().c_str() << "\n";
-  rImageFile.labelAdd (rProj.getLabel());
-  rImageFile.labelAdd (os.str().c_str(), timerRecon.timerEnd());    
+  pImageFile->labelAdd (rProj.getLabel());
+  pImageFile->labelAdd (os.str().c_str(), timerRecon.timerEnd());    
 }