1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // few STL include files
27 // few Med Memory include files
28 #include "MEDMEM_define.hxx"
29 #include "MEDMEM_Mesh.hxx"
30 #include "MEDMEM_SkyLineArray.hxx"
31 #include "MEDMEM_ConnectZone.hxx"
33 using namespace MEDMEM;
35 CONNECTZONE::CONNECTZONE():
38 ,_localDomainNumber(0)
39 ,_distantDomainNumber(0)
43 _entityCorresp.clear();
46 CONNECTZONE::~CONNECTZONE(){
47 if (_nodeCorresp !=0) delete _nodeCorresp;
48 if (_faceCorresp !=0) delete _faceCorresp;
49 for (map < pair <MED_EN::medEntityMesh, MED_EN::medEntityMesh>,MEDMEM::MEDSKYLINEARRAY * >::iterator
50 iter = _entityCorresp.begin(); iter != _entityCorresp.end(); iter++)
56 CONNECTZONE::CONNECTZONE(const CONNECTZONE & myConnectZone):
57 _name(myConnectZone._name)
58 ,_description(myConnectZone._description)
59 ,_localDomainNumber(myConnectZone._localDomainNumber)
60 ,_distantDomainNumber(myConnectZone._distantDomainNumber)
61 ,_nodeCorresp(myConnectZone._nodeCorresp)
62 ,_faceCorresp(myConnectZone._faceCorresp)
63 ,_entityCorresp(myConnectZone._entityCorresp)
66 string CONNECTZONE::getName() const
70 string CONNECTZONE::getDescription() const
74 int CONNECTZONE::getDistantDomainNumber() const
76 return _distantDomainNumber;
78 int CONNECTZONE::getLocalDomainNumber() const
80 return _localDomainNumber;
83 MEDMEM::MESH * CONNECTZONE::getLocalMesh() const
88 MEDMEM::MESH * CONNECTZONE::getDistantMesh() const
93 bool CONNECTZONE::isEntityCorrespPresent(MED_EN::medEntityMesh localEntity,
94 MED_EN::medEntityMesh distantEntity) const
96 typedef map<pair<MED_EN::medEntityMesh,MED_EN::medEntityMesh>, MEDMEM::MEDSKYLINEARRAY*>::const_iterator map_iter;
98 for (map_iter iter=_entityCorresp.begin(); iter != _entityCorresp.end(); iter++)
100 if ((iter->first).first==localEntity && (iter->first).second==distantEntity)
106 const int * CONNECTZONE::getNodeCorrespIndex() const
108 return _nodeCorresp->getIndex();
111 const int * CONNECTZONE::getNodeCorrespValue() const
113 return _nodeCorresp->getValue();
115 int CONNECTZONE::getNodeNumber() const
117 return _nodeCorresp->getNumberOf();
119 const int * CONNECTZONE::getFaceCorrespIndex() const
121 return _faceCorresp->getIndex();
124 const int * CONNECTZONE::getFaceCorrespValue() const
126 return _faceCorresp->getValue();
128 int CONNECTZONE::getFaceNumber() const
130 return _faceCorresp->getNumberOf();
132 const int * CONNECTZONE::getEntityCorrespIndex(MED_EN::medEntityMesh localEntity,
133 MED_EN::medEntityMesh distantEntity) const
135 typedef map<pair<MED_EN::medEntityMesh,MED_EN::medEntityMesh>, MEDMEM::MEDSKYLINEARRAY*>::const_iterator map_iter;
137 for (map_iter iter=_entityCorresp.begin(); iter != _entityCorresp.end(); iter++)
139 if ((iter->first).first==localEntity && (iter->first).second==distantEntity)
140 return iter->second->getIndex();
145 const int * CONNECTZONE::getEntityCorrespValue(MED_EN::medEntityMesh localEntity,
146 MED_EN::medEntityMesh distantEntity) const
148 typedef map<pair<MED_EN::medEntityMesh,MED_EN::medEntityMesh>, MEDMEM::MEDSKYLINEARRAY*>::const_iterator map_iter;
150 for (map_iter iter=_entityCorresp.begin(); iter != _entityCorresp.end(); iter++)
152 if ((iter->first).first==localEntity && (iter->first).second==distantEntity)
153 return iter->second->getValue();
158 int CONNECTZONE::getEntityCorrespNumber(MED_EN::medEntityMesh localEntity,
159 MED_EN::medEntityMesh distantEntity) const
161 typedef map<pair<MED_EN::medEntityMesh,MED_EN::medEntityMesh>, MEDMEM::MEDSKYLINEARRAY*>::const_iterator map_iter;
163 for (map_iter iter=_entityCorresp.begin(); iter != _entityCorresp.end(); iter++)
165 if ((iter->first).first==localEntity && (iter->first).second==distantEntity)
166 return iter->second->getNumberOf();
172 int CONNECTZONE::getEntityCorrespLength(MED_EN::medEntityMesh localEntity,
173 MED_EN::medEntityMesh distantEntity) const
175 typedef map<pair<MED_EN::medEntityMesh,MED_EN::medEntityMesh>, MEDMEM::MEDSKYLINEARRAY*>::const_iterator map_iter;
177 for (map_iter iter=_entityCorresp.begin(); iter != _entityCorresp.end(); iter++)
179 if ((iter->first).first==localEntity && (iter->first).second==distantEntity)
180 return iter->second->getLength();
185 void CONNECTZONE::setName(string name)
189 void CONNECTZONE::setDescription(string description)
191 _description=description;
193 void CONNECTZONE::setDistantDomainNumber(int distantDomainNumber)
195 _distantDomainNumber=distantDomainNumber;
197 void CONNECTZONE::setLocalDomainNumber(int localDomainNumber)
199 _localDomainNumber=localDomainNumber;
201 void CONNECTZONE::setLocalMesh(MEDMEM::MESH * localMesh)
203 _localMesh=localMesh;
206 void CONNECTZONE::setDistantMesh(MEDMEM::MESH * distantMesh)
208 _distantMesh=distantMesh;
211 /*! transforms an int array containing
212 * the node-node connections
213 * to a MEDSKYLINEARRAY
215 void CONNECTZONE::setNodeCorresp(int * nodeCorresp, int nbnode)
217 int* index= new int[nbnode];
218 for (int i=0; i<nbnode; i++)
222 _nodeCorresp = new MEDMEM::MEDSKYLINEARRAY(nbnode, 2*nbnode, index, nodeCorresp);
225 void CONNECTZONE::setNodeCorresp(MEDMEM::MEDSKYLINEARRAY* array)
227 _nodeCorresp = array;
229 /*! transforms an int array containing
230 * the face-face connections
231 * to a MEDSKYLINEARRAY
233 void CONNECTZONE::setFaceCorresp(int * faceCorresp, int nbface)
235 int* index= new int[nbface];
236 for (int i=0; i<nbface; i++)
240 _faceCorresp = new MEDMEM::MEDSKYLINEARRAY(nbface, 2*nbface, index, faceCorresp);
243 void CONNECTZONE::setFaceCorresp(MEDMEM::MEDSKYLINEARRAY* array)
245 _faceCorresp = array;
248 /*! transforms an int array containing
249 * the entity-entity connections
250 * to a MEDSKYLINEARRAY
252 * the resulting MEDSKYLINEARRAY is put in the map
254 void CONNECTZONE::setEntityCorresp(MED_EN::medEntityMesh localEntity,
255 MED_EN::medEntityMesh distantEntity,
256 int * entityCorresp, int nbentity)
258 int* index= new int[nbentity];
259 for (int i=0; i<nbentity; i++)
263 _entityCorresp[make_pair(localEntity,distantEntity)]=
264 new MEDMEM::MEDSKYLINEARRAY(nbentity, 2*nbentity, index, entityCorresp);
268 void CONNECTZONE::setEntityCorresp(MED_EN::medEntityMesh localEntity,
269 MED_EN::medEntityMesh distantEntity,
270 MEDMEM::MEDSKYLINEARRAY* array)
272 _entityCorresp[make_pair(localEntity,distantEntity)]=array;