Back to index

salome-med  6.5.0
MEDMEM_Family.hxx
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 #ifndef FAMILY_HXX
00024 #define FAMILY_HXX
00025 
00026 #include <string>
00027 #include "MEDMEM_Support.hxx"
00028 
00039 namespace MEDMEM {
00040   class FAMILY;
00041   MEDMEM_EXPORT std::ostream & operator<<(std::ostream &os, FAMILY &my);
00042   MEDMEM_EXPORT std::ostream & operator<<(std::ostream &os, const FAMILY &my) ;
00043 
00044 class MEDMEM_EXPORT FAMILY : virtual public SUPPORT
00045 {
00046 protected :
00053   int      _identifier ;
00060   int      _numberOfAttribute ;
00067   PointerOf<int>    _attributeIdentifier ;
00074   PointerOf<int>    _attributeValue ;
00081   //PointerOf<string>  _attributeDescription ;
00082   std::vector<std::string>  _attributeDescription ;
00088   int      _numberOfGroup ;
00094   //PointerOf<string> _groupName ;
00095   std::vector<std::string> _groupName ;
00096  protected:
00098   virtual ~FAMILY();
00099 public:
00101   FAMILY();
00107   FAMILY( GMESH* Mesh, int Identifier, string Name, 
00108           int NumberOfAttribute, int *AttributeIdentifier,
00109           int *AttributeValue, string AttributeDescription,
00110           int NumberOfGroup,   string GroupName,
00111           int * MEDArrayNodeFamily,
00112           int ** MEDArrayCellFamily,
00113           int ** MEDArrayFaceFamily,
00114           int ** MEDArrayEdgeFamily
00115           ) ;
00116 
00118   FAMILY(const FAMILY & m);
00119 
00121   FAMILY(const SUPPORT & s);
00122 
00123                         
00124   FAMILY & operator=(const FAMILY &fam);
00125   friend std::ostream & operator<<(std::ostream &os, FAMILY &my) ;
00126 
00127   friend std::ostream & operator<<(std::ostream &os, const FAMILY &my) ;
00128 
00129   bool build(MED_EN::medEntityMesh Entity,int **FamilyNumber);
00130 
00131   // Il faudrait mettre en cohérence les méthodes set
00132   // avec l'opérateur d'affection ! Rmq from EF !!!
00133 
00134   inline void setIdentifier             (int Identifier);        
00135   inline void setNumberOfAttributes     (int NumberOfAttribute);
00136   inline void setAttributesIdentifiers  (int * AttributeIdentifier);
00137   inline void setAttributesValues       (int * AttributeValue);
00138   inline void setAttributesDescriptions (std::string * AttributeDescription); 
00139   inline void setNumberOfGroups         (int NumberOfGroups);
00140   inline void setGroupsNames            (std::string * GroupName, bool giveOwnership=false);
00141 
00142   inline int      getIdentifier()                    const;
00143   inline int      getNumberOfAttributes()            const;
00144   inline const int *    getAttributesIdentifiers()   const;
00145   inline const int *    getAttributesValues()        const;
00146   inline const std::string*  getAttributesDescriptions()  const;
00147   inline int      getNumberOfGroups()                const;
00148   inline const std::string*  getGroupsNames()             const;
00149 
00150   // A FAIRE : VERIFIER LA VALIDITE DES PARAMETRES !
00151   inline int      getAttributeIdentifier(int i)  const;
00152   inline int      getAttributeValue(int i)       const;
00153   inline std::string   getAttributeDescription(int i) const;
00154   inline std::string   getGroupName(int i)            const;
00155 };
00156 
00157 // inline methods :
00159 //----------------------------------------------
00160 inline void FAMILY::setIdentifier(int Identifier)         
00161 //----------------------------------------------
00162 { 
00163     _identifier = Identifier; 
00164 }
00165 
00167 //--------------------------------------------------------------
00168 inline void FAMILY::setNumberOfAttributes(int NumberOfAttribute) 
00169 //--------------------------------------------------------------
00170 { 
00171     _numberOfAttribute = NumberOfAttribute; 
00172 }
00173 
00175 //---------------------------------------------------------------------
00176 inline void FAMILY::setAttributesIdentifiers(int * AttributeIdentifier) 
00177 //---------------------------------------------------------------------
00178 { 
00179     //_attributeIdentifier = AttributeIdentifier ; 
00180     _attributeIdentifier.setShallowAndOwnership(AttributeIdentifier) ;
00181 }
00182 
00184 //-----------------------------------------------------------
00185 inline void FAMILY::setAttributesValues(int * AttributeValue) 
00186 //-----------------------------------------------------------
00187 { 
00188     //_attributeValue = AttributeValue ; 
00189     _attributeValue.setShallowAndOwnership(AttributeValue) ;
00190 }
00191 
00193 //--------------------------------------------------------------------------
00194 inline void FAMILY::setAttributesDescriptions(std::string * AttributeDescription) 
00195 //--------------------------------------------------------------------------
00196 { 
00197   //_attributeDescription = AttributeDescription ; 
00198   //_attributeDescription.setShallowAndOwnership(AttributeDescription) ;
00199   int nbAttr = getNumberOfAttributes();
00200 //   if(nbAttr<1) {
00201 //     std::string diagnosis;
00202 //     diagnosis="Can not set attributes descriptions - number of attributes is not set";
00203 //     throw MEDMEM::MEDEXCEPTION(diagnosis.c_str());
00204 //   }
00205   _attributeDescription.resize(nbAttr);
00206   for(int i=0; i<nbAttr; i++) {
00207     _attributeDescription[i] = AttributeDescription[i];
00208   }
00209 }
00210 
00212 //-------------------------------------------------------
00213 inline void FAMILY::setNumberOfGroups(int NumberOfGroups) 
00214 //-------------------------------------------------------
00215 { 
00216     _numberOfGroup = NumberOfGroups ; 
00217 }
00218 
00220 //----------------------------------------------------
00221   inline void FAMILY::setGroupsNames(std::string * GroupName, bool giveOwnership) 
00222 //----------------------------------------------------
00223 { 
00224   // SKL, CPP TESTS: _groupName is no more PointerOf(string) but vector<string>
00225 //   if (giveOwnership)
00226 //     _groupName.setShallowAndOwnership(GroupName);
00227 //   else  
00228 //     //_groupName = GroupName ; 
00229 //     _groupName.set(_numberOfGroup, GroupName) ;
00230 
00231   int nbGr = getNumberOfGroups();
00232 //   if(nbGr<1) {
00233 //     std::string diagnosis;
00234 //     diagnosis="Can not set groups names - number of groups is not set";
00235 //     throw MEDMEM::MEDEXCEPTION(diagnosis.c_str());
00236 //   }
00237   if (giveOwnership) {
00238     //_groupName.setShallowAndOwnership(GroupName);
00239     _groupName.resize(nbGr);
00240     for(int i=0; i<nbGr; i++) {
00241       _groupName[i] = GroupName[i];
00242     }
00243     delete [] GroupName;
00244   }
00245   else {
00246     //_groupName = GroupName ; 
00247     //_groupName.set(_numberOfGroup, GroupName) ;
00248     _groupName.resize(nbGr);
00249     for(int i=0; i<nbGr; i++) {
00250       _groupName[i] = GroupName[i];
00251     }
00252   }
00253 }
00256 //--------------------------------------
00257 inline int FAMILY::getIdentifier() const
00258 //--------------------------------------
00259 { 
00260     return _identifier ; 
00261 }
00262 
00264 //----------------------------------------------
00265 inline int FAMILY::getNumberOfAttributes() const
00266 //----------------------------------------------
00267 { 
00268     return _numberOfAttribute ; 
00269 }
00272 //---------------------------------------------------
00273 inline const int * FAMILY::getAttributesIdentifiers() const
00274 //---------------------------------------------------
00275 { 
00276     return _attributeIdentifier ; 
00277 }
00280 //----------------------------------------------------
00281 inline int FAMILY::getAttributeIdentifier(int i) const     
00282 //----------------------------------------------------
00283 { 
00284     return _attributeIdentifier[i-1] ; 
00285 }
00288 //----------------------------------------------
00289 inline const int * FAMILY::getAttributesValues() const
00290 //----------------------------------------------
00291 { 
00292     return _attributeValue ; 
00293 }
00296 //-----------------------------------------------
00297 inline int FAMILY::getAttributeValue(int i) const          
00298 //-----------------------------------------------
00299 { 
00300     return _attributeValue[i-1] ; 
00301 }
00302 //-------------------------------------------------------
00303 inline const std::string * FAMILY::getAttributesDescriptions() const
00304 //-------------------------------------------------------
00305 { 
00306     return &(_attributeDescription[0]);
00307 }
00310 //--------------------------------------------------------
00311 inline std::string FAMILY::getAttributeDescription(int i) const 
00312 //--------------------------------------------------------
00313 { 
00314     return _attributeDescription[i-1] ; 
00315 }
00317 //------------------------------------------
00318 inline int FAMILY::getNumberOfGroups() const                   
00319 //------------------------------------------
00320 { 
00321     return _numberOfGroup; 
00322 }
00324 //--------------------------------------------
00325 inline const std::string * FAMILY::getGroupsNames() const
00326 //--------------------------------------------
00327 { 
00328   return &(_groupName[0]);
00329 }
00332 //---------------------------------------------
00333 inline std::string FAMILY::getGroupName(int i) const            
00334 //---------------------------------------------
00335 { 
00336     return _groupName[i-1] ; 
00337 }
00338 
00339 }//End namespace MEDMEM
00340 #endif /* FAMILY_HXX */