Back to index

salome-med  6.5.0
MEDMEM_Group_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 //=============================================================================
00024 // File      : MEDMEM_Group_i.cxx
00025 // Project   : SALOME
00026 // Author    : EDF 
00027 // $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_Group_i.cxx
00028 //=============================================================================
00029 //
00030 #include <vector>
00031 
00032 #include "utilities.h"
00033 #include "Utils_CorbaException.hxx"
00034 
00035 #include "MEDMEM_Group_i.hxx"
00036 #include "MEDMEM_Family_i.hxx"
00037 
00038 #include "MEDMEM_Group.hxx"
00039 #include "MEDMEM_Family.hxx"
00040 using namespace MEDMEM;
00041 
00042 //=============================================================================
00046 //=============================================================================
00047 GROUP_i::GROUP_i():_group((::GROUP*)NULL)
00048 {
00049 }
00050 //=============================================================================
00054 //=============================================================================
00055 GROUP_i::~GROUP_i()
00056 {
00057 }
00058 //=============================================================================
00062 //=============================================================================
00063 GROUP_i::GROUP_i(const ::GROUP * const g):SUPPORT_i(g),_group(g)
00064 {
00065 }
00066 //=============================================================================
00070 //=============================================================================
00071 GROUP_i::GROUP_i(const GROUP_i & g):SUPPORT_i(g._group),_group(g._group)
00072 {
00073 }
00074 //=============================================================================
00078 //=============================================================================
00079 
00080 CORBA::Long  GROUP_i::getNumberOfFamilies() 
00081 throw (SALOME::SALOME_Exception)
00082 {
00083         if (_group==NULL)
00084                 THROW_SALOME_CORBA_EXCEPTION("No associated Group",\
00085                                              SALOME::INTERNAL_ERROR);
00086         try
00087         {
00088                 return _group->getNumberOfFamilies();
00089         }
00090         catch (MEDEXCEPTION &ex)
00091         {
00092                 MESSAGE("Unable to get number of families of the group");
00093                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00094         }
00095 }
00096 //=============================================================================
00100 //=============================================================================
00101 
00102 SALOME_MED::Family_array* GROUP_i::getFamilies()         
00103 throw (SALOME::SALOME_Exception)
00104 {
00105         if (_group==NULL)
00106                 THROW_SALOME_CORBA_EXCEPTION("No associated Group",\
00107                                              SALOME::INTERNAL_ERROR);
00108         SALOME_MED::Family_array_var myseq = new SALOME_MED::Family_array;
00109         try
00110         {
00111                 int nbfam= _group->getNumberOfFamilies();
00112                 myseq->length(nbfam);
00113                 vector<FAMILY*> fam(nbfam);
00114                 fam = _group->getFamilies();
00115                 for (int i=0;i<nbfam;i++)
00116                 {
00117                         FAMILY_i * f1=new FAMILY_i(fam[i]);
00118                         myseq[i] = f1->_this();
00119                 }
00120         }
00121         catch (MEDEXCEPTION &ex)
00122         {
00123                 MESSAGE("Unable to access families");
00124                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00125         }
00126         return myseq._retn();
00127 }
00128 //=============================================================================
00132 //=============================================================================
00133 
00134 SALOME_MED::FAMILY_ptr GROUP_i::getFamily(CORBA::Long i) 
00135 throw (SALOME::SALOME_Exception)
00136 {
00137         if (_group==NULL)
00138                 THROW_SALOME_CORBA_EXCEPTION("No associated Group",\
00139                                              SALOME::INTERNAL_ERROR);
00140         try
00141         {
00142                 FAMILY * fam=_group->getFamily(i);
00143                 FAMILY_i * f1=new FAMILY_i(fam);
00144                 return f1->_this();
00145         }
00146         catch (MEDEXCEPTION &ex)
00147         {
00148                 MESSAGE("Unable to acces to the specified family");
00149                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00150         }
00151 }