Back to index

salome-paravis  6.5.0
VTKParaMEDFieldClient.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2010-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "VTKParaMEDFieldClient.hxx"
00021 #include "VTKMEDCouplingFieldClient.hxx"
00022 
00023 #include "vtkDataSet.h"
00024 #include "vtkUnstructuredGrid.h"
00025 #include "vtkMultiBlockDataSet.h"
00026 #include "vtkMultiBlockDataGroupFilter.h"
00027 #include "vtkCompositeDataToUnstructuredGridFilter.h"
00028 
00029 std::vector<double> ParaMEDMEM2VTK::FillMEDCouplingParaFieldDoubleInstanceFrom(SALOME_MED::ParaMEDCouplingFieldDoubleCorbaInterface_ptr fieldPtr, int begin, int end,
00030                                                                                vtkMultiBlockDataSet *ret)
00031 {
00032   std::vector<double> ret2;
00033   int nbOfParts=end-begin;
00034   Engines::IORTab *allSlices=fieldPtr->tior();
00035   vtkMultiBlockDataGroupFilter *tmp=vtkMultiBlockDataGroupFilter::New();
00036   for(int i=0;i<nbOfParts;i++)
00037     {
00038       CORBA::Object_ptr obj=(*allSlices)[i+begin];
00039       SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_var fieldCorba=SALOME_MED::MEDCouplingFieldDoubleCorbaInterface::_narrow(obj);
00040       std::vector<double> times;
00041       vtkDataSet *part=ParaMEDMEM2VTK::BuildFullyFilledFromMEDCouplingFieldDoubleInstance(fieldCorba,times);
00042       tmp->AddInputConnection(part->GetProducerPort());
00043       part->Delete();
00044     }
00045   vtkCompositeDataToUnstructuredGridFilter *tmp2=vtkCompositeDataToUnstructuredGridFilter::New();
00046   tmp2->AddInputConnection(tmp->GetOutput()->GetProducerPort());
00047   tmp2->Update();
00048   //
00049   vtkUnstructuredGrid *ret3=tmp2->GetOutput();
00050   ret->SetBlock(0,ret3);
00051   //
00052   tmp->Delete();
00053   tmp2->Delete();
00054   delete allSlices;
00055   return ret2;
00056 }