Back to index

salome-med  6.5.0
MEDMEM_convert.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //=============================================================================
00024 // File      : MEDMEM_convert.cxx
00025 // Created   : mer fév 20 15:47:57 CET 2002
00026 // Author    : EDF
00027 // Project   : SALOME
00028 // $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_convert.cxx
00029 //=============================================================================
00030 //
00031 #include "utilities.h"
00032 #include "Utils_CorbaException.hxx"
00033 
00034 #include "MEDMEM_convert.hxx"
00035 
00036 
00037 SALOME_MED::medGeometryElement convertMedEltToIdlElt(medGeometryElement element) 
00038 throw (SALOME::SALOME_Exception)
00039 {
00040   switch (element)
00041     {
00042     case MED_NONE    :  return SALOME_MED::MED_NONE;
00043     case MED_POINT1  :  return SALOME_MED::MED_POINT1;
00044     case MED_SEG2    :  return SALOME_MED::MED_SEG2;
00045     case MED_SEG3    :  return SALOME_MED::MED_SEG3;
00046     case MED_TRIA3   :  return SALOME_MED::MED_TRIA3;
00047     case MED_QUAD4   :  return SALOME_MED::MED_QUAD4;
00048     case MED_TRIA6   :  return SALOME_MED::MED_TRIA6;
00049     case MED_QUAD8   :  return SALOME_MED::MED_QUAD8;
00050     case MED_TETRA4  :  return SALOME_MED::MED_TETRA4;
00051     case MED_PYRA5   :  return SALOME_MED::MED_PYRA5;
00052     case MED_PENTA6  :  return SALOME_MED::MED_PENTA6;
00053     case MED_HEXA8   :  return SALOME_MED::MED_HEXA8;
00054     case MED_TETRA10 :  return SALOME_MED::MED_TETRA10;
00055     case MED_PYRA13  :  return SALOME_MED::MED_PYRA13;
00056     case MED_PENTA15 :  return SALOME_MED::MED_PENTA15;
00057     case MED_HEXA20  :  return SALOME_MED::MED_HEXA20;
00058     case MED_POLYGON      :  return SALOME_MED::MED_POLYGON;
00059     case MED_POLYHEDRA    :  return SALOME_MED::MED_POLYHEDRA;
00060     case MED_ALL_ELEMENTS :  return SALOME_MED::MED_ALL_ELEMENTS;
00061     default :
00062         { MESSAGE("Unknown Geometry Element");
00063           THROW_SALOME_CORBA_EXCEPTION("Unknown Geometry Element",
00064                                         SALOME::INTERNAL_ERROR);
00065         } 
00066    }
00067 }
00068 
00069 medGeometryElement convertIdlEltToMedElt(SALOME_MED::medGeometryElement element) 
00070 throw (SALOME::SALOME_Exception)
00071 {
00072 
00073   SCRUTE(element);
00074 
00075   switch (element)
00076     {
00077     case SALOME_MED::MED_NONE     :  return MED_NONE;
00078     case SALOME_MED::MED_POINT1   :  return MED_POINT1;
00079     case SALOME_MED::MED_SEG2     :  return MED_SEG2;
00080     case SALOME_MED::MED_SEG3     :  return MED_SEG3;
00081     case SALOME_MED::MED_TRIA3    :  return MED_TRIA3;
00082     case SALOME_MED::MED_QUAD4    :  return MED_QUAD4;
00083     case SALOME_MED::MED_TRIA6    :  return MED_TRIA6;
00084     case SALOME_MED::MED_QUAD8    :  return MED_QUAD8;
00085     case SALOME_MED::MED_TETRA4   :  return MED_TETRA4;
00086     case SALOME_MED::MED_PYRA5    :  return MED_PYRA5;
00087     case SALOME_MED::MED_PENTA6   :  return MED_PENTA6;
00088     case SALOME_MED::MED_HEXA8    :  return MED_HEXA8;
00089     case SALOME_MED::MED_TETRA10  :  return MED_TETRA10;
00090     case SALOME_MED::MED_PYRA13   :  return MED_PYRA13;
00091     case SALOME_MED::MED_PENTA15  :  return MED_PENTA15;
00092     case SALOME_MED::MED_HEXA20   :  return MED_HEXA20;
00093     case SALOME_MED::MED_POLYGON      :  return MED_POLYGON;
00094     case SALOME_MED::MED_POLYHEDRA    :  return MED_POLYHEDRA;
00095     case SALOME_MED::MED_ALL_ELEMENTS :  return MED_ALL_ELEMENTS;
00096     default :
00097         { MESSAGE("unknown Geometry Element");
00098           THROW_SALOME_CORBA_EXCEPTION("Unknown Geometry Element",
00099                                         SALOME::INTERNAL_ERROR);
00100         } 
00101    }
00102 }
00103 
00104 SALOME_MED::medEntityMesh convertMedEntToIdlEnt(medEntityMesh entity)
00105 throw (SALOME::SALOME_Exception)
00106 {
00107   switch (entity)
00108     {
00109     case MED_CELL    :  return SALOME_MED::MED_CELL;
00110     case MED_FACE    :  return SALOME_MED::MED_FACE;
00111     case MED_EDGE    :  return SALOME_MED::MED_EDGE;
00112     case MED_NODE    :  return SALOME_MED::MED_NODE;
00113     case MED_ALL_ENTITIES : return SALOME_MED::MED_ALL_ENTITIES;
00114     default :
00115         { MESSAGE("Unknown entity element");
00116           THROW_SALOME_CORBA_EXCEPTION("Unknown Entity Element",
00117                                         SALOME::INTERNAL_ERROR);
00118         } 
00119    }
00120 }
00121 
00122 medEntityMesh convertIdlEntToMedEnt(SALOME_MED::medEntityMesh entity)
00123 throw (SALOME::SALOME_Exception)
00124 {
00125   switch (entity)
00126     {
00127     case SALOME_MED::MED_CELL    :  return MED_CELL; 
00128     case SALOME_MED::MED_FACE    :  return MED_FACE;
00129     case SALOME_MED::MED_EDGE    :  return MED_EDGE;
00130     case SALOME_MED::MED_NODE    :  return MED_NODE;
00131     case SALOME_MED::MED_ALL_ENTITIES : return MED_ALL_ENTITIES;
00132     default :
00133         { MESSAGE("Unknown Entity Element");
00134           THROW_SALOME_CORBA_EXCEPTION("Unknown Entity Element",
00135                                         SALOME::INTERNAL_ERROR);
00136         } 
00137    }
00138 }
00139 
00140 medModeSwitch convertIdlModeToMedMode(SALOME_MED::medModeSwitch mode)
00141 throw (SALOME::SALOME_Exception)
00142 {
00143   switch (mode)
00144     {
00145     case SALOME_MED::MED_FULL_INTERLACE       : return MED_FULL_INTERLACE; 
00146     case SALOME_MED::MED_NO_INTERLACE         : return MED_NO_INTERLACE; 
00147     case SALOME_MED::MED_NO_INTERLACE_BY_TYPE : return MED_NO_INTERLACE_BY_TYPE; 
00148     default :
00149         { MESSAGE("Unknown interlace mode");
00150           THROW_SALOME_CORBA_EXCEPTION("Unknown interlace mode",
00151                                         SALOME::INTERNAL_ERROR);
00152         } 
00153    }
00154 }
00155 
00156 SALOME_MED::medModeSwitch convertMedModeToIdlMode(medModeSwitch mode)
00157 throw (SALOME::SALOME_Exception)
00158 {
00159   switch (mode)
00160     {
00161     case MED_FULL_INTERLACE       :  return SALOME_MED::MED_FULL_INTERLACE; 
00162     case MED_NO_INTERLACE         :  return SALOME_MED::MED_NO_INTERLACE; 
00163     case MED_NO_INTERLACE_BY_TYPE :  return SALOME_MED::MED_NO_INTERLACE_BY_TYPE; 
00164     default :
00165         { MESSAGE("Unknown interlace mode");
00166           THROW_SALOME_CORBA_EXCEPTION("Unknown interlace mode",
00167                                         SALOME::INTERNAL_ERROR);
00168         } 
00169    }
00170 }
00171 SALOME_MED::medConnectivity convertMedConnToIdlConn(medConnectivity connectivite)
00172 throw (SALOME::SALOME_Exception)
00173 {
00174   switch (connectivite)
00175     {
00176     case MED_NODAL       :  return SALOME_MED::MED_NODAL; 
00177     case MED_DESCENDING  :  return SALOME_MED::MED_DESCENDING; 
00178     default :
00179         { MESSAGE("Unknown connectivity type");
00180           THROW_SALOME_CORBA_EXCEPTION("Unknown connectivity type",
00181                                         SALOME::INTERNAL_ERROR);
00182         } 
00183    }
00184 }
00185 medConnectivity convertIdlConnToMedConn(SALOME_MED::medConnectivity connectivite)
00186 throw (SALOME::SALOME_Exception)
00187 {
00188   switch (connectivite)
00189     {
00190     case SALOME_MED::MED_NODAL       :  return MED_NODAL; 
00191     case SALOME_MED::MED_DESCENDING  :  return MED_DESCENDING; 
00192     default :
00193         { MESSAGE("Unknown connectivity type");
00194           THROW_SALOME_CORBA_EXCEPTION("Unknown connectivity type",
00195                                         SALOME::INTERNAL_ERROR);
00196         } 
00197    }
00198 }
00199 SALOME_MED::medDriverTypes convertMedDriverToIdlDriver(MEDMEM::driverTypes driverType)
00200 throw (SALOME::SALOME_Exception)
00201 {
00202   switch (driverType)
00203     {
00204     case MEDMEM::MED_DRIVER  :  return SALOME_MED::MED_DRIVER; 
00205     case MEDMEM::VTK_DRIVER  :  return SALOME_MED::VTK_DRIVER; 
00206     case MEDMEM::NO_DRIVER   :  return SALOME_MED::NO_DRIVER;
00207     default :
00208         { MESSAGE("Unknown driver type");
00209           THROW_SALOME_CORBA_EXCEPTION("Unknown driver type",
00210                                         SALOME::INTERNAL_ERROR);
00211         } 
00212    }
00213 }
00214 
00215 MEDMEM::driverTypes convertIdlDriverToMedDriver(SALOME_MED::medDriverTypes driverType)
00216 throw (SALOME::SALOME_Exception)
00217 {
00218   switch (driverType)
00219     {
00220     case SALOME_MED::MED_DRIVER  :  return MEDMEM::MED_DRIVER; 
00221     case SALOME_MED::VTK_DRIVER  :  return MEDMEM::VTK_DRIVER; 
00222     case SALOME_MED::NO_DRIVER   :  return MEDMEM::NO_DRIVER;
00223     default :
00224         { MESSAGE("Unknown driver type");
00225           THROW_SALOME_CORBA_EXCEPTION("Unknown driver type",
00226                                         SALOME::INTERNAL_ERROR);
00227         } 
00228    }
00229 }
00230 bool verifieParam (SALOME_MED::medEntityMesh entity,SALOME_MED::medGeometryElement geomElement)
00231 throw (SALOME::SALOME_Exception)
00232 {
00233   SCRUTE(entity);
00234   SCRUTE(geomElement);
00235   bool coherent=false;
00236   switch (entity)
00237    { 
00238     case SALOME_MED::MED_FACE :
00239        {
00240          switch (geomElement)
00241            {
00242            case SALOME_MED::MED_TRIA3    : coherent=true;
00243            case SALOME_MED::MED_QUAD4    : coherent=true;
00244            case SALOME_MED::MED_TRIA6    : coherent=true;
00245            case SALOME_MED::MED_QUAD8    : coherent=true;
00246            case SALOME_MED::MED_POLYGON  : coherent=true;
00247            }
00248          break;
00249        }
00250     case SALOME_MED::MED_CELL :
00251        {
00252          switch (geomElement)
00253            {
00254            case SALOME_MED::MED_POINT1   : coherent=true;
00255            case SALOME_MED::MED_SEG2     : coherent=true;
00256            case SALOME_MED::MED_SEG3     : coherent=true;
00257            case SALOME_MED::MED_TRIA3    : coherent=true;
00258            case SALOME_MED::MED_TRIA6    : coherent=true;
00259            case SALOME_MED::MED_QUAD4    : coherent=true;
00260            case SALOME_MED::MED_QUAD8    : coherent=true;
00261            case SALOME_MED::MED_TETRA4   : coherent=true;
00262            case SALOME_MED::MED_TETRA10  : coherent=true;
00263            case SALOME_MED::MED_HEXA8    : coherent=true;
00264            case SALOME_MED::MED_HEXA20   : coherent=true;
00265            case SALOME_MED::MED_PENTA6   : coherent=true;
00266            case SALOME_MED::MED_PENTA15  : coherent=true;
00267            case SALOME_MED::MED_PYRA5    : coherent=true;
00268            case SALOME_MED::MED_PYRA13   : coherent=true;
00269            case SALOME_MED::MED_POLYGON  : coherent=true;
00270            case SALOME_MED::MED_POLYHEDRA: coherent=true;
00271            }
00272          break;
00273        }
00274     case SALOME_MED::MED_EDGE :
00275        {
00276          switch (geomElement)
00277            {
00278            case SALOME_MED::MED_SEG2     : coherent=true;
00279            case SALOME_MED::MED_SEG3     : coherent=true;
00280            }
00281          break;
00282        }         
00283     case SALOME_MED::MED_NODE :
00284        {
00285          switch (geomElement)
00286            {
00287            case SALOME_MED::MED_POINT1   : coherent=true;
00288            }
00289          break;
00290        }
00291     case SALOME_MED::MED_ALL_ENTITIES :
00292        {
00293          switch (geomElement)
00294            {
00295            case SALOME_MED::MED_NONE     : coherent=true;
00296            }
00297          break;
00298        }
00299     default :
00300         { MESSAGE("Unknown geometric entity");
00301           THROW_SALOME_CORBA_EXCEPTION("Unknown geometric entity",
00302                                         SALOME::INTERNAL_ERROR);
00303         } 
00304          break;
00305     } 
00306 
00307      switch (geomElement)
00308      {
00309            case SALOME_MED::MED_ALL_ELEMENTS     : coherent=true;
00310      }
00311     return coherent;
00312 }