Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[modules/gui.git] / src / VTKViewer / VTKViewer_TransformFilter.cxx
1 //  SALOME FILTER : interactive object for VISU entities implementation
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //
23 //
24 //  File   : SALOME_TransformFilter.h
25 //  Author : Laurent CORNABE with help of Nicolas REJNERI
26 //  Module : SALOME
27
28
29 #include "VTKViewer_TransformFilter.h"
30 #include "VTKViewer_Transform.h"
31
32 #include <vtkObjectFactory.h>
33 #include <vtkPointSet.h>
34 #include <vtkPointData.h>
35 #include <vtkCellData.h>
36 #include <vtkPoints.h>
37
38
39 vtkStandardNewMacro(VTKViewer_TransformFilter);
40
41 /*!Execution method. Calculate output.*/
42 void VTKViewer_TransformFilter::Execute(){
43   vtkPoints *inPts;
44   vtkPoints *newPts;
45   int numPts, numCells;
46   vtkPointSet *input = this->GetInput();
47   vtkPointSet *output = this->GetOutput();
48   vtkPointData *pd=input->GetPointData(), *outPD=output->GetPointData();
49   vtkCellData *cd=input->GetCellData(), *outCD=output->GetCellData();
50   output->CopyStructure( input );
51   if(Transform){
52     bool anIsIdentity = true;
53     if(VTKViewer_Transform* aTransform = dynamic_cast<VTKViewer_Transform*>(Transform))
54       anIsIdentity = aTransform->IsIdentity() != 0;
55     inPts = input->GetPoints();
56     if(!anIsIdentity && inPts){
57       numPts = inPts->GetNumberOfPoints();
58       numCells = input->GetNumberOfCells();
59       newPts = vtkPoints::New();
60       newPts->Allocate(numPts);
61       this->UpdateProgress(.2);
62       this->Transform->TransformPoints(inPts,newPts);
63       this->UpdateProgress(.8);
64       output->SetPoints(newPts);
65       newPts->Delete();
66     }
67   }
68   outPD->PassData(pd);
69   outCD->PassData(cd);
70 }