Back to index

salome-smesh  6.5.0
SMESH_MEDMesh_i.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 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
00024 //  File   : SMESH_MEDMesh_i.cxx
00025 //  Module : SMESH
00026 //
00027 #include "SMESH_MEDMesh_i.hxx"
00028 #include "SMESH_Gen_i.hxx"
00029 #include "SMESH_Mesh_i.hxx"
00030 
00031 #include "SMESHDS_Mesh.hxx"
00032 #include "SMESHDS_SubMesh.hxx"
00033 
00034 #include <TopExp.hxx>
00035 #include <TopExp_Explorer.hxx>
00036 #include <TopoDS.hxx>
00037 #include <TopoDS_Iterator.hxx>
00038 #include <TopoDS_Compound.hxx>
00039 #include <TopoDS_CompSolid.hxx>
00040 #include <TopoDS_Solid.hxx>
00041 #include <TopoDS_Shell.hxx>
00042 #include <TopoDS_Face.hxx>
00043 #include <TopoDS_Wire.hxx>
00044 #include <TopoDS_Edge.hxx>
00045 #include <TopoDS_Vertex.hxx>
00046 #include <TopoDS_Shape.hxx>
00047 #include <TopTools_MapOfShape.hxx>
00048 
00049 #include "utilities.h"
00050 #include "Utils_CorbaException.hxx"
00051 
00052 #include "SMESH_MEDSupport_i.hxx"
00053 #include "SMESH_MEDFamily_i.hxx"
00054 
00055 # include "Utils_ORB_INIT.hxx"
00056 # include "Utils_SINGLETON.hxx"
00057 # include "Utils_ExceptHandlers.hxx"
00058 
00059 extern "C"
00060 {
00061 #include <stdio.h>
00062 }
00063 
00064 using namespace std;
00065 
00066 //=============================================================================
00070 //=============================================================================
00071 // PN Est-ce un const ?
00072 SMESH_MEDMesh_i::SMESH_MEDMesh_i()
00073 {
00074   BEGIN_OF("Default Constructor SMESH_MEDMesh_i");
00075   END_OF("Default Constructor SMESH_MEDMesh_i");
00076 }
00077 
00078 //=============================================================================
00082 //=============================================================================
00083 SMESH_MEDMesh_i::~SMESH_MEDMesh_i()
00084 {
00085 }
00086 
00087 //=============================================================================
00091 //=============================================================================
00092 SMESH_MEDMesh_i::SMESH_MEDMesh_i(::SMESH_Mesh_i * m_i):_meshId(""),
00093                                                        _compte(false),
00094                                                        _creeFamily(false),
00095                                                        _famIdent(0),
00096                                                        _indexElts(0),
00097                                                        _indexEnts(0)
00098 {
00099   BEGIN_OF("Constructor SMESH_MEDMesh_i");
00100 
00101   _mesh_i = m_i;
00102   _meshDS = _mesh_i->GetImpl().GetMeshDS();
00103 
00104   END_OF("Constructor SMESH_MEDMesh_i");
00105 }
00106 
00107 //=============================================================================
00111 //=============================================================================
00112 char *SMESH_MEDMesh_i::getName() throw(SALOME::SALOME_Exception)
00113 {
00114   if (_meshDS == NULL)
00115     THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
00116                                  SALOME::INTERNAL_ERROR);
00117 
00118   try
00119   {
00120     SMESH_Gen_i*             gen = SMESH_Gen_i::GetSMESHGen();
00121     SALOMEDS::Study_var    study = gen->GetCurrentStudy();
00122     SALOMEDS::SObject_var meshSO = gen->ObjectToSObject( study, _mesh_i->_this());
00123     if ( meshSO->_is_nil() )
00124       return CORBA::string_dup("toto");
00125 
00126     CORBA::String_var name = meshSO->GetName();
00127     return CORBA::string_dup( name.in() );
00128   }
00129   catch(...)
00130   {
00131     MESSAGE("Exception en accedant au nom");
00132     THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object",
00133                                  SALOME::INTERNAL_ERROR);
00134   }
00135   return 0;
00136 }
00137 
00138 //=============================================================================
00142 //=============================================================================
00143 CORBA::Long SMESH_MEDMesh_i::getCorbaIndex()throw(SALOME::SALOME_Exception)
00144 {
00145   MESSAGE("Non Implemente");
00146   THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
00147 }
00148 
00149 //=============================================================================
00153 //=============================================================================
00154 CORBA::Long SMESH_MEDMesh_i::getSpaceDimension()throw(SALOME::SALOME_Exception)
00155 {
00156   // PN : Il semblerait que la dimension soit fixee a 3
00157   if (_mesh_i == 0)
00158     THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
00159                                  SALOME::INTERNAL_ERROR);
00160   return 3;
00161 }
00162 
00163 //=============================================================================
00167 //=============================================================================
00168 CORBA::Long SMESH_MEDMesh_i::getMeshDimension()throw(SALOME::SALOME_Exception)
00169 {
00170   if (_mesh_i == 0)
00171     THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
00172                                  SALOME::INTERNAL_ERROR);
00173   // PN : Il semblerait que la dimension soit fixee a 3
00174   if (_mesh_i == 0)
00175     THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
00176                                  SALOME::INTERNAL_ERROR);
00177   return 3;
00178 }
00179 //=============================================================================
00183 //=============================================================================
00184 CORBA::Boolean SMESH_MEDMesh_i::getIsAGrid() throw (SALOME::SALOME_Exception)
00185 {
00186   MESSAGE("!!!!!! NOT YET IMPLEMENTED !!!!!!");
00187 
00188   THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
00189 
00190   return false;
00191 }
00192 //=============================================================================
00196 //=============================================================================
00197 CORBA::Boolean
00198 SMESH_MEDMesh_i::existConnectivity(SALOME_MED::medConnectivity connectivityType,
00199                                    SALOME_MED::medEntityMesh entity)
00200   throw (SALOME::SALOME_Exception)
00201 {
00202   MESSAGE("!!!!!! IMPLEMENTED BUT ONLY PARTIALLY !!!!!!");
00203 
00204 
00205   return false;
00206 
00207 }
00208 //=============================================================================
00212 //=============================================================================
00213 CORBA::Double SMESH_MEDMesh_i::getCoordinate(CORBA::Long Number, CORBA::Long Axis)
00214   throw (SALOME::SALOME_Exception)
00215 {
00216   MESSAGE("!!!!!! NOT YET IMPLEMENTED !!!!");
00217 
00218   THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
00219 
00220   return 0.0;
00221 }
00222 //=============================================================================
00226 //=============================================================================
00227 char *SMESH_MEDMesh_i::getCoordinatesSystem() throw(SALOME::SALOME_Exception)
00228 {
00229   if (_mesh_i == 0)
00230     THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
00231                                  SALOME::INTERNAL_ERROR);
00232   // PN : En dur. Non encore prevu
00233   try
00234   {
00235     string systcoo = "CARTESIEN";
00236     return CORBA::string_dup(systcoo.c_str());
00237   }
00238   catch(...)
00239   {
00240     MESSAGE("Exception en accedant au maillage");
00241     THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object",
00242                                  SALOME::INTERNAL_ERROR);
00243   }
00244 }
00245 
00246 //=============================================================================
00250 //=============================================================================
00251 SALOME_TYPES::ListOfDouble * SMESH_MEDMesh_i::getCoordinates
00252 (SALOME_MED::medModeSwitch typeSwitch) throw(SALOME::SALOME_Exception)
00253 {
00254   if (_mesh_i == 0)
00255     THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
00256                                  SALOME::INTERNAL_ERROR);
00257   SALOME_TYPES::ListOfDouble_var myseq = new SALOME_TYPES::ListOfDouble;
00258   try
00259   {
00260     // PN  : En dur
00261     int spaceDimension = 3;
00262     int nbNodes = _meshDS->NbNodes();
00263     SCRUTE(nbNodes);
00264     myseq->length(nbNodes * spaceDimension);
00265     int i = 0;
00266 
00267     SMDS_NodeIteratorPtr itNodes=_meshDS->nodesIterator();
00268     while(itNodes->more())
00269     {
00270       const SMDS_MeshNode* node = itNodes->next();
00271 
00272       if (typeSwitch == SALOME_MED::MED_FULL_INTERLACE)
00273       {
00274         myseq[i * 3] = node->X();
00275         myseq[i * 3 + 1] = node->Y();
00276         myseq[i * 3 + 2] = node->Z();
00277         SCRUTE(myseq[i * 3]);
00278         SCRUTE(myseq[i * 3 + 1]);
00279         SCRUTE(myseq[i * 3 + 2]);
00280       }
00281       else
00282       {
00283         ASSERT(typeSwitch == SALOME_MED::MED_NO_INTERLACE);
00284         myseq[i] = node->X();
00285         myseq[i + nbNodes] = node->Y();
00286         myseq[i + (nbNodes * 2)] = node->Z();
00287         SCRUTE(myseq[i]);
00288         SCRUTE(myseq[i + nbNodes]);
00289         SCRUTE(myseq[i + (nbNodes * 2)]);
00290       }
00291       i++;
00292     }
00293   }
00294   catch(...)
00295   {
00296     MESSAGE("Exception en accedant aux coordonnees");
00297     THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object",
00298                                  SALOME::INTERNAL_ERROR);
00299   }
00300   return myseq._retn();
00301 }
00302 
00303 //=============================================================================
00307 //=============================================================================
00308 SALOME_TYPES::ListOfString *
00309 SMESH_MEDMesh_i::getCoordinatesNames()throw(SALOME::SALOME_Exception)
00310 {
00311   if (_mesh_i == 0)
00312     THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
00313                                  SALOME::INTERNAL_ERROR);
00314   SALOME_TYPES::ListOfString_var myseq = new SALOME_TYPES::ListOfString;
00315   try
00316   {
00317     // PN : en dur
00318     int spaceDimension = 3;
00319     myseq->length(spaceDimension);
00320     myseq[0] = CORBA::string_dup("x");
00321     myseq[1] = CORBA::string_dup("y");
00322     myseq[2] = CORBA::string_dup("z");
00323   }
00324   catch(...)
00325   {
00326     MESSAGE("Exception en accedant aux noms des coordonnees");
00327     THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object",
00328                                  SALOME::INTERNAL_ERROR);
00329   }
00330   return myseq._retn();
00331 
00332 }
00333 
00334 //=============================================================================
00338 //=============================================================================
00339 SALOME_TYPES::ListOfString *
00340 SMESH_MEDMesh_i::getCoordinatesUnits()throw(SALOME::SALOME_Exception)
00341 {
00342   if (_mesh_i == 0)
00343     THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
00344                                  SALOME::INTERNAL_ERROR);
00345   SALOME_TYPES::ListOfString_var myseq = new SALOME_TYPES::ListOfString;
00346   try
00347   {
00348     // PN : en dur
00349     int spaceDimension = 3;
00350     myseq->length(spaceDimension);
00351     myseq[0] = CORBA::string_dup("m");
00352     myseq[1] = CORBA::string_dup("m");
00353     myseq[2] = CORBA::string_dup("m");
00354   }
00355   catch(...)
00356   {
00357     MESSAGE("Exception en accedant aux unites des coordonnees");
00358     THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object",
00359                                  SALOME::INTERNAL_ERROR);
00360   }
00361   return myseq._retn();
00362 }
00363 
00364 //=============================================================================
00368 //=============================================================================
00369 CORBA::Long SMESH_MEDMesh_i::getNumberOfNodes()throw(SALOME::SALOME_Exception)
00370 {
00371   if (_mesh_i == 0)
00372     THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
00373                                  SALOME::INTERNAL_ERROR);
00374   try
00375   {
00376     return _meshDS->NbNodes();
00377   }
00378   catch(...)
00379   {
00380     MESSAGE("Exception en accedant au nombre de noeuds");
00381     THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object",
00382                                  SALOME::INTERNAL_ERROR);
00383   }
00384 }
00385 
00386 //=============================================================================
00390 //=============================================================================
00391 CORBA::Long SMESH_MEDMesh_i::getNumberOfTypes(SALOME_MED::medEntityMesh entity)
00392   throw(SALOME::SALOME_Exception)
00393 {
00394   if (_mesh_i == 0)
00395     THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
00396                                  SALOME::INTERNAL_ERROR);
00397   try
00398   {
00399     if (!_compte)
00400       calculeNbElts();
00401     int retour = 0;
00402     if (_mapNbTypes.find(entity) != _mapNbTypes.end())
00403       retour = _mapNbTypes[entity];
00404     return retour;
00405   }
00406   catch(...)
00407   {
00408     MESSAGE("Exception en accedant au nombre de Types");
00409     THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object",
00410                                  SALOME::INTERNAL_ERROR);
00411   }
00412 }
00413 
00414 //=============================================================================
00419 //=============================================================================
00420 SALOME_MED::medGeometryElement_array *
00421 SMESH_MEDMesh_i::getTypes(SALOME_MED::medEntityMesh entity) throw(SALOME::
00422                                                                   SALOME_Exception)
00423 {
00424   if (_mesh_i == 0)
00425     THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
00426                                  SALOME::INTERNAL_ERROR);
00427   if (entity == SALOME_MED::MED_ALL_ENTITIES)
00428     THROW_SALOME_CORBA_EXCEPTION("Not implemented for MED_ALL_ENTITIES",
00429                                  SALOME::BAD_PARAM);
00430   if (!_compte)
00431     calculeNbElts();
00432   SALOME_MED::medGeometryElement_array_var myseq =
00433     new SALOME_MED::medGeometryElement_array;
00434   try
00435   {
00436     if (_mapNbTypes.find(entity) == _mapNbTypes.end())
00437       THROW_SALOME_CORBA_EXCEPTION("No Such Entity in the mesh",
00438                                    SALOME::BAD_PARAM);
00439     int nbTypes = _mapNbTypes[entity];
00440 
00441     myseq->length(nbTypes);
00442 
00443     if (_mapIndToVectTypes.find(entity) == _mapIndToVectTypes.end())
00444       THROW_SALOME_CORBA_EXCEPTION("No Such Entity in the mesh",
00445                                    SALOME::INTERNAL_ERROR);
00446 
00447     int index = _mapIndToVectTypes[entity];
00448     ASSERT(_TypesId[index].size() != 0);
00449     int i = 0;
00450     vector < SALOME_MED::medGeometryElement >::iterator it;
00451     for (it = _TypesId[index].begin(); it != _TypesId[index].end(); it++)
00452     {
00453       myseq[i++] = *it;
00454     };
00455   }
00456   catch(...)
00457   {
00458     MESSAGE("Exception en accedant aux differents types");
00459     THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object",
00460                                  SALOME::INTERNAL_ERROR);
00461   }
00462   return myseq._retn();
00463 }
00464 
00465 //=============================================================================
00474 //=============================================================================
00475 CORBA::Long SMESH_MEDMesh_i::getNumberOfElements(SALOME_MED::
00476                                                  medEntityMesh entity,
00477                                                  SALOME_MED::medGeometryElement geomElement) throw(SALOME::SALOME_Exception)
00478 {
00479   if (_mesh_i == 0)
00480     THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
00481                                  SALOME::INTERNAL_ERROR);
00482   if (geomElement == SALOME_MED::MED_ALL_ELEMENTS)
00483     THROW_SALOME_CORBA_EXCEPTION("Not implemented for MED_ALL_ELEMENTS",
00484                                  SALOME::BAD_PARAM);
00485   if (!_compte)
00486     calculeNbElts();
00487 
00488   try
00489   {
00490     int retour = 0;
00491     if (_mapIndToSeqElts.find(geomElement) != _mapIndToSeqElts.end())
00492     {
00493       int index = _mapIndToSeqElts[geomElement];
00494 
00495       retour = _seq_elemId[index]->length();
00496     }
00497     return retour;
00498   }
00499   catch(...)
00500   {
00501     MESSAGE("Exception en accedant au nombre d élements");
00502     THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object",
00503                                  SALOME::INTERNAL_ERROR);
00504   }
00505 }
00506 
00507 //=============================================================================
00511 //=============================================================================
00512 SALOME_TYPES::ListOfLong *
00513 SMESH_MEDMesh_i::getConnectivity(SALOME_MED::medConnectivity mode,
00514                                  SALOME_MED::medEntityMesh entity,
00515                                  SALOME_MED::medGeometryElement geomElement)
00516   throw(SALOME::SALOME_Exception)
00517 {
00518   if (_mesh_i == 0)
00519     THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
00520                                  SALOME::INTERNAL_ERROR);
00521   if (mode != SALOME_MED::MED_NODAL)
00522     THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM);
00523   /*if (typeSwitch == SALOME_MED::MED_NO_INTERLACE)
00524     THROW_SALOME_CORBA_EXCEPTION("Not Yet Implemented", SALOME::BAD_PARAM);*/
00525   if (!_compte)
00526     calculeNbElts();
00527 
00528   // Faut-il renvoyer un pointeur vide ???
00529   if (_mapIndToSeqElts.find(geomElement) != _mapIndToSeqElts.end())
00530     THROW_SALOME_CORBA_EXCEPTION("No Such Element in the mesh",
00531                                  SALOME::BAD_PARAM);
00532 
00533   int index = _mapIndToSeqElts[geomElement];
00534 
00535   return _seq_elemId[index]._retn();
00536 }
00537 
00538 //=============================================================================
00542 //=============================================================================
00543 SALOME_TYPES::ListOfLong *
00544 SMESH_MEDMesh_i::getConnectivityIndex(SALOME_MED::medConnectivity mode,
00545                                       SALOME_MED::medEntityMesh entity)
00546   throw(SALOME::SALOME_Exception)
00547 {
00548   MESSAGE("Pas Implemente dans SMESH");
00549   THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
00550   return 0;
00551 }
00552 
00553 //=============================================================================
00557 //=============================================================================
00558 CORBA::Long
00559 SMESH_MEDMesh_i::getElementNumber(SALOME_MED::medConnectivity mode,
00560                                   SALOME_MED::medEntityMesh entity,
00561                                   SALOME_MED::medGeometryElement type,
00562                                   const SALOME_TYPES::ListOfLong & connectivity)
00563   throw(SALOME::SALOME_Exception)
00564 {
00565   const char *LOC = "getElementNumber ";
00566   MESSAGE(LOC << "Pas Implemente dans SMESH");
00567   THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
00568   return -1;
00569 }
00570 
00571 //=============================================================================
00576 //=============================================================================
00577 SALOME_TYPES::ListOfLong *
00578 SMESH_MEDMesh_i::getReverseConnectivity(SALOME_MED::
00579                                         medConnectivity mode) throw(SALOME::SALOME_Exception)
00580 {
00581   MESSAGE("Pas Implemente dans SMESH");
00582   THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
00583   return 0;
00584 }
00585 
00586 //=============================================================================
00590 //=============================================================================
00591 SALOME_TYPES::ListOfLong *
00592 SMESH_MEDMesh_i::getReverseConnectivityIndex(SALOME_MED::
00593                                              medConnectivity mode) throw(SALOME::SALOME_Exception)
00594 {
00595   MESSAGE("Pas Implemente dans SMESH");
00596   THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
00597   return 0;
00598 }
00599 
00600 //=============================================================================
00604 //=============================================================================
00605 CORBA::Long SMESH_MEDMesh_i::getNumberOfFamilies(SALOME_MED::
00606                                                  medEntityMesh entity) throw(SALOME::SALOME_Exception)
00607 {
00608   if (_creeFamily == false)
00609     createFamilies();
00610   if (_mesh_i == 0)
00611     THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
00612                                  SALOME::INTERNAL_ERROR);
00613   return _families.size();
00614 }
00615 
00616 //=============================================================================
00620 //=============================================================================
00621 CORBA::Long SMESH_MEDMesh_i::getNumberOfGroups(SALOME_MED::medEntityMesh entity)
00622   throw(SALOME::SALOME_Exception)
00623 {
00624   if (_mesh_i == 0)
00625     THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
00626                                  SALOME::INTERNAL_ERROR);
00627   MESSAGE(" Pas d implementation des groupes dans SMESH");
00628   return 0;
00629 }
00630 
00631 //=============================================================================
00635 //=============================================================================
00636 SALOME_MED::Family_array *
00637 SMESH_MEDMesh_i::getFamilies(SALOME_MED::
00638                              medEntityMesh entity) throw(SALOME::SALOME_Exception)
00639 {
00640   if (_creeFamily == false)
00641     createFamilies();
00642   if (_mesh_i == 0)
00643     THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
00644                                  SALOME::INTERNAL_ERROR);
00645   SALOME_MED::Family_array_var myseq = new SALOME_MED::Family_array;
00646   int nbfam = _families.size();
00647   myseq->length(nbfam);
00648   int i = 0;
00649   vector < SALOME_MED::FAMILY_ptr >::iterator it;
00650   for (it = _families.begin(); it != _families.end(); it++)
00651   {
00652     myseq[i++] = *it;
00653   };
00654   return myseq._retn();
00655 }
00656 
00657 //=============================================================================
00661 //=============================================================================
00662 SALOME_MED::FAMILY_ptr SMESH_MEDMesh_i::getFamily(SALOME_MED::
00663                                                   medEntityMesh entity, CORBA::Long i) throw(SALOME::SALOME_Exception)
00664 {
00665   if (_creeFamily == false)
00666     createFamilies();
00667   if (_mesh_i == 0)
00668     THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
00669                                  SALOME::INTERNAL_ERROR);
00670 
00671   SCRUTE(_families[i]->getName());
00672   MESSAGE(" SMESH_MEDMesh_i::getFamily " << i) return _families[i];
00673 }
00674 
00675 //=============================================================================
00679 //=============================================================================
00680 SALOME_MED::Group_array *
00681 SMESH_MEDMesh_i::getGroups(SALOME_MED::medEntityMesh entity) throw(SALOME::
00682                                                                    SALOME_Exception)
00683 {
00684   if (_mesh_i == 0)
00685     THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
00686                                  SALOME::INTERNAL_ERROR);
00687   MESSAGE(" Pas d implementation des groupes dans SMESH");
00688   THROW_SALOME_CORBA_EXCEPTION("No group implementation", SALOME::BAD_PARAM);
00689 }
00690 
00691 //=============================================================================
00695 //=============================================================================
00696 SALOME_MED::GROUP_ptr SMESH_MEDMesh_i::getGroup(SALOME_MED::
00697                                                 medEntityMesh entity, CORBA::Long i) throw(SALOME::SALOME_Exception)
00698 {
00699   if (_mesh_i == 0)
00700     THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
00701                                  SALOME::INTERNAL_ERROR);
00702   MESSAGE(" Pas d implementation des groupes dans SMESH");
00703   THROW_SALOME_CORBA_EXCEPTION("No group implementation", SALOME::BAD_PARAM);
00704 }
00705 //=============================================================================
00709 //=============================================================================
00710 SALOME_TYPES::ListOfLong*
00711 SMESH_MEDMesh_i::getGlobalNumberingIndex(SALOME_MED::medEntityMesh entity)
00712   throw (SALOME::SALOME_Exception)
00713 {
00714   MESSAGE("!!!! NOT YET IMPLEMENTED !!!!!");
00715 
00716   THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
00717 
00718   return NULL;
00719 }
00720 //=============================================================================
00725 //=============================================================================
00726 SALOME_MED::SUPPORT_ptr
00727 SMESH_MEDMesh_i::getBoundaryElements(SALOME_MED::medEntityMesh entity)
00728   throw (SALOME::SALOME_Exception)
00729 {
00730   MESSAGE("!!!! NOT YET IMPLEMENTED !!!!!");
00731 
00732   THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
00733 
00734   return NULL;
00735 }
00736 //=============================================================================
00741 //=============================================================================
00742 SALOME_MED::SUPPORT_ptr
00743 SMESH_MEDMesh_i::getSupportOnAll(SALOME_MED::medEntityMesh entity)
00744   throw (SALOME::SALOME_Exception)
00745 {
00746   MESSAGE("!!!! NOT YET IMPLEMENTED !!!!!");
00747 
00748   THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
00749 
00750   return NULL;
00751 }
00752 //=============================================================================
00757 //=============================================================================
00758 SALOME_MED::SUPPORT_ptr
00759 SMESH_MEDMesh_i::getSkin(SALOME_MED::SUPPORT_ptr mySupport3D)
00760   throw (SALOME::SALOME_Exception)
00761 {
00762   MESSAGE("!!!! NOT YET IMPLEMENTED !!!!!");
00763 
00764   THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
00765 
00766   return NULL;
00767 }
00768 //=============================================================================
00772 //=============================================================================
00773 SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getVolume(SALOME_MED::
00774                                                  SUPPORT_ptr mySupport) throw(SALOME::SALOME_Exception)
00775 {
00776   MESSAGE("Pas Implemente dans SMESH");
00777   THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
00778   return 0;
00779 }
00780 
00781 //=============================================================================
00785 //=============================================================================
00786 SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getArea(SALOME_MED::
00787                                                SUPPORT_ptr mySupport) throw(SALOME::SALOME_Exception)
00788 {
00789   MESSAGE("Pas Implemente dans SMESH");
00790   THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
00791   return 0;
00792 }
00793 
00794 //=============================================================================
00798 //=============================================================================
00799 SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getLength(SALOME_MED::
00800                                                  SUPPORT_ptr mySupport) throw(SALOME::SALOME_Exception)
00801 {
00802   MESSAGE("Pas Implemente dans SMESH");
00803   THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
00804   return 0;
00805 }
00806 
00807 //=============================================================================
00811 //=============================================================================
00812 SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getNormal(SALOME_MED::
00813                                                  SUPPORT_ptr mySupport) throw(SALOME::SALOME_Exception)
00814 {
00815   MESSAGE("Pas Implemente dans SMESH");
00816   THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
00817   return 0;
00818 }
00819 
00820 //=============================================================================
00824 //=============================================================================
00825 SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getBarycenter(SALOME_MED::
00826                                                      SUPPORT_ptr mySupport) throw(SALOME::SALOME_Exception)
00827 {
00828   MESSAGE("Pas Implemente dans SMESH");
00829   THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
00830   return 0;
00831 }
00832 
00833 //=============================================================================
00837 //=============================================================================
00838 SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getNeighbourhood(SALOME_MED::
00839                                                         SUPPORT_ptr mySupport) throw(SALOME::SALOME_Exception)
00840 {
00841   MESSAGE("Non Implemente");
00842   THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
00843   return 0;
00844 }
00845 
00846 //=============================================================================
00851 //=============================================================================
00852 void SMESH_MEDMesh_i::addInStudy(SALOMEDS::Study_ptr myStudy,
00853                                  SALOME_MED::GMESH_ptr myIor) throw(SALOME::SALOME_Exception)
00854 {
00855   BEGIN_OF("MED_Mesh_i::addInStudy");
00856   if (_meshId != "")
00857   {
00858     MESSAGE("Mesh already in Study");
00859     THROW_SALOME_CORBA_EXCEPTION("Mesh already in Study",
00860                                  SALOME::BAD_PARAM);
00861   };
00862 
00863   /*
00864    * SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder();
00865    * 
00866    * // Create SComponent labelled 'MED' if it doesn't already exit
00867    * SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED");
00868    * if ( CORBA::is_nil(medfather) ) 
00869    * {
00870    * MESSAGE("Add Component MED");
00871    * medfather = myBuilder->NewComponent("MED");
00872    * //myBuilder->AddAttribute (medfather,SALOMEDS::Name,"MED");
00873    * SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(
00874    * myBuilder->FindOrCreateAttribute(medfather, "AttributeName"));
00875    * aName->SetValue("MED");
00876    * 
00877    * myBuilder->DefineComponentInstance(medfather,myIor);
00878    * 
00879    * } ;
00880    * 
00881    * MESSAGE("Add a mesh Object under MED");
00882    * myBuilder->NewCommand();
00883    * SALOMEDS::SObject_var newObj = myBuilder->NewObject(medfather);
00884    * 
00885    * ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
00886    * ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
00887    * CORBA::ORB_var &orb = init(0,0);
00888    * CORBA::String_var iorStr = orb->object_to_string(myIor);
00889    * //myBuilder->AddAttribute(newObj,SALOMEDS::IOR,iorStr.in());
00890    * SALOMEDS::AttributeIOR_var aIOR = SALOMEDS::AttributeIOR::_narrow(
00891    * myBuilder->FindOrCreateAttribute(newObj, "AttributeIOR"));
00892    * aIOR->SetValue(iorStr.c_str());
00893    * 
00894    * //myBuilder->AddAttribute(newObj,SALOMEDS::Name,_mesh_i->getName().c_str());
00895    * SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(
00896    * myBuilder->FindOrCreateAttribute(newObj, "AttributeName"));
00897    * aName->SetValue(_mesh_i->getName().c_str());
00898    * 
00899    * _meshId = newObj->GetID();
00900    * myBuilder->CommitCommand();
00901    * 
00902    */
00903   END_OF("Mesh_i::addInStudy(SALOMEDS::Study_ptr myStudy)");
00904 }
00905 
00906 //=============================================================================
00910 //=============================================================================
00911 void SMESH_MEDMesh_i::write(CORBA::Long i, const char *driverMeshName)
00912   throw(SALOME::SALOME_Exception)
00913 {
00914   MESSAGE("Non Implemente");
00915   THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
00916 }
00917 
00918 //=============================================================================
00922 //=============================================================================
00923 void SMESH_MEDMesh_i::read(CORBA::Long i) throw(SALOME::SALOME_Exception)
00924 {
00925   MESSAGE("Non Implemente");
00926   THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
00927 }
00928 
00929 //=============================================================================
00933 //=============================================================================
00934 void SMESH_MEDMesh_i::rmDriver(CORBA::Long i) throw(SALOME::SALOME_Exception)
00935 {
00936   MESSAGE("Non Implemente");
00937   THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
00938 }
00939 
00940 //=============================================================================
00944 //=============================================================================
00945 CORBA::Long SMESH_MEDMesh_i::addDriver(SALOME_MED::medDriverTypes driverType,
00946                                        const char *fileName, const char *meshName) throw(SALOME::SALOME_Exception)
00947 {
00948   MESSAGE("Non Implemente");
00949   THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
00950   return 0;
00951 }
00952 
00953 //=============================================================================
00957 //=============================================================================
00958 void SMESH_MEDMesh_i::calculeNbElts() throw(SALOME::SALOME_Exception)
00959 {
00960   if (!_compte)
00961   {
00962     _compte = true;
00963 
00964     _mapNbTypes[SALOME_MED::MED_NODE] = 1;
00965     // On compte les aretes MED_SEG2 ou MED_SEG3
00966     // On range les elements dans  les vecteurs correspondants 
00967 
00968     _mapIndToSeqElts[SALOME_MED::MED_SEG2] = _indexElts++;
00969     _mapIndToSeqElts[SALOME_MED::MED_SEG3] = _indexElts++;
00970     _mapIndToVectTypes[SALOME_MED::MED_EDGE] = _indexEnts++;
00971 
00972     int trouveSeg2 = 0;
00973     int trouveSeg3 = 0;
00974     SALOME_MED::medGeometryElement medElement;
00975 
00976     SMDS_EdgeIteratorPtr itEdges=_meshDS->edgesIterator();
00977     while(itEdges->more())
00978     {
00979       const SMDS_MeshEdge* elem = itEdges->next();
00980       int nb_of_nodes = elem->NbNodes();
00981 
00982       switch (nb_of_nodes)
00983       {
00984       case 2:
00985         {
00986           medElement = SALOME_MED::MED_SEG2;
00987           if (trouveSeg2 == 0)
00988           {
00989             trouveSeg2 = 1;
00990             _TypesId[SALOME_MED::MED_EDGE].
00991               push_back(SALOME_MED::MED_SEG2);
00992           }
00993           break;
00994         }
00995       case 3:
00996         {
00997           medElement = SALOME_MED::MED_SEG3;
00998           if (trouveSeg3 == 0)
00999           {
01000             trouveSeg3 = 1;
01001             _TypesId[SALOME_MED::MED_EDGE].
01002               push_back(SALOME_MED::MED_SEG3);
01003           }
01004           break;
01005         }
01006       }
01007       int index = _mapIndToSeqElts[medElement];
01008       SCRUTE(index);
01009       // Traitement de l arete
01010 
01011       int longueur = _seq_elemId[index]->length();
01012       _seq_elemId[index]->length(longueur + nb_of_nodes);
01013 
01014       SMDS_NodeIteratorPtr itn=_meshDS->nodesIterator();
01015 
01016       for(int k=0; itn->more(); k++)
01017         _seq_elemId[index][longueur + k] = itn->next()->GetID()+1;
01018     }
01019 
01020     _mapNbTypes[SALOME_MED::MED_EDGE] = trouveSeg2 + trouveSeg3;
01021 
01022     // On compte les faces MED_TRIA3, MED_HEXA8, MED_TRIA6
01023     // On range les elements dans  les vecteurs correspondants 
01024     int trouveTria3 = 0;
01025     int trouveTria6 = 0;
01026     int trouveQuad4 = 0;
01027 
01028     _mapIndToSeqElts[SALOME_MED::MED_TRIA3] = _indexElts++;
01029     _mapIndToSeqElts[SALOME_MED::MED_TRIA6] = _indexElts++;
01030     _mapIndToSeqElts[SALOME_MED::MED_QUAD4] = _indexElts++;
01031     _mapIndToVectTypes[SALOME_MED::MED_FACE] = _indexEnts++;
01032 
01033     SMDS_FaceIteratorPtr itFaces=_meshDS->facesIterator();
01034     while(itFaces->more())
01035     {
01036       const SMDS_MeshFace * elem = itFaces->next();
01037       int nb_of_nodes = elem->NbNodes();
01038 
01039       switch (nb_of_nodes)
01040       {
01041       case 3:
01042         {
01043           medElement = SALOME_MED::MED_TRIA3;
01044           if (trouveTria3 == 0)
01045           {
01046             trouveTria3 = 1;
01047             _TypesId[SALOME_MED::MED_FACE].
01048               push_back(SALOME_MED::MED_TRIA3);
01049           }
01050           break;
01051         }
01052       case 4:
01053         {
01054           medElement = SALOME_MED::MED_QUAD4;
01055           if (trouveQuad4 == 0)
01056           {
01057             trouveQuad4 = 1;
01058             _TypesId[SALOME_MED::MED_FACE].
01059               push_back(SALOME_MED::MED_QUAD4);
01060           }
01061           break;
01062         }
01063       case 6:
01064         {
01065           medElement = SALOME_MED::MED_TRIA6;
01066           if (trouveTria6 == 0)
01067           {
01068             trouveTria6 = 1;
01069             _TypesId[SALOME_MED::MED_FACE].
01070               push_back(SALOME_MED::MED_TRIA6);
01071           }
01072           break;
01073         }
01074       }
01075       int index = _mapIndToSeqElts[medElement];
01076       SCRUTE(index);
01077 
01078       // Traitement de la face
01079       // Attention La numérotation des noeuds Med commence a 1
01080 
01081       int longueur = _seq_elemId[index]->length();
01082       _seq_elemId[index]->length(longueur + nb_of_nodes);
01083 
01084       SMDS_NodeIteratorPtr itn=_meshDS->nodesIterator();
01085 
01086       for(int k=0; itn->more(); k++)
01087         _seq_elemId[index][longueur + k] = itn->next()->GetID()+1;
01088     } //itFaces
01089 
01090     _mapNbTypes[SALOME_MED::MED_FACE] =
01091       trouveTria3 + trouveTria6 + trouveQuad4;
01092 
01093     _mapIndToSeqElts[SALOME_MED::MED_HEXA8] = _indexElts++;
01094     _mapIndToVectTypes[SALOME_MED::MED_CELL] = _indexEnts++;
01095     int index = _mapIndToSeqElts[medElement];
01096 
01097     int trouveHexa8 = 0;
01098 
01099     SMDS_VolumeIteratorPtr itVolumes=_meshDS->volumesIterator();
01100     while(itVolumes->more())
01101     {
01102       const SMDS_MeshVolume * elem = itVolumes->next();
01103 
01104       int nb_of_nodes = elem->NbNodes();
01105       medElement = SALOME_MED::MED_HEXA8;
01106       ASSERT(nb_of_nodes == 8);
01107 
01108       if (trouveHexa8 == 0)
01109       {
01110         trouveHexa8 = 1;
01111         _TypesId[SALOME_MED::MED_CELL].push_back(SALOME_MED::MED_HEXA8);
01112       };
01113       // Traitement de la maille
01114       int longueur = _seq_elemId[index]->length();
01115       _seq_elemId[index]->length(longueur + nb_of_nodes);
01116 
01117       SMDS_NodeIteratorPtr itn=_meshDS->nodesIterator();
01118       for(int k=0; itn->more(); k++)
01119         _seq_elemId[index][longueur + k] = itn->next()->GetID()+1;
01120     }
01121 
01122     _mapNbTypes[SALOME_MED::MED_CELL] = trouveHexa8;
01123     _mapNbTypes[SALOME_MED::MED_ALL_ENTITIES]
01124       =
01125       trouveHexa8 + trouveTria3 + trouveTria6 + trouveQuad4 + trouveSeg2 +
01126       trouveSeg3;
01127   }// fin du _compte
01128 };
01129 
01130 //=============================================================================
01134 //=============================================================================
01135 void SMESH_MEDMesh_i::createFamilies() throw(SALOME::SALOME_Exception)
01136 {
01137   Unexpect aCatch(SALOME_SalomeException);
01138   string famDes = ("Je ne sais pas");
01139   string famName0 = "Famille_";
01140   string famName;
01141   char numero[10];
01142 
01143   if (_creeFamily == false)
01144   {
01145     _creeFamily = true;
01146     //SMESH_subMesh_i *subMeshServant;
01147 
01148     map < int, SMESH_subMesh_i * >::iterator it;
01149     for (it = _mesh_i->_mapSubMesh_i.begin();
01150          it != _mesh_i->_mapSubMesh_i.end(); it++)
01151     {
01152       SMESH_subMesh_i *submesh_i = (*it).second;
01153       int famIdent = (*it).first;
01154 
01155       ASSERT(famIdent < 999999999);
01156       sprintf(numero, "%d\n", famIdent);
01157       famName = famName0 + numero;
01158 
01159       SMESH_MEDFamily_i *famservant =
01160         new SMESH_MEDFamily_i(famIdent, submesh_i,
01161                               famName, famDes, SALOME_MED::MED_NODE);
01162 #ifdef WNT
01163       SALOME_MED::FAMILY_ptr famille = SALOME_MED::FAMILY::_nil();
01164       POA_SALOME_MED::FAMILY* servantbase = dynamic_cast<POA_SALOME_MED::FAMILY*>(famservant);
01165       if ( servantbase )
01166         famille = SALOME_MED::FAMILY::_narrow( servantbase->_this() );
01167 #else 
01168       SALOME_MED::FAMILY_ptr famille = 
01169         SALOME_MED::FAMILY::_narrow( famservant->POA_SALOME_MED::FAMILY::_this() );
01170 #endif
01171       _families.push_back(famille);
01172     }
01173   }
01174 };
01175 //=============================================================================
01179 //=============================================================================
01180 SALOME_MED::GMESH::meshInfos * SMESH_MEDMesh_i::getMeshGlobal()
01181   throw (SALOME::SALOME_Exception)
01182 {
01183   MESSAGE("!!!! NOT YET IMPLEMENTED !!!!!");
01184 
01185   THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
01186 
01187   return NULL;
01188 }
01189 
01190 //================================================================================
01194 //================================================================================
01195 
01196 SALOME_MED::MESH_ptr SMESH_MEDMesh_i::convertInMESH() throw (SALOME::SALOME_Exception)
01197 {
01198   MESSAGE("!!!! NOT YET IMPLEMENTED !!!!!");
01199 
01200   THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
01201 
01202   return NULL;
01203 }
01204 
01205 //=============================================================================
01209 //=============================================================================
01210 SALOME_MED::GMESH::coordinateInfos * SMESH_MEDMesh_i::getCoordGlobal()
01211   throw (SALOME::SALOME_Exception)
01212 {
01213   MESSAGE("!!!! NOT YET IMPLEMENTED !!!!!");
01214 
01215   THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
01216 
01217   return NULL;
01218 }
01219 //=============================================================================
01224 //=============================================================================
01225 SALOME_MED::MESH::connectivityInfos *
01226 SMESH_MEDMesh_i::getConnectGlobal(SALOME_MED::medEntityMesh entity)
01227   throw (SALOME::SALOME_Exception)
01228 {
01229   MESSAGE("!!!! NOT YET IMPLEMENTED !!!!!");
01230 
01231   THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
01232 
01233   return NULL;
01234 }
01235 //=============================================================================
01239 //=============================================================================
01240 SALOME_MED::medGeometryElement
01241 SMESH_MEDMesh_i::getElementType(SALOME_MED::medEntityMesh entity,
01242                                 CORBA::Long number)
01243   throw (SALOME::SALOME_Exception)
01244 {
01245   MESSAGE("!!!! NOT YET IMPLEMENTED !!!!!");
01246 
01247   THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
01248 
01249   return (SALOME_MED::medGeometryElement) 0;
01250 }