VTK
dox/IO/Exodus/vtkExodusIIReaderPrivate.h
Go to the documentation of this file.
00001 #ifndef __vtkExodusIIReaderPrivate_h
00002 #define __vtkExodusIIReaderPrivate_h
00003 
00004 // Do not include this file directly. It is only for use
00005 // from inside the ExodusII reader and its descendants.
00006 
00007 #include "vtkToolkits.h" // make sure VTK_USE_PARALLEL is properly set
00008 #include "vtkExodusIICache.h"
00009 #include "vtksys/RegularExpression.hxx"
00010 
00011 #include <map>
00012 #include <vector>
00013 
00014 #include "vtk_exodusII.h"
00015 #include "vtkIOExodusModule.h" // For export macro
00016 class vtkExodusIIReaderParser;
00017 class vtkMutableDirectedGraph;
00018 
00022 class VTKIOEXODUS_EXPORT vtkExodusIIReaderPrivate : public vtkObject
00023 {
00024 public:
00025   static vtkExodusIIReaderPrivate* New();
00026   void PrintData( ostream& os, vtkIndent indent );
00027   vtkTypeMacro(vtkExodusIIReaderPrivate,vtkObject);
00028   //virtual void Modified();
00029 
00031   int OpenFile( const char* filename );
00032 
00034   int CloseFile();
00035 
00037   int RequestInformation();
00038 
00040   vtkMutableDirectedGraph* GetSIL()
00041     { return this->SIL; }
00042 
00044   int RequestData( vtkIdType timeStep, vtkMultiBlockDataSet* output );
00045 
00050   int SetUpEmptyGrid( vtkMultiBlockDataSet* output );
00051 
00063   void Reset();
00064 
00069   void ResetSettings();
00070 
00072   void ResetCache();
00073 
00075   void SetCacheSize(double size);
00076 
00078   vtkGetMacro(CacheSize, double);
00079 
00084   int GetNumberOfTimeSteps() { return (int) this->Times.size(); }
00085 
00087   vtkGetMacro(TimeStep,int);
00088 
00090   vtkSetMacro(TimeStep,int);
00091 
00094   vtkGetMacro(SqueezePoints,int);
00095 
00098   void SetSqueezePoints( int sp );
00099 
00102   vtkBooleanMacro(SqueezePoints,int);
00103 
00105   int GetNumberOfNodes();
00106 
00111   int GetNumberOfObjectsOfType( int otype );
00112 
00123   int GetNumberOfObjectArraysOfType( int otype );
00124 
00129   const char* GetObjectName( int otype, int i );
00130 
00135   int GetObjectId( int otype, int i );
00136 
00143   int GetObjectSize( int otype, int i );
00144 
00149   int GetObjectStatus( int otype, int i );
00150 
00156   int GetUnsortedObjectStatus( int otype, int i );
00157 
00162   void SetObjectStatus( int otype, int i, int stat );
00163 
00169   void SetUnsortedObjectStatus( int otype, int i, int stat );
00170 
00175   const char* GetObjectArrayName( int otype, int i );
00176 
00181   int GetNumberOfObjectArrayComponents( int otype, int i );
00182 
00187   int GetObjectArrayStatus( int otype, int i );
00188 
00193   void SetObjectArrayStatus( int otype, int i, int stat );
00194 
00201   int GetNumberOfObjectAttributes( int objectType, int objectIndex );
00202   const char* GetObjectAttributeName( int objectType,
00203                                       int objectIndex,
00204                                       int attributeIndex );
00205   int GetObjectAttributeIndex( int objectType,
00206                                int objectIndex,
00207                                const char* attribName );
00208   int GetObjectAttributeStatus( int objectType,
00209                                 int objectIndex,
00210                                 int attribIndex );
00211   void SetObjectAttributeStatus( int objectType,
00212                                  int objectIndex,
00213                                  int attribIndex, int status );
00214 
00216   vtkGetMacro(GenerateObjectIdArray,int);
00217   vtkSetMacro(GenerateObjectIdArray,int);
00218   static const char* GetObjectIdArrayName() { return "ObjectId"; }
00219 
00220   vtkSetMacro(GenerateGlobalElementIdArray,int);
00221   vtkGetMacro(GenerateGlobalElementIdArray,int);
00222   static const char* GetGlobalElementIdArrayName() { return "GlobalElementId"; }
00223 
00224   vtkSetMacro(GenerateGlobalNodeIdArray,int);
00225   vtkGetMacro(GenerateGlobalNodeIdArray,int);
00226   static const char* GetGlobalNodeIdArrayName() { return "GlobalNodeId"; }
00227 
00228   vtkSetMacro(GenerateImplicitElementIdArray,int);
00229   vtkGetMacro(GenerateImplicitElementIdArray,int);
00230   static const char* GetImplicitElementIdArrayName() { return "ImplicitElementId"; }
00231 
00232   vtkSetMacro(GenerateImplicitNodeIdArray,int);
00233   vtkGetMacro(GenerateImplicitNodeIdArray,int);
00234   static const char* GetImplicitNodeIdArrayName() { return "ImplicitNodeId"; }
00235 
00239   vtkSetMacro(GenerateFileIdArray,int);
00240   vtkGetMacro(GenerateFileIdArray,int);
00241   static const char* GetFileIdArrayName() { return "FileId"; }
00242 
00244   vtkSetMacro(FileId,int);
00245   vtkGetMacro(FileId,int);
00246 
00247   static const char *GetGlobalVariableValuesArrayName()
00248     { return "GlobalVariableValues"; }
00249   static const char *GetGlobalVariableNamesArrayName()
00250     { return "GlobalVariableNames"; }
00251 
00252   virtual void SetApplyDisplacements( int d );
00253   vtkGetMacro(ApplyDisplacements,int);
00254 
00255   virtual void SetDisplacementMagnitude( double s );
00256   vtkGetMacro(DisplacementMagnitude,double);
00257 
00258   vtkSetMacro(HasModeShapes,int);
00259   vtkGetMacro(HasModeShapes,int);
00260 
00261   vtkSetMacro(ModeShapeTime,double);
00262   vtkGetMacro(ModeShapeTime,double);
00263 
00264   vtkSetMacro(AnimateModeShapes, int);
00265   vtkGetMacro(AnimateModeShapes, int);
00266 
00267   vtkDataArray* FindDisplacementVectors( int timeStep );
00268 
00269   const struct ex_init_params* GetModelParams() const
00270     { return &this->ModelParameters; }
00271 
00273   struct VTKIOEXODUS_EXPORT ArrayInfoType {
00275     vtkStdString Name;
00277     int Components;
00284     int GlomType;
00287     int StorageType;
00289     int Source;
00291     int Status;
00294     std::vector<vtkStdString> OriginalNames;
00297     std::vector<int> OriginalIndices;
00306     std::vector<int> ObjectTruth;
00308     void Reset();
00309   };
00310 
00312   struct VTKIOEXODUS_EXPORT ObjectInfoType {
00314     int Size;
00316     int Status;
00318     int Id;
00320     vtkStdString Name;
00321   };
00322 
00324   struct VTKIOEXODUS_EXPORT MapInfoType : public ObjectInfoType {
00325   };
00326 
00329   struct VTKIOEXODUS_EXPORT BlockSetInfoType : public ObjectInfoType {
00331     vtkIdType FileOffset;
00336     std::map<vtkIdType,vtkIdType> PointMap;
00341     std::map<vtkIdType,vtkIdType> ReversePointMap;
00345     vtkIdType NextSqueezePoint;
00347     vtkUnstructuredGrid* CachedConnectivity;
00348 
00349     BlockSetInfoType(){this->CachedConnectivity=0;}
00350     BlockSetInfoType(const BlockSetInfoType& block);
00351     ~BlockSetInfoType();
00352   };
00353 
00355   struct VTKIOEXODUS_EXPORT BlockInfoType : public BlockSetInfoType {
00356     vtkStdString OriginalName; // useful to reset the name if XML metadata is invalid.
00357     vtkStdString TypeName;
00358     // number of boundaries per entry
00359     // The index is the dimensionality of the entry. 0=node, 1=edge, 2=face
00360     int BdsPerEntry[3];
00361     int AttributesPerEntry;
00362     std::vector<vtkStdString> AttributeNames;
00363     std::vector<int> AttributeStatus;
00364     // VTK cell type (a function of TypeName and BdsPerEntry...)
00365     int CellType;
00366     // Number of points per cell as used by VTK
00367     // -- not what's in the file (i.e., BdsPerEntry[0] >= PointsPerCell)
00368     int PointsPerCell;
00369   };
00370 
00372   struct PartInfoType : public ObjectInfoType {
00373     std::vector<int> BlockIndices;
00374   };
00375   struct AssemblyInfoType : public ObjectInfoType {
00376     std::vector<int> BlockIndices;
00377   };
00378   struct MaterialInfoType : public ObjectInfoType {
00379     std::vector<int> BlockIndices;
00380   };
00381 
00383   struct SetInfoType : public BlockSetInfoType {
00384     int DistFact;     // Number of distribution factors
00385                       // (for the entire block, not per array or entry)
00386   };
00387 
00390   enum GlomTypes {
00391     Scalar=0,          
00392     Vector2=1,         
00393     Vector3=2,         
00394     SymmetricTensor=3, 
00395                        //   (order xx, yy, zz, xy, yz, zx)
00396     IntegrationPoint=4 
00397   };
00398 
00400   enum ArraySourceTypes {
00401     Result=0,        
00402                      //   (that vary over time)
00403     Attribute=1,     
00404                      //   (constants over time)
00405     Map=2,           
00406     Generated=3      
00407   };
00408 
00410   vtkTimeStamp InformationTimeStamp;
00411 
00412   friend class vtkExodusIIReader;
00413   friend class vtkPExodusIIReader;
00414 
00415   virtual void SetParser( vtkExodusIIReaderParser* );
00416   vtkGetObjectMacro(Parser,vtkExodusIIReaderParser);
00417 
00418   // Because Parts, Materials, and assemblies are not stored as arrays,
00419   // but rather as maps to the element blocks they make up,
00420   // we cannot use the Get|SetObject__() methods directly.
00421 
00422   int GetNumberOfParts();
00423   const char* GetPartName(int idx);
00424   const char* GetPartBlockInfo(int idx);
00425   int GetPartStatus(int idx);
00426   int GetPartStatus(vtkStdString name);
00427   void SetPartStatus(int idx, int on);
00428   void SetPartStatus(vtkStdString name, int flag);
00429 
00430   int GetNumberOfMaterials();
00431   const char* GetMaterialName(int idx);
00432   int GetMaterialStatus(int idx);
00433   int GetMaterialStatus(vtkStdString name);
00434   void SetMaterialStatus(int idx, int on);
00435   void SetMaterialStatus(vtkStdString name, int flag);
00436 
00437   int GetNumberOfAssemblies();
00438   const char* GetAssemblyName(int idx);
00439   int GetAssemblyStatus(int idx);
00440   int GetAssemblyStatus(vtkStdString name);
00441   void SetAssemblyStatus(int idx, int on);
00442   void SetAssemblyStatus(vtkStdString name, int flag);
00443 
00444   void SetFastPathObjectType(vtkExodusIIReader::ObjectType type)
00445     {this->FastPathObjectType = type;};
00446   void SetFastPathObjectId(vtkIdType id){this->FastPathObjectId = id;};
00447   vtkSetStringMacro(FastPathIdType);
00448 
00449   bool IsXMLMetadataValid();
00450 
00458   void GetInitialObjectStatus( int otype, ObjectInfoType *info );
00459 
00467   void GetInitialObjectArrayStatus( int otype, ArrayInfoType *info );
00468 
00475   void SetInitialObjectStatus( int otype, const char *name, int stat );
00476 
00482   void SetInitialObjectArrayStatus( int otype, const char *name, int stat );
00483 
00484   int UpdateTimeInformation();
00485 
00486   bool ProducedFastPathOutput;
00487 
00488 protected:
00489   vtkExodusIIReaderPrivate();
00490   ~vtkExodusIIReaderPrivate();
00491 
00493   void BuildSIL();
00494 
00497   int VerifyIntegrationPointGlom( int nn,
00498                                   char** np,
00499                                   vtksys::RegularExpression& re,
00500                                   vtkStdString& field,
00501                                   vtkStdString& ele );
00502 
00504   void GlomArrayNames( int i,
00505                        int num_obj,
00506                        int num_vars,
00507                        char** var_names,
00508                        int* truth_tab );
00509 
00511   void PrepareGeneratedArrayInfo();
00512 
00528   int AssembleOutputConnectivity( vtkIdType timeStep,
00529     int otyp, int oidx, int conntypidx, BlockSetInfoType* bsinfop,
00530     vtkUnstructuredGrid* output );
00537   int AssembleOutputPoints( vtkIdType timeStep,
00538     BlockSetInfoType* bsinfop, vtkUnstructuredGrid* output );
00542   int AssembleOutputPointArrays( vtkIdType timeStep,
00543     BlockSetInfoType* bsinfop, vtkUnstructuredGrid* output );
00547   int AssembleOutputCellArrays( vtkIdType timeStep,
00548     int otyp, int oidx, BlockSetInfoType* bsinfop, vtkUnstructuredGrid* output );
00553   int AssembleOutputProceduralArrays( vtkIdType timeStep,
00554     int otyp, int oidx, vtkUnstructuredGrid* output );
00556   int AssembleOutputGlobalArrays( vtkIdType timeStep,
00557     int otyp, int oidx, BlockSetInfoType* bsinfop, vtkUnstructuredGrid* output );
00564   int AssembleOutputPointMaps( vtkIdType timeStep,
00565     BlockSetInfoType* bsinfop, vtkUnstructuredGrid* output );
00566   int AssembleOutputCellMaps( vtkIdType timeStep,
00567     int otyp, int oidx, BlockSetInfoType* bsinfop, vtkUnstructuredGrid* output );
00570   int AssembleArraysOverTime(vtkMultiBlockDataSet* output);
00571 
00573   void InsertBlockCells(
00574     int otyp, int obj, int conn_type, int timeStep, BlockInfoType* binfop );
00575 
00577   void InsertSetCells(
00578     int otyp, int obj, int conn_type, int timeStep, SetInfoType* sinfop );
00579 
00581   void AddPointArray(
00582     vtkDataArray* src, BlockSetInfoType* bsinfop, vtkUnstructuredGrid* output );
00583 
00585   void InsertSetNodeCopies(
00586     vtkIntArray* refs, int otyp, int obj, SetInfoType* sinfo );
00587 
00589   void InsertSetCellCopies(
00590     vtkIntArray* refs, int otyp, int obj, SetInfoType* sinfo );
00591 
00593   void InsertSetSides(
00594     vtkIntArray* refs, int otyp, int obj, SetInfoType* sinfo );
00595 
00601   vtkDataArray* GetCacheOrRead( vtkExodusIICacheKey );
00602 
00607   int GetConnTypeIndexFromConnType( int ctyp );
00608 
00613   int GetObjectTypeIndexFromObjectType( int otyp );
00614 
00620   int GetNumberOfObjectsAtTypeIndex( int typeIndex );
00621 
00629   ObjectInfoType* GetObjectInfo( int typeIndex, int objectIndex );
00630 
00637   ObjectInfoType* GetSortedObjectInfo( int objectType, int objectIndex );
00638 
00645   ObjectInfoType* GetUnsortedObjectInfo( int objectType, int objectIndex );
00646 
00651   int GetBlockIndexFromFileGlobalId( int otyp, int refId );
00652 
00657   BlockInfoType* GetBlockFromFileGlobalId( int otyp, int refId );
00658 
00662   vtkIdType GetSqueezePointId( BlockSetInfoType* bsinfop, int i );
00663 
00665   void DetermineVtkCellType( BlockInfoType& binfo );
00666 
00670   ArrayInfoType* FindArrayInfoByName( int otyp, const char* name );
00671 
00675   int IsObjectTypeBlock( int otyp );
00676   int IsObjectTypeSet( int otyp );
00677   int IsObjectTypeMap( int otyp );
00678 
00682   int GetObjectTypeFromMapType( int mtyp );
00683   int GetMapTypeFromObjectType( int otyp );
00684   int GetTemporalTypeFromObjectType( int otyp );
00685 
00689   int GetSetTypeFromSetConnType( int sctyp );
00690 
00694   int GetBlockConnTypeFromBlockType( int btyp );
00695 
00701   void RemoveBeginningAndTrailingSpaces( int len, char **names );
00702 
00704   void ClearConnectivityCaches();
00705 
00709   std::map<int,std::vector<BlockInfoType> > BlockInfo;
00713   std::map<int,std::vector<SetInfoType> > SetInfo;
00719   std::map<int,std::vector<MapInfoType> > MapInfo;
00720 
00721   std::vector<PartInfoType> PartInfo;
00722   std::vector<MaterialInfoType> MaterialInfo;
00723   std::vector<AssemblyInfoType> AssemblyInfo;
00724 
00729   std::map<int,std::vector<int> > SortedObjectIndices;
00731   //  defined on that type.
00732   std::map<int,std::vector<ArrayInfoType> > ArrayInfo;
00733 
00738   std::map<int,std::vector<ArrayInfoType> > InitialArrayInfo;
00739 
00744   std::map<int,std::vector<ObjectInfoType> > InitialObjectInfo;
00745 
00747   int AppWordSize;
00748   int DiskWordSize;
00749 
00753   float ExodusVersion;
00754 
00756   int Exoid;
00757 
00759   struct ex_init_params ModelParameters;
00760 
00762   std::vector<double> Times;
00763 
00765   int TimeStep;
00766 
00770   double ModeShapeTime;
00771 
00772   int GenerateObjectIdArray;
00773   int GenerateGlobalIdArray;
00774   int GenerateFileIdArray;
00775   int GenerateGlobalElementIdArray;
00776   int GenerateGlobalNodeIdArray;
00777   int GenerateImplicitElementIdArray;
00778   int GenerateImplicitNodeIdArray;
00779 
00783   int FileId;
00784 
00786   vtkExodusIICache* Cache;
00787   //
00789   double CacheSize;
00790 
00791   int ApplyDisplacements;
00792   float DisplacementMagnitude;
00793   int HasModeShapes;
00794   int AnimateModeShapes;
00795 
00807   int SqueezePoints;
00808 
00812   vtkExodusIIReader* Parent;
00813 
00814   vtkExodusIIReaderParser* Parser;
00815 
00816   vtkExodusIIReader::ObjectType FastPathObjectType;
00817   vtkIdType FastPathObjectId;
00818   char* FastPathIdType;
00819 
00820   vtkMutableDirectedGraph* SIL;
00821 private:
00822   vtkExodusIIReaderPrivate( const vtkExodusIIReaderPrivate& ); // Not implemented.
00823   void operator = ( const vtkExodusIIReaderPrivate& ); // Not implemented.
00824 };
00825 
00826 #endif // __vtkExodusIIReaderPrivate_h
00827 // VTK-HeaderTest-Exclude: vtkExodusIIReaderPrivate.h