VTK
|
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 #ifdef VTK_USE_PARALLEL 00010 # include "vtkMultiProcessController.h" 00011 #else // VTK_USE_PARALLEL 00012 class vtkMultiProcessController; 00013 #endif // VTK_USE_PARALLEL 00014 00015 #include "vtksys/RegularExpression.hxx" 00016 00017 #include <vtkstd/map> 00018 #include <vtkstd/vector> 00019 00020 #include "vtk_exodusII.h" 00021 00022 class vtkExodusIIReaderParser; 00023 class vtkMutableDirectedGraph; 00024 00028 class vtkExodusIIReaderPrivate : public vtkObject 00029 { 00030 public: 00031 static vtkExodusIIReaderPrivate* New(); 00032 void PrintData( ostream& os, vtkIndent indent ); 00033 vtkTypeMacro(vtkExodusIIReaderPrivate,vtkObject); 00034 //virtual void Modified(); 00035 00037 int OpenFile( const char* filename ); 00038 00040 int CloseFile(); 00041 00043 int RequestInformation(); 00044 00046 vtkMutableDirectedGraph* GetSIL() 00047 { return this->SIL; } 00048 00050 void Broadcast( vtkMultiProcessController* controller ); 00051 00053 void Receive( vtkMultiProcessController* controller ); 00054 00056 int RequestData( vtkIdType timeStep, vtkMultiBlockDataSet* output ); 00057 00058 // Description: 00059 // Prepare a data set with the proper structure and arrays but no cells. 00060 // This is used by the parallel reader when a process has no files assigned to it. 00061 int SetUpEmptyGrid( vtkMultiBlockDataSet* output ); 00062 00074 void Reset(); 00075 00080 void ResetSettings(); 00081 00083 void ResetCache(); 00084 00089 int GetNumberOfTimeSteps() { return (int) this->Times.size(); } 00090 00092 vtkGetMacro(TimeStep,int); 00093 00095 vtkSetMacro(TimeStep,int); 00096 00099 vtkGetMacro(SqueezePoints,int); 00100 00103 void SetSqueezePoints( int sp ); 00104 00107 vtkBooleanMacro(SqueezePoints,int); 00108 00110 int GetNumberOfNodes(); 00111 00116 int GetNumberOfObjectsOfType( int otype ); 00117 00128 int GetNumberOfObjectArraysOfType( int otype ); 00129 00134 const char* GetObjectName( int otype, int i ); 00135 00140 int GetObjectId( int otype, int i ); 00141 00148 int GetObjectSize( int otype, int i ); 00149 00154 int GetObjectStatus( int otype, int i ); 00155 00161 int GetUnsortedObjectStatus( int otype, int i ); 00162 00167 void SetObjectStatus( int otype, int i, int stat ); 00168 00174 void SetUnsortedObjectStatus( int otype, int i, int stat ); 00175 00180 const char* GetObjectArrayName( int otype, int i ); 00181 00186 int GetNumberOfObjectArrayComponents( int otype, int i ); 00187 00192 int GetObjectArrayStatus( int otype, int i ); 00193 00198 void SetObjectArrayStatus( int otype, int i, int stat ); 00199 00206 int GetNumberOfObjectAttributes( int objectType, int objectIndex ); 00207 const char* GetObjectAttributeName( int objectType, 00208 int objectIndex, 00209 int attributeIndex ); 00210 int GetObjectAttributeIndex( int objectType, 00211 int objectIndex, 00212 const char* attribName ); 00213 int GetObjectAttributeStatus( int objectType, 00214 int objectIndex, 00215 int attribIndex ); 00216 void SetObjectAttributeStatus( int objectType, 00217 int objectIndex, 00218 int attribIndex, int status ); 00219 00221 vtkGetMacro(GenerateObjectIdArray,int); 00222 vtkSetMacro(GenerateObjectIdArray,int); 00223 static const char* GetObjectIdArrayName() { return "ObjectId"; } 00224 00225 vtkSetMacro(GenerateGlobalElementIdArray,int); 00226 vtkGetMacro(GenerateGlobalElementIdArray,int); 00227 static const char* GetGlobalElementIdArrayName() { return "GlobalElementId"; } 00228 00229 vtkSetMacro(GenerateGlobalNodeIdArray,int); 00230 vtkGetMacro(GenerateGlobalNodeIdArray,int); 00231 static const char* GetGlobalNodeIdArrayName() { return "GlobalNodeId"; } 00232 00233 vtkSetMacro(GenerateImplicitElementIdArray,int); 00234 vtkGetMacro(GenerateImplicitElementIdArray,int); 00235 static const char* GetImplicitElementIdArrayName() { return "ImplicitElementId"; } 00236 00237 vtkSetMacro(GenerateImplicitNodeIdArray,int); 00238 vtkGetMacro(GenerateImplicitNodeIdArray,int); 00239 static const char* GetImplicitNodeIdArrayName() { return "ImplicitNodeId"; } 00240 00244 vtkSetMacro(GenerateFileIdArray,int); 00245 vtkGetMacro(GenerateFileIdArray,int); 00246 static const char* GetFileIdArrayName() { return "FileId"; } 00247 00249 vtkSetMacro(FileId,int); 00250 vtkGetMacro(FileId,int); 00251 00252 static const char *GetGlobalVariableValuesArrayName() 00253 { return "GlobalVariableValues"; } 00254 static const char *GetGlobalVariableNamesArrayName() 00255 { return "GlobalVariableNames"; } 00256 00257 virtual void SetApplyDisplacements( int d ); 00258 vtkGetMacro(ApplyDisplacements,int); 00259 00260 virtual void SetDisplacementMagnitude( double s ); 00261 vtkGetMacro(DisplacementMagnitude,double); 00262 00263 vtkSetMacro(HasModeShapes,int); 00264 vtkGetMacro(HasModeShapes,int); 00265 00266 vtkSetMacro(ModeShapeTime,double); 00267 vtkGetMacro(ModeShapeTime,double); 00268 00269 vtkSetMacro(AnimateModeShapes, int); 00270 vtkGetMacro(AnimateModeShapes, int); 00271 00272 vtkDataArray* FindDisplacementVectors( int timeStep ); 00273 00274 vtkSetMacro(EdgeFieldDecorations,int); 00275 vtkGetMacro(EdgeFieldDecorations,int); 00276 00277 vtkSetMacro(FaceFieldDecorations,int); 00278 vtkGetMacro(FaceFieldDecorations,int); 00279 00280 const struct ex_init_params* GetModelParams() const 00281 { return &this->ModelParameters; } 00282 00284 struct ArrayInfoType { 00286 vtkStdString Name; 00288 int Components; 00295 int GlomType; 00298 int StorageType; 00300 int Source; 00302 int Status; 00305 vtkstd::vector<vtkStdString> OriginalNames; 00308 vtkstd::vector<int> OriginalIndices; 00317 vtkstd::vector<int> ObjectTruth; 00319 void Reset(); 00320 }; 00321 00323 struct ObjectInfoType { 00325 int Size; 00327 int Status; 00329 int Id; 00331 vtkStdString Name; 00332 }; 00333 00335 struct MapInfoType : public ObjectInfoType { 00336 }; 00337 00340 struct BlockSetInfoType : public ObjectInfoType { 00342 vtkIdType FileOffset; 00347 vtkstd::map<vtkIdType,vtkIdType> PointMap; 00352 vtkstd::map<vtkIdType,vtkIdType> ReversePointMap; 00356 vtkIdType NextSqueezePoint; 00358 vtkUnstructuredGrid* CachedConnectivity; 00359 00360 BlockSetInfoType(){this->CachedConnectivity=0;} 00361 BlockSetInfoType(const BlockSetInfoType& block); 00362 ~BlockSetInfoType(); 00363 }; 00364 00366 struct BlockInfoType : public BlockSetInfoType { 00367 vtkStdString OriginalName; // useful to reset the name if XML metadata is invalid. 00368 vtkStdString TypeName; 00369 // number of boundaries per entry 00370 // The index is the dimensionality of the entry. 0=node, 1=edge, 2=face 00371 int BdsPerEntry[3]; 00372 int AttributesPerEntry; 00373 vtkstd::vector<vtkStdString> AttributeNames; 00374 vtkstd::vector<int> AttributeStatus; 00375 // VTK cell type (a function of TypeName and BdsPerEntry...) 00376 int CellType; 00377 // Number of points per cell as used by VTK 00378 // -- not what's in the file (i.e., BdsPerEntry[0] >= PointsPerCell) 00379 int PointsPerCell; 00380 }; 00381 00383 struct PartInfoType : public ObjectInfoType { 00384 vtkstd::vector<int> BlockIndices; 00385 }; 00386 struct AssemblyInfoType : public ObjectInfoType { 00387 vtkstd::vector<int> BlockIndices; 00388 }; 00389 struct MaterialInfoType : public ObjectInfoType { 00390 vtkstd::vector<int> BlockIndices; 00391 }; 00392 00394 struct SetInfoType : public BlockSetInfoType { 00395 int DistFact; // Number of distribution factors 00396 // (for the entire block, not per array or entry) 00397 }; 00398 00401 enum GlomTypes { 00402 Scalar=0, 00403 Vector2=1, 00404 Vector3=2, 00405 SymmetricTensor=3, 00406 // (order xx, yy, zz, xy, yz, zx) 00407 IntegrationPoint=4 00408 }; 00409 00411 enum ArraySourceTypes { 00412 Result=0, 00413 // (that vary over time) 00414 Attribute=1, 00415 // (constants over time) 00416 Map=2, 00417 Generated=3 00418 }; 00419 00421 vtkTimeStamp InformationTimeStamp; 00422 00423 friend class vtkExodusIIReader; 00424 friend class vtkPExodusIIReader; 00425 00426 virtual void SetParser( vtkExodusIIReaderParser* ); 00427 vtkGetObjectMacro(Parser,vtkExodusIIReaderParser); 00428 00429 // Because Parts, Materials, and assemblies are not stored as arrays, 00430 // but rather as maps to the element blocks they make up, 00431 // we cannot use the Get|SetObject__() methods directly. 00432 00433 int GetNumberOfParts(); 00434 const char* GetPartName(int idx); 00435 const char* GetPartBlockInfo(int idx); 00436 int GetPartStatus(int idx); 00437 int GetPartStatus(vtkStdString name); 00438 void SetPartStatus(int idx, int on); 00439 void SetPartStatus(vtkStdString name, int flag); 00440 00441 int GetNumberOfMaterials(); 00442 const char* GetMaterialName(int idx); 00443 int GetMaterialStatus(int idx); 00444 int GetMaterialStatus(vtkStdString name); 00445 void SetMaterialStatus(int idx, int on); 00446 void SetMaterialStatus(vtkStdString name, int flag); 00447 00448 int GetNumberOfAssemblies(); 00449 const char* GetAssemblyName(int idx); 00450 int GetAssemblyStatus(int idx); 00451 int GetAssemblyStatus(vtkStdString name); 00452 void SetAssemblyStatus(int idx, int on); 00453 void SetAssemblyStatus(vtkStdString name, int flag); 00454 00455 void SetFastPathObjectType(vtkExodusIIReader::ObjectType type) 00456 {this->FastPathObjectType = type;}; 00457 void SetFastPathObjectId(vtkIdType id){this->FastPathObjectId = id;}; 00458 vtkSetStringMacro(FastPathIdType); 00459 00460 bool IsXMLMetadataValid(); 00461 00469 void GetInitialObjectStatus( int otype, ObjectInfoType *info ); 00470 00478 void GetInitialObjectArrayStatus( int otype, ArrayInfoType *info ); 00479 00486 void SetInitialObjectStatus( int otype, const char *name, int stat ); 00487 00493 void SetInitialObjectArrayStatus( int otype, const char *name, int stat ); 00494 00495 int UpdateTimeInformation(); 00496 00497 bool ProducedFastPathOutput; 00498 00499 protected: 00500 vtkExodusIIReaderPrivate(); 00501 ~vtkExodusIIReaderPrivate(); 00502 00504 void BuildSIL(); 00505 00508 int VerifyIntegrationPointGlom( int nn, 00509 char** np, 00510 vtksys::RegularExpression& re, 00511 vtkStdString& field, 00512 vtkStdString& ele ); 00513 00515 void GlomArrayNames( int i, 00516 int num_obj, 00517 int num_vars, 00518 char** var_names, 00519 int* truth_tab ); 00520 00522 void PrepareGeneratedArrayInfo(); 00523 00539 int AssembleOutputConnectivity( vtkIdType timeStep, 00540 int otyp, int oidx, int conntypidx, BlockSetInfoType* bsinfop, 00541 vtkUnstructuredGrid* output ); 00548 int AssembleOutputPoints( vtkIdType timeStep, 00549 BlockSetInfoType* bsinfop, vtkUnstructuredGrid* output ); 00553 int AssembleOutputPointArrays( vtkIdType timeStep, 00554 BlockSetInfoType* bsinfop, vtkUnstructuredGrid* output ); 00558 int AssembleOutputCellArrays( vtkIdType timeStep, 00559 int otyp, int oidx, BlockSetInfoType* bsinfop, vtkUnstructuredGrid* output ); 00564 int AssembleOutputProceduralArrays( vtkIdType timeStep, 00565 int otyp, int oidx, vtkUnstructuredGrid* output ); 00567 int AssembleOutputGlobalArrays( vtkIdType timeStep, 00568 int otyp, int oidx, BlockSetInfoType* bsinfop, vtkUnstructuredGrid* output ); 00575 int AssembleOutputPointMaps( vtkIdType timeStep, 00576 BlockSetInfoType* bsinfop, vtkUnstructuredGrid* output ); 00577 int AssembleOutputCellMaps( vtkIdType timeStep, 00578 int otyp, int oidx, BlockSetInfoType* bsinfop, vtkUnstructuredGrid* output ); 00581 int AssembleArraysOverTime(vtkMultiBlockDataSet* output); 00582 00583 // Generate the decorations for edge fields. 00584 void AssembleOutputEdgeDecorations(); 00585 00586 // Generate the decorations for face fields. 00587 void AssembleOutputFaceDecorations(); 00588 00590 void InsertBlockCells( 00591 int otyp, int obj, int conn_type, int timeStep, BlockInfoType* binfop ); 00592 00594 void InsertSetCells( 00595 int otyp, int obj, int conn_type, int timeStep, SetInfoType* sinfop ); 00596 00598 void AddPointArray( 00599 vtkDataArray* src, BlockSetInfoType* bsinfop, vtkUnstructuredGrid* output ); 00600 00602 void InsertSetNodeCopies( 00603 vtkIntArray* refs, int otyp, int obj, SetInfoType* sinfo ); 00604 00606 void InsertSetCellCopies( 00607 vtkIntArray* refs, int otyp, int obj, SetInfoType* sinfo ); 00608 00610 void InsertSetSides( 00611 vtkIntArray* refs, int otyp, int obj, SetInfoType* sinfo ); 00612 00618 vtkDataArray* GetCacheOrRead( vtkExodusIICacheKey ); 00619 00624 int GetConnTypeIndexFromConnType( int ctyp ); 00625 00630 int GetObjectTypeIndexFromObjectType( int otyp ); 00631 00637 int GetNumberOfObjectsAtTypeIndex( int typeIndex ); 00638 00646 ObjectInfoType* GetObjectInfo( int typeIndex, int objectIndex ); 00647 00654 ObjectInfoType* GetSortedObjectInfo( int objectType, int objectIndex ); 00655 00662 ObjectInfoType* GetUnsortedObjectInfo( int objectType, int objectIndex ); 00663 00668 int GetBlockIndexFromFileGlobalId( int otyp, int refId ); 00669 00674 BlockInfoType* GetBlockFromFileGlobalId( int otyp, int refId ); 00675 00679 vtkIdType GetSqueezePointId( BlockSetInfoType* bsinfop, int i ); 00680 00682 void DetermineVtkCellType( BlockInfoType& binfo ); 00683 00687 ArrayInfoType* FindArrayInfoByName( int otyp, const char* name ); 00688 00692 int IsObjectTypeBlock( int otyp ); 00693 int IsObjectTypeSet( int otyp ); 00694 int IsObjectTypeMap( int otyp ); 00695 00699 int GetObjectTypeFromMapType( int mtyp ); 00700 int GetMapTypeFromObjectType( int otyp ); 00701 int GetTemporalTypeFromObjectType( int otyp ); 00702 00706 int GetSetTypeFromSetConnType( int sctyp ); 00707 00711 int GetBlockConnTypeFromBlockType( int btyp ); 00712 00718 void RemoveBeginningAndTrailingSpaces( int len, char **names ); 00719 00721 void ClearConnectivityCaches(); 00722 00726 vtkstd::map<int,vtkstd::vector<BlockInfoType> > BlockInfo; 00730 vtkstd::map<int,vtkstd::vector<SetInfoType> > SetInfo; 00736 vtkstd::map<int,vtkstd::vector<MapInfoType> > MapInfo; 00737 00738 vtkstd::vector<PartInfoType> PartInfo; 00739 vtkstd::vector<MaterialInfoType> MaterialInfo; 00740 vtkstd::vector<AssemblyInfoType> AssemblyInfo; 00741 00746 vtkstd::map<int,vtkstd::vector<int> > SortedObjectIndices; 00748 // defined on that type. 00749 vtkstd::map<int,vtkstd::vector<ArrayInfoType> > ArrayInfo; 00750 00755 vtkstd::map<int,vtkstd::vector<ArrayInfoType> > InitialArrayInfo; 00756 00761 vtkstd::map<int,vtkstd::vector<ObjectInfoType> > InitialObjectInfo; 00762 00764 int AppWordSize; 00765 int DiskWordSize; 00766 00770 float ExodusVersion; 00771 00773 int Exoid; 00774 00776 struct ex_init_params ModelParameters; 00777 00779 vtkstd::vector<double> Times; 00780 00782 int TimeStep; 00783 00787 double ModeShapeTime; 00788 00789 int GenerateObjectIdArray; 00790 int GenerateGlobalIdArray; 00791 int GenerateFileIdArray; 00792 int GenerateGlobalElementIdArray; 00793 int GenerateGlobalNodeIdArray; 00794 int GenerateImplicitElementIdArray; 00795 int GenerateImplicitNodeIdArray; 00796 00800 int FileId; 00801 00803 vtkExodusIICache* Cache; 00804 00805 int ApplyDisplacements; 00806 float DisplacementMagnitude; 00807 int HasModeShapes; 00808 int AnimateModeShapes; 00809 00810 // Specify how to decorate edge and face variables. 00811 int EdgeFieldDecorations; 00812 int FaceFieldDecorations; 00813 00814 // Meshes to support edge and face glyph decorations. 00815 vtkPolyData* EdgeDecorationMesh; 00816 vtkPolyData* FaceDecorationMesh; 00817 00829 int SqueezePoints; 00830 00834 vtkExodusIIReader* Parent; 00835 00836 vtkExodusIIReaderParser* Parser; 00837 00838 vtkExodusIIReader::ObjectType FastPathObjectType; 00839 vtkIdType FastPathObjectId; 00840 char* FastPathIdType; 00841 00842 vtkMutableDirectedGraph* SIL; 00843 private: 00844 vtkExodusIIReaderPrivate( const vtkExodusIIReaderPrivate& ); // Not implemented. 00845 void operator = ( const vtkExodusIIReaderPrivate& ); // Not implemented. 00846 }; 00847 00848 #endif // __vtkExodusIIReaderPrivate_h