Back to index

salome-med  6.5.0
MEDMEM_ConnectZone.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 // few STL include files
00024 //
00025 #include <map>
00026 
00027 // few Med Memory include files
00028 #include "MEDMEM_define.hxx"
00029 #include "MEDMEM_Mesh.hxx"
00030 #include "MEDMEM_SkyLineArray.hxx"
00031 #include "MEDMEM_ConnectZone.hxx"
00032 
00033 using namespace MEDMEM;
00034 
00035   CONNECTZONE::CONNECTZONE():
00036   _name("")
00037   ,_description("")
00038   ,_localDomainNumber(0)
00039   ,_distantDomainNumber(0)
00040   ,_nodeCorresp(0)
00041   ,_faceCorresp(0)
00042   {
00043         _entityCorresp.clear();
00044   }
00045   
00046   CONNECTZONE::~CONNECTZONE(){
00047   if (_nodeCorresp !=0) delete _nodeCorresp;
00048   if (_faceCorresp !=0) delete _faceCorresp;
00049   for (map < pair <MED_EN::medEntityMesh, MED_EN::medEntityMesh>,MEDMEM::MEDSKYLINEARRAY * >::iterator 
00050    iter = _entityCorresp.begin(); iter != _entityCorresp.end(); iter++)
00051    {
00052                 delete iter->second;
00053    }
00054   }
00055   
00056   CONNECTZONE::CONNECTZONE(const CONNECTZONE & myConnectZone):
00057   _name(myConnectZone._name)
00058   ,_description(myConnectZone._description)
00059   ,_localDomainNumber(myConnectZone._localDomainNumber)
00060   ,_distantDomainNumber(myConnectZone._distantDomainNumber)
00061   ,_nodeCorresp(myConnectZone._nodeCorresp)
00062   ,_faceCorresp(myConnectZone._faceCorresp)
00063   ,_entityCorresp(myConnectZone._entityCorresp)
00064   {
00065   }
00066   string CONNECTZONE::getName() const 
00067   {
00068         return _name;
00069   }
00070   string CONNECTZONE::getDescription() const 
00071   {
00072         return _description;
00073   }
00074   int CONNECTZONE::getDistantDomainNumber() const 
00075   {
00076         return _distantDomainNumber;
00077   }
00078   int CONNECTZONE::getLocalDomainNumber() const 
00079   {
00080         return _localDomainNumber;
00081   }
00082   
00083   MEDMEM::MESH * CONNECTZONE::getLocalMesh() const 
00084   {
00085         return _localMesh;
00086   }
00087   
00088   MEDMEM::MESH * CONNECTZONE::getDistantMesh() const 
00089   {
00090         return _distantMesh;
00091   }
00092 
00093   bool CONNECTZONE::isEntityCorrespPresent(MED_EN::medEntityMesh localEntity,
00094                               MED_EN::medEntityMesh distantEntity) const
00095 {
00096         typedef map<pair<MED_EN::medEntityMesh,MED_EN::medEntityMesh>, MEDMEM::MEDSKYLINEARRAY*>::const_iterator map_iter;
00097         
00098         for (map_iter iter=_entityCorresp.begin(); iter != _entityCorresp.end(); iter++)
00099         {
00100                 if ((iter->first).first==localEntity && (iter->first).second==distantEntity)
00101                         return true;
00102         }
00103         return false;
00104 }                
00105               
00106   const int * CONNECTZONE::getNodeCorrespIndex() const
00107   {
00108         return _nodeCorresp->getIndex();
00109   }
00110   
00111   const int * CONNECTZONE::getNodeCorrespValue() const
00112   {
00113         return _nodeCorresp->getValue();
00114   }
00115   int CONNECTZONE::getNodeNumber() const
00116   {
00117         return _nodeCorresp->getNumberOf();
00118   }
00119   const int * CONNECTZONE::getFaceCorrespIndex() const
00120   {
00121         return _faceCorresp->getIndex();
00122   }
00123   
00124   const int * CONNECTZONE::getFaceCorrespValue() const
00125   {
00126         return _faceCorresp->getValue();
00127   }
00128   int CONNECTZONE::getFaceNumber() const
00129   {
00130         return _faceCorresp->getNumberOf();
00131   }
00132 const int * CONNECTZONE::getEntityCorrespIndex(MED_EN::medEntityMesh localEntity,
00133                                     MED_EN::medEntityMesh distantEntity) const
00134 {
00135         typedef map<pair<MED_EN::medEntityMesh,MED_EN::medEntityMesh>, MEDMEM::MEDSKYLINEARRAY*>::const_iterator map_iter;
00136         
00137         for (map_iter iter=_entityCorresp.begin(); iter != _entityCorresp.end(); iter++)
00138         {
00139                 if ((iter->first).first==localEntity && (iter->first).second==distantEntity)
00140                         return iter->second->getIndex();
00141         }
00142         return 0;                       
00143 }
00144 
00145 const int * CONNECTZONE::getEntityCorrespValue(MED_EN::medEntityMesh localEntity,
00146                                     MED_EN::medEntityMesh distantEntity) const
00147 {
00148         typedef map<pair<MED_EN::medEntityMesh,MED_EN::medEntityMesh>, MEDMEM::MEDSKYLINEARRAY*>::const_iterator map_iter;
00149         
00150         for (map_iter iter=_entityCorresp.begin(); iter != _entityCorresp.end(); iter++)
00151         {
00152                 if ((iter->first).first==localEntity && (iter->first).second==distantEntity)
00153                         return iter->second->getValue();
00154         }
00155         return 0;                       
00156 }
00157 
00158 int CONNECTZONE::getEntityCorrespNumber(MED_EN::medEntityMesh localEntity,
00159                   MED_EN::medEntityMesh distantEntity) const
00160 {
00161   typedef map<pair<MED_EN::medEntityMesh,MED_EN::medEntityMesh>, MEDMEM::MEDSKYLINEARRAY*>::const_iterator map_iter;
00162   
00163   for (map_iter iter=_entityCorresp.begin(); iter != _entityCorresp.end(); iter++)
00164   {
00165     if ((iter->first).first==localEntity && (iter->first).second==distantEntity)
00166       return iter->second->getNumberOf();
00167   }
00168   return 0;           
00169 }
00170 
00171 
00172 int CONNECTZONE::getEntityCorrespLength(MED_EN::medEntityMesh localEntity,
00173                   MED_EN::medEntityMesh distantEntity) const
00174 {
00175   typedef map<pair<MED_EN::medEntityMesh,MED_EN::medEntityMesh>, MEDMEM::MEDSKYLINEARRAY*>::const_iterator map_iter;
00176   
00177   for (map_iter iter=_entityCorresp.begin(); iter != _entityCorresp.end(); iter++)
00178   {
00179     if ((iter->first).first==localEntity && (iter->first).second==distantEntity)
00180       return iter->second->getLength();
00181   }
00182   return 0;           
00183 }
00184 
00185   void CONNECTZONE::setName(string name) 
00186   {
00187         _name=name;
00188   }
00189   void CONNECTZONE::setDescription(string description)
00190   {
00191         _description=description;
00192   }
00193   void CONNECTZONE::setDistantDomainNumber(int distantDomainNumber)
00194   {
00195         _distantDomainNumber=distantDomainNumber;
00196   }
00197   void CONNECTZONE::setLocalDomainNumber(int localDomainNumber)
00198   {
00199         _localDomainNumber=localDomainNumber;
00200   }
00201   void CONNECTZONE::setLocalMesh(MEDMEM::MESH * localMesh)
00202   {
00203         _localMesh=localMesh;
00204   }
00205   
00206   void CONNECTZONE::setDistantMesh(MEDMEM::MESH * distantMesh)
00207   {
00208         _distantMesh=distantMesh;
00209   }
00210 
00215   void CONNECTZONE::setNodeCorresp(int * nodeCorresp, int nbnode)
00216   {
00217         int* index= new int[nbnode];
00218         for (int i=0; i<nbnode; i++)
00219         {
00220                 index[i]=2*i;
00221         }
00222         _nodeCorresp = new MEDMEM::MEDSKYLINEARRAY(nbnode, 2*nbnode, index, nodeCorresp);
00223   }
00224   
00225   void CONNECTZONE::setNodeCorresp(MEDMEM::MEDSKYLINEARRAY* array)
00226   {
00227         _nodeCorresp = array;
00228   }
00233   void CONNECTZONE::setFaceCorresp(int * faceCorresp, int nbface)
00234   {
00235         int* index= new int[nbface];
00236         for (int i=0; i<nbface; i++)
00237         {
00238                 index[i]=2*i;
00239         }
00240         _faceCorresp = new MEDMEM::MEDSKYLINEARRAY(nbface, 2*nbface, index, faceCorresp);
00241   }
00242   
00243   void CONNECTZONE::setFaceCorresp(MEDMEM::MEDSKYLINEARRAY* array)
00244   {
00245         _faceCorresp = array;
00246   }
00247   
00254   void CONNECTZONE::setEntityCorresp(MED_EN::medEntityMesh localEntity,
00255                         MED_EN::medEntityMesh distantEntity,
00256                         int * entityCorresp, int nbentity)
00257   {
00258         int* index= new int[nbentity];
00259         for (int i=0; i<nbentity; i++)
00260         {
00261                 index[i]=2*i;
00262         }
00263         _entityCorresp[make_pair(localEntity,distantEntity)]=
00264          new MEDMEM::MEDSKYLINEARRAY(nbentity, 2*nbentity, index, entityCorresp);
00265   }
00266   
00267   
00268     void CONNECTZONE::setEntityCorresp(MED_EN::medEntityMesh localEntity,
00269                         MED_EN::medEntityMesh distantEntity,
00270                         MEDMEM::MEDSKYLINEARRAY* array)
00271   {
00272         _entityCorresp[make_pair(localEntity,distantEntity)]=array;
00273   }
00274   
00275 
00276 
00277 
00278 
00279 
00280