Salome HOME
Merge branch 'origin/akl/22533'
[modules/paravis.git] / src / Plugins / ParaMEDCorba / VTKParaMEDFieldClient.cxx
1 // Copyright (C) 2010-2014  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "VTKParaMEDFieldClient.hxx"
21 #include "VTKMEDCouplingFieldClient.hxx"
22
23 #include "vtkDataSet.h"
24 #include "vtkUnstructuredGrid.h"
25 #include "vtkMultiBlockDataSet.h"
26 #include "vtkMultiBlockDataGroupFilter.h"
27 #include "vtkCompositeDataToUnstructuredGridFilter.h"
28
29 std::vector<double> ParaMEDMEM2VTK::FillMEDCouplingParaFieldDoubleInstanceFrom(SALOME_MED::ParaMEDCouplingFieldDoubleCorbaInterface_ptr fieldPtr, int begin, int end,
30                                                                                vtkMultiBlockDataSet *ret)
31 {
32   std::vector<double> ret2;
33   int nbOfParts=end-begin;
34   Engines::IORTab *allSlices=fieldPtr->tior();
35   vtkMultiBlockDataGroupFilter *tmp=vtkMultiBlockDataGroupFilter::New();
36   for(int i=0;i<nbOfParts;i++)
37     {
38       CORBA::Object_ptr obj=(*allSlices)[i+begin];
39       SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_var fieldCorba=SALOME_MED::MEDCouplingFieldDoubleCorbaInterface::_narrow(obj);
40       std::vector<double> times;
41       vtkDataSet *part=ParaMEDMEM2VTK::BuildFullyFilledFromMEDCouplingFieldDoubleInstance(fieldCorba,times);
42       tmp->SetInputData(part);
43       part->Delete();
44     }
45   vtkCompositeDataToUnstructuredGridFilter *tmp2=vtkCompositeDataToUnstructuredGridFilter::New();
46   tmp2->SetInputData(tmp->GetOutput());
47   tmp2->Update();
48   //
49   vtkUnstructuredGrid *ret3=tmp2->GetOutput();
50   ret->SetBlock(0,ret3);
51   //
52   tmp->Delete();
53   tmp2->Delete();
54   delete allSlices;
55   return ret2;
56 }