Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[modules/visu.git] / src / VVTK / VVTK_ImageWriter.cxx
index 9d04759878202e582e0d658e41de7e7b9b80376d..079557b1a7f24fa564f450cf39f612eda636bcc4 100755 (executable)
-//  SALOME VTKViewer : build VTK viewer into Salome desktop\r
-//\r
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS \r
-// \r
-//  This library is free software; you can redistribute it and/or \r
-//  modify it under the terms of the GNU Lesser General Public \r
-//  License as published by the Free Software Foundation; either \r
-//  version 2.1 of the License. \r
-// \r
-//  This library is distributed in the hope that it will be useful, \r
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of \r
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU \r
-//  Lesser General Public License for more details. \r
-// \r
-//  You should have received a copy of the GNU Lesser General Public \r
-//  License along with this library; if not, write to the Free Software \r
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA \r
-// \r
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org \r
-//\r
-//\r
-//\r
-//  File   :\r
-//  Author :\r
-//  Module :\r
-//  $Header$\r
-\r
-#include "VVTK_ImageWriter.h"\r
-\r
-#include <qsemaphore.h>\r
-\r
-#include <vtkImageData.h>\r
-#include <vtkImageClip.h>\r
-#include <vtkJPEGWriter.h>\r
-#include <vtkSmartPointer.h>\r
-\r
-#ifdef _DEBUG_\r
-static int MYDEBUG = 0;\r
-#else\r
-static int MYDEBUG = 0;\r
-#endif\r
-\r
-\r
-//----------------------------------------------------------------------------\r
-VVTK_ImageWriter\r
-::VVTK_ImageWriter(QSemaphore* theSemaphore,\r
-                  vtkImageData* theImageData,\r
-                  const std::string& theName,\r
-                  int theProgressive,\r
-                  int theQuality):\r
-  mySemaphore(theSemaphore),\r
-  myImageData(theImageData),\r
-  myName(theName),\r
-  myProgressive(theProgressive),\r
-  myQuality(theQuality),\r
-  myConstraint16Flag(true)\r
-{}\r
-\r
-//----------------------------------------------------------------------------\r
-VVTK_ImageWriter\r
-::~VVTK_ImageWriter()\r
-{\r
-  if(MYDEBUG) cout<<"VVTK_ImageWriter::~VVTK_ImageWriter - this = "<<this<<endl;\r
-}\r
-\r
-\r
-//----------------------------------------------------------------------------\r
-void\r
-VVTK_ImageWriter\r
-::run()\r
-{\r
-  vtkJPEGWriter *aWriter = vtkJPEGWriter::New();\r
-  vtkImageData *anImageData = myImageData;\r
-  vtkSmartPointer<vtkImageClip> anImageClip;\r
-  //\r
-  if(myConstraint16Flag){ \r
-    int uExtent[6];\r
-    myImageData->GetUpdateExtent(uExtent);\r
-    unsigned int width = uExtent[1] - uExtent[0] + 1;\r
-    unsigned int height = uExtent[3] - uExtent[2] + 1;\r
-    width = (width / 16) * 16;\r
-    height= (height / 16) * 16;\r
-    uExtent[1] = uExtent[0] + width - 1;\r
-    uExtent[3] = uExtent[2] + height - 1;\r
-    //\r
-    anImageClip = vtkImageClip::New();\r
-    anImageClip->Delete();\r
-\r
-    anImageClip->SetInput(myImageData);\r
-    anImageClip->SetOutputWholeExtent(uExtent);\r
-    anImageClip->ClipDataOn();\r
-    anImageData = anImageClip->GetOutput();\r
-  }\r
-  //\r
-  aWriter->WriteToMemoryOff();\r
-  aWriter->SetFileName(myName.c_str());\r
-  aWriter->SetQuality(myQuality);\r
-  aWriter->SetProgressive(myProgressive);\r
-  aWriter->SetInput(anImageData);\r
-  aWriter->Write();\r
-\r
-  aWriter->Delete();\r
-  myImageData->Delete();\r
-\r
-  if(MYDEBUG) cout<<"VVTK_ImageWriter::run "<<\r
-               "- this = "<<this<<\r
-               "; total = "<<mySemaphore->total()<<\r
-               "; available = "<<mySemaphore->available()<<endl;\r
-  *mySemaphore -= 1;\r
-}\r
-\r
+//  SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  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. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//
+//
+//
+//  File   :
+//  Author :
+//  Module :
+//  $Header$
+
+#include "VVTK_ImageWriter.h"
+
+#include <qsemaphore.h>
+
+#include <vtkImageData.h>
+#include <vtkImageClip.h>
+#include <vtkJPEGWriter.h>
+#include <vtkSmartPointer.h>
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+
+//----------------------------------------------------------------------------
+VVTK_ImageWriter
+::VVTK_ImageWriter(QSemaphore* theSemaphore,
+                  vtkImageData* theImageData,
+                  const std::string& theName,
+                  int theProgressive,
+                  int theQuality):
+  mySemaphore(theSemaphore),
+  myImageData(theImageData),
+  myName(theName),
+  myProgressive(theProgressive),
+  myQuality(theQuality),
+  myConstraint16Flag(true)
+{}
+
+//----------------------------------------------------------------------------
+VVTK_ImageWriter
+::~VVTK_ImageWriter()
+{
+  if(MYDEBUG) cout<<"VVTK_ImageWriter::~VVTK_ImageWriter - this = "<<this<<endl;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_ImageWriter
+::run()
+{
+  vtkJPEGWriter *aWriter = vtkJPEGWriter::New();
+  vtkImageData *anImageData = myImageData;
+  vtkSmartPointer<vtkImageClip> anImageClip;
+  //
+  if(myConstraint16Flag){ 
+    int uExtent[6];
+    myImageData->GetUpdateExtent(uExtent);
+    unsigned int width = uExtent[1] - uExtent[0] + 1;
+    unsigned int height = uExtent[3] - uExtent[2] + 1;
+    width = (width / 16) * 16;
+    height= (height / 16) * 16;
+    uExtent[1] = uExtent[0] + width - 1;
+    uExtent[3] = uExtent[2] + height - 1;
+    //
+    anImageClip = vtkImageClip::New();
+    anImageClip->Delete();
+
+    anImageClip->SetInput(myImageData);
+    anImageClip->SetOutputWholeExtent(uExtent);
+    anImageClip->ClipDataOn();
+    anImageData = anImageClip->GetOutput();
+  }
+  //
+  aWriter->WriteToMemoryOff();
+  aWriter->SetFileName(myName.c_str());
+  aWriter->SetQuality(myQuality);
+  aWriter->SetProgressive(myProgressive);
+  aWriter->SetInput(anImageData);
+  aWriter->Write();
+
+  aWriter->Delete();
+  myImageData->Delete();
+
+  if(MYDEBUG) cout<<"VVTK_ImageWriter::run "<<
+               "- this = "<<this<<
+               "; total = "<<mySemaphore->total()<<
+               "; available = "<<mySemaphore->available()<<endl;
+  *mySemaphore -= 1;
+}
+