1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 # include "MEDMEM_Med.hxx"
24 # include "MEDMEM_DriverFactory.hxx"
25 # include "MEDMEM_STRING.hxx"
27 # include "MEDMEM_Mesh.hxx"
28 # include "MEDMEM_Grid.hxx"
29 # include "MEDMEM_Field.hxx"
30 # include "MEDMEM_Group.hxx"
31 # include "MEDMEM_Family.hxx"
33 # include "MEDMEM_Exception.hxx"
34 # include "MEDMEM_Utilities.hxx"
37 using namespace MEDMEM;
38 using namespace MED_EN;
46 MESSAGE("MED::MED()");
52 MED::MED(driverTypes driverType, const string & fileName)
54 const char * LOC = "MED::MED(driverTypes driverType, const string & fileName) : ";
57 MESSAGE(LOC << "driverType = " << driverType);
59 int current = addDriver(driverType,fileName,MED_LECT);
61 _drivers[current]->open();
62 _drivers[current]->readFileStruct();
63 _drivers[current]->close();
73 const char * LOC = "MED::~MED() : ";
76 // Analysis of the object MED
80 map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
82 for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
83 if ( (*currentField).first != NULL) index++;
86 MESSAGE(LOC << " there is(are) " << index << " field(s):");
87 for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
88 if ( (*currentField).first != NULL) MESSAGE(" " << ((*currentField).first)->getName().c_str());
91 map<MESH_NAME_, map<MED_EN::medEntityMesh,SUPPORT *> >::iterator itSupportOnMesh ;
93 for ( itSupportOnMesh=_support.begin();itSupportOnMesh != _support.end(); itSupportOnMesh++ ) {
94 map<MED_EN::medEntityMesh,SUPPORT *>::iterator itSupport ;
95 for ( itSupport=(*itSupportOnMesh).second.begin();itSupport!=(*itSupportOnMesh).second.end();itSupport++)
99 MESSAGE(LOC << " there is(are) " << index << " support(s):");
101 map<MESH_NAME_,MESH*>::const_iterator currentMesh;
103 for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
104 if ( (*currentMesh).second != NULL)
108 MESSAGE(LOC << " there is(are) " << index << " meshe(s):");
109 // for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
110 // if ( (*currentMesh).second != NULL)
112 // SCRUTE((*currentMesh).second);
114 // string meshName = ((*currentMesh).second)->getName();
116 // MESSAGE(" " << meshName);
120 // delete all ? : PG : YES !
121 // map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
122 for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
123 if ( (*currentField).first != NULL) {
124 // cast in right type to delete it !
125 switch ((*currentField).first->getValueType()) {
127 delete (FIELD<int>*) (*currentField).first ;
130 delete (FIELD<double>*) (*currentField).first ;
133 MESSAGE(LOC << "Field has type different of int or double, could not destroy its values array !") ;
134 delete (*currentField).first;
138 // map<MESH_NAME_, map<MED_EN::medEntityMesh,SUPPORT *> >::iterator itSupportOnMesh ;
139 for ( itSupportOnMesh=_support.begin();itSupportOnMesh != _support.end(); itSupportOnMesh++ ) {
140 map<MED_EN::medEntityMesh,SUPPORT *>::iterator itSupport ;
141 for ( itSupport=(*itSupportOnMesh).second.begin();itSupport!=(*itSupportOnMesh).second.end();itSupport++)
142 if (! dynamic_cast<GROUP*>( (*itSupport).second ) &&
143 ! dynamic_cast<FAMILY*>( (*itSupport).second ) )
144 delete (*itSupport).second ;
147 // map<MESH_NAME_,MESH*>::const_iterator currentMesh;
148 for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
149 if ( (*currentMesh).second != NULL)
151 if (!((*currentMesh).second)->getIsAGrid())
152 delete (*currentMesh).second;
154 delete (GRID *) (*currentMesh).second;
158 index =_drivers.size();
160 MESSAGE(LOC << "In this object MED there is(are) " << index << " driver(s):");
162 for (unsigned int ind=0; ind < _drivers.size(); ind++ )
164 SCRUTE(_drivers[ind]);
165 if ( _drivers[ind] != NULL) delete _drivers[ind];
175 Create the specified driver and return its index reference to path to
176 read or write methods.
178 int MED::addDriver(driverTypes driverType,
179 const string & fileName="Default File Name.med",
180 MED_EN::med_mode_acces access) {
182 const char * LOC = "MED::addDriver(driverTypes driverType, const string & fileName=\"Default File Name.med\") : ";
186 MESSAGE(LOC << " the file name is " << fileName);
191 GENDRIVER *driver = DRIVERFACTORY::buildDriverForMed(driverType,fileName,
194 _drivers.push_back(driver);
196 int current = _drivers.size()-1;
198 driver->setId(current);
206 Duplicate the given driver and return its index reference to path to
207 read or write methods.
209 int MED::addDriver(GENDRIVER & driver) {
210 const char * LOC = "MED::addDriver(GENDRIVER &) : ";
215 SCRUTE(_drivers.size());
217 _drivers.push_back(&driver);
219 SCRUTE(_drivers.size());
224 current = _drivers.size()-1;
226 driver.setId(current);
235 Remove the driver referenced by its index.
237 void MED::rmDriver (int index/*=0*/)
238 throw (MED_EXCEPTION)
240 const char * LOC = "MED::rmDriver (int index=0): ";
244 //_drivers.erase(&_drivers[index]);
247 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
248 << "The index given is invalid, index must be between 0 and |"
256 ??? to do comment ???
258 void MED::writeFrom (int index/*=0*/)
259 throw (MED_EXCEPTION)
261 const char * LOC = "MED::write (int index=0): ";
264 if (_drivers[index]) {
265 // open and close are made by all objects !
266 _drivers[index]->writeFrom();
268 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
269 << "The index given is invalid, index must be between 0 and |"
277 Write all objects with the driver given by its index.
279 void MED::write (int index/*=0*/)
280 throw (MED_EXCEPTION)
282 const char * LOC = "MED::write (int index=0): ";
285 if (_drivers[index]) {
286 // open and close are made by the subsequent objects !
287 _drivers[index]->write();
290 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
291 << "The index given is invalid, index must be between 0 and |"
299 Parse all the file and generate empty object.
301 All object must be read explicitly later with their own method read
302 or use MED::read to read all.
304 This method is automaticaly call by constructor with driver information.
306 void MED::readFileStruct (int index/*=0*/)
307 throw (MED_EXCEPTION)
309 const char * LOC = "MED::readFileStruct (int index=0): ";
312 if (_drivers[index]) {
313 _drivers[index]->open();
314 _drivers[index]->readFileStruct();
315 _drivers[index]->close();
318 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
319 << "The index given is invalid, index must be between 0 and |"
326 Read all objects in the file specified in the driver given by its index.
328 void MED::read (int index/*=0*/)
329 throw (MED_EXCEPTION)
331 const char * LOC = "MED::read (int index=0): ";
336 if (_drivers[index]) {
337 // open and close are made by all objects !
339 SCRUTE(_drivers[index]);
340 SCRUTE(&_drivers[index]);
341 // _drivers[index]->open();
342 _drivers[index]->read();
343 // _drivers[index]->close();
346 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
347 << "The index given is invalid, index must be between >0 and < |"
355 // ------- End Of Drivers Management Part
358 Get the number of MESH objects.
360 int MED::getNumberOfMeshes ( void ) const {
362 const char * LOC = "MED::getNumberOfMeshes ( void ) const : ";
365 return _meshes.size();
369 Get the number of FIELD objects.
371 int MED::getNumberOfFields ( void ) const {
373 const char * LOC = "MED::getNumberOfFields ( void ) const : ";
376 return _fields.size(); // we get number of field with different name
380 Get the names of all MESH objects.
382 meshNames is an in/out argument.
384 It is a string array of size the
385 number of MESH objects. It must be allocated before calling
386 this method. All names are put in it.
388 void MED::getMeshNames ( string * meshNames ) const
389 throw (MED_EXCEPTION)
391 const char * LOC = "MED::getMeshNames ( string * ) const : ";
394 // REM : ALLOCATION D'UN TABLEAU DE POINTEURS SUR STRING FAITE PAR LE CLIENT
395 map<MESH_NAME_,MESH*>::const_iterator currentMesh; // ??ITERATEUR CONST SUR UN OBJET NON CONST ??
397 int meshNamesIndex = 0;
399 for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
400 meshNames[meshNamesIndex]=(*currentMesh).first;
401 meshNamesIndex++; // CF OPTIMISATION
408 Get the names of all MESH objects.
410 Return a deque<string> object which contain the name of all MESH objects.
412 deque<string> MED::getMeshNames () const {
414 const char * LOC = "MED::getMeshNames () const : ";
417 deque<string> meshNames(_meshes.size());
419 map<MESH_NAME_,MESH*>::const_iterator currentMesh; // ??ITERATEUR CONST SUR UN OBJET NON CONST ??
421 int meshNamesIndex = 0;
423 for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
424 meshNames[meshNamesIndex]=(*currentMesh).first;
425 meshNamesIndex++; // CF OPTIMISATION
434 Return a reference to the MESH object named meshName.
436 MESH * MED::getMesh ( const string & meshName ) const
437 throw (MED_EXCEPTION)
440 const char * LOC = "MED::getMesh ( const string & meshName ) const : ";
443 map<MESH_NAME_,MESH*>::const_iterator itMeshes = _meshes.find(meshName);
445 if ( itMeshes == _meshes.end() )
446 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
447 << "There is no known mesh named |"
452 return (*itMeshes).second;
458 \internal Return a reference to the MESH object associated with
461 MESH * MED::getMesh (const FIELD_ * const field ) const
462 throw (MED_EXCEPTION)
465 const char * LOC = "MED::getMesh ( const FIELD * field ) const : ";
468 FIELD_ * f = const_cast< FIELD_* > (field); // Comment faire mieux ?
469 map<FIELD_ *, MESH_NAME_>::const_iterator itMeshName = _meshName.find(f);
471 if ( itMeshName == _meshName.end() )
472 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
473 << "There is no known mesh associated with |"
474 << field << "| pointer"
478 string meshName = (*itMeshName).second;
479 map<MESH_NAME_,MESH*>::const_iterator itMeshes = _meshes.find(meshName);
480 if ( itMeshes == _meshes.end() )
481 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
482 << "There is no known mesh named |"
483 << meshName << " while it's associated with the found field |"
484 << field << "| pointer"
490 return (*itMeshes).second;
495 Get the names of all FIELD objects.
497 fieldNames is an in/out argument.
499 It is an array of string of size the
500 number of FIELD objects. It must be allocated before calling
501 this method. All names are put in it.
503 void MED::getFieldNames ( string * fieldNames ) const
504 throw (MED_EXCEPTION)
506 const char * LOC = "MED::getFieldNames ( string * ) const : ";
509 // unsigned int fieldNamesSize = sizeof(fieldNames) / sizeof(string *);
511 // if ( fieldNamesSize != _fields.size() )
512 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
513 // << "Size of parameter fieldNames is |"
514 // << fieldNamesSize << "| and should be |"
515 // << _fields.size() << "| and should be |"
519 // REM : ALLOCATION D'UN TABLEAU DE POINTEURS SUR STRING FAITE PAR LE CLIENT
520 map<FIELD_NAME_,MAP_DT_IT_>::const_iterator currentField;
522 int fieldNamesIndex = 0;
523 for ( currentField=_fields.begin();currentField != _fields.end(); currentField++ ) {
524 fieldNames[fieldNamesIndex]=(*currentField).first;
525 fieldNamesIndex++; // CF OPTIMISATION
533 Get the names of all FIELD objects.
535 Return a deque<string> object which contain the name of all FIELD objects.
537 deque<string> MED::getFieldNames () const {
539 const char * LOC = "MED::getFieldNames ( ) const : ";
542 deque<string> fieldNames(_fields.size());
544 map<FIELD_NAME_,MAP_DT_IT_>::const_iterator currentField;
546 int fieldNamesIndex = 0;
548 for ( currentField=_fields.begin();currentField != _fields.end(); currentField++ ) {
549 fieldNames[fieldNamesIndex]=(*currentField).first;
550 fieldNamesIndex++; // CF OPTIMISATION
558 Return a deque<DT_IT_> which contain all iteration step for the FIELD
559 identified by its name.
561 deque<DT_IT_> MED::getFieldIteration (const string & fieldName) const
562 throw (MED_EXCEPTION)
565 const char * LOC = "MED::getFieldIteration ( const string & ) const : ";
568 map<FIELD_NAME_,MAP_DT_IT_>::const_iterator itFields = _fields.find(fieldName);
570 if ( itFields == _fields.end() )
571 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
572 << "There is no known field named |"
576 // const MAP_DT_IT_ & myIterationMap = const_cast<const MAP_DT_IT_ & > ((*itFields).second);
577 const MAP_DT_IT_ & myIterationMap = (*itFields).second ;
578 MAP_DT_IT_::const_iterator currentIterator ;
580 int iterationSize = myIterationMap.size();
582 SCRUTE(iterationSize);
584 deque<DT_IT_> Iteration(iterationSize);
586 int iterationIndex = 0;
588 for (currentIterator = myIterationMap.begin();
589 currentIterator != myIterationMap.end(); currentIterator++ )
591 SCRUTE(((*currentIterator).first).dt);
592 SCRUTE(((*currentIterator).first).it);
594 Iteration[iterationIndex].dt = ((*currentIterator).first).dt;
595 Iteration[iterationIndex].it = ((*currentIterator).first).it;
597 // Iteration[iterationIndex]=(*currentIterator).first;
598 SCRUTE(Iteration[iterationIndex].dt);
599 SCRUTE(Iteration[iterationIndex].it);
600 iterationIndex++; // CF OPTIMISATION
608 Return a reference to the FIELD object named fieldName with
609 time step number dt and order number it.
611 FIELD_ * MED::getField ( const string & fieldName, const int dt=MED_NOPDT, const int it=MED_NOPDT ) const
612 throw (MED_EXCEPTION)
615 const char * LOC = "MED::getField ( const string &, const int, const int ) const : ";
618 MESSAGE(LOC << "fieldName = "<<fieldName<<", dt ="<<dt<<", it = "<<it);
625 map<FIELD_NAME_,MAP_DT_IT_>::const_iterator itFields = _fields.find(fieldName);
627 if ( itFields == _fields.end() )
628 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
629 << "There is no known field named |"
634 const MAP_DT_IT_ & map_dtIt = const_cast<const MAP_DT_IT_ & > ((*itFields).second);
635 MAP_DT_IT_::const_iterator itMap_dtIt = map_dtIt.find(dtIt);
637 if ( itMap_dtIt == map_dtIt.end() )
638 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
639 << "There is no (dt,it) |("
640 << dt << "," << it << ")| associated with the found field |"
647 //return _fields[fieldName][dtIt];
648 return (*itMap_dtIt).second;
653 Return a reference to the FIELD object named fieldName with
654 time and iteration nb it.
656 FIELD_ *MED::getField2(const string & fieldName, double time, int it) const throw (MEDEXCEPTION)
658 const char * LOC = "MED::getField2 ( const string &, const int, const int ) const : ";
659 const double eps=1e-9;
660 map<FIELD_NAME_,MAP_DT_IT_>::const_iterator itFields=_fields.find(fieldName);
661 if ( itFields == _fields.end() )
662 throw MED_EXCEPTION (LOCALIZED( STRING(LOC) << "There is no known field named |" << fieldName << "|"));
663 MAP_DT_IT_::const_iterator iters=(*itFields).second.begin();
666 for(;iters!=(*itFields).second.end() && !found;iters++)
667 if(fabs((*iters).second->getTime()-time)<eps)
668 //if(it==(*iters).first.it)
674 throw MED_EXCEPTION(LOCALIZED( STRING(LOC) << "There is no known field existing at specified time and iteration !!! "));
679 // fiend ostream & MED::operator<<(ostream &os,const MED & med) const {
684 Return a map<MED_EN::medEntityMesh,SUPPORT*> which contain
685 foreach entity, a reference to the SUPPORT on all elements.
687 const map<MED_EN::medEntityMesh,SUPPORT*> & MED::getSupports(const string & meshName) const
688 throw (MED_EXCEPTION)
690 const char * LOC = "MED::getSupports ( const string ) const : ";
693 map<MESH_NAME_, map<MED_EN::medEntityMesh,SUPPORT *> >::const_iterator itSupportOnMesh = _support.find(meshName) ;
695 if ( itSupportOnMesh == _support.end() )
696 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
697 << "There is no support on mesh named |"
702 return (*itSupportOnMesh).second ;
706 Return a reference to the SUPPORT object on all elements of entity
707 for the MESH named meshName.
709 SUPPORT * MED::getSupport (const string & meshName,MED_EN::medEntityMesh entity) const
710 throw (MED_EXCEPTION)
712 const char * LOC = "MED::getSupport ( const string, MED_EN::medEntityMesh ) const : ";
716 map<MESH_NAME_, map<MED_EN::medEntityMesh,SUPPORT *> >::const_iterator const_itSupportOnMesh;
718 for (const_itSupportOnMesh=_support.begin(); const_itSupportOnMesh != _support.end();
719 const_itSupportOnMesh++ )
721 map<MED_EN::medEntityMesh,SUPPORT *>::const_iterator const_itSupport ;
722 for (const_itSupport=(*const_itSupportOnMesh).second.begin();
723 const_itSupport!=(*const_itSupportOnMesh).second.end();const_itSupport++) index++;
726 MESSAGE(LOC << "In this MED object there is(are) " << index << " support(s):");
728 for (const_itSupportOnMesh=_support.begin();const_itSupportOnMesh != _support.end(); const_itSupportOnMesh++ )
730 map<MED_EN::medEntityMesh,SUPPORT *>::const_iterator const_itSupport ;
731 for (const_itSupport=(*const_itSupportOnMesh).second.begin();
732 const_itSupport!=(*const_itSupportOnMesh).second.end();const_itSupport++)
734 MESSAGE(LOC << "Support on mesh " << (*const_itSupportOnMesh).first << " on entity " << (*const_itSupport).first << " : " << *((*const_itSupport).second));
738 const_itSupportOnMesh = _support.find(meshName) ;
740 if ( const_itSupportOnMesh == _support.end() )
741 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
742 << "There is no support on mesh named |"
747 // map<MED_EN::medEntityMesh,SUPPORT *> & SupportOnMesh = (map<MED_EN::medEntityMesh,SUPPORT *>&) ((*itSupportOnMesh).second) ;
748 // map<MED_EN::medEntityMesh,SUPPORT *>::const_iterator itSupport = SupportOnMesh.find(entity) ;
750 // if (itSupport == SupportOnMesh.end() )
751 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
752 // << "There is no support on entity "
753 // << entity << " in mesh named |"
754 // << meshName << "|"
759 map<MED_EN::medEntityMesh,SUPPORT *> SupportOnMesh = ((*const_itSupportOnMesh).second);
761 map<MED_EN::medEntityMesh,SUPPORT *>::const_iterator itSupport = SupportOnMesh.find(entity) ;
763 if (itSupport == SupportOnMesh.end() )
764 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
765 << "There is no support on entity "
766 << entity << " in mesh named |"
771 return (*itSupport).second ;
775 Temporary method : when all MESH objects are read, this methods
776 update all SUPPORT objects with the rigth dimension.
778 void MED::updateSupport ()
780 const char * LOC = "MED::updateSupport () : ";
783 map<MESH_NAME_, map<MED_EN::medEntityMesh,SUPPORT *> >::iterator itSupportOnMesh ;
784 for ( itSupportOnMesh=_support.begin();itSupportOnMesh != _support.end(); itSupportOnMesh++ ) {
785 map<MED_EN::medEntityMesh,SUPPORT *>& anEntity2Support = (*itSupportOnMesh).second;
786 map<MED_EN::medEntityMesh,SUPPORT *> anEntity2SupportTmp;
787 map<MED_EN::medEntityMesh,SUPPORT *>::iterator itSupport ;
788 for ( itSupport=anEntity2Support.begin();itSupport!=anEntity2Support.end();itSupport++)
790 MED_EN::medEntityMesh aKey = (*itSupport).first;
791 SUPPORT* aData = (*itSupport).second;
794 anEntity2SupportTmp[aKey] = aData;
796 catch (MEDEXCEPTION & ex) {
797 // entity not defined in mesh -> we remove support on it !
798 MESSAGE(LOC<<ex.what());
799 delete (*itSupport).second ;
800 //(*itSupportOnMesh).second.erase(itSupport) ; // that's right ????
802 map<MED_EN::medEntityMesh,SUPPORT *>::iterator itSupportCurr = itSupport;
803 itSupport--; // decrement before erase()
804 (*itSupportOnMesh).second.erase(itSupportCurr);
808 // some entities has not defined in mesh -> we should remove their supports!
809 anEntity2Support.swap( anEntity2SupportTmp );
811 for ( itSupport=anEntity2SupportTmp.begin();itSupport!=anEntity2SupportTmp.end();itSupport++)
813 MED_EN::medEntityMesh aKey = (*itSupport).first;
814 SUPPORT* aData = (*itSupport).second;
815 if( anEntity2Support.find( aKey ) == anEntity2Support.end() )
824 Add the given MESH object. MED object control it,
825 and destroy it, so you must not destroy it after.
827 The meshName is given by the MESH object.
829 void MED::addMesh( MESH * const ptrMesh)
830 throw (MED_EXCEPTION)
832 const char * LOC = "MED::addMesh(const MESH * ptrMesh): ";
836 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "ptrMesh must not be NULL !"));
839 if ( ! ( meshName = ptrMesh->getName()).size() )
840 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "ptrMesh->_name must not be NULL !"));
842 // MESH * meshToMed = new MESH(*ptrMesh); DO WE HAVE TO COPY THE ENTRY MESH OR NOT ????? (NB)
844 _meshes[meshName] = ptrMesh; // if ptrMesh->meshName already exists it is modified
846 // _meshes[meshName] = meshToMed;
852 Add the given FIELD object. MED object control it,
853 and destroy it, so you must not destroy it after.
855 The fieldName is given by the FIELD object.
857 void MED::addField( FIELD_ * const ptrField)
858 throw (MED_EXCEPTION)
860 const char * LOC = "MED::addField(const FIELD_ * const ptrField): ";
864 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "ptrField must not be NULL !"));
867 if ( ! (fieldName = ptrField->getName()).size() )
868 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "ptrField->_name must not be NULL !"));
870 SUPPORT * ptrSupport;
871 if ( ! ( ptrSupport = (SUPPORT * ) ptrField->getSupport()) )
872 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "ptrField->_support must not be NULL !"));
875 if ( ! ( ptrMesh = ptrSupport->getMesh()) )
876 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "ptrField->_support->_mesh must not be NULL !"));
879 if ( ! ( meshName = ptrMesh->getName()).size() )
880 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "ptrField->_support->_mesh->_name must not be NULL !"));
883 dtIt.dt = ptrField->getIterationNumber();
884 dtIt.it = ptrField->getOrderNumber();
886 _fields [fieldName][dtIt] = ptrField; // if it already exists it is replaced
887 _meshName [ptrField] = meshName; // if it already exists it is replaced
888 _meshes [meshName] = ptrMesh; // if it already exists it is replaced
890 // int numberOfTypes = ptrSupport->getNumberOfTypes(); !! UNUSED VARIABLE !!
891 _support [meshName][ptrSupport->getEntity()] = ptrSupport;// if it already exists it is replaced