src/CONVERTOR/VISU_Convertor.hxx

Go to the documentation of this file.
00001 //  VISU CONVERTOR :
00002 //
00003 //  Copyright (C) 2003  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 //  File   : VISU_Convertor.hxx
00024 //  Author : Alexey PETROV
00025 //  Module : VISU
00026 
00027 #ifndef VISU_Convertor_HeaderFile
00028 #define VISU_Convertor_HeaderFile
00029 
00035 #include "VISU_IDMapper.hxx"
00036 #include "VISU_ConvertorDef.hxx"
00037 
00038 #include "MED_Vector.hxx"
00039 
00040 #include <map>
00041 #include <set>
00042 #include <utility>
00043 #include <string>
00044 #include <stdexcept>
00045 
00046 namespace VISU
00047 {
00048   using MED::TVector;
00049 
00050   //---------------------------------------------------------------
00051   typedef std::string TName;
00052 
00053   typedef TVector<TName> TNames;
00054 
00055   //---------------------------------------------------------------
00057   struct TIntId: virtual TBaseStructure
00058   {
00059     vtkIdType myId;
00060 
00061     TIntId(): myId(0)
00062     {}
00063   };
00064 
00065 
00066   //---------------------------------------------------------------
00067   typedef std::map<TEntity,PMeshOnEntity> TMeshOnEntityMap;
00068   typedef std::map<TName,PGroup> TGroupMap;
00069 
00071 
00075   struct TMesh: virtual TBaseStructure
00076   {
00077     TMeshOnEntityMap myMeshOnEntityMap; 
00078     TGroupMap myGroupMap; 
00079     TName myName; 
00080     int myDim; 
00081 
00082     std::string myGroupsEntry; 
00083     std::string myFieldsEntry; 
00084 
00085     TMesh(): myDim(0)
00086     {}
00087   };
00088   typedef std::map<std::string,PMesh> TMeshMap;
00089 
00090 
00091   //---------------------------------------------------------------
00093   struct TSubProfile: virtual TBaseStructure
00094   {};
00095 
00096 
00097   //---------------------------------------------------------------
00099   struct TProfile: virtual TNamedIDMapper
00100   {};
00101 
00102 
00103   //---------------------------------------------------------------
00104   bool
00105   operator<(const PSubProfile& theLeft, const PSubProfile& theRight);
00106 
00107   typedef std::set<PSubProfile> TProfileKey;
00108   typedef std::map<TProfileKey,PProfile> TProfileMap;
00109 
00110 
00111   //---------------------------------------------------------------
00113   struct TGauss: virtual TBaseStructure
00114   {};
00115 
00116 
00117   //---------------------------------------------------------------
00119   struct TGaussSubMesh: virtual TBaseStructure
00120   {
00121     PSubProfile mySubProfile; 
00122   };
00123 
00124   
00125   //---------------------------------------------------------------
00127   struct TGaussMesh: virtual TGaussPtsIDMapper
00128   {};
00129 
00130 
00131   //---------------------------------------------------------------
00132   bool
00133   operator<(const PGaussSubMesh& theLeft, const PGaussSubMesh& theRight);
00134 
00135   typedef std::set<PGaussSubMesh> TGaussKey;
00136   typedef std::map<TGaussKey,PGaussMesh> TGaussMeshMap;
00137 
00138 
00139   //---------------------------------------------------------------
00140 
00141   typedef std::map<TName,PFamily> TFamilyMap;
00142   typedef std::map<TName,PField> TFieldMap;
00143 
00145 
00149   struct TMeshOnEntity: virtual TNamedIDMapper
00150   {
00151     TGaussMeshMap myGaussMeshMap; 
00152     TProfileMap myProfileMap; 
00153 
00154     TFamilyMap myFamilyMap; 
00155     TFieldMap myFieldMap; 
00156 
00157     TName myMeshName; 
00158     TEntity myEntity; 
00159   };
00160 
00161 
00162   //---------------------------------------------------------------
00164   struct TFamily: virtual TIntId,
00165             virtual TIDMapper
00166   {
00167     TEntity myEntity; 
00168     TName myName; 
00169   };
00170 
00171 
00172   //---------------------------------------------------------------
00173   typedef std::set<PFamily> TFamilySet;
00174 
00176   struct TGroup: virtual TIDMapper
00177   {
00178     TFamilySet myFamilySet;
00179   };
00180 
00181 
00182   //---------------------------------------------------------------
00183   typedef std::map<vtkIdType,PValForTime> TValField;
00184   typedef std::pair<vtkFloatingPointType,vtkFloatingPointType> TMinMax;
00185 
00187   struct TField: virtual TIntId
00188   {
00189     TEntity myEntity; 
00190     TName myName; 
00191     TName myMeshName; 
00192     TValField myValField; 
00193     TNames myCompNames; 
00194     TNames myUnitNames; 
00195     vtkIdType myNbComp; 
00196 
00198 
00202     virtual
00203     TMinMax 
00204     GetMinMax(vtkIdType theCompID) = 0;
00205     
00206     bool myIsMinMaxInitilized; 
00207 
00208     TField(): 
00209       myNbComp(0),
00210       myIsMinMaxInitilized(false)
00211     {}
00212   };
00213  
00214 
00215   //---------------------------------------------------------------
00216   typedef std::pair<double,std::string> TTime;
00217 
00219   struct TValForTime: virtual TIntId
00220   {
00221     TEntity myEntity; 
00222     TName myMeshName; 
00223     TName myFieldName; 
00224     TTime myTime;
00225 
00226     PProfile myProfile; 
00227     PGaussMesh myGaussMesh;
00228   };
00229 
00230 
00231   //---------------------------------------------------------------
00233   void 
00234   WriteToFile(vtkUnstructuredGrid* theDataSet, 
00235            const std::string& theFileName);
00236 };
00237 
00238 
00239 //---------------------------------------------------------------
00241 
00254 class VISU_Convertor
00255 {
00256 protected:
00257   std::string myName;
00258   VISU::TMeshMap myMeshMap;
00259   int myIsDone;
00260 
00261 public:
00262   virtual 
00263   ~VISU_Convertor()
00264   {};
00265   
00267   virtual
00268   const std::string& 
00269   GetName(){ return myName;}
00270 
00272   virtual
00273   int
00274   IsDone() const { return myIsDone; }
00275 
00277   typedef VISU::TVTKOutput TOutput;
00278 
00280   virtual
00281   VISU_Convertor* 
00282   Build() = 0;
00283 
00285   virtual
00286   VISU_Convertor* 
00287   BuildEntities() = 0;
00288 
00290   virtual
00291   VISU_Convertor* 
00292   BuildFields() = 0;
00293 
00295   virtual
00296   VISU_Convertor* 
00297   BuildMinMax() = 0;
00298 
00300   virtual
00301   VISU_Convertor* 
00302   BuildGroups() = 0;
00303 
00305   virtual
00306   const VISU::TMeshMap& 
00307   GetMeshMap();
00308 
00310   virtual
00311   vtkFloatingPointType
00312   GetSize() = 0;
00313 
00315   virtual
00316   VISU::PNamedIDMapper 
00317   GetMeshOnEntity(const std::string& theMeshName, 
00318             const VISU::TEntity& theEntity) = 0;
00319   
00321   virtual
00322   vtkFloatingPointType
00323   GetMeshOnEntitySize(const std::string& theMeshName, 
00324                 const VISU::TEntity& theEntity) = 0;
00325   
00327   virtual 
00328   VISU::PIDMapper 
00329   GetFamilyOnEntity(const std::string& theMeshName, 
00330               const VISU::TEntity& theEntity,
00331               const std::string& theFamilyName) = 0;
00332 
00334   virtual 
00335   vtkFloatingPointType 
00336   GetFamilyOnEntitySize(const std::string& theMeshName, 
00337                const VISU::TEntity& theEntity,
00338                const std::string& theFamilyName) = 0;
00339 
00341   virtual
00342   VISU::PIDMapper
00343   GetMeshOnGroup(const std::string& theMeshName, 
00344            const std::string& theGroupName) = 0;
00345   
00347   virtual
00348   vtkFloatingPointType
00349   GetMeshOnGroupSize(const std::string& theMeshName, 
00350                const std::string& theGroupName) = 0;
00351   
00353   virtual
00354   VISU::PIDMapper 
00355   GetTimeStampOnMesh(const std::string& theMeshName, 
00356                const VISU::TEntity& theEntity,
00357                const std::string& theFieldName,
00358                int theStampsNum) = 0;
00359 
00361   virtual
00362   VISU::PGaussPtsIDMapper 
00363   GetTimeStampOnGaussPts(const std::string& theMeshName, 
00364                 const VISU::TEntity& theEntity,
00365                 const std::string& theFieldName,
00366                 int theStampsNum) = 0;
00367    
00369   virtual 
00370   vtkFloatingPointType
00371   GetTimeStampSize(const std::string& theMeshName, 
00372              const VISU::TEntity& theEntity,
00373              const std::string& theFieldName,
00374              int theStampsNum) = 0;
00375     
00377   virtual 
00378   vtkFloatingPointType
00379   GetFieldOnMeshSize(const std::string& theMeshName, 
00380                const VISU::TEntity& theEntity,
00381                const std::string& theFieldName) = 0;
00382   
00384   virtual
00385   const VISU::PField 
00386   GetField(const std::string& theMeshName, 
00387         VISU::TEntity theEntity, 
00388         const std::string& theFieldName) = 0;
00389   
00391   virtual
00392   const VISU::PValForTime 
00393   GetTimeStamp(const std::string& theMeshName, 
00394             const VISU::TEntity& theEntity,
00395             const std::string& theFieldName,
00396             int theStampsNum) = 0;
00397     
00399   static 
00400   std::string 
00401   GenerateName(const VISU::TTime& aTime);
00402 
00403   static 
00404   std::string 
00405   GenerateName(const std::string& theName, unsigned int theTimeId);
00406 };
00407 
00408 extern "C"
00409 {
00411   VISU_Convertor* 
00412   CreateConvertor(const std::string& theFileName);
00413 };
00414 
00415 
00416 #endif