Back to index

salome-paravis  6.5.0
VTKMEDCouplingCMeshClient.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 "VTKMEDCouplingCMeshClient.hxx"
00021 
00022 #include "vtkErrorCode.h"
00023 #include "vtkDoubleArray.h"
00024 #include "vtkRectilinearGrid.h"
00025 
00026 #include <vector>
00027 #include <string>
00028 
00029 void ParaMEDMEM2VTK::FillMEDCouplingCMeshInstanceFrom(SALOME_MED::MEDCouplingCMeshCorbaInterface_ptr meshPtr, vtkRectilinearGrid *ret)
00030 {
00031   meshPtr->Register();
00032   SALOME_TYPES::ListOfDouble *tinyD;
00033   SALOME_TYPES::ListOfLong *tinyI;
00034   SALOME_TYPES::ListOfString *tinyS;
00035   meshPtr->getTinyInfo(tinyD,tinyI,tinyS);
00036   int sizePerAxe[3];
00037   sizePerAxe[0]=(*tinyI)[0];
00038   sizePerAxe[1]=(*tinyI)[1];
00039   sizePerAxe[2]=(*tinyI)[2];
00040   ret->SetDimensions(sizePerAxe[0],sizePerAxe[1],sizePerAxe[2]);
00041   delete tinyI;
00042   delete tinyS;
00043   SALOME_TYPES::ListOfDouble *bigD;
00044   meshPtr->getSerialisationData(tinyI,bigD);
00045   delete tinyI;
00046   int offset=0;
00047   vtkDoubleArray *da=0;
00048   if(sizePerAxe[0]>0)
00049     {
00050       da=vtkDoubleArray::New();
00051       da->SetNumberOfTuples(sizePerAxe[0]);
00052       da->SetNumberOfComponents(1);
00053       double *pt=da->GetPointer(0);
00054       for(int i=0;i<sizePerAxe[0];i++)
00055         pt[i]=(*bigD)[i];
00056       ret->SetXCoordinates(da);
00057       da->Delete();
00058       offset+=sizePerAxe[0];
00059     }
00060   if(sizePerAxe[1]>0)
00061     {
00062       da=vtkDoubleArray::New();
00063       da->SetNumberOfTuples(sizePerAxe[1]);
00064       da->SetNumberOfComponents(1);
00065       double *pt=da->GetPointer(0);
00066       for(int i=0;i<sizePerAxe[1];i++)
00067         pt[i]=(*bigD)[offset+i];
00068       ret->SetYCoordinates(da);
00069       da->Delete();
00070       offset+=sizePerAxe[1];
00071     }
00072   if(sizePerAxe[2]>0)
00073     {
00074       da=vtkDoubleArray::New();
00075       da->SetNumberOfTuples(sizePerAxe[2]);
00076       da->SetNumberOfComponents(1);
00077       double *pt=da->GetPointer(0);
00078       for(int i=0;i<sizePerAxe[2];i++)
00079         pt[i]=(*bigD)[offset+i];
00080       ret->SetZCoordinates(da);
00081       da->Delete();
00082     }
00083   delete bigD;
00084   meshPtr->UnRegister();
00085 }