Main Page | Directories | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

vtkModelMetadata.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   ParaView
00004   Module:    $RCSfile: vtkModelMetadata.h,v $
00005 
00006   Copyright (c) Kitware, Inc.
00007   All rights reserved.
00008   See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00015 /*----------------------------------------------------------------------------
00016  Copyright (c) Sandia Corporation
00017  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
00018 ----------------------------------------------------------------------------*/
00019 
00084 #ifndef __vtkModelMetadata_h
00085 #define __vtkModelMetadata_h
00086 
00087 #include "vtkObject.h"
00088 
00089 #define myVtkGetMacro(name, type) virtual type Get##name() const { return this->name; }
00090 
00091 #define myVtkGetStringMacro(name) virtual char* Get##name () const { return this->name; }
00092 
00093 class vtkDataSet;
00094 class vtkCharArray;
00095 class vtkIntArray;
00096 class vtkFloatArray;
00097 class vtkIntArray;
00098 class vtkModelMetadataSTLCloak;
00099 
00100 class VTK_EXPORT vtkModelMetadata : public vtkObject
00101 { 
00102 public:
00103   vtkTypeRevisionMacro(vtkModelMetadata, vtkObject);
00104   virtual void PrintSelf(ostream &os, vtkIndent indent);
00105   static vtkModelMetadata *New();
00106 
00111   virtual void PrintGlobalInformation();
00112 
00123   virtual void PrintLocalInformation();
00124 
00126 
00127   vtkSetStringMacro(Title);
00128   myVtkGetStringMacro(Title);
00130 
00133   void SetInformationLines(int numLines, char **lines);
00134   
00137   void AddInformationLine(char *info);
00138 
00141   int GetInformationLines(char ***lines) const;
00142 
00144   myVtkGetMacro(NumberOfInformationLines, int);
00145 
00149   void SetQARecords(int numberOfRecords, char *QARecords[][4]); 
00150   
00155   void AddQARecord(char *name, char *version, char *date, char *time);
00156 
00158 
00159   void GetQARecord(int which, 
00160           char **name, char **version, char **date, char **time) const;
00162 
00164   myVtkGetMacro(NumberOfQARecords, int);
00165 
00167 
00170   vtkSetMacro(TimeStepIndex, int);
00171   myVtkGetMacro(TimeStepIndex, int);
00173 
00175 
00178   void SetTimeSteps(int numberOfTimeSteps, float *timeStepValues);
00179   myVtkGetMacro(NumberOfTimeSteps, int);
00181 
00183   float *GetTimeStepValues() const {return this->TimeStepValues;}
00184 
00186 
00188   void SetCoordinateNames(int dimension, char **);
00189   char **GetCoordinateNames() const {return this->CoordinateNames;}
00191 
00194   myVtkGetMacro(Dimension, int);
00195 
00197 
00199   vtkSetMacro(NumberOfBlocks, int);
00200   myVtkGetMacro(NumberOfBlocks, int);
00202 
00204 
00206   void SetBlockIds(int *);
00207   int *GetBlockIds() const {return this->BlockIds;}
00209 
00211 
00215   void SetBlockElementType(char **);
00216   char **GetBlockElementType() const {return this->BlockElementType;}
00218 
00220 
00223   int SetBlockNumberOfElements(int *nelts);
00224   int *GetBlockNumberOfElements()const{return this->BlockNumberOfElements;}
00226 
00228 
00231   void SetBlockNodesPerElement(int *);
00232   int *GetBlockNodesPerElement()const{return this->BlockNodesPerElement;}
00234 
00236 
00239   void SetBlockElementIdList(int *);
00240   int *GetBlockElementIdList() const {return this->BlockElementIdList;}
00242 
00244   myVtkGetMacro(SumElementsPerBlock, int);                                         
00245 
00248   int *GetBlockElementIdListIndex()const {return this->BlockElementIdListIndex;} 
00249 
00251 
00254   int SetBlockNumberOfAttributesPerElement(int *natts);
00255   int *GetBlockNumberOfAttributesPerElement()const {return this->BlockNumberOfAttributesPerElement;}
00257 
00259 
00262   void SetBlockAttributes(float *);
00263   float *GetBlockAttributes()const {return this->BlockAttributes;}
00265 
00267   myVtkGetMacro(SizeBlockAttributeArray, int);
00268 
00271   int *GetBlockAttributesIndex()const {return this->BlockAttributesIndex;};
00272 
00274 
00276   vtkSetMacro(NumberOfNodeSets, int);
00277   myVtkGetMacro(NumberOfNodeSets, int);
00279 
00281 
00284   void SetNodeSetIds(int *);
00285   int *GetNodeSetIds()const {return this->NodeSetIds;}
00287 
00289 
00292   int SetNodeSetSize(int *);
00293   int *GetNodeSetSize()const {return this->NodeSetSize;}
00295 
00297 
00301   void SetNodeSetNodeIdList(int *);
00302   int *GetNodeSetNodeIdList()const {return this->NodeSetNodeIdList;}
00304 
00306 
00310   int SetNodeSetNumberOfDistributionFactors(int *);
00311   int *GetNodeSetNumberOfDistributionFactors()const {return this->NodeSetNumberOfDistributionFactors;}
00313 
00315 
00318   void SetNodeSetDistributionFactors(float *);
00319   float *GetNodeSetDistributionFactors()const {return this->NodeSetDistributionFactors;}
00321 
00323   myVtkGetMacro(SumNodesPerNodeSet, int);     
00324 
00326   myVtkGetMacro(SumDistFactPerNodeSet, int);
00327 
00330   int *GetNodeSetNodeIdListIndex() const {return this->NodeSetNodeIdListIndex;}
00331 
00334   int *GetNodeSetDistributionFactorIndex() const {return this->NodeSetDistributionFactorIndex;}
00335 
00337 
00339   vtkSetMacro(NumberOfSideSets, int);
00340   myVtkGetMacro(NumberOfSideSets, int);
00342 
00344 
00346   void SetSideSetIds(int *);
00347   int *GetSideSetIds()const {return this->SideSetIds;}
00349 
00351 
00354   int SetSideSetSize(int *sizes);
00355   int *GetSideSetSize()const {return this->SideSetSize;}
00357 
00359 
00363   int SetSideSetNumberOfDistributionFactors(int *df);
00364   int *GetSideSetNumberOfDistributionFactors()const {return this->SideSetNumberOfDistributionFactors;}
00366 
00368 
00372   void SetSideSetElementList(int *);
00373   int *GetSideSetElementList()const {return this->SideSetElementList;}
00375 
00377 
00382   void SetSideSetSideList( int *);
00383   int *GetSideSetSideList()const {return this->SideSetSideList;}
00385 
00387 
00391   void SetSideSetNumDFPerSide(int *numNodes);
00392   int *GetSideSetNumDFPerSide()const {return this->SideSetNumDFPerSide;}
00394 
00396 
00404   void SetSideSetDistributionFactors(float *);
00405   float *GetSideSetDistributionFactors()const {return this->SideSetDistributionFactors;}
00407 
00409   myVtkGetMacro(SumSidesPerSideSet, int);
00410 
00412   myVtkGetMacro(SumDistFactPerSideSet, int);
00413 
00416   int *GetSideSetListIndex()const {return this->SideSetListIndex;}
00417 
00420   int *GetSideSetDistributionFactorIndex()const {return this->SideSetDistributionFactorIndex;}
00421 
00423   myVtkGetMacro(NumberOfBlockProperties, int);
00424 
00426 
00428   void SetBlockPropertyNames(int numProp, char **names);
00429   char **GetBlockPropertyNames()const {return this->BlockPropertyNames;}
00431 
00433 
00435   void SetBlockPropertyValue(int *);
00436   int *GetBlockPropertyValue()const {return this->BlockPropertyValue;}
00438 
00440   myVtkGetMacro(NumberOfNodeSetProperties, int);
00441 
00443 
00445   void SetNodeSetPropertyNames(int numProp, char **names);
00446   char **GetNodeSetPropertyNames()const {return this->NodeSetPropertyNames;}
00448 
00450 
00452   void SetNodeSetPropertyValue(int *);
00453   int *GetNodeSetPropertyValue()const {return this->NodeSetPropertyValue;}
00455 
00457   myVtkGetMacro(NumberOfSideSetProperties, int);
00458 
00460 
00462   void SetSideSetPropertyNames(int numProp, char **names);
00463   char **GetSideSetPropertyNames()const {return this->SideSetPropertyNames;}
00465 
00467 
00469   void SetSideSetPropertyValue(int *);
00470   int *GetSideSetPropertyValue()const {return this->SideSetPropertyValue;}
00472 
00474   myVtkGetMacro(NumberOfGlobalVariables, int);
00475 
00477 
00478   void SetGlobalVariableNames(int numVarNames, char **n);
00479   char **GetGlobalVariableNames()const {return this->GlobalVariableNames;}
00481 
00483 
00485   void SetGlobalVariableValue(float *f);
00486   float *GetGlobalVariableValue()const {return this->GlobalVariableValue;}
00488 
00490 
00499   void SetElementVariableInfo(int numOrigNames, char **origNames,
00500             int numNames, char **names,  int *numComp, int *map);
00502 
00504 
00513   void SetNodeVariableInfo(int numOrigNames, char **origNames,
00514             int numNames, char **names,  int *numComp, int *map);
00516 
00518 
00522   void SetElementVariableTruthTable(int *);
00523   int *GetElementVariableTruthTable()const {return this->ElementVariableTruthTable;}
00525 
00527 
00529   vtkSetMacro(AllVariablesDefinedInAllBlocks, int);
00530   myVtkGetMacro(AllVariablesDefinedInAllBlocks, int);
00531   vtkBooleanMacro(AllVariablesDefinedInAllBlocks, int);
00533 
00540   int ElementVariableIsDefinedInBlock(char *varname, int blockId);
00541 
00543 
00555   myVtkGetMacro(OriginalNumberOfElementVariables, int);
00556   char **GetOriginalElementVariableNames()const {return this->OriginalElementVariableNames;}
00557   myVtkGetMacro(NumberOfElementVariables, int);
00558   char **GetElementVariableNames()const {return this->ElementVariableNames;}
00559   int *GetElementVariableNumberOfComponents()const {return this->ElementVariableNumberOfComponents;}
00560   int *GetMapToOriginalElementVariableNames()const {return this->MapToOriginalElementVariableNames;}
00562 
00563   myVtkGetMacro(OriginalNumberOfNodeVariables, int);
00564   char **GetOriginalNodeVariableNames()const {return this->OriginalNodeVariableNames;}
00565   myVtkGetMacro(NumberOfNodeVariables, int);
00566   char **GetNodeVariableNames()const {return this->NodeVariableNames;}
00567   int *GetNodeVariableNumberOfComponents()const {return this->NodeVariableNumberOfComponents;}
00568   int *GetMapToOriginalNodeVariableNames()const {return this->MapToOriginalNodeVariableNames;}
00569 
00574   char *FindOriginalElementVariableName(const char *name, int component);
00575 
00580   char *FindOriginalNodeVariableName(const char *name, int component);
00581 
00584   static int HasMetadata(vtkDataSet *grid);
00585 
00587   void Pack(vtkDataSet *ugrid);
00588 
00593   int Unpack(vtkDataSet *ugrid, int deleteIt);
00594 
00596 
00607   int AddUGridElementVariable(char *ugridVarName, char *origName, int numComponents);
00608   int RemoveUGridElementVariable(char *ugridVarName);
00610 
00611   int AddUGridNodeVariable(char *ugridVarName, char *origName, int numComponents);
00612   int RemoveUGridNodeVariable(char *ugridVarName);
00613 
00622   int MergeModelMetadata(const vtkModelMetadata *em);
00623 
00627   int MergeGlobalInformation(const vtkModelMetadata *em);
00628 
00630 
00635   vtkModelMetadata *ExtractModelMetadata(vtkIntArray *globalCellIdList,
00636                                      vtkDataSet *grid,
00637                                      const char *globalCellIdArrayName,
00638                                      const char *globalNodeIdArrayName);
00640 
00643   vtkModelMetadata *ExtractGlobalMetadata();
00644 
00646 
00655   void FreeAllGlobalData();
00656   void FreeAllLocalData();
00657   void FreeBlockDependentData();
00658   void FreeOriginalElementVariableNames();
00659   void FreeOriginalNodeVariableNames();
00660   void FreeUsedElementVariableNames();
00661   void FreeUsedNodeVariableNames();
00662   void FreeUsedElementVariables();
00663   void FreeUsedNodeVariables();
00665 
00667   void Reset();
00668 
00671   int GetBlockLocalIndex(int id);
00672 
00673 protected:
00674   vtkModelMetadata();
00675   ~vtkModelMetadata();
00676 
00677 private:
00678   void InitializeAllMetadata();
00679   void InitializeAllIvars();
00680 
00681   void FreeAllMetadata();
00682   void FreeAllIvars();
00683 
00684   void FreeQARecords();
00685 
00686   int BuildBlockElementIdListIndex();
00687   int BuildBlockAttributesIndex();
00688   int BuildNodeSetNodeIdListIndex();
00689   int BuildNodeSetDistributionFactorIndex();
00690   int BuildSideSetListIndex();
00691   int BuildSideSetDistributionFactorIndex();
00692 
00693   int InitializeFromSizeArray(vtkIntArray *ia, int &maxStr, int &maxLine);
00694   vtkIntArray *PackSizeArray(int maxStr, int maxLine);
00695   int InitializeFromIntArray(vtkModelMetadata *sizes, vtkIntArray *ia);
00696   vtkIntArray *PackIntArray();
00697   int InitializeFromCharArray(vtkModelMetadata *sizes, 
00698                    vtkCharArray *uca, int maxStr, int maxLine);
00699   vtkCharArray *PackCharArray(int maxStr, int maxLine);
00700   int InitializeFromFloatArray(vtkFloatArray *fa);
00701   vtkFloatArray *PackFloatArray();
00702 
00703   static char *StrDupWithNew(const char *s);
00704 
00705   static char *WriteLines(char *p, int maxLines, int maxLen, char **lines);
00706   static char *ReadLines(char ***to, int maxLines, 
00707                             int maxLen, char *from);
00708   static char **CopyLines(char **lines, int num);
00709   static int *CopyInts(int *vals, int num);
00710 
00711   static int FindNameOnList(char *name, char **list, int listLen);
00712 
00713   int MergeIdLists(int numSubLists,
00714     int *id1, int *id1Idx, int id1Len,
00715       float *dist1, int *dist1Idx, int dist1Len,
00716     int *id2, int *id2Idx, int id2Len,
00717       float *dist2, int *dist2Idx, int dist2Len,
00718     int **idNew, int **idNewIdx, int *idNewLen,
00719       float **distNew, int **distNewIdx, int *distNewLen);
00720 
00721   int AppendFloatLists(int numSubLists,
00722     float *id1, int *id1Idx, int id1Len,
00723     float *id2, int *id2Idx, int id2Len,
00724     float **idNew, int **idNewIdx, int *idNewLen);
00725 
00726   int AppendIntegerLists(int numSubLists,
00727     int *id1, int *id1Idx, int id1Len,
00728     int *id2, int *id2Idx, int id2Len,
00729     int **idNew, int **idNewIdx, int *idNewLen);
00730 
00731   void ExtractCellsFromBlockData(vtkModelMetadataSTLCloak *idset, 
00732                                  vtkModelMetadata *mmd);
00733   void ExtractNodesFromNodeSetData(vtkModelMetadataSTLCloak *idset, 
00734                                    vtkModelMetadata *mmd);
00735   void ExtractSidesFromSideSetData(vtkModelMetadataSTLCloak *idset, 
00736                                    vtkModelMetadata *mmd);
00737 
00738   void ShowFloats(const char *what, int num, float *f);
00739   void ShowLines(const char *what, int num, char **l);
00740   void ShowIntArray(const char *what, int numx, int numy, int *id);
00741   void ShowInts(const char *what, int num, int *id);
00742   void ShowListsOfInts(const char *what, int *list,
00743                        int nlists, int *idx, int len, int verbose);
00744   void ShowListsOfFloats(const char *what, float *list,
00745                          int nlists, int *idx, int len, int verbose);
00746 
00747   void SetOriginalElementVariableNames(int nvars, char **names);
00748   void SetElementVariableNames(int nvars, char **names);
00749   void SetElementVariableNumberOfComponents(int *comp);
00750   void SetMapToOriginalElementVariableNames(int *map);
00751 
00752   void SetOriginalNodeVariableNames(int nvars, char **names);
00753   void SetNodeVariableNames(int nvars, char **names);
00754   void SetNodeVariableNumberOfComponents(int *comp);
00755   void SetMapToOriginalNodeVariableNames(int *map);
00756 
00757   int CalculateMaximumLengths(int &maxString, int &maxLine);
00758 
00759   // Fields in Exodus II file and their size (defined in exodusII.h)
00760   //   (G - global fields, the same in every file)
00761   //   (L - local fields, they differ depending on which cells and nodes are
00762   //        in a file)
00763 
00764   char *Title;                 // MAX_LINE_LENGTH    (G)
00765 
00766   int NumberOfQARecords;       // (G)
00767 //BTX
00768   char *(*QARecord)[4];        // NumberOfQARecords * 4 * MAX_STR_LENGTH (G)
00769 //ETX
00770 
00771   int NumberOfInformationLines; // (G)
00772   char **InformationLine;       // each record is MAX_LINE_LENGTH (G)
00773 
00774   int Dimension;            // (G)
00775   char **CoordinateNames;   // MAX_STR_LENGTH each (at most 3 of these) (G)
00776 
00777   // Time steps
00778 
00779   int TimeStepIndex;     // starting at 0 (Exodus file starts at 1) 
00780   int NumberOfTimeSteps; // (G)
00781   float *TimeStepValues; // (G)
00782 
00783   // Block information - arrays that are input with Set*
00784 
00785   int NumberOfBlocks;       // (G)
00786 
00787   int *BlockIds;               // NumberOfBlocks (G) (start at 1)
00788   char **BlockElementType;     // NumberOfBlocks, length MAX_STR_LENGTH (G)
00789   int *BlockNumberOfElements;  // NumberOfBlocks (L)
00790   int *BlockNodesPerElement;   // NumberOfBlocks (G)
00791   int *BlockNumberOfAttributesPerElement;// NumberOfBlocks (G)
00792   int *BlockElementIdList;     // SumElementsPerBlock     (L)
00793   float *BlockAttributes;      // SizeBlockAttributeArray (L)
00794 
00795   // Block information - values that we calculate
00796 
00797   int SumElementsPerBlock;                                         
00798   int SizeBlockAttributeArray;
00799 
00800   int *BlockElementIdListIndex;          // NumberOfBlocks         
00801   int *BlockAttributesIndex;             // NumberOfBlocks
00802 
00803   vtkModelMetadataSTLCloak *BlockIdIndex;    // computed map
00804 
00805   // Node Sets - arrays that are input to the class with Set*
00806 
00807   int NumberOfNodeSets; // (G)
00808 
00809   int *NodeSetIds;             // NumberOfNodeSets (G)
00810   int *NodeSetSize;            // NumberOfNodeSets (L)
00811   int *NodeSetNumberOfDistributionFactors;  // NNS (L) (NSNDF[i] is 0 or NSS[i])
00812   int *NodeSetNodeIdList;   // SumNodesPerNodeSet (L)
00813   float *NodeSetDistributionFactors; // SumDistFactPerNodeSet (L)
00814 
00815   // Node Sets - values or arrays that the class computes
00816 
00817   int SumNodesPerNodeSet;
00818   int SumDistFactPerNodeSet;
00819 
00820   int *NodeSetNodeIdListIndex;           // NumberOfNodeSets
00821   int *NodeSetDistributionFactorIndex;   // NumberOfNodeSets
00822 
00823   // Side Sets - input to class with Set*
00824 
00825   int NumberOfSideSets; // (G)
00826   
00827   int *SideSetIds;                          // NumberOfSideSets (G)
00828   int *SideSetSize;                         // NumberOfSideSets (L)
00829   int *SideSetNumberOfDistributionFactors;  // NSS (L) (SSNDF[i] = 0 or NumNodesInSide)
00830   int *SideSetElementList;               // SumSidesPerSideSet (L)
00831   int *SideSetSideList;                  // SumSidesPerSideSet (L)
00832   int *SideSetNumDFPerSide;              // SumSidesPerSideSet (L)
00833   float *SideSetDistributionFactors;     // SumDistFactPerSideSet (L)
00834 
00835   // Side Sets - calculated by class
00836 
00837   int SumSidesPerSideSet;
00838   int SumDistFactPerSideSet;
00839 
00840   int *SideSetListIndex;                 // NumberOfSideSets
00841   int *SideSetDistributionFactorIndex;   // NumberOfSideSets
00842 
00843   // Other properties, provided as input with Set*
00844 
00845   int NumberOfBlockProperties; // (G)
00846   char **BlockPropertyNames;   // one per property, MAX_STR_LENGTH (G)
00847   int *BlockPropertyValue;     // NumBlocks * NumBlockProperties (G)
00848 
00849   int NumberOfNodeSetProperties; // (G)
00850   char **NodeSetPropertyNames;   // one per property, MAX_STR_LENGTH (G)
00851   int *NodeSetPropertyValue;     // NumNodeSets * NumNodeSetProperties (G)
00852 
00853   int NumberOfSideSetProperties; // (G)
00854   char **SideSetPropertyNames;   // one per property, MAX_STR_LENGTH (G)
00855   int *SideSetPropertyValue;     // NumSideSets * NumSideSetProperties (G)
00856 
00857   // Global variables, 1 value per time step per variable.  We store
00858   // these as floats, even if they are doubles in the file.  The values
00859   // are global in the sense that they apply to the whole data set, but
00860   // the are local in the sense that they can change with each time step.
00861   // For the purpose of this object, which represents a particular
00862   // time step, they are therefore considered "local".  (Since they need
00863   // to be updated everytime another read is done from the file.)
00864 
00865   int NumberOfGlobalVariables;   // (G)
00866   char **GlobalVariableNames;    // (G) NumberOfGlobalVariables, MAX_STR_LENGTH
00867   float *GlobalVariableValue;   // (G) NumberOfGlobalVariables
00868 
00869   // The element and node arrays in the file were all scalar arrays.
00870   // Those with similar names were combined into vectors in VTK.  Here
00871   // are all the original names from the Exodus file, the names given
00872   // the variables in the VTK ugrid, and a mapping from the VTK names
00873   // to the Exodus names.
00874 
00875   int OriginalNumberOfElementVariables;    // (G)
00876   char **OriginalElementVariableNames;     // (G) OriginalNumberOfElementVariables
00877   int NumberOfElementVariables;            // (G)
00878   int MaxNumberOfElementVariables;         // (G)
00879   char **ElementVariableNames;             // (G) MaxNumberOfElementVariables
00880   int *ElementVariableNumberOfComponents;  // (G) MaxNumberOfElementVariables
00881   int *MapToOriginalElementVariableNames;  // (G) MaxNumberOfElementVariables
00882 
00883   int OriginalNumberOfNodeVariables;       // (G)
00884   char **OriginalNodeVariableNames;        // (G) OriginalNumberOfNodeVariables
00885   int NumberOfNodeVariables;               // (G)
00886   int MaxNumberOfNodeVariables;            // (G)
00887   char **NodeVariableNames;                // (G) NumberOfNodeVariables
00888   int *NodeVariableNumberOfComponents;     // (G) NumberOfNodeVariables
00889   int *MapToOriginalNodeVariableNames;     // (G) NumberOfNodeVariables
00890 
00891   int *ElementVariableTruthTable;  // (G) NumBlocks*OrigNumberOfElementVariables
00892   int AllVariablesDefinedInAllBlocks;
00893 
00894 private:
00895   vtkModelMetadata(const vtkModelMetadata&); // Not implemented
00896   void operator=(const vtkModelMetadata&); // Not implemented
00897 };
00898 #endif