Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/med.git] / src / MEDCouplingCorba / MEDCouplingFieldServant.cxx
1 // Copyright (C) 2007-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 "MEDCouplingFieldServant.hxx"
21 #include "MEDCouplingMeshServant.hxx"
22 #include "MEDCouplingUMeshServant.hxx"
23 #include "MEDCouplingCMeshServant.hxx"
24 #include "MEDCouplingExtrudedMeshServant.hxx"
25 #include "MEDCouplingField.hxx"
26 #include "MEDCouplingUMesh.hxx"
27 #include "MEDCouplingCMesh.hxx"
28 #include "MEDCouplingExtrudedMesh.hxx"
29
30 using namespace ParaMEDMEM;
31
32 MEDCouplingFieldServant::MEDCouplingFieldServant(const MEDCouplingField *cppPointerOfMesh):MEDCouplingRefCountServant(cppPointerOfMesh,cppPointerOfMesh)
33 {
34 }
35
36 SALOME_MED::MEDCouplingMeshCorbaInterface_ptr MEDCouplingFieldServant::BuildCorbaRefFromCppPointer(const MEDCouplingMesh *mesh)
37 {
38   const MEDCouplingUMesh *uMesh=dynamic_cast<const MEDCouplingUMesh *>(mesh);
39   if(uMesh)
40     {
41       MEDCouplingUMeshServant *retServ=new MEDCouplingUMeshServant(uMesh);
42       SALOME_MED::MEDCouplingUMeshCorbaInterface_ptr ret=retServ->_this();//let this line even if it seems fool
43       return ret;
44     }
45   const MEDCouplingCMesh *cMesh=dynamic_cast<const MEDCouplingCMesh *>(mesh);
46   if(cMesh)
47     {
48       MEDCouplingCMeshServant *retServ=new MEDCouplingCMeshServant(cMesh);
49       SALOME_MED::MEDCouplingCMeshCorbaInterface_ptr ret=retServ->_this();//let this line even if it seems fool
50       return ret;
51     }
52   const MEDCouplingExtrudedMesh *eMesh=dynamic_cast<const MEDCouplingExtrudedMesh *>(mesh);
53   if(eMesh)
54     {
55       MEDCouplingExtrudedMeshServant *retServ=new MEDCouplingExtrudedMeshServant(eMesh);
56       return retServ->_this();
57     }
58   throw INTERP_KERNEL::Exception("Not dealt mesh type !");
59 }
60
61 SALOME_MED::MEDCouplingMeshCorbaInterface_ptr MEDCouplingFieldServant::getMesh()
62 {
63   const MEDCouplingMesh *mesh=getPointer()->getMesh();
64   return BuildCorbaRefFromCppPointer(mesh);
65 }