Back to index

salome-med  6.5.0
MEDMEM_Group.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 Group.cxx
00025 */
00026 #include <list>
00027 
00028 #include "MEDMEM_Group.hxx"
00029 #include "MEDMEM_Family.hxx"
00030 #include "MEDMEM_Mesh.hxx"
00031 
00032 using namespace std;
00033 using namespace MEDMEM;
00034 using namespace MED_EN;
00035 
00036 GROUP::GROUP():SUPPORT(),_numberOfFamilies(0),_family() 
00037 {
00038   MESSAGE_MED("GROUP()");
00039 }
00040 
00041 GROUP::~GROUP() 
00042 {
00043   MESSAGE_MED("~GROUP()");
00044 }
00045   
00046 GROUP & GROUP::operator=(const GROUP &group) 
00047 {
00048   MESSAGE_MED("GROUP::operator=");
00049   if ( &group == this ) return *this;
00050   SUPPORT::operator=(group);
00051   _numberOfFamilies = group._numberOfFamilies ;
00052   _family           = group._family ;
00053   return *this;
00054 }
00055 
00056 ostream & MEDMEM::operator<<(ostream &os, GROUP &myGroup)
00057 {
00058   os << (SUPPORT&) myGroup;
00059 
00060   int numberoffamilies = myGroup.getNumberOfFamilies();
00061   os << "  - Families ("<<numberoffamilies<<") :"<<endl;
00062   for (int j=1;j<numberoffamilies+1;j++)
00063     os << "    * "<<myGroup.getFamily(j)->getName().c_str()<<endl ;
00064 
00065   return os;
00066 }
00067 
00068 GROUP::GROUP(const string & name, const list<FAMILY*> & families) throw (MEDEXCEPTION)
00069 {
00070   const char * LOC = "GROUP( const string & , const list<FAMILY*> & ) : " ;
00071   
00072   BEGIN_OF_MED(LOC);
00073 
00074   MESSAGE_MED(LOC<<name);
00075 
00076   int numberOfFamilies = families.size();
00077   _name = name ;
00078   _description = "GROUP";
00079   // description : none !
00080   // first FAMILY to set all !
00081   FAMILY * myFamily = families.front() ;
00082   _mesh =  myFamily->getMesh() ;
00083   if(_mesh)
00084     _mesh->addReference();
00085   _entity = myFamily->getEntity() ;
00086   bool isOnAllElts = myFamily->isOnAllElements() ;
00087 
00088   SCRUTE_MED(isOnAllElts);
00089   SCRUTE_MED(numberOfFamilies);
00090 
00091 
00092   if ((numberOfFamilies==1) && (isOnAllElts))
00093     {
00094       _numberOfFamilies = numberOfFamilies;
00095       _isOnAllElts = isOnAllElts ;
00096       _family.resize(_numberOfFamilies) ;
00097       _family[0] = myFamily;
00098       update();
00099       return;
00100     }
00101   else if ((!(numberOfFamilies==1)) && (isOnAllElts))
00102     throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "building of a GROUP object from several FAMILY, and one of them is on all entities"  )) ;
00103 
00104   _numberOfGeometricType = myFamily->getNumberOfTypes() ;
00105 
00106   _geometricType.set(_numberOfGeometricType);
00107   _numberOfElements.set(_numberOfGeometricType) ;
00108 
00109   const medGeometryElement * geometricType = myFamily->getTypes() ;
00110 
00111   SCRUTE_MED(_numberOfGeometricType);
00112 
00113   for (int i=0 ; i<_numberOfGeometricType; i++) {
00114     _geometricType[i]= geometricType[i] ;
00115     _numberOfElements[i]=myFamily->getNumberOfElements(geometricType[i]);
00116     MESSAGE_MED(LOC << " Type : " << _geometricType[i] << " number of element(s) " << _numberOfElements[i]);
00117   }
00118   _isOnAllElts = false ;
00119 
00120 
00121   MEDSKYLINEARRAY * famNumber = myFamily->getnumber();
00122 
00123   const int * famNumberValue = myFamily->getNumber(MED_ALL_ELEMENTS);
00124 
00125   const int * famNumberIndex = myFamily->getNumberIndex();
00126 
00127   int famNumberCount = famNumber->getNumberOf();
00128   int famNumberLength = famNumber->getLength();
00129 
00130   SCRUTE_MED(famNumber);
00131   SCRUTE_MED(famNumberCount);
00132   SCRUTE_MED(famNumberLength);
00133   SCRUTE_MED(famNumberValue);
00134   SCRUTE_MED(famNumberIndex);
00135 
00136   _number = new MEDSKYLINEARRAY(famNumberCount,famNumberLength,
00137                                 famNumberIndex,famNumberValue) ;
00138 
00139   _numberOfFamilies = families.size();
00140 
00141   _family.resize(_numberOfFamilies) ;
00142   list<FAMILY*>::const_iterator li ;
00143 
00144   int it = 0 ;
00145   for (li=families.begin();li!=families.end();li++) {
00146     blending(*li);
00147     _family[it] = (*li) ;
00148     it++ ;
00149   }
00150 
00151   END_OF_MED(LOC);
00152 }
00153 
00154 GROUP::GROUP(const GROUP & m):SUPPORT(m)
00155 {
00156   _numberOfFamilies = m._numberOfFamilies;
00157   _family = m._family; //Copie profonde dans FAMILY Rmq from EF
00158 }
00159