1 // Copyright (C) 2010-2016 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "VTKMEDCouplingCMeshClient.hxx"
22 #include "vtkErrorCode.h"
23 #include "vtkDoubleArray.h"
24 #include "vtkRectilinearGrid.h"
29 void ParaMEDMEM2VTK::FillMEDCouplingCMeshInstanceFrom(SALOME_MED::MEDCouplingCMeshCorbaInterface_ptr meshPtr, vtkRectilinearGrid *ret)
32 SALOME_TYPES::ListOfDouble *tinyD;
33 SALOME_TYPES::ListOfLong *tinyI;
34 SALOME_TYPES::ListOfString *tinyS;
35 meshPtr->getTinyInfo(tinyD,tinyI,tinyS);
36 int sizePerAxe[3]={1,1,1};
37 bool isOK[3]={false,false,false};
39 { sizePerAxe[0]=(*tinyI)[0]; isOK[0]=true; }
41 { sizePerAxe[1]=(*tinyI)[1]; isOK[1]=true; }
43 { sizePerAxe[2]=(*tinyI)[2]; isOK[2]=true; }
44 ret->SetDimensions(sizePerAxe[0],sizePerAxe[1],sizePerAxe[2]);
48 SALOME_TYPES::ListOfDouble *bigD;
49 meshPtr->getSerialisationData(tinyI,bigD);
55 da=vtkDoubleArray::New();
56 da->SetNumberOfTuples(sizePerAxe[0]);
57 da->SetNumberOfComponents(1);
58 double *pt=da->GetPointer(0);
59 for(int i=0;i<sizePerAxe[0];i++)
61 ret->SetXCoordinates(da);
63 offset+=sizePerAxe[0];
67 da=vtkDoubleArray::New();
68 da->SetNumberOfTuples(sizePerAxe[1]);
69 da->SetNumberOfComponents(1);
70 double *pt=da->GetPointer(0);
71 for(int i=0;i<sizePerAxe[1];i++)
72 pt[i]=(*bigD)[offset+i];
73 ret->SetYCoordinates(da);
75 offset+=sizePerAxe[1];
79 da=vtkDoubleArray::New(); da->SetNumberOfTuples(1); da->SetNumberOfComponents(1);
80 double *pt=da->GetPointer(0); *pt=0.; ret->SetYCoordinates(da); da->Delete();
84 da=vtkDoubleArray::New();
85 da->SetNumberOfTuples(sizePerAxe[2]);
86 da->SetNumberOfComponents(1);
87 double *pt=da->GetPointer(0);
88 for(int i=0;i<sizePerAxe[2];i++)
89 pt[i]=(*bigD)[offset+i];
90 ret->SetZCoordinates(da);
95 da=vtkDoubleArray::New(); da->SetNumberOfTuples(1); da->SetNumberOfComponents(1);
96 double *pt=da->GetPointer(0); *pt=0.; ret->SetZCoordinates(da); da->Delete();
99 meshPtr->UnRegister();