Back to index

salome-paravis  6.5.0
vtkMedReader.h
Go to the documentation of this file.
00001 // Copyright (C) 2010-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #ifndef __vtkMedReader_h_
00021 #define __vtkMedReader_h_
00022 
00023 #include "vtkMultiBlockDataSetAlgorithm.h"
00024 #include "vtkMedSetGet.h"
00025 #include <map>
00026 
00027 class vtkMedFile;
00028 class vtkMedDriver;
00029 class vtkMedSelection;
00030 class vtkMedFieldOverEntity;
00031 class vtkMedFieldStep;
00032 class vtkMedField;
00033 class vtkMedMesh;
00034 class vtkMedFamily;
00035 class vtkMedLocalization;
00036 class vtkMedEntityArray;
00037 class vtkMedFamilyOnEntity;
00038 class vtkMedFamilyOnEntityOnProfile;
00039 class vtkMedProfile;
00040 class vtkMedComputeStep;
00041 class vtkMedGrid;
00042 class vtkMedFieldOnProfile;
00043 class vtkMedListOfFieldSteps;
00044 class vtkMedEntity;
00045 
00046 class vtkUnstructuredGrid;
00047 class vtkUnsignedCharArray;
00048 class vtkIdList;
00049 class vtkDoubleArray;
00050 class vtkFieldData;
00051 class vtkInformationDataObjectKey;
00052 class vtkMutableDirectedGraph;
00053 class vtkDataSet;
00054 
00055 class VTK_EXPORT vtkMedReader: public vtkMultiBlockDataSetAlgorithm
00056 {
00057 public:
00058   static vtkMedReader* New();
00059   vtkTypeRevisionMacro(vtkMedReader, vtkMultiBlockDataSetAlgorithm);
00060   void PrintSelf(ostream& os, vtkIndent indent);
00061 
00062   // Description:
00063   // Set the file name to read from
00064   virtual void SetFileName(const char*);
00065   vtkGetStringMacro(FileName)
00066 
00067   // Description:
00068   // Is the given file a MED file?
00069   virtual int CanReadFile(const char* fname);
00070 
00071   // Description:
00072   // Get the file extensions for this format.
00073   // Returns a string with a space separated list of extensions in
00074   // the format .extension
00075   virtual const char*
00076   GetFileExtensions()
00077   {
00078     return ".med .rmed";
00079   }
00080 
00081   // Description:
00082   // Return a descriptive name for the file format that might be
00083   // useful in a GUI.
00084   virtual const char*
00085   GetDescriptiveName()
00086   {
00087     return "MED file (Modele d'Echange de Donnees)";
00088   }
00089 
00090   // Description:
00091   // use these methods to enable/disable point arrays
00092   virtual int GetPointFieldArrayStatus(const char* name);
00093   virtual void SetPointFieldArrayStatus(const char* name, int status);
00094   virtual int GetNumberOfPointFieldArrays();
00095   virtual const char* GetPointFieldArrayName(int);
00096 
00097   // Description:
00098   // use these methods to enable/disable cell arrays
00099   virtual int GetCellFieldArrayStatus(const char* name);
00100   virtual void SetCellFieldArrayStatus(const char* name, int status);
00101   virtual int GetNumberOfCellFieldArrays();
00102   virtual const char* GetCellFieldArrayName(int);
00103 
00104   // Description:
00105   // use these methods to enable/disable quadrature arrays
00106   virtual int GetQuadratureFieldArrayStatus(const char* name);
00107   virtual void SetQuadratureFieldArrayStatus(const char* name, int status);
00108   virtual int GetNumberOfQuadratureFieldArrays();
00109   virtual const char* GetQuadratureFieldArrayName(int);
00110 
00111   // Description:
00112   // use these methods to enable/disable quadrature arrays
00113   virtual int GetElnoFieldArrayStatus(const char* name);
00114   virtual void SetElnoFieldArrayStatus(const char* name, int status);
00115   virtual int GetNumberOfElnoFieldArrays();
00116   virtual const char* GetElnoFieldArrayName(int);
00117 
00118   // Description:
00119   // use this method to enable/disable cell types
00120   // the key is encoded with the vtkMedUtilities::EntityKey method
00121   // which returns a string
00122   // CELL_TYPE/MED_ENTITE_MAILLAGE/MED_GEOMETRIE_ELEMENT
00123   virtual void SetEntityStatus(const char* key, int flag);
00124   virtual int GetEntityStatus(const vtkMedEntity&);
00125 
00126   // Description:
00127   // use this method to enable/disable a family support
00128   // the key is formatted by the vtkMedUtilities::FamilyKey method which
00129   // returns a string
00130   // GROUP/MESH_NAME/OnPoint/FAMILY_NAME or MESH_NAME/OnCell/FAMILY_NAME
00131   virtual void SetGroupStatus(const char* key, int flag);
00132   virtual int GetGroupStatus(const char* key);
00133 
00134   // Description:
00135   // the animation mode modify the way the reader answers time requests from
00136   // the pipeline.
00137   // Default (0) : this is PhysicalTime if there are times, or Iterations
00138   // if there are only iterations
00139   // PhysicalTime (1) : the reader aggregates all physical times available
00140   // in the file.
00141   // for a given time t, the reader will return for each field the
00142   // ComputeStep with the highest time inferior
00143   // to t, and with the highest iteration.
00144   // Iteration (2) : you need to also set the TimeIndexForIterations field.
00145   // In this case, the reader will understand
00146   // time requests has a request to iterate over iterations for the given time.
00147   // Modes (3) : the reader will output the selected fields at all selected
00148   // frequencies, and will output a fake TimeRange of -PI/+PI.
00149   // Use the *FrequencyArray* interface to select them.
00150   //BTX
00151   enum eAnimationMode
00152   {
00153     Default=0, PhysicalTime=1, Iteration=2, Modes=3
00154   };
00155   //ETX
00156   vtkSetMacro(AnimationMode, int);
00157   vtkGetMacro(AnimationMode, int);
00158 
00159   // Description:
00160   // in med files, the ComputeSteps are defined by a
00161   // pair <iteration, physicalTime>.
00162   // the TimeIndexForIterations ivar is used only if the TimeMode is
00163   // Iteration.
00164   // it fixes the PhysicalTime index when iterating over iterations : only
00165   // iterations with the corresponding physical time will be iterated over.
00166   // The index given here is an index into the AvailableTimes array
00167   // that is returned be the GetAvailableTimes Method.
00168   vtkSetMacro(TimeIndexForIterations, double);
00169   vtkGetMacro(TimeIndexForIterations, double);
00170 
00171   // Description:
00172   // use these methods to enable/disable a given frequency for modal analysis
00173   virtual int GetFrequencyArrayStatus(const char* name);
00174   virtual void SetFrequencyArrayStatus(const char* name, int status);
00175   virtual int GetNumberOfFrequencyArrays();
00176   virtual const char* GetFrequencyArrayName(int);
00177 
00178   // Description:
00179   // returns the available physical times. Use this to get the times when in
00180   // iteration mode.
00181   virtual vtkDoubleArray* GetAvailableTimes();
00182 
00183   // Description:
00184   // Build the graph used to pass information to the client on the supports
00185   virtual void BuildSIL(vtkMutableDirectedGraph*);
00186 
00187   // Description:
00188   // Every time the SIL is updated a this will return a different value.
00189   virtual int GetSILUpdateStamp();
00190 
00191   // Description:
00192   // reset the selection arrays without having to rebuild the SIL.
00193   virtual void ClearSelections();
00194 
00195   // Description:
00196   // The CacheStrategy indicates to the reader if it
00197   // should cache some of the arrays.
00198   //BTX
00199   enum eCacheStrategy
00200   {
00201     CacheNothing, CacheGeometry, CacheGeometryAndFields
00202   };
00203   //ETX
00204   vtkSetMacro(CacheStrategy, int)
00205   vtkGetMacro(CacheStrategy, int)
00206 
00207   // Description :
00208   // release arrays read from MED (point coordinates, profile ids, family ids)
00209   void ClearMedSupports();
00210 
00211   // Description :
00212   // release arrays read from MED (fields)
00213   void ClearMedFields();
00214 
00215   // Description:
00216   // If this flag is set, the reader will output a vector field for each
00217   // field in the file that has 2 or more components by extracting the
00218   // first 3 compoenents
00219   vtkSetMacro(GenerateVectors, int);
00220   vtkGetMacro(GenerateVectors, int);
00221 
00222 protected:
00223   vtkMedReader();
00224   virtual ~vtkMedReader();
00225 
00226   // Description:
00227   // This is called by the superclass.
00228   virtual int RequestDataObject(vtkInformation*, vtkInformationVector**,
00229       vtkInformationVector*);
00230 
00231   // Description:
00232   // This is called by the superclass.
00233   virtual int RequestInformation(vtkInformation*, vtkInformationVector**,
00234       vtkInformationVector*);
00235 
00236   // Description:
00237   // This is called by the superclass.
00238   virtual int RequestData(vtkInformation*, vtkInformationVector**,
00239       vtkInformationVector*);
00240 
00241   // Description:
00242   // Gather all compute steps in the fields
00243   virtual void GatherComputeSteps();
00244 
00245   // Description:
00246   // Give the animation steps to the pipeline
00247   virtual void AdvertiseTime(vtkInformation*);
00248 
00249   // Description:
00250   // returns 1 if at least one the families of this mesh is selected,
00251   // 0 otherwise.
00252   virtual int IsMeshSelected(vtkMedMesh*);
00253 
00254   // Description:
00255   // returns if the field is selected.
00256   virtual int IsFieldSelected(vtkMedField*);
00257   virtual int IsPointFieldSelected(vtkMedField*);
00258   virtual int IsCellFieldSelected(vtkMedField*);
00259   virtual int IsQuadratureFieldSelected(vtkMedField*);
00260   virtual int IsElnoFieldSelected(vtkMedField*);
00261 
00262   virtual void AddQuadratureSchemeDefinition(vtkInformation*,
00263       vtkMedLocalization*);
00264 
00265   //BTX
00266   enum
00267   {
00268     Initialize,
00269     StartRequest,
00270     AfterCreateMedSupports,
00271     EndBuildVTKSupports,
00272     EndRequest
00273   };
00274   //ETX
00275   virtual void ClearCaches(int when);
00276 
00277   virtual void CreateMedSupports();
00278 
00279   virtual bool BuildVTKSupport(vtkMedFamilyOnEntityOnProfile*,
00280                                int doBuildSupport);
00281 
00282   virtual void MapFieldsOnSupport(vtkMedFamilyOnEntityOnProfile* foe,
00283                                   int doMapField);
00284 
00285   virtual void CreateVTKFieldOnSupport(vtkMedFieldOnProfile*,
00286                                        vtkMedFamilyOnEntityOnProfile*,
00287                                        int doCreateField);
00288 
00289   virtual void MapFieldOnSupport(vtkMedFieldOnProfile*,
00290                                  vtkMedFamilyOnEntityOnProfile*,
00291                                  int doCreateField);
00292 
00293   // Description:
00294   // Necessary call for the initialization of the filters used for the MED
00295   // library in their parallel reads
00296   virtual void InitializeParallelRead();
00297 
00298   // Description:
00299   // This method is called after all info from all med files are read.
00300   // it links information coming from different files :
00301   // for instance, it creates the vtkMedFamilyOnEntityOnProfile instances
00302   // to link mesh and field.
00303   virtual void  LinkMedInfo();
00304 
00305   virtual vtkMedProfile* GetProfile(const char*);
00306 
00307   virtual vtkMedLocalization* GetLocalization(const char*);
00308 
00309   virtual int GetLocalizationKey(vtkMedFieldOnProfile*);
00310 
00311   virtual void InitializeQuadratureOffsets(vtkMedFieldOnProfile*,
00312                                            vtkMedFamilyOnEntityOnProfile*);
00313 
00314   virtual void SetVTKFieldOnSupport(vtkMedFieldOnProfile*,
00315                                     vtkMedFamilyOnEntityOnProfile*);
00316 
00317   // Description:
00318   // returns the current grid to use for this mesh.
00319   vtkMedGrid* FindGridStep(vtkMedMesh* mesh);
00320 
00321   virtual void  GatherFieldSteps(vtkMedField*, vtkMedListOfFieldSteps&);
00322 
00323   // Description:
00324   // returns the index of the given frequency in the AvailableTimes array.
00325   vtkIdType GetFrequencyIndex(double);
00326 
00327   virtual void ChooseRealAnimationMode();
00328 
00329   // Description :
00330   // Load the connectivity of this entities, and also those of the
00331   // sub-entities in the case of non nodal connectivity.
00332   virtual void LoadConnectivity(vtkMedEntityArray*);
00333 
00334   virtual void InitializeCellGlobalIds();
00335 
00336   // Description :
00337   // returns 1 if any point/cell family of this mesh is selected.
00338   int HasMeshAnyCellSelectedFamily(vtkMedMesh*);
00339   int HasMeshAnyPointSelectedFamily(vtkMedMesh*);
00340 
00341   // Description:
00342   // use this method to enable/disable a family support
00343   // the key is formatted by the vtkMedUtilities::FamilyKey method which
00344   // returns a string
00345   // FAMILY/MESH_NAME/OnPoint/FAMILY_NAME or MESH_NAME/OnCell/FAMILY_NAME
00346   virtual void SetFamilyStatus(const char* key, int flag);
00347   virtual int GetFamilyStatus(vtkMedMesh*, vtkMedFamily*);
00348 
00349   // Description:
00350   // This is a helper function that is called when requesting a family status
00351   // if a group status has been set after the last family status update.
00352   virtual void SelectFamiliesFromGroups();
00353 
00354   // Description:
00355   // Instanciate a new vtkDataSet and initialize it to the points
00356   // of this support.
00357   vtkDataSet* CreateUnstructuredGridForPointSupport(
00358       vtkMedFamilyOnEntityOnProfile* foep);
00359 
00360   // Field selections
00361   vtkMedSelection* PointFields;
00362   vtkMedSelection* CellFields;
00363   vtkMedSelection* QuadratureFields;
00364   vtkMedSelection* ElnoFields;
00365 
00366   // Support selection
00367   vtkMedSelection* Entities;
00368   vtkMedSelection* Groups;
00369 
00370   // name of the file to read from
00371   char* FileName;
00372 
00373   // time management
00374   int AnimationMode;
00375   double TimeIndexForIterations;
00376   vtkDoubleArray* AvailableTimes;
00377   double TimePrecision;
00378   vtkMedSelection* Frequencies;
00379 
00380   int CacheStrategy;
00381   int GenerateVectors;
00382 
00383   //BTX
00384   class vtkMedReaderInternal;
00385   vtkMedReaderInternal* Internal;
00386   //ETX
00387 
00388 private:
00389   vtkMedReader(const vtkMedReader&); // Not implemented.
00390   void operator=(const vtkMedReader&); // Not implemented.
00391 };
00392 
00393 #endif //__vtkMedReader_h_