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