Salome HOME
refs #416: to store the open state of object browser items in the binary array
[modules/gui.git] / src / SVTK / SVTK_ImageWriter.cxx
index 581111ba6dfd65678fa688634b722e482d2efde5..233e9d9fbbed8149790119394f317433ec652799 100755 (executable)
@@ -1,9 +1,9 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -21,6 +21,7 @@
 
 #include <QSemaphore>
 
+#include <vtkAlgorithm.h>
 #include <vtkImageData.h>
 #include <vtkImageClip.h>
 #include <vtkJPEGWriter.h>
@@ -36,11 +37,13 @@ static int MYDEBUG = 0;
 //----------------------------------------------------------------------------
 SVTK_ImageWriter
 ::SVTK_ImageWriter(QSemaphore* theSemaphore,
+                   vtkAlgorithm* theAlgorithm,
                    vtkImageData* theImageData,
                    const std::string& theName,
                    int theProgressive,
                    int theQuality):
   mySemaphore(theSemaphore),
+  myAlgorithm(theAlgorithm),
   myImageData(theImageData),
   myName(theName),
   myProgressive(theProgressive),
@@ -62,13 +65,13 @@ SVTK_ImageWriter
 ::run()
 {
   vtkJPEGWriter *aWriter = vtkJPEGWriter::New();
-  vtkImageData *anImageData = myImageData;
+  vtkAlgorithmOutput *anImageData = 0;
   vtkSmartPointer<vtkImageClip> anImageClip;
   //
   if(myConstraint16Flag){ 
     int uExtent[6];
-    myImageData->UpdateInformation();
-    myImageData->GetUpdateExtent(uExtent);
+    myAlgorithm->UpdateInformation();
+    myAlgorithm->GetUpdateExtent(uExtent);
     unsigned int width = uExtent[1] - uExtent[0] + 1;
     unsigned int height = uExtent[3] - uExtent[2] + 1;
     width = (width / 16) * 16;
@@ -79,17 +82,20 @@ SVTK_ImageWriter
     anImageClip = vtkImageClip::New();
     anImageClip->Delete();
 
-    anImageClip->SetInput(myImageData);
+    anImageClip->SetInputData(myImageData);
     anImageClip->SetOutputWholeExtent(uExtent);
     anImageClip->ClipDataOn();
-    anImageData = anImageClip->GetOutput();
+    anImageData = anImageClip->GetOutputPort();
   }
   //
   aWriter->WriteToMemoryOff();
   aWriter->SetFileName(myName.c_str());
   aWriter->SetQuality(myQuality);
   aWriter->SetProgressive(myProgressive);
-  aWriter->SetInput(anImageData);
+  if(myConstraint16Flag)
+    aWriter->SetInputConnection(anImageData);
+  else
+    aWriter->SetInputData(myImageData);
   aWriter->Write();
 
   aWriter->Delete();