1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SALOME FILTER : interactive object for VISU entities implementation
23 // File : SALOME_TransformFilter.h
24 // Author : Laurent CORNABE with help of Nicolas REJNERI
27 #include "VTKViewer_TransformFilter.h"
28 #include "VTKViewer_Transform.h"
30 #include <vtkObjectFactory.h>
31 #include <vtkPointSet.h>
32 #include <vtkPointData.h>
33 #include <vtkCellData.h>
34 #include <vtkPoints.h>
35 #include <vtkInformation.h>
36 #include <vtkInformationVector.h>
38 vtkStandardNewMacro(VTKViewer_TransformFilter);
40 /*!Execution method. Calculate output.*/
41 int VTKViewer_TransformFilter::RequestData(
42 vtkInformation *vtkNotUsed(request),
43 vtkInformationVector **inputVector,
44 vtkInformationVector *outputVector)
46 // get the info objects
47 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
48 vtkInformation *outInfo = outputVector->GetInformationObject(0);
50 // get the input and ouptut
51 vtkPointSet *input = vtkPointSet::SafeDownCast(
52 inInfo->Get(vtkDataObject::DATA_OBJECT()));
53 vtkPointSet *output = vtkPointSet::SafeDownCast(
54 outInfo->Get(vtkDataObject::DATA_OBJECT()));
59 vtkPointData *pd=input->GetPointData(), *outPD=output->GetPointData();
60 vtkCellData *cd=input->GetCellData(), *outCD=output->GetCellData();
61 output->CopyStructure( input );
63 bool anIsIdentity = true;
64 if(VTKViewer_Transform* aTransform = dynamic_cast<VTKViewer_Transform*>(Transform))
65 anIsIdentity = aTransform->IsIdentity() != 0;
66 inPts = input->GetPoints();
67 if(!anIsIdentity && inPts){
68 numPts = inPts->GetNumberOfPoints();
69 numCells = input->GetNumberOfCells();
70 newPts = vtkPoints::New();
71 newPts->Allocate(numPts);
72 this->UpdateProgress(.2);
73 this->Transform->TransformPoints(inPts,newPts);
74 this->UpdateProgress(.8);
75 output->SetPoints(newPts);