Back to index

salome-gui  6.5.0
VTKViewer_TransformFilter.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SALOME FILTER : interactive object for VISU entities implementation
00024 //  File   : SALOME_TransformFilter.h
00025 //  Author : Laurent CORNABE with help of Nicolas REJNERI
00026 //  Module : SALOME
00027 //
00028 #include "VTKViewer_TransformFilter.h"
00029 #include "VTKViewer_Transform.h"
00030 
00031 #include <vtkObjectFactory.h>
00032 #include <vtkPointSet.h>
00033 #include <vtkPointData.h>
00034 #include <vtkCellData.h>
00035 #include <vtkPoints.h>
00036 #include <vtkInformation.h>
00037 #include <vtkInformationVector.h>
00038 
00039 vtkStandardNewMacro(VTKViewer_TransformFilter);
00040 
00042 int VTKViewer_TransformFilter::RequestData(
00043   vtkInformation *vtkNotUsed(request),
00044   vtkInformationVector **inputVector,
00045   vtkInformationVector *outputVector)
00046 {
00047   // get the info objects
00048   vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
00049   vtkInformation *outInfo = outputVector->GetInformationObject(0);
00050 
00051   // get the input and ouptut
00052   vtkPointSet *input = vtkPointSet::SafeDownCast(
00053     inInfo->Get(vtkDataObject::DATA_OBJECT()));
00054   vtkPointSet *output = vtkPointSet::SafeDownCast(
00055     outInfo->Get(vtkDataObject::DATA_OBJECT()));
00056 
00057   vtkPoints *inPts;
00058   vtkPoints *newPts;
00059   int numPts/*, numCells*/;
00060   vtkPointData *pd=input->GetPointData(), *outPD=output->GetPointData();
00061   vtkCellData *cd=input->GetCellData(), *outCD=output->GetCellData();
00062   output->CopyStructure( input );
00063   if(Transform){
00064     bool anIsIdentity = true;
00065     if(VTKViewer_Transform* aTransform = dynamic_cast<VTKViewer_Transform*>(Transform))
00066       anIsIdentity = aTransform->IsIdentity() != 0;
00067     inPts = input->GetPoints();
00068     if(!anIsIdentity && inPts){
00069       numPts = inPts->GetNumberOfPoints();
00070       // numCells = input->GetNumberOfCells();
00071       newPts = vtkPoints::New();
00072       newPts->Allocate(numPts);
00073       this->UpdateProgress(.2);
00074       this->Transform->TransformPoints(inPts,newPts);
00075       this->UpdateProgress(.8);
00076       output->SetPoints(newPts);
00077       newPts->Delete();
00078     }
00079   }
00080   outPD->PassData(pd);
00081   outCD->PassData(cd);
00082   InvokeEvent("VTKViewer_TransformFilter::TransformationFinished");
00083   
00084   return 1;
00085 }