Back to index

salome-smesh  6.5.0
SMESH_PreMeshInfo.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 // File      : SMESH_PreMeshInfo.hxx
00023 // Created   : Fri Feb 10 13:25:02 2012
00024 // Author    : Edward AGAPOV (eap)
00025 
00026 
00027 #ifndef __SMESH_PreMeshInfo_HXX__
00028 #define __SMESH_PreMeshInfo_HXX__
00029 
00030 #include "SMDS_MeshInfo.hxx"
00031 #include <SALOMEconfig.h>
00032 #include CORBA_SERVER_HEADER(SMESH_Mesh)
00033 #include CORBA_SERVER_HEADER(SALOMEDS)
00034 
00035 #include <TopAbs_ShapeEnum.hxx>
00036 
00037 class DriverMED_R_SMESHDS_Mesh;
00038 class HDFfile;
00039 class HDFgroup;
00040 class SMESH_Mesh_i;
00041 
00052 class SMESH_PreMeshInfo : public SMDS_MeshInfo
00053 {
00054 public:
00055   // fills SMESH_PreMeshInfo field of all objects of mesh
00056   static void LoadFromFile( SMESH_Mesh_i*      mesh,
00057                             const int          meshID,
00058                             const std::string& medFile,
00059                             const std::string& hdfFile,
00060                             const bool         toRemoveFiles);
00061 
00062   // saves SMESH_PreMeshInfo to the study file
00063   static void SaveToFile( SMESH_Mesh_i* mesh,
00064                           const int     meshID,
00065                           HDFfile*      hdfFile);
00066 
00067   // reads all data and remove all SMESH_PreMeshInfo fields from objects
00068   void FullLoadFromFile() const;
00069 
00070   // remove all SMESH_PreMeshInfo fields from objects w/o data loading
00071   void ForgetAllData() const;
00072 
00073   // calls either FullLoadFromFile() or ForgetAllData() depending on preferences;
00074   // is called on hypothesis modification
00075   void ForgetOrLoad() const;
00076 
00077   // meshods of SMESH_IDSource interface
00078   SMESH::array_of_ElementType* GetTypes() const;
00079   SMESH::long_array*           GetMeshInfo() const;
00080   bool                         IsMeshInfoCorrect() const;
00081 
00082   ~SMESH_PreMeshInfo();
00083 
00084   // TEMPORARY method to remove study files on closing study;
00085   // RIGHT WAY: study files are remove automatically when meshes are destroyed
00086   static void RemoveStudyFiles_TMP_METHOD(SALOMEDS::SComponent_ptr smeshComp);
00087 
00088 private:
00089 
00090   // creation by LoadFromFile() only
00091   SMESH_PreMeshInfo(SMESH_Mesh_i*      mesh,
00092                     const int          meshID,
00093                     const std::string& medFile,
00094                     const std::string& hdfFile);
00095 
00096   SMESH_PreMeshInfo* newInstance()
00097   { return new SMESH_PreMeshInfo( _mesh,_meshID,_medFileName,_hdfFileName ); }
00098 
00099   // reading from the new study, for which SaveToFile() was called
00100   bool readPreInfoFromHDF();
00101   void hdf2meshInfo( const std::string& dataSetName, HDFgroup* infoHdfGroup );
00102 
00103   // reading from the old study, for which SaveToFile() was not called
00104   bool readMeshInfo();
00105   void readGroupInfo();
00106   void readSubMeshInfo();
00107   SMDSAbs_EntityType getElemType( const TopAbs_ShapeEnum shapeType,
00108                                   const int              nbElemsInSubMesh,
00109                                   bool&                  isKoType) const;
00110 
00111   void readSubMeshes(DriverMED_R_SMESHDS_Mesh* reader) const;
00112 
00113   // general data
00114   std::string   _medFileName, _hdfFileName;
00115   bool          _toRemoveFiles;
00116   int           _meshID;
00117   SMESH_Mesh_i* _mesh;
00118   bool          _isInfoOk;
00119 
00120   int _elemCounter; /* used as a counter while mesh info reading and
00121                        as a signal that mesh info is incorrect after reading
00122                      */
00123 };
00124 
00125 #endif