Back to index

salome-smesh  6.5.0
SMESH_MEDSupport_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_MEDSupport_i.cxx
00025 //  Module : SMESH
00026 //
00027 #include "SMESH_MEDSupport_i.hxx"
00028 #include "utilities.h"
00029 #include "Utils_CorbaException.hxx"
00030 #include "Utils_ExceptHandlers.hxx"
00031 
00032 #include "SMESHDS_Mesh.hxx"
00033 
00034 #include "SMESH_subMesh.hxx"
00035 #include "SMESH_Mesh_i.hxx"
00036 #include "SMESH_subMesh_i.hxx"
00037 #include "SMESH_Gen_i.hxx"
00038 
00039 #include <TopoDS_Iterator.hxx>
00040 
00041 using namespace std;
00042 
00043 
00044 //=============================================================================
00048 //=============================================================================
00049 SMESH_MEDSupport_i::SMESH_MEDSupport_i()
00050 {
00051         BEGIN_OF("Default Constructor SMESH_MEDSupport_i");
00052         END_OF("Default Constructor SMESH_MEDSupport_i");
00053 }
00054 
00055 //=============================================================================
00059 //=============================================================================
00060 SMESH_MEDSupport_i::SMESH_MEDSupport_i(SMESH_subMesh_i * sm, string name,
00061         string description, SALOME_MED::medEntityMesh entity)
00062   :_subMesh_i(sm), _name(name), _description(description), _entity(entity),
00063    _seqNumber(false), _seqLength(0)
00064 {
00065         BEGIN_OF("Constructor SMESH_MEDSupport_i");
00066 
00067         int subMeshId = sm->GetId();
00068 
00069         MESSAGE(" subMeshId " << subMeshId);
00070 
00071         SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( sm->GetMesh() );
00072         _subMesh = mesh_i->GetImpl().GetSubMeshContaining( subMeshId );
00073 
00074         if (_entity == SALOME_MED::MED_NODE)
00075         {
00076                 _numberOfGeometricType = 1;
00077                 _geometricType = new SALOME_MED::medGeometryElement[1];
00078                 _geometricType[0] = SALOME_MED::MED_NONE;
00079         }
00080         else
00081         {
00082                 MESSAGE("Pas implemente dans cette version");
00083                 THROW_SALOME_CORBA_EXCEPTION
00084                         ("Seules les familles de noeuds sont implementees ",
00085                         SALOME::BAD_PARAM);
00086         }
00087 
00088         END_OF("Constructor SMESH_MEDSupport_i");
00089 }
00090 
00091 //=============================================================================
00095 //=============================================================================
00096 SMESH_MEDSupport_i::
00097 SMESH_MEDSupport_i(const SMESH_MEDSupport_i & s):_subMesh(s._subMesh),
00098 _name(s._name), _description(s._description), _entity(s._entity),
00099 _seqNumber(false), _seqLength(0)
00100 {
00101         BEGIN_OF("Constructor SMESH_MEDSupport_i");
00102 
00103         END_OF("Constructor SMESH_MEDSupport_i");
00104 }
00105 
00106 //=============================================================================
00110 //=============================================================================
00111 
00112 SMESH_MEDSupport_i::~SMESH_MEDSupport_i()
00113 {
00114 }
00115 
00116 //=============================================================================
00120 //=============================================================================
00121 
00122 CORBA::Long SMESH_MEDSupport_i::getCorbaIndex()throw(SALOME::SALOME_Exception)
00123 {
00124         if (_subMesh == NULL)
00125                 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
00126                         SALOME::INTERNAL_ERROR);
00127         MESSAGE("Not implemented for SMESH_i");
00128         THROW_SALOME_CORBA_EXCEPTION("Not Implemented ", SALOME::BAD_PARAM);
00129 
00130 }
00131 
00132 //=============================================================================
00136 //=============================================================================
00137 
00138 char *SMESH_MEDSupport_i::getName() throw(SALOME::SALOME_Exception)
00139 {
00140         if (_subMesh==NULL)
00141                 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
00142                         SALOME::INTERNAL_ERROR);
00143         return CORBA::string_dup(_name.c_str());
00144 
00145 }
00146 
00147 //=============================================================================
00151 //=============================================================================
00152 
00153 char *SMESH_MEDSupport_i::getDescription() throw(SALOME::SALOME_Exception)
00154 {
00155         if (_subMesh==NULL)
00156                 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
00157                         SALOME::INTERNAL_ERROR);
00158         return CORBA::string_dup(_description.c_str());
00159 }
00160 
00161 //=============================================================================
00165 //=============================================================================
00166 
00167 SALOME_MED::GMESH_ptr SMESH_MEDSupport_i::getMesh()throw(SALOME::
00168         SALOME_Exception)
00169 {
00170         if (_subMesh==NULL)
00171                 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
00172                         SALOME::INTERNAL_ERROR);
00173 
00174         return _subMesh_i->GetMesh()->GetMEDMesh();
00175 }
00176 
00177 //=============================================================================
00181 //=============================================================================
00182 
00183 CORBA::Boolean SMESH_MEDSupport_i::isOnAllElements()throw(SALOME::
00184         SALOME_Exception)
00185 {
00186         if (_subMesh==NULL)
00187                 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
00188                         SALOME::INTERNAL_ERROR);
00189         if (_seqNumber == false)
00190         {
00191                 if (_entity != SALOME_MED::MED_NONE)
00192                 {
00193                         _seqLength = _subMesh_i->GetNumberOfNodes(/*all=*/false);
00194                         _seqNumber = true;
00195                 }
00196                 else
00197                 {
00198                         MESSAGE("Only Node Families are implemented ");
00199                         THROW_SALOME_CORBA_EXCEPTION("Not implemented Yet ",
00200                                 SALOME::BAD_PARAM);
00201                 }
00202         }
00203         try
00204         {
00205           _isOnAllElements = (_seqLength == _subMesh->GetFather()->NbNodes());
00206         }
00207         catch(...)
00208         {
00209                 MESSAGE("unable to acces related Mesh");
00210                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
00211                         SALOME::INTERNAL_ERROR);
00212         };
00213         return _isOnAllElements;
00214 }
00215 
00216 //=============================================================================
00220 //=============================================================================
00221 
00222 SALOME_MED::medEntityMesh SMESH_MEDSupport_i::getEntity()throw(SALOME::
00223         SALOME_Exception)
00224 {
00225         if (_subMesh==NULL)
00226                 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
00227                         SALOME::INTERNAL_ERROR);
00228         return _entity;
00229 }
00230 
00231 //=============================================================================
00235 //=============================================================================
00236 
00237 SALOME_MED::medGeometryElement_array *
00238         SMESH_MEDSupport_i::getTypes()throw(SALOME::SALOME_Exception)
00239 {
00240         if (_subMesh==NULL)
00241                 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
00242                         SALOME::INTERNAL_ERROR);
00243         SALOME_MED::medGeometryElement_array_var myseq =
00244                 new SALOME_MED::medGeometryElement_array;
00245         try
00246         {
00247                 int mySeqLength = _numberOfGeometricType;
00248                 myseq->length(mySeqLength);
00249                 for (int i = 0; i < mySeqLength; i++)
00250                 {
00251                         myseq[i] = _geometricType[i];
00252                 }
00253         }
00254         catch(...)
00255         {
00256                 MESSAGE("Exception lors de la recherche des differents types");
00257                 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support Types",
00258                         SALOME::INTERNAL_ERROR);
00259         }
00260         return myseq._retn();
00261 }
00262 
00263 //=============================================================================
00268 //=============================================================================
00269 CORBA::Long SMESH_MEDSupport_i::getNumberOfElements(SALOME_MED::
00270         medGeometryElement geomElement) throw(SALOME::SALOME_Exception)
00271 {
00272         if (_subMesh==NULL)
00273                 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
00274                         SALOME::INTERNAL_ERROR);
00275         return _numberOfGeometricType;
00276 
00277 }
00278 
00279 //=============================================================================
00283 //=============================================================================
00284 
00285 SALOME_TYPES::ListOfLong * SMESH_MEDSupport_i::getNumber(
00286         SALOME_MED::medGeometryElement geomElement) throw(SALOME::SALOME_Exception)
00287 {
00288   Unexpect aCatch(SALOME_SalomeException);
00289         if (_subMesh==NULL)
00290                 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
00291                         SALOME::INTERNAL_ERROR);
00292 
00293         // A changer s'il ne s agit plus seulement de famille de noeuds
00294         if (geomElement != SALOME_MED::MED_NONE)
00295                 THROW_SALOME_CORBA_EXCEPTION("Not implemented", SALOME::BAD_PARAM);
00296 
00297         SALOME_TYPES::ListOfLong_var myseq = new SALOME_TYPES::ListOfLong;
00298 
00299         int i = 0;
00300         myseq->length(_subMesh_i->GetNumberOfNodes(/*all=*/false));
00301 
00302         if ( _subMesh->GetSubMeshDS() )
00303         {
00304           SMDS_NodeIteratorPtr it = _subMesh->GetSubMeshDS()->GetNodes();
00305           while(it->more())
00306           {
00307             myseq[i] = it->next()->GetID();
00308             i++;
00309           };
00310         }
00311 
00312         SCRUTE(myseq->length());
00313         MESSAGE("End of SMESH_MEDSupport_i::getNumber");
00314         return myseq._retn();
00315 
00316 }
00317 
00318 //=============================================================================
00322 //=============================================================================
00323 
00324 SALOME_TYPES::ListOfLong * SMESH_MEDSupport_i::getNumberFromFile(
00325         SALOME_MED::medGeometryElement geomElement) throw(SALOME::SALOME_Exception)
00326 {
00327   return getNumber(geomElement);
00328 }
00329 
00330 //=============================================================================
00335 //=============================================================================
00336 
00337 SALOME_TYPES::ListOfLong *
00338         SMESH_MEDSupport_i::getNumberIndex()throw(SALOME::SALOME_Exception)
00339 {
00340         MESSAGE("Not implemented for SMESH_i");
00341         THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM);
00342         return NULL;
00343 }
00344 //=============================================================================
00348 //=============================================================================
00349 
00350 CORBA::Long SMESH_MEDSupport_i::getNumberOfGaussPoint(SALOME_MED::
00351         medGeometryElement geomElement) throw(SALOME::SALOME_Exception)
00352 {
00353         MESSAGE("Not implemented for SMESH_i");
00354         return 0;
00355 }
00356 //=============================================================================
00360 //=============================================================================
00361 CORBA::Long SMESH_MEDSupport_i::getNumberOfTypes()
00362   throw (SALOME::SALOME_Exception)
00363 {
00364   MESSAGE("!!! NOT YET IMPLEMENTED !!!!");
00365   THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM);
00366   return 0;
00367 }
00368 //=============================================================================
00373 //=============================================================================
00374 SALOME_TYPES::ListOfLong* SMESH_MEDSupport_i::getNumbersOfGaussPoint()
00375   throw (SALOME::SALOME_Exception)
00376 {
00377   MESSAGE("!!! NOT YET IMPLEMENTED !!!!");
00378   THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM);
00379   return NULL;
00380 }
00381 //=============================================================================
00385 //=============================================================================
00386 void SMESH_MEDSupport_i::getBoundaryElements()
00387   throw (SALOME::SALOME_Exception)
00388 {
00389   MESSAGE("!!! NOT YET IMPLEMENTED !!!!");
00390   THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM);
00391 }
00392 //=============================================================================
00396 //=============================================================================
00397 SALOME_MED::SUPPORT::supportInfos * SMESH_MEDSupport_i::getSupportGlobal()
00398   throw (SALOME::SALOME_Exception)
00399 {
00400   MESSAGE("!!! NOT YET IMPLEMENTED !!!!");
00401   THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM);
00402   return NULL;
00403 }