]> Creatis software - clitk.git/blobdiff - vv/vvSlicerManager.cxx
Copy pasted code from overlay to fusion for sequences. This yet another
[clitk.git] / vv / vvSlicerManager.cxx
index e975da28babd5ee04bdb31120ccd77bd50b5412f..89fd42b49fae4177e89ec0c2ee4590e38c9a6f54 100644 (file)
@@ -279,20 +279,18 @@ bool vvSlicerManager::SetOverlay(std::vector<std::string> filenames,int dim, std
 \r
 \r
 //----------------------------------------------------------------------------\r
-bool vvSlicerManager::SetFusion(std::string filename,int dim, std::string component)\r
+bool vvSlicerManager::SetFusion(std::vector<std::string> filenames,int dim, std::string component, vvImageReader::LoadedImageType type)\r
 {\r
-  mFusionName = filename;\r
+  mFusionName = filenames[0];\r
   mFusionComponent = component;\r
   if (dim > mImage->GetNumberOfDimensions()) {\r
-    mLastError = " Overlay dimension cannot be greater then reference image!";\r
+    mLastError = " Fusion dimension cannot be greater than reference image!";\r
     return false;\r
   }\r
   if (mFusionReader.IsNull())\r
     mFusionReader = vvImageReader::New();\r
-  std::vector<std::string> filenames;\r
-  filenames.push_back(filename);\r
   mFusionReader->SetInputFilenames(filenames);\r
-  mFusionReader->Update(mImage->GetNumberOfDimensions(),component.c_str(),mType);\r
+  mFusionReader->Update(type);\r
   if (mFusionReader->GetLastError().size() == 0) {\r
     for ( unsigned int i = 0; i < mSlicers.size(); i++) {\r
       mSlicers[i]->SetFusion(mFusionReader->GetOutput());\r
@@ -351,7 +349,7 @@ bool vvSlicerManager::SetFusionSequence(std::vector<std::string> filenames, int
        }\r
 \r
        //adjust the time slider in the overlay panel\r
-       mFusionSequenceNbFrames = mFusionSequenceReader->GetOutput()->GetTransform().size()-1; //actually, this is the maximum index...\r
+       mFusionSequenceNbFrames = mFusionSequenceReader->GetOutput()->GetTransform().size()\r
        mFusionSequenceFrameIndex = std::max<int>( 0, std::min<int>(mFusionSequenceFrameIndex, mFusionSequenceNbFrames));\r
 \r
        return true;\r
@@ -965,6 +963,10 @@ void vvSlicerManager::ReloadFusion()
 //the secondary sequence is being reloaded.\r
 void vvSlicerManager::ReloadFusionSequence()\r
 {\r
+  //  this is to keep the slice thickness, which needs to be artificially increased for visualization\r
+  double sp_x, sp_y, sp_z;\r
+  this->GetImage()->GetVTKImages()[0]->GetSpacing(sp_x, sp_y, sp_z);\r
+\r
   mFusionSequenceReader->Update(mImage->GetNumberOfDimensions(),mFusionComponent.c_str(),vvImageReader::MERGEDWITHTIME);\r
 \r
   for ( unsigned int i = 0; i < mSlicers.size(); i++) {\r
@@ -984,6 +986,13 @@ void vvSlicerManager::ReloadFusionSequence()
          this->AddFusionSequenceInitialTransformMatrices( mFusionSequenceReader->GetOutput()->GetTransform()[i]->GetMatrix() );\r
   }\r
 \r
+  //  also update the slice thickness\r
+  for (unsigned i=0 ; i<this->GetImage()->GetTransform().size() ; i++) {\r
+    sp_x = this->GetImage()->GetVTKImages()[i]->GetSpacing()[0];\r
+    sp_y = this->GetImage()->GetVTKImages()[i]->GetSpacing()[1];\r
+    this->GetImage()->GetVTKImages()[i]->SetSpacing( sp_x, sp_y, sp_z);\r
+  }\r
+\r
 }\r
 //----------------------------------------------------------------------------\r
 \r