]> Creatis software - clitk.git/commitdiff
Merge branch 'master' of git.creatis.insa-lyon.fr:clitk
authorDavid Sarrut <david.sarrut@creatis.insa-lyon.fr>
Mon, 8 Apr 2013 06:18:35 +0000 (08:18 +0200)
committerDavid Sarrut <david.sarrut@creatis.insa-lyon.fr>
Mon, 8 Apr 2013 06:18:35 +0000 (08:18 +0200)
tools/clitkBinaryImageToMesh.cxx
tools/clitkBinaryImageToMesh.ggo
vv/vvMainWindow.cxx
vv/vvOverlayPanel.cxx
vv/vvSlicerManager.cxx

index 4e00f7e7dd0e42e8d745755aadb1b6fd9d031be3..220d033946908c4d7f490d358693eb62eb9a307c 100644 (file)
@@ -32,6 +32,8 @@
 
 #include "itksys/SystemTools.hxx"
 
+#include "vtkPolyDataWriter.h"
+
 void run(const args_info_clitkBinaryImageToMesh& argsInfo);
 
 int main(int argc, char** argv)
@@ -60,17 +62,17 @@ void run(const args_info_clitkBinaryImageToMesh& argsInfo)
     psurface->SetInputConnection(pcontour->GetOutputPort());
 
     vtkSmartPointer<vtkPolyDataMapper> skinMapper = vtkPolyDataMapper::New();
-      skinMapper->SetInputConnection(psurface->GetOutputPort());
-      skinMapper->ScalarVisibilityOff();
-    
+    skinMapper->SetInputConnection(psurface->GetOutputPort());
+    skinMapper->ScalarVisibilityOff();
+      
     vtkSmartPointer<vtkActor> skin = vtkActor::New();
-      skin->SetMapper(skinMapper);
-    
+    skin->SetMapper(skinMapper);
+      
     vtkSmartPointer<vtkCamera> aCamera = vtkCamera::New();
-      aCamera->SetViewUp (0, 0, -1);
-      aCamera->SetPosition (0, 1, 0);
-      aCamera->SetFocalPoint (0, 0, 0);
-      aCamera->ComputeViewPlaneNormal();
+    aCamera->SetViewUp (0, 0, -1);
+    aCamera->SetPosition (0, 1, 0);
+    aCamera->SetFocalPoint (0, 0, 0);
+    aCamera->ComputeViewPlaneNormal();
     aCamera->Dolly(1.5);
 
     vtkSmartPointer<vtkRenderer> aRenderer = vtkRenderer::New();
@@ -81,32 +83,50 @@ void run(const args_info_clitkBinaryImageToMesh& argsInfo)
     aRenderer->ResetCameraClippingRange ();
 
     vtkSmartPointer<vtkRenderWindow> renWin = vtkRenderWindow::New();
-      renWin->AddRenderer(aRenderer);
+    renWin->AddRenderer(aRenderer);
     renWin->SetSize(640, 480);
-    
-    vtkSmartPointer<vtkOBJExporter> pwriter2 = vtkOBJExporter::New();
-    pwriter2->SetRenderWindow(renWin);
-
     std::string output;
-    if (argsInfo.output_given) {
-      output = argsInfo.output_arg;
-      if (itksys::SystemTools::FileIsDirectory(output.c_str())) {
-        file = itksys::SystemTools::GetFilenameName(file.c_str());
-        file = itksys::SystemTools::GetFilenameWithoutExtension(file.c_str());
-        file = itksys::SystemTools::CollapseFullPath(file.c_str(), output.c_str());
-      }
-      else {
-        file = output;
+    if (argsInfo.output_given) { output = argsInfo.output_arg; }
+
+    bool writeVTK = false;
+    if (output.length()>4) {
+      if (output.compare(output.length()-4, 4, ".vtk")==0) {
+        writeVTK=true;
       }
     }
-    else { 
-      file = itksys::SystemTools::GetFilenameWithoutExtension(file);
+    if (writeVTK) {
+      vtkSmartPointer<vtkPolyDataWriter> wr = vtkSmartPointer<vtkPolyDataWriter>::New();
+      wr->SetInputConnection(psurface->GetOutputPort());
+      wr->SetFileName(output.c_str());
+      wr->Update();
+      wr->Write();
+    }
+    else {
+      vtkSmartPointer<vtkOBJExporter> pwriter2 = vtkOBJExporter::New();
+      pwriter2->SetRenderWindow(renWin);
+  
+      if (argsInfo.output_given) {
+        output = argsInfo.output_arg;
+        if (itksys::SystemTools::FileIsDirectory(output.c_str())) {
+          file = itksys::SystemTools::GetFilenameName(file.c_str());
+          file = itksys::SystemTools::GetFilenameWithoutExtension(file.c_str());
+          file = itksys::SystemTools::CollapseFullPath(file.c_str(), output.c_str());
+        }
+        else {
+          file = output;
+        }
+      }
+      else { 
+        file = itksys::SystemTools::GetFilenameWithoutExtension(file);
+      }
+      pwriter2->SetFilePrefix(file.c_str());
+      pwriter2->Write();
     }
-    pwriter2->SetFilePrefix(file.c_str());
-    pwriter2->Write();
+
 
     vtkSmartPointer<vtkRenderWindowInteractor> iren = vtkRenderWindowInteractor::New();
-      iren->SetRenderWindow(renWin);
+    iren->SetRenderWindow(renWin);
 
     skinMapper->Update();
     bool interact = argsInfo.view_flag;
index d04462d012718ab8c206146375dbd6421de98610..3381298cfe8a5488903f12385bd10d7580e46ee4 100644 (file)
@@ -1,11 +1,11 @@
 #File clitkBinaryImageToMesh.ggo
 package "clitkBinaryImageToMesh"
 version "1.0"
-purpose "Get the HU profile along the given line. Output to stdout."
+purpose "Converts a binary image into a mesh object."
 
 option "config"   - "Config file"   string  no
 option "verbose"  v     "Verbose"   flag  off
 
 option "input"    i "Input image"   string  yes
-option "output"    o "Output mesh file prefix (if empty, use input file's base name as prefix; if a directoy, output to it using input file's base name as prefix; otherwise, use given name as prefix"  string  no
+option "output"   o "Output mesh file prefix (if empty, use input file's base name as prefix; if a directoy, output to it using input file's base name as prefix; otherwise, use given name as prefix ; if names ends with .vtk the output is written as a vtkPolyData file"  string  no
 option "view"   - "View result"        flag    off
index 186976333f88a8d80e72624ab484fbe79ce90763..ca0f542989b9fb6f715de7b8c483e38554d4c30e 100644 (file)
@@ -2477,7 +2477,7 @@ void vvMainWindow::SelectFusionSequenceCorrespondances() {
   bool signalOK = true;
   unsigned nbFrameMain = mSlicerManagers[index]->GetImage()->GetTransform().size();
   unsigned nbFrameSecondary = mSlicerManagers[index]->GetFusionSequenceNbFrames();
-
+std::cout<<"nbFrameMain = "<<nbFrameMain<<", nbFrameSecondary= "<<nbFrameSecondary<<", signal size: "<<tmpVect.size()<<std::endl;
   std::vector<unsigned> temporalCorrespondances;
   if ( tmpVect.size() == nbFrameMain + nbFrameSecondary ) {
     for (unsigned i=0 ; i<tmpVect.size() ; i++) {
@@ -2520,6 +2520,7 @@ void vvMainWindow::AddFusionSequence(int index, std::vector<std::string> fileNam
     mInputPathName = itksys::SystemTools::GetFilenamePath(file.toStdString()).c_str();
     itk::ImageIOBase::Pointer reader = itk::ImageIOFactory::CreateImageIO(
       file.toStdString().c_str(), itk::ImageIOFactory::ReadMode);
+    std::sort (fileNames.begin(), fileNames.end());//make sure the files are sorted.
     reader->SetFileName(fileNames[0].c_str());
     reader->ReadImageInformation();
     std::string component = reader->GetComponentTypeAsString(reader->GetComponentType());
index b394bb55de4fc079c9c8e1123f8723d1de27661a..3490933fb89b3ce180af5d8bdf1bc598d4167c77 100644 (file)
@@ -264,7 +264,7 @@ void vvOverlayPanel::getFusionSequenceProperty(int sequenceFrameIndex, bool spat
                fCTUSFrame->setEnabled(1);
                fCTUSSlider->setEnabled(1);
                fCTUSSlider->setValue(sequenceFrameIndex);
-               fCTUSSlider->setMaximum(sequenceLenth);
+               fCTUSSlider->setMaximum(sequenceLenth-1); //the maximum IS included, since we start at 0, go until n-1!
                if (spatialSync) fCTUSActivateSpaceSyncCheckBox->setCheckState(Qt::Checked);
                else             fCTUSActivateSpaceSyncCheckBox->setCheckState(Qt::Unchecked);          
                if (fCTUSActivateTimeSyncCheckBox->isEnabled()) {
@@ -292,7 +292,7 @@ void vvOverlayPanel::setFusionSequenceProperty()
 {
   if (disableFusionSequenceSignals)
     return;
-  emit FusionSequencePropertyUpdated(fCTUSSlider->value(), fCTUSActivateSpaceSyncCheckBox->isChecked(), fCTUSSlider->maximum(), fCTUSActivateTimeSyncCheckBox->isChecked());
+  emit FusionSequencePropertyUpdated(fCTUSSlider->value(), fCTUSActivateSpaceSyncCheckBox->isChecked(), fCTUSSlider->maximum()+1, fCTUSActivateTimeSyncCheckBox->isChecked());
 }
 
 void vvOverlayPanel::enableFusionSequenceTemporalSync() {
@@ -303,7 +303,7 @@ void vvOverlayPanel::enableFusionSequenceTemporalSync() {
   disableFusionSequenceSignals = backup; //
        
        if (disableFusionSequenceSignals) return;
-       emit FusionSequencePropertyUpdated(fCTUSSlider->value(), fCTUSActivateSpaceSyncCheckBox->isChecked(), fCTUSSlider->maximum(), fCTUSActivateTimeSyncCheckBox->isChecked());
+       emit FusionSequencePropertyUpdated(fCTUSSlider->value(), fCTUSActivateSpaceSyncCheckBox->isChecked(), fCTUSSlider->maximum()+1, fCTUSActivateTimeSyncCheckBox->isChecked());
 }
 
 void vvOverlayPanel::updateFusionSequenceSliderValueFromWindow(int val, bool updateVisualization) {
@@ -314,7 +314,7 @@ void vvOverlayPanel::updateFusionSequenceSliderValueFromWindow(int val, bool upd
   disableFusionSequenceSignals = false;
 
   if (disableFusionSequenceSignals) return;
-       if (updateVisualization) emit FusionSequencePropertyUpdated(fCTUSSlider->value(), fCTUSActivateSpaceSyncCheckBox->isChecked(), fCTUSSlider->maximum(), fCTUSActivateTimeSyncCheckBox->isChecked());
+       if (updateVisualization) emit FusionSequencePropertyUpdated(fCTUSSlider->value(), fCTUSActivateSpaceSyncCheckBox->isChecked(), fCTUSSlider->maximum()+1, fCTUSActivateTimeSyncCheckBox->isChecked());
 }
 
 void vvOverlayPanel::VFColorChangeRequest()
index e975da28babd5ee04bdb31120ccd77bd50b5412f..24ec62a36d6d8473d0a6c8cb61aa34b067362cce 100644 (file)
@@ -351,7 +351,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