src/CONVERTOR/VISU_MedConvertor.hxx

Go to the documentation of this file.
00001 //  License as published by the Free Software Foundation; either 
00002 //  version 2.1 of the License. 
00003 // 
00004 //  This library is distributed in the hope that it will be useful, 
00005 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
00006 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
00007 //  Lesser General Public License for more details. 
00008 // 
00009 //  You should have received a copy of the GNU Lesser General Public 
00010 //  License along with this library; if not, write to the Free Software 
00011 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
00012 // 
00013 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00014 //
00015 //  File   : VISU_MedConvertor.hxx
00016 //  Author : Alexey PETROV
00017 //  Module : VISU
00018 
00019 #ifndef VISU_MedConvertor_HeaderFile
00020 #define VISU_MedConvertor_HeaderFile
00021 
00022 #include "VISU_Convertor_impl.hxx"
00023 
00024 #include "MED_Wrapper.hxx"
00025 #include "MED_Common.hxx"
00026 #include "MED_Structures.hxx"
00027 
00028 #include <boost/thread/mutex.hpp>
00029 #include <qfileinfo.h>
00030 
00031 namespace VISU
00032 {
00033   typedef TVector<TName> TNames;
00034 
00035   //---------------------------------------------------------------
00036   class TMEDNamedPointCoords: public virtual TNamedPointCoords
00037   {
00038     MED::PNodeInfo myNodeInfo;
00039     TNames myPointNames;
00040   public:
00041     void
00042     Init(vtkIdType theNbPoints,
00043       vtkIdType theDim,
00044       const MED::PNodeInfo& theNodeInfo);
00045 
00046     void
00047     Init(vtkIdType theNbPoints,
00048       vtkIdType theDim,
00049       const MED::PGrilleInfo& theGrilleInfo);
00050 
00051     virtual
00052     std::string 
00053     GetNodeName(vtkIdType theObjID) const;
00054   };
00055   typedef SharedPtr<TMEDNamedPointCoords> PMEDNamedPointCoords;
00056 
00057 
00058   //---------------------------------------------------------------
00059   struct TMEDMesh: virtual TMeshImpl
00060   {
00061     MED::PMeshInfo myMeshInfo;
00062     MED::TEntityInfo myEntityInfo;
00063   };
00064   typedef SharedPtr<TMEDMesh> PMEDMesh;
00065 
00066 
00067   //---------------------------------------------------------------
00068   struct TMEDSubProfile: virtual TSubProfileImpl
00069   {
00070     MED::EGeometrieElement myMGeom;
00071 
00072     TMEDSubProfile():
00073       myIsElemNum(MED::eFAUX)
00074     {}
00075 
00076     MED::EBooleen myIsElemNum;
00077     MED::TElemNum myElemNum;
00078 
00079     virtual 
00080     vtkIdType 
00081     GetElemObjID(vtkIdType theID) const;
00082   };
00083   typedef SharedPtr<TMEDSubProfile> PMEDSubProfile;
00084 
00085 
00086   //---------------------------------------------------------------
00087   struct TMEDProfile: virtual TProfileImpl
00088   {};
00089   typedef SharedPtr<TMEDProfile> PMEDProfile;
00090 
00091 
00092   //---------------------------------------------------------------
00093   struct TMEDGauss: virtual TGaussImpl
00094   {
00095     MED::PGaussInfo myGaussInfo;
00096 
00098     virtual
00099     void
00100     LessThan(const PGaussImpl& theGauss,
00101           bool& theResult) const;
00102   };
00103   typedef SharedPtr<TMEDGauss> PMEDGauss;
00104 
00105 
00106   //---------------------------------------------------------------
00107   struct TMEDGaussSubMesh: virtual TGaussSubMeshImpl
00108   {
00109     TMEDGaussSubMesh():
00110       myIsElemNum(MED::eFAUX)
00111     {}
00112 
00113     MED::EBooleen myIsElemNum;
00114     MED::TElemNum myElemNum;
00115 
00116     virtual
00117     TGaussPointID
00118     GetObjID(vtkIdType theID,
00119           vtkIdType theStartID) const;
00120   };
00121   typedef SharedPtr<TMEDGaussSubMesh> PMEDGaussSubMesh;
00122 
00123 
00124   //---------------------------------------------------------------
00125   struct TMEDGaussMesh: virtual TGaussMeshImpl
00126   {};
00127   typedef SharedPtr<TMEDGaussMesh> PMEDGaussMesh;
00128 
00129 
00130   //---------------------------------------------------------------
00131   struct TMEDSubMesh: virtual TSubMeshImpl
00132   {
00133     TMEDSubMesh():
00134       myIsElemNum(MED::eFAUX)
00135     {}
00136 
00137     MED::EBooleen myIsElemNum;
00138     MED::TElemNum myElemNum;
00139     MED::PElemInfo myElemInfo;
00140 
00141     void
00142     Init(const MED::PElemInfo& theElemInfo);
00143 
00144     void
00145     Init(const MED::PGrilleInfo& theGrilleInfo);
00146 
00147     virtual 
00148     vtkIdType 
00149     GetElemObjID(vtkIdType theID) const;
00150 
00151     virtual
00152     std::string 
00153     GetElemName(vtkIdType theObjID) const;
00154   };
00155   typedef SharedPtr<TMEDSubMesh> PMEDSubMesh;
00156 
00157 
00158   //---------------------------------------------------------------
00159   typedef std::map<vtkIdType,vtkIdType> TFamilyID2CellsSize;
00160 
00161   struct TMEDMeshOnEntity: virtual TMeshOnEntityImpl
00162   {
00163     TFamilyID2CellsSize myFamilyID2CellsSize;
00164     MED::TGeom2Size myGeom2Size;
00165   };
00166   typedef SharedPtr<TMEDMeshOnEntity> PMEDMeshOnEntity;
00167 
00168 
00169   //---------------------------------------------------------------
00170   struct TMEDFamily: virtual TFamilyImpl
00171   {};
00172   typedef SharedPtr<TMEDFamily> PMEDFamily;
00173   
00174 
00175   //---------------------------------------------------------------
00176   struct TMEDGroup: virtual TGroupImpl
00177   {};
00178   typedef SharedPtr<TMEDGroup> PMEDGroup;
00179 
00180 
00181   //---------------------------------------------------------------
00182   struct TMEDField: virtual TFieldImpl
00183   {};
00184   typedef SharedPtr<TMEDField> PMEDField;
00185 
00186 
00187   //---------------------------------------------------------------
00188   struct TMEDValForTime: virtual TValForTimeImpl
00189   {};
00190   typedef SharedPtr<TMEDValForTime> PMEDValForTime;
00191 
00192 }
00193 
00194 class VISU_MedConvertor: public VISU_Convertor_impl
00195 {  
00196   VISU_MedConvertor();
00197   VISU_MedConvertor(const VISU_MedConvertor&);
00198   
00199   bool myIsEntitiesDone;
00200   bool myIsFieldsDone;
00201   bool myIsGroupsDone;
00202   bool myIsMinMaxDone;
00203 
00204 public:
00205   VISU_MedConvertor(const std::string& theFileName, MED::PWrapper theMed);
00206 
00207   virtual
00208   VISU_Convertor* 
00209   BuildEntities();
00210 
00211   virtual
00212   VISU_Convertor* 
00213   BuildFields();
00214 
00215   virtual
00216   VISU_Convertor* 
00217   BuildMinMax();
00218 
00219   virtual
00220   VISU_Convertor* 
00221   BuildGroups();
00222 
00223 protected:
00224   QFileInfo myFileInfo;
00225   MED::PWrapper myMed; // mpv : bug 13568: one med per converter
00226 
00227   virtual
00228   int
00229   LoadMeshOnEntity(VISU::PMeshImpl theMesh,
00230              VISU::PMeshOnEntityImpl theMeshOnEntity);
00231   
00232   virtual
00233   int
00234   LoadFamilyOnEntity(VISU::PMeshImpl theMesh,
00235                VISU::PMeshOnEntityImpl theMeshOnEntity, 
00236                VISU::PFamilyImpl theFamily);
00237 
00238   virtual
00239   int
00240   LoadMeshOnGroup(VISU::PMeshImpl theMesh, 
00241             const VISU::TFamilySet& theFamilySet);
00242   
00243   virtual
00244   int
00245   LoadValForTimeOnMesh(VISU::PMeshImpl theMesh, 
00246                  VISU::PMeshOnEntityImpl theMeshOnEntity, 
00247                  VISU::PFieldImpl theField, 
00248                  VISU::PValForTimeImpl theValForTime);
00249   
00250   virtual 
00251   int
00252   LoadValForTimeOnGaussPts(VISU::PMeshImpl theMesh, 
00253                   VISU::PMeshOnEntityImpl theMeshOnEntity, 
00254                   VISU::PFieldImpl theField, 
00255                   VISU::PValForTimeImpl theValForTime);
00256 
00257   int
00258   LoadPoints(const MED::PWrapper& theMed,
00259           const VISU::PMEDMesh theMesh);
00260   
00261   int
00262   LoadPointsOnFamily(const MED::PWrapper& theMed,
00263                const VISU::PMEDMesh theMesh, 
00264                const VISU::PMEDFamily theFamily);
00265   
00266   int
00267   LoadCellsOnEntity(const MED::PWrapper& theMed,
00268               const VISU::PMEDMesh theMesh,
00269               const VISU::PMEDMeshOnEntity theMeshOnEntity);
00270   
00271   int
00272   LoadCellsOnFamily(const MED::PWrapper& theMed,
00273               const VISU::PMEDMesh theMesh,
00274               const VISU::PMEDMeshOnEntity theMeshOnEntity,
00275               const VISU::PMEDFamily theFamily);
00276   
00277   int
00278   LoadValForTimeOnMesh(const MED::PWrapper& theMed,
00279                  VISU::PMEDMesh theMesh,
00280                  VISU::PMEDMeshOnEntity theMeshOnEntity,
00281                  VISU::PMEDField theField, 
00282                  VISU::PMEDValForTime theValForTime);
00283   
00284   int
00285   LoadValForTimeOnGaussPts(const MED::PWrapper& theMed,
00286                   VISU::PMEDMesh theMesh,
00287                   VISU::PMEDMeshOnEntity theMeshOnEntity,
00288                   VISU::PMEDField theField, 
00289                   VISU::PMEDValForTime theValForTime);
00290 };
00291 
00292 #endif