Back to index

salome-med  6.5.0
MEDMEM_CellModel.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 /*
00024  File MEDMEM_CellModel.hxx
00025 */
00026 
00027 #ifndef CELLMODEL_HXX
00028 #define CELLMODEL_HXX
00029 
00030 #include <MEDMEM.hxx>
00031 
00032 #include <set>
00033 #include <map>
00034 #include <string>
00035 
00036 #include "MEDMEM_Utilities.hxx"
00037 #include "MEDMEM_define.hxx"
00038 
00039 using namespace std ;
00040 
00050 namespace MEDMEM {
00051   class CELLMODEL;
00052   MEDMEM_EXPORT ostream & operator<<(ostream &os,const CELLMODEL &my);
00053 
00054 class MEDMEM_EXPORT CELLMODEL 
00055 {
00056 
00057 private:
00060   void init(const CELLMODEL &m);
00061 
00063   void clean();
00064 
00065 
00066   //protected:
00068   string             _name;
00070   MED_EN::medGeometryElement _type;
00072   int                _dimension;
00074   int                _numberOfNodes;
00076   int                _numberOfVertexes;
00078   int                _numberOfConstituentsDimension;
00080   int*               _numberOfConstituents ;
00083   int**              _numberOfNodeOfEachConstituent ;
00092   int***                _constituents ;
00093   MED_EN::medGeometryElement**  _constituentsType ;
00094 
00095 public :
00096 
00098   inline CELLMODEL();
00100   CELLMODEL(MED_EN::medGeometryElement t);
00102   inline CELLMODEL(const CELLMODEL &m);
00104   inline ~CELLMODEL();
00105 
00107   inline CELLMODEL & operator=(const CELLMODEL &m);
00108 
00110   friend MEDMEM_EXPORT ostream & operator<<(ostream &os,const CELLMODEL &my);
00111 
00114   inline string                 getName()             const;
00115 
00117   inline int                    getNumberOfVertexes() const;
00118 
00120   inline int                    getNumberOfNodes()    const;
00121 
00124   inline int                    getDimension()        const;
00125 
00128   inline MED_EN::medGeometryElement     getType()             const;
00129 
00131   int** getConstituents(int dim) const;
00132 
00134   int   getNumberOfConstituents(int dim) const;
00135 
00138   int* getNodesConstituent(int dim,int num) const;
00139 
00142   int getNodeConstituent(int dim,int num,int nodes_index) const;
00143 
00146   MED_EN::medGeometryElement*  getConstituentsType(int dim) const;
00147 
00150   MED_EN::medGeometryElement getConstituentType(int dim,int num) const;
00151 
00154   int getNumberOfConstituentsType() const;
00155 
00158   set<MED_EN::medGeometryElement>  getAllConstituentsType() const;
00159 
00162   map<MED_EN::medGeometryElement,int>  getNumberOfConstituentsForeachType() const;
00163 
00164 
00165 };
00166 
00167 // ------------------------------------------
00168 //      Methodes Inline
00169 // ------------------------------------------
00170 
00171 inline CELLMODEL::CELLMODEL():
00172     _type(MED_EN::MED_NONE),
00173     _dimension(0),
00174     _numberOfNodes(0),
00175     _numberOfVertexes(0),
00176     _numberOfConstituentsDimension(0),
00177     _numberOfConstituents((int*)NULL),
00178     _numberOfNodeOfEachConstituent((int**)NULL),
00179     _constituents((int***)NULL),
00180     _constituentsType((MED_EN::medGeometryElement**)NULL)
00181 {
00182 }
00183 inline CELLMODEL::CELLMODEL(const CELLMODEL &m):
00184     _type(MED_EN::MED_NONE),
00185     _dimension(0),
00186     _numberOfNodes(0),
00187     _numberOfVertexes(0),
00188     _numberOfConstituentsDimension(0),
00189     _numberOfConstituents((int*)NULL),
00190     _numberOfNodeOfEachConstituent((int**)NULL),
00191     _constituents((int***)NULL),
00192     _constituentsType((MED_EN::medGeometryElement**)NULL)
00193 {
00194     init(m) ;
00195 }
00196 inline CELLMODEL::~CELLMODEL() 
00197 {
00198   //  MESSAGE_MED("CELLMODEL::~CELLMODEL() destroying the cell");
00199   clean() ;
00200 }
00201 inline CELLMODEL & CELLMODEL::operator=(const CELLMODEL &m) 
00202 {
00203     clean() ;
00204     init(m) ;
00205     return *this ;
00206 }
00207 inline string CELLMODEL::getName() const
00208 {
00209   return _name ;
00210 }
00211 inline int CELLMODEL::getNumberOfVertexes() const
00212 {
00213   return _numberOfVertexes;
00214 }
00215 inline int CELLMODEL::getNumberOfNodes() const
00216 {
00217   return _numberOfNodes;
00218 }
00219 inline int CELLMODEL::getDimension() const
00220 {
00221   return _dimension;
00222 }
00223 inline MED_EN::medGeometryElement CELLMODEL::getType() const
00224 {
00225   return _type;
00226 }
00227 inline int** CELLMODEL::getConstituents(int dim) const
00228 {
00229   return _constituents[dim-1] ;
00230 }
00231 inline int CELLMODEL::getNumberOfConstituents(int dim) const
00232 {
00233   return _numberOfConstituents[dim-1] ;
00234 }
00235 inline int* CELLMODEL::getNodesConstituent(int dim,int num) const
00236 {
00237   return _constituents[dim-1][num-1];
00238 }
00239 inline int CELLMODEL::getNodeConstituent(int dim,int num,int nodesNumber) const
00240 {
00241   return _constituents[dim-1][num-1][nodesNumber-1] ;
00242 }
00243 inline MED_EN::medGeometryElement* CELLMODEL::getConstituentsType(int dim) const
00244 {
00245   return _constituentsType[dim-1];
00246 }
00247 inline MED_EN::medGeometryElement CELLMODEL::getConstituentType(int dim,int num) const
00248 {
00249   return _constituentsType[dim-1][num-1];
00250 }
00251 
00255 class MEDMEM_EXPORT CELLMODEL_Map
00256 {
00257 public:
00258   static const MEDMEM::CELLMODEL& retrieveCellModel(MED_EN::medGeometryElement type);
00259 private:
00260   static CELLMODEL_Map *getInstance();
00261   static CELLMODEL_Map *_singleton;
00262   std::map<MED_EN::medGeometryElement,MEDMEM::CELLMODEL> _cell_models;
00263 
00264   CELLMODEL_Map() {}
00265   ~CELLMODEL_Map(){ if(_singleton) delete _singleton;}
00266 
00267   const MEDMEM::CELLMODEL& getCellModel(MED_EN::medGeometryElement type);
00268 
00269 };
00270 
00271 }//End of namespace MEDMEM
00272 
00273 #endif /* CELLMODEL_HXX */