1 // Copyright (C) 2010-2011 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef __vtkMedReader_h_
21 #define __vtkMedReader_h_
23 #include "vtkMultiBlockDataSetAlgorithm.h"
24 #include "vtkMedSetGet.h"
29 class vtkMedSelection;
30 class vtkMedFieldOverEntity;
31 class vtkMedFieldStep;
35 class vtkMedLocalization;
36 class vtkMedEntityArray;
37 class vtkMedFamilyOnEntity;
38 class vtkMedFamilyOnEntityOnProfile;
40 class vtkMedComputeStep;
42 class vtkMedFieldOnProfile;
43 class vtkMedListOfFieldSteps;
46 class vtkUnstructuredGrid;
47 class vtkUnsignedCharArray;
51 class vtkInformationDataObjectKey;
52 class vtkMutableDirectedGraph;
55 class VTK_EXPORT vtkMedReader: public vtkMultiBlockDataSetAlgorithm
58 static vtkMedReader* New();
59 vtkTypeMacro(vtkMedReader, vtkMultiBlockDataSetAlgorithm);
60 void PrintSelf(ostream& os, vtkIndent indent);
63 // Set the file name to read from
64 virtual void SetFileName(const char*);
65 vtkGetStringMacro(FileName)
68 // Is the given file a MED file?
69 virtual int CanReadFile(const char* fname);
72 // Get the file extensions for this format.
73 // Returns a string with a space separated list of extensions in
74 // the format .extension
82 // Return a descriptive name for the file format that might be
87 return "MED file (Modele d'Echange de Donnees)";
91 // use these methods to enable/disable point arrays
92 virtual int GetPointFieldArrayStatus(const char* name);
93 virtual void SetPointFieldArrayStatus(const char* name, int status);
94 virtual int GetNumberOfPointFieldArrays();
95 virtual const char* GetPointFieldArrayName(int);
98 // use these methods to enable/disable cell arrays
99 virtual int GetCellFieldArrayStatus(const char* name);
100 virtual void SetCellFieldArrayStatus(const char* name, int status);
101 virtual int GetNumberOfCellFieldArrays();
102 virtual const char* GetCellFieldArrayName(int);
105 // use these methods to enable/disable quadrature arrays
106 virtual int GetQuadratureFieldArrayStatus(const char* name);
107 virtual void SetQuadratureFieldArrayStatus(const char* name, int status);
108 virtual int GetNumberOfQuadratureFieldArrays();
109 virtual const char* GetQuadratureFieldArrayName(int);
112 // use these methods to enable/disable quadrature arrays
113 virtual int GetElnoFieldArrayStatus(const char* name);
114 virtual void SetElnoFieldArrayStatus(const char* name, int status);
115 virtual int GetNumberOfElnoFieldArrays();
116 virtual const char* GetElnoFieldArrayName(int);
119 // use this method to enable/disable cell types
120 // the key is encoded with the vtkMedUtilities::EntityKey method
121 // which returns a string
122 // CELL_TYPE/MED_ENTITE_MAILLAGE/MED_GEOMETRIE_ELEMENT
123 virtual void SetEntityStatus(const char* key, int flag);
124 virtual int GetEntityStatus(const vtkMedEntity&);
127 // use this method to enable/disable a family support
128 // the key is formatted by the vtkMedUtilities::FamilyKey method which
130 // GROUP/MESH_NAME/OnPoint/FAMILY_NAME or MESH_NAME/OnCell/FAMILY_NAME
131 virtual void SetGroupStatus(const char* key, int flag);
132 virtual int GetGroupStatus(const char* key);
135 // the animation mode modify the way the reader answers time requests from
137 // Default (0) : this is PhysicalTime if there are times, or Iterations
138 // if there are only iterations
139 // PhysicalTime (1) : the reader aggregates all physical times available
141 // for a given time t, the reader will return for each field the
142 // ComputeStep with the highest time inferior
143 // to t, and with the highest iteration.
144 // Iteration (2) : you need to also set the TimeIndexForIterations field.
145 // In this case, the reader will understand
146 // time requests has a request to iterate over iterations for the given time.
147 // Modes (3) : the reader will output the selected fields at all selected
148 // frequencies, and will output a fake TimeRange of -PI/+PI.
149 // Use the *FrequencyArray* interface to select them.
153 Default=0, PhysicalTime=1, Iteration=2, Modes=3
156 vtkSetMacro(AnimationMode, int);
157 vtkGetMacro(AnimationMode, int);
160 // in med files, the ComputeSteps are defined by a
161 // pair <iteration, physicalTime>.
162 // the TimeIndexForIterations ivar is used only if the TimeMode is
164 // it fixes the PhysicalTime index when iterating over iterations : only
165 // iterations with the corresponding physical time will be iterated over.
166 // The index given here is an index into the AvailableTimes array
167 // that is returned be the GetAvailableTimes Method.
168 vtkSetMacro(TimeIndexForIterations, double);
169 vtkGetMacro(TimeIndexForIterations, double);
172 // use these methods to enable/disable a given frequency for modal analysis
173 virtual int GetFrequencyArrayStatus(const char* name);
174 virtual void SetFrequencyArrayStatus(const char* name, int status);
175 virtual int GetNumberOfFrequencyArrays();
176 virtual const char* GetFrequencyArrayName(int);
179 // returns the available physical times. Use this to get the times when in
181 virtual vtkDoubleArray* GetAvailableTimes();
184 // Build the graph used to pass information to the client on the supports
185 virtual void BuildSIL(vtkMutableDirectedGraph*);
188 // Every time the SIL is updated a this will return a different value.
189 virtual int GetSILUpdateStamp();
192 // reset the selection arrays without having to rebuild the SIL.
193 virtual void ClearSelections();
196 // The CacheStrategy indicates to the reader if it
197 // should cache some of the arrays.
201 CacheNothing, CacheGeometry, CacheGeometryAndFields
204 vtkSetMacro(CacheStrategy, int)
205 vtkGetMacro(CacheStrategy, int)
208 // release arrays read from MED (point coordinates, profile ids, family ids)
209 void ClearMedSupports();
212 // release arrays read from MED (fields)
213 void ClearMedFields();
216 // If this flag is set, the reader will output a vector field for each
217 // field in the file that has 2 or more components by extracting the
218 // first 3 compoenents
219 vtkSetMacro(GenerateVectors, int);
220 vtkGetMacro(GenerateVectors, int);
224 virtual ~vtkMedReader();
227 // This is called by the superclass.
228 virtual int RequestDataObject(vtkInformation*, vtkInformationVector**,
229 vtkInformationVector*);
232 // This is called by the superclass.
233 virtual int RequestInformation(vtkInformation*, vtkInformationVector**,
234 vtkInformationVector*);
237 // This is called by the superclass.
238 virtual int RequestData(vtkInformation*, vtkInformationVector**,
239 vtkInformationVector*);
242 // Gather all compute steps in the fields
243 virtual void GatherComputeSteps();
246 // Give the animation steps to the pipeline
247 virtual void AdvertiseTime(vtkInformation*);
250 // returns 1 if at least one the families of this mesh is selected,
252 virtual int IsMeshSelected(vtkMedMesh*);
255 // returns if the field is selected.
256 virtual int IsFieldSelected(vtkMedField*);
257 virtual int IsPointFieldSelected(vtkMedField*);
258 virtual int IsCellFieldSelected(vtkMedField*);
259 virtual int IsQuadratureFieldSelected(vtkMedField*);
260 virtual int IsElnoFieldSelected(vtkMedField*);
262 virtual void AddQuadratureSchemeDefinition(vtkInformation*,
263 vtkMedLocalization*);
270 AfterCreateMedSupports,
275 virtual void ClearCaches(int when);
277 virtual void CreateMedSupports();
279 virtual bool BuildVTKSupport(vtkMedFamilyOnEntityOnProfile*,
282 virtual void MapFieldsOnSupport(vtkMedFamilyOnEntityOnProfile* foe,
285 virtual void CreateVTKFieldOnSupport(vtkMedFieldOnProfile*,
286 vtkMedFamilyOnEntityOnProfile*,
289 virtual void MapFieldOnSupport(vtkMedFieldOnProfile*,
290 vtkMedFamilyOnEntityOnProfile*,
294 // Necessary call for the initialization of the filters used for the MED
295 // library in their parallel reads
296 virtual void InitializeParallelRead();
299 // This method is called after all info from all med files are read.
300 // it links information coming from different files :
301 // for instance, it creates the vtkMedFamilyOnEntityOnProfile instances
302 // to link mesh and field.
303 virtual void LinkMedInfo();
305 virtual vtkMedProfile* GetProfile(const char*);
307 virtual vtkMedLocalization* GetLocalization(const char*);
309 virtual int GetLocalizationKey(vtkMedFieldOnProfile*);
311 virtual void InitializeQuadratureOffsets(vtkMedFieldOnProfile*,
312 vtkMedFamilyOnEntityOnProfile*);
314 virtual void SetVTKFieldOnSupport(vtkMedFieldOnProfile*,
315 vtkMedFamilyOnEntityOnProfile*);
318 // returns the current grid to use for this mesh.
319 vtkMedGrid* FindGridStep(vtkMedMesh* mesh);
321 virtual void GatherFieldSteps(vtkMedField*, vtkMedListOfFieldSteps&);
324 // returns the index of the given frequency in the AvailableTimes array.
325 vtkIdType GetFrequencyIndex(double);
327 virtual void ChooseRealAnimationMode();
330 // Load the connectivity of this entities, and also those of the
331 // sub-entities in the case of non nodal connectivity.
332 virtual void LoadConnectivity(vtkMedEntityArray*);
334 virtual void InitializeCellGlobalIds();
337 // returns 1 if any point/cell family of this mesh is selected.
338 int HasMeshAnyCellSelectedFamily(vtkMedMesh*);
339 int HasMeshAnyPointSelectedFamily(vtkMedMesh*);
342 // use this method to enable/disable a family support
343 // the key is formatted by the vtkMedUtilities::FamilyKey method which
345 // FAMILY/MESH_NAME/OnPoint/FAMILY_NAME or MESH_NAME/OnCell/FAMILY_NAME
346 virtual void SetFamilyStatus(const char* key, int flag);
347 virtual int GetFamilyStatus(vtkMedMesh*, vtkMedFamily*);
350 // This is a helper function that is called when requesting a family status
351 // if a group status has been set after the last family status update.
352 virtual void SelectFamiliesFromGroups();
355 // Instanciate a new vtkDataSet and initialize it to the points
357 vtkDataSet* CreateUnstructuredGridForPointSupport(
358 vtkMedFamilyOnEntityOnProfile* foep);
361 vtkMedSelection* PointFields;
362 vtkMedSelection* CellFields;
363 vtkMedSelection* QuadratureFields;
364 vtkMedSelection* ElnoFields;
367 vtkMedSelection* Entities;
368 vtkMedSelection* Groups;
370 // name of the file to read from
375 double TimeIndexForIterations;
376 vtkDoubleArray* AvailableTimes;
377 double TimePrecision;
378 vtkMedSelection* Frequencies;
384 class vtkMedReaderInternal;
385 vtkMedReaderInternal* Internal;
389 vtkMedReader(const vtkMedReader&); // Not implemented.
390 void operator=(const vtkMedReader&); // Not implemented.
393 #endif //__vtkMedReader_h_