-// SALOME OBJECT : kernel of SALOME component
+// Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 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, or (at your option) any later version.
//
-// 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 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"
#include <vtkObjectFactory.h>
#include <vtkPointData.h>
#include <vtkUnstructuredGrid.h>
+#include <vtkInformation.h>
+#include <vtkInformationVector.h>
-#ifdef _DEBUG_
-static int MYDEBUG = 0;
-static int MYDEBUGWITHFILES = 0;
-#else
-static int MYDEBUG = 0;
-static int MYDEBUGWITHFILES = 0;
-#endif
-
-vtkCxxRevisionMacro(VTKViewer_ShrinkFilter, "$Revision$");
-vtkStandardNewMacro(VTKViewer_ShrinkFilter);
-
+vtkStandardNewMacro(VTKViewer_ShrinkFilter)
+/*!Constructor. Sets store mapping to zero.*/
VTKViewer_ShrinkFilter::VTKViewer_ShrinkFilter():
myStoreMapping(0)
{}
-
+/*!Destructor.*/
VTKViewer_ShrinkFilter::~VTKViewer_ShrinkFilter()
{}
-void VTKViewer_ShrinkFilter::Execute()
+/*!Execute method. Calculate output.*/
+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 i, numIds, abort=0;
+ int j;
vtkIdType cellId, numCells, numPts;
vtkIdType oldId, newId;
- float 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;
- float decimal;
+ double decimal;
vtkDebugMacro(<<"Shrinking cells");
if (numCells < 1 || numPts < 1)
{
vtkErrorMacro(<<"No data to shrink!");
- return;
+ return 0;
}
ptIds = vtkIdList::New();
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);
ptIds->Delete();
newPtIds->Delete();
newPts->Delete();
+
+ return 1;
}
-
+/*!Sets store mapping.*/
void VTKViewer_ShrinkFilter::SetStoreMapping(int theStoreMapping){
myStoreMapping = theStoreMapping;
this->Modified();
}
-vtkIdType VTKViewer_ShrinkFilter::GetNodeObjId(int theVtkID){
- if(myVTK2ObjIds.empty() || theVtkID > myVTK2ObjIds.size()) return -1;
+/*!Return node object id by vtk node id.
+ *\retval -1 - if no object, else return id.
+ */
+vtkIdType VTKViewer_ShrinkFilter::GetNodeObjId(vtkIdType theVtkID)
+{
+ if ( myVTK2ObjIds.empty() || theVtkID > (vtkIdType)myVTK2ObjIds.size() )
+ return -1;
return myVTK2ObjIds.at(theVtkID);
}