]> SALOME platform Git repositories - modules/paravis.git/blob - src/Plugins/ParaMEDCorba/VTKMEDCouplingCMeshClient.cxx
Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/paravis.git] / src / Plugins / ParaMEDCorba / VTKMEDCouplingCMeshClient.cxx
1 // Copyright (C) 2010-2012  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.
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 "VTKMEDCouplingCMeshClient.hxx"
21
22 #include "vtkErrorCode.h"
23 #include "vtkDoubleArray.h"
24 #include "vtkRectilinearGrid.h"
25
26 #include <vector>
27 #include <string>
28
29 void ParaMEDMEM2VTK::FillMEDCouplingCMeshInstanceFrom(SALOME_MED::MEDCouplingCMeshCorbaInterface_ptr meshPtr, vtkRectilinearGrid *ret)
30 {
31   meshPtr->Register();
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];
37   sizePerAxe[0]=(*tinyI)[0];
38   sizePerAxe[1]=(*tinyI)[1];
39   sizePerAxe[2]=(*tinyI)[2];
40   ret->SetDimensions(sizePerAxe[0],sizePerAxe[1],sizePerAxe[2]);
41   delete tinyI;
42   delete tinyS;
43   SALOME_TYPES::ListOfDouble *bigD;
44   meshPtr->getSerialisationData(tinyI,bigD);
45   delete tinyI;
46   int offset=0;
47   vtkDoubleArray *da=0;
48   if(sizePerAxe[0]>0)
49     {
50       da=vtkDoubleArray::New();
51       da->SetNumberOfTuples(sizePerAxe[0]);
52       da->SetNumberOfComponents(1);
53       double *pt=da->GetPointer(0);
54       for(int i=0;i<sizePerAxe[0];i++)
55         pt[i]=(*bigD)[i];
56       ret->SetXCoordinates(da);
57       da->Delete();
58       offset+=sizePerAxe[0];
59     }
60   if(sizePerAxe[1]>0)
61     {
62       da=vtkDoubleArray::New();
63       da->SetNumberOfTuples(sizePerAxe[1]);
64       da->SetNumberOfComponents(1);
65       double *pt=da->GetPointer(0);
66       for(int i=0;i<sizePerAxe[1];i++)
67         pt[i]=(*bigD)[offset+i];
68       ret->SetYCoordinates(da);
69       da->Delete();
70       offset+=sizePerAxe[1];
71     }
72   if(sizePerAxe[2]>0)
73     {
74       da=vtkDoubleArray::New();
75       da->SetNumberOfTuples(sizePerAxe[2]);
76       da->SetNumberOfComponents(1);
77       double *pt=da->GetPointer(0);
78       for(int i=0;i<sizePerAxe[2];i++)
79         pt[i]=(*bigD)[offset+i];
80       ret->SetZCoordinates(da);
81       da->Delete();
82     }
83   delete bigD;
84   meshPtr->UnRegister();
85 }