Salome HOME
Upgrade to paraview 5.4
[modules/gui.git] / src / VTKViewer / VTKViewer_ShrinkFilter.cxx
index c485a7092c7b628906315a4d7f38e9fdfdbbf4dd..b92e2f1efb945b4215af450a5ccba4571f0e1d1f 100755 (executable)
@@ -1,30 +1,28 @@
-//  SALOME OBJECT : kernel of SALOME component
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  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 
+// 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, 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
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+//  SALOME OBJECT : kernel of SALOME component
 //  File   : SALOME_GeometryFilter.cxx
 //  Author : Michael ZORIN
-//  Module : SALOME
-//  $Header$
 
 #include "VTKViewer_ShrinkFilter.h"
 
@@ -34,8 +32,9 @@
 #include <vtkObjectFactory.h>
 #include <vtkPointData.h>
 #include <vtkUnstructuredGrid.h>
+#include <vtkInformation.h>
+#include <vtkInformationVector.h>
 
-vtkCxxRevisionMacro(VTKViewer_ShrinkFilter, "$Revision$");
 vtkStandardNewMacro(VTKViewer_ShrinkFilter);
 
 /*!Constructor. Sets store mapping to zero.*/
@@ -49,19 +48,30 @@ VTKViewer_ShrinkFilter::~VTKViewer_ShrinkFilter()
 
 
 /*!Execute method. Calculate output.*/
-void VTKViewer_ShrinkFilter::Execute()
+int VTKViewer_ShrinkFilter::RequestData(
+  vtkInformation *vtkNotUsed(request),
+  vtkInformationVector **inputVector,
+  vtkInformationVector *outputVector)
 {
+  // get the info objects
+  vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
+  vtkInformation *outInfo = outputVector->GetInformationObject(0);
+
+  // get the input and ouptut
+  vtkDataSet *input = vtkDataSet::SafeDownCast(
+    inInfo->Get(vtkDataObject::DATA_OBJECT()));
+  vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(
+    outInfo->Get(vtkDataObject::DATA_OBJECT()));
+
   vtkPoints *newPts;
   int i, j, numIds, abort=0;
   vtkIdType cellId, numCells, numPts;
   vtkIdType oldId, newId;
-  vtkFloatingPointType center[3], *p, pt[3];
+  double center[3], *p, pt[3];
   vtkPointData *pd, *outPD;;
   vtkIdList *ptIds, *newPtIds;
-  vtkDataSet *input= this->GetInput();
-  vtkUnstructuredGrid *output = this->GetOutput();
   vtkIdType tenth;
-  vtkFloatingPointType decimal;
+  double decimal;
 
   vtkDebugMacro(<<"Shrinking cells");
 
@@ -70,7 +80,7 @@ void VTKViewer_ShrinkFilter::Execute()
   if (numCells < 1 || numPts < 1)
     {
     vtkErrorMacro(<<"No data to shrink!");
-    return;
+    return 0;
     }
 
   ptIds = vtkIdList::New();
@@ -136,7 +146,7 @@ void VTKViewer_ShrinkFilter::Execute()
       oldId = ptIds->GetId(i);
       newId = newPts->InsertNextPoint(pt);
       if(myStoreMapping)
-       myVTK2ObjIds.push_back(oldId);
+        myVTK2ObjIds.push_back(oldId);
       newPtIds->InsertId(i,newId);
 
       outPD->CopyData(pd, oldId, newId);
@@ -154,6 +164,8 @@ void VTKViewer_ShrinkFilter::Execute()
   ptIds->Delete();
   newPtIds->Delete();
   newPts->Delete();
+  
+  return 1;
 }
 
 /*!Sets store mapping.*/
@@ -166,7 +178,9 @@ void VTKViewer_ShrinkFilter::SetStoreMapping(int theStoreMapping){
 /*!Return node object id by vtk node id.
  *\retval -1 - if no object, else return id.
  */
-vtkIdType VTKViewer_ShrinkFilter::GetNodeObjId(int theVtkID){
-  if(myVTK2ObjIds.empty() || theVtkID > myVTK2ObjIds.size()) return -1;
+vtkIdType VTKViewer_ShrinkFilter::GetNodeObjId(int theVtkID)
+{
+  if ( myVTK2ObjIds.empty() || theVtkID > (int)myVTK2ObjIds.size() )
+    return -1;
   return myVTK2ObjIds.at(theVtkID);
 }