Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | 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 
00074 #ifndef __vtkModelMetadata_h
00075 #define __vtkModelMetadata_h
00076 
00077 #include "vtkObject.h"
00078 
00079 #define myVtkGetMacro(name, type) virtual type Get##name() const { return this->name; }
00080 
00081 #define myVtkGetStringMacro(name) virtual char* Get##name () const { return this->name; }
00082 
00083 class vtkDataSet;
00084 class vtkCharArray;
00085 class vtkIntArray;
00086 class vtkFloatArray;
00087 class vtkIntArray;
00088 class vtkModelMetadataSTLCloak;
00089 
00090 class VTK_GRAPHICS_EXPORT vtkModelMetadata : public vtkObject
00091 { 
00092 public:
00093   vtkTypeRevisionMacro(vtkModelMetadata, vtkObject);
00094   virtual void PrintSelf(ostream &os, vtkIndent indent);
00095   static vtkModelMetadata *New();
00096 
00101   virtual void PrintGlobalInformation();
00102 
00113   virtual void PrintLocalInformation();
00114 
00116 
00117   vtkSetStringMacro(Title);
00118   myVtkGetStringMacro(Title);
00120 
00122   void SetInformationLines(int numLines, char **lines);
00123   
00125   void AddInformationLine(char *info);
00126 
00129   int GetInformationLines(char ***lines) const;
00130 
00132   myVtkGetMacro(NumberOfInformationLines, int);
00133 
00137   void SetQARecords(int numberOfRecords, char *QARecords[][4]); 
00138   
00142   void AddQARecord(char *name, char *version, char *date, char *time);
00143 
00145 
00146   void GetQARecord(int which, 
00147           char **name, char **version, char **date, char **time) const;
00149 
00151   myVtkGetMacro(NumberOfQARecords, int);
00152 
00154 
00157   vtkSetMacro(TimeStepIndex, int);
00158   myVtkGetMacro(TimeStepIndex, int);
00160 
00162 
00165   void SetTimeSteps(int numberOfTimeSteps, float *timeStepValues);
00166   myVtkGetMacro(NumberOfTimeSteps, int);
00168 
00170   float *GetTimeStepValues() const {return this->TimeStepValues;}
00171 
00173 
00174   void SetCoordinateNames(int dimension, char **);
00175   char **GetCoordinateNames() const {return this->CoordinateNames;}
00177 
00180   myVtkGetMacro(Dimension, int);
00181 
00183 
00185   vtkSetMacro(NumberOfBlocks, int);
00186   myVtkGetMacro(NumberOfBlocks, int);
00188 
00190 
00192   void SetBlockIds(int *);
00193   int *GetBlockIds() const {return this->BlockIds;}
00195 
00197 
00200   void SetBlockElementType(char **);
00201   char **GetBlockElementType() const {return this->BlockElementType;}
00203 
00205 
00208   int SetBlockNumberOfElements(int *nelts);
00209   int *GetBlockNumberOfElements()const{return this->BlockNumberOfElements;}
00211 
00213 
00216   void SetBlockNodesPerElement(int *);
00217   int *GetBlockNodesPerElement()const{return this->BlockNodesPerElement;}
00219 
00221 
00224   void SetBlockElementIdList(int *);
00225   int *GetBlockElementIdList() const {return this->BlockElementIdList;}
00227 
00229   myVtkGetMacro(SumElementsPerBlock, int);                                         
00230 
00233   int *GetBlockElementIdListIndex()const {return this->BlockElementIdListIndex;} 
00234 
00236 
00239   int SetBlockNumberOfAttributesPerElement(int *natts);
00240   int *GetBlockNumberOfAttributesPerElement()const {return this->BlockNumberOfAttributesPerElement;}
00242 
00244 
00247   void SetBlockAttributes(float *);
00248   float *GetBlockAttributes()const {return this->BlockAttributes;}
00250 
00252   myVtkGetMacro(SizeBlockAttributeArray, int);
00253 
00256   int *GetBlockAttributesIndex()const {return this->BlockAttributesIndex;};
00257 
00259 
00261   vtkSetMacro(NumberOfNodeSets, int);
00262   myVtkGetMacro(NumberOfNodeSets, int);
00264 
00266 
00269   void SetNodeSetIds(int *);
00270   int *GetNodeSetIds()const {return this->NodeSetIds;}
00272 
00274 
00277   int SetNodeSetSize(int *);
00278   int *GetNodeSetSize()const {return this->NodeSetSize;}
00280 
00282 
00286   void SetNodeSetNodeIdList(int *);
00287   int *GetNodeSetNodeIdList()const {return this->NodeSetNodeIdList;}
00289 
00291 
00295   int SetNodeSetNumberOfDistributionFactors(int *);
00296   int *GetNodeSetNumberOfDistributionFactors()const {return this->NodeSetNumberOfDistributionFactors;}
00298 
00300 
00303   void SetNodeSetDistributionFactors(float *);
00304   float *GetNodeSetDistributionFactors()const {return this->NodeSetDistributionFactors;}
00306 
00308   myVtkGetMacro(SumNodesPerNodeSet, int);     
00309 
00311   myVtkGetMacro(SumDistFactPerNodeSet, int);
00312 
00315   int *GetNodeSetNodeIdListIndex() const {return this->NodeSetNodeIdListIndex;}
00316 
00319   int *GetNodeSetDistributionFactorIndex() const {return this->NodeSetDistributionFactorIndex;}
00320 
00322 
00324   vtkSetMacro(NumberOfSideSets, int);
00325   myVtkGetMacro(NumberOfSideSets, int);
00327 
00329 
00331   void SetSideSetIds(int *);
00332   int *GetSideSetIds()const {return this->SideSetIds;}
00334 
00336 
00339   int SetSideSetSize(int *sizes);
00340   int *GetSideSetSize()const {return this->SideSetSize;}
00342 
00344 
00348   int SetSideSetNumberOfDistributionFactors(int *df);
00349   int *GetSideSetNumberOfDistributionFactors()const {return this->SideSetNumberOfDistributionFactors;}
00351 
00353 
00357   void SetSideSetElementList(int *);
00358   int *GetSideSetElementList()const {return this->SideSetElementList;}
00360 
00362 
00367   void SetSideSetSideList( int *);
00368   int *GetSideSetSideList()const {return this->SideSetSideList;}
00370 
00372 
00376   void SetSideSetNumDFPerSide(int *numNodes);
00377   int *GetSideSetNumDFPerSide()const {return this->SideSetNumDFPerSide;}
00379 
00381 
00389   void SetSideSetDistributionFactors(float *);
00390   float *GetSideSetDistributionFactors()const {return this->SideSetDistributionFactors;}
00392 
00394   myVtkGetMacro(SumSidesPerSideSet, int);
00395 
00397   myVtkGetMacro(SumDistFactPerSideSet, int);
00398 
00401   int *GetSideSetListIndex()const {return this->SideSetListIndex;}
00402 
00405   int *GetSideSetDistributionFactorIndex()const {return this->SideSetDistributionFactorIndex;}
00406 
00408   myVtkGetMacro(NumberOfBlockProperties, int);
00409 
00411 
00412   void SetBlockPropertyNames(int numProp, char **names);
00413   char **GetBlockPropertyNames()const {return this->BlockPropertyNames;}
00415 
00417 
00419   void SetBlockPropertyValue(int *);
00420   int *GetBlockPropertyValue()const {return this->BlockPropertyValue;}
00422 
00424   myVtkGetMacro(NumberOfNodeSetProperties, int);
00425 
00427 
00428   void SetNodeSetPropertyNames(int numProp, char **names);
00429   char **GetNodeSetPropertyNames()const {return this->NodeSetPropertyNames;}
00431 
00433 
00435   void SetNodeSetPropertyValue(int *);
00436   int *GetNodeSetPropertyValue()const {return this->NodeSetPropertyValue;}
00438 
00440   myVtkGetMacro(NumberOfSideSetProperties, int);
00441 
00443 
00444   void SetSideSetPropertyNames(int numProp, char **names);
00445   char **GetSideSetPropertyNames()const {return this->SideSetPropertyNames;}
00447 
00449 
00451   void SetSideSetPropertyValue(int *);
00452   int *GetSideSetPropertyValue()const {return this->SideSetPropertyValue;}
00454 
00456   myVtkGetMacro(NumberOfGlobalVariables, int);
00457 
00459 
00460   void SetGlobalVariableNames(int numVarNames, char **n);
00461   char **GetGlobalVariableNames()const {return this->GlobalVariableNames;}
00463 
00465 
00467   void SetGlobalVariableValue(float *f);
00468   float *GetGlobalVariableValue()const {return this->GlobalVariableValue;}
00470 
00472 
00481   void SetElementVariableInfo(int numOrigNames, char **origNames,
00482             int numNames, char **names,  int *numComp, int *map);
00484 
00486 
00495   void SetNodeVariableInfo(int numOrigNames, char **origNames,
00496             int numNames, char **names,  int *numComp, int *map);
00498 
00500 
00504   void SetElementVariableTruthTable(int *);
00505   int *GetElementVariableTruthTable()const {return this->ElementVariableTruthTable;}
00507 
00509 
00511   vtkSetMacro(AllVariablesDefinedInAllBlocks, int);
00512   myVtkGetMacro(AllVariablesDefinedInAllBlocks, int);
00513   vtkBooleanMacro(AllVariablesDefinedInAllBlocks, int);
00515 
00522   int ElementVariableIsDefinedInBlock(char *varname, int blockId);
00523 
00525 
00537   myVtkGetMacro(OriginalNumberOfElementVariables, int);
00538   char **GetOriginalElementVariableNames()const {return this->OriginalElementVariableNames;}
00539   myVtkGetMacro(NumberOfElementVariables, int);
00540   char **GetElementVariableNames()const {return this->ElementVariableNames;}
00541   int *GetElementVariableNumberOfComponents()const {return this->ElementVariableNumberOfComponents;}
00542   int *GetMapToOriginalElementVariableNames()const {return this->MapToOriginalElementVariableNames;}
00544 
00545   myVtkGetMacro(OriginalNumberOfNodeVariables, int);
00546   char **GetOriginalNodeVariableNames()const {return this->OriginalNodeVariableNames;}
00547   myVtkGetMacro(NumberOfNodeVariables, int);
00548   char **GetNodeVariableNames()const {return this->NodeVariableNames;}
00549   int *GetNodeVariableNumberOfComponents()const {return this->NodeVariableNumberOfComponents;}
00550   int *GetMapToOriginalNodeVariableNames()const {return this->MapToOriginalNodeVariableNames;}
00551 
00556   char *FindOriginalElementVariableName(const char *name, int component);
00557 
00562   char *FindOriginalNodeVariableName(const char *name, int component);
00563 
00566   static int HasMetadata(vtkDataSet *grid);
00567 
00570   static void RemoveMetadata(vtkDataSet *grid);
00571 
00573   void Pack(vtkDataSet *ugrid);
00574 
00579   int Unpack(vtkDataSet *ugrid, int deleteIt);
00580 
00582 
00593   int AddUGridElementVariable(char *ugridVarName, char *origName, int numComponents);
00594   int RemoveUGridElementVariable(char *ugridVarName);
00596 
00597   int AddUGridNodeVariable(char *ugridVarName, char *origName, int numComponents);
00598   int RemoveUGridNodeVariable(char *ugridVarName);
00599 
00608   int MergeModelMetadata(const vtkModelMetadata *em);
00609 
00613   int MergeGlobalInformation(const vtkModelMetadata *em);
00614 
00616 
00621   vtkModelMetadata *ExtractModelMetadata(vtkIntArray *globalCellIdList,
00622                                      vtkDataSet *grid,
00623                                      const char *globalCellIdArrayName,
00624                                      const char *globalNodeIdArrayName);
00626 
00629   vtkModelMetadata *ExtractGlobalMetadata();
00630 
00632 
00641   void FreeAllGlobalData();
00642   void FreeAllLocalData();
00643   void FreeBlockDependentData();
00644   void FreeOriginalElementVariableNames();
00645   void FreeOriginalNodeVariableNames();
00646   void FreeUsedElementVariableNames();
00647   void FreeUsedNodeVariableNames();
00648   void FreeUsedElementVariables();
00649   void FreeUsedNodeVariables();
00651 
00653   void Reset();
00654 
00657   int GetBlockLocalIndex(int id);
00658 
00659 protected:
00660   vtkModelMetadata();
00661   ~vtkModelMetadata();
00662 
00663 private:
00664   void InitializeAllMetadata();
00665   void InitializeAllIvars();
00666 
00667   void FreeAllMetadata();
00668   void FreeAllIvars();
00669 
00670   void FreeQARecords();
00671 
00672   int BuildBlockElementIdListIndex();
00673   int BuildBlockAttributesIndex();
00674   int BuildNodeSetNodeIdListIndex();
00675   int BuildNodeSetDistributionFactorIndex();
00676   int BuildSideSetListIndex();
00677   int BuildSideSetDistributionFactorIndex();
00678 
00679   int InitializeFromSizeArray(vtkIntArray *ia, int &maxStr, int &maxLine);
00680   vtkIntArray *PackSizeArray(int maxStr, int maxLine);
00681   int InitializeFromIntArray(vtkModelMetadata *sizes, vtkIntArray *ia);
00682   vtkIntArray *PackIntArray();
00683   int InitializeFromCharArray(vtkModelMetadata *sizes, 
00684                    vtkCharArray *uca, int maxStr, int maxLine);
00685   vtkCharArray *PackCharArray(int maxStr, int maxLine);
00686   int InitializeFromFloatArray(vtkFloatArray *fa);
00687   vtkFloatArray *PackFloatArray();
00688 
00689   static char *StrDupWithNew(const char *s);
00690 
00691   static char *WriteLines(char *p, int maxLines, int maxLen, char **lines);
00692   static char *ReadLines(char ***to, int maxLines, 
00693                             int maxLen, char *from);
00694   static char **CopyLines(char **lines, int num);
00695   static int *CopyInts(int *vals, int num);
00696 
00697   static int FindNameOnList(char *name, char **list, int listLen);
00698 
00699   int MergeIdLists(int numSubLists,
00700     int *id1, int *id1Idx, int id1Len,
00701       float *dist1, int *dist1Idx, int dist1Len,
00702     int *id2, int *id2Idx, int id2Len,
00703       float *dist2, int *dist2Idx, int dist2Len,
00704     int **idNew, int **idNewIdx, int *idNewLen,
00705       float **distNew, int **distNewIdx, int *distNewLen);
00706 
00707   int AppendFloatLists(int numSubLists,
00708     float *id1, int *id1Idx, int id1Len,
00709     float *id2, int *id2Idx, int id2Len,
00710     float **idNew, int **idNewIdx, int *idNewLen);
00711 
00712   int AppendIntegerLists(int numSubLists,
00713     int *id1, int *id1Idx, int id1Len,
00714     int *id2, int *id2Idx, int id2Len,
00715     int **idNew, int **idNewIdx, int *idNewLen);
00716 
00717   void ExtractCellsFromBlockData(vtkModelMetadataSTLCloak *idset, 
00718                                  vtkModelMetadata *mmd);
00719   void ExtractNodesFromNodeSetData(vtkModelMetadataSTLCloak *idset, 
00720                                    vtkModelMetadata *mmd);
00721   void ExtractSidesFromSideSetData(vtkModelMetadataSTLCloak *idset, 
00722                                    vtkModelMetadata *mmd);
00723 
00724   void ShowFloats(const char *what, int num, float *f);
00725   void ShowLines(const char *what, int num, char **l);
00726   void ShowIntArray(const char *what, int numx, int numy, int *id);
00727   void ShowInts(const char *what, int num, int *id);
00728   void ShowListsOfInts(const char *what, int *list,
00729                        int nlists, int *idx, int len, int verbose);
00730   void ShowListsOfFloats(const char *what, float *list,
00731                          int nlists, int *idx, int len, int verbose);
00732 
00733   void SetOriginalElementVariableNames(int nvars, char **names);
00734   void SetElementVariableNames(int nvars, char **names);
00735   void SetElementVariableNumberOfComponents(int *comp);
00736   void SetMapToOriginalElementVariableNames(int *map);
00737 
00738   void SetOriginalNodeVariableNames(int nvars, char **names);
00739   void SetNodeVariableNames(int nvars, char **names);
00740   void SetNodeVariableNumberOfComponents(int *comp);
00741   void SetMapToOriginalNodeVariableNames(int *map);
00742 
00743   int CalculateMaximumLengths(int &maxString, int &maxLine);
00744 
00745   // Fields in Exodus II file and their size (defined in exodusII.h)
00746   //   (G - global fields, relevant to entire file or file set)
00747   //   (L - local fields, they differ depending on which cells and nodes are
00748   //        in a file of a partitioned set, or are read in from file)
00749 
00750   char *Title;                 // (G)
00751 
00752   int NumberOfQARecords;       // (G)
00753 //BTX
00754   char *(*QARecord)[4];        // NumberOfQARecords * 4 (G)
00755 //ETX
00756 
00757   int NumberOfInformationLines; // (G)
00758   char **InformationLine;       // (G)
00759 
00760   int Dimension;            // (G)
00761   char **CoordinateNames;   // (at most 3 of these) (G)
00762 
00763   // Time steps
00764 
00765   int TimeStepIndex;     // starting at 0 (Exodus file starts at 1) 
00766   int NumberOfTimeSteps; // (G)
00767   float *TimeStepValues; // (G)
00768 
00769   // Block information - arrays that are input with Set*
00770 
00771   int NumberOfBlocks;       // (G)
00772 
00773   int *BlockIds;               // NumberOfBlocks (G) (start at 1)
00774   char **BlockElementType;     // NumberOfBlocks (G)
00775   int *BlockNumberOfElements;  // NumberOfBlocks (L)
00776   int *BlockNodesPerElement;   // NumberOfBlocks (G)
00777   int *BlockNumberOfAttributesPerElement;// NumberOfBlocks (G)
00778   int *BlockElementIdList;     // SumElementsPerBlock     (L)
00779   float *BlockAttributes;      // SizeBlockAttributeArray (L)
00780 
00781   // Block information - values that we calculate
00782 
00783   int SumElementsPerBlock;                                         
00784   int SizeBlockAttributeArray;
00785 
00786   int *BlockElementIdListIndex;          // NumberOfBlocks         
00787   int *BlockAttributesIndex;             // NumberOfBlocks
00788 
00789   vtkModelMetadataSTLCloak *BlockIdIndex;    // computed map
00790 
00791   // Node Sets - arrays that are input to the class with Set*
00792 
00793   int NumberOfNodeSets; // (G)
00794 
00795   int *NodeSetIds;             // NumberOfNodeSets (G)
00796   int *NodeSetSize;            // NumberOfNodeSets (L)
00797   int *NodeSetNumberOfDistributionFactors;  // NNS (L) (NSNDF[i] is 0 or NSS[i])
00798   int *NodeSetNodeIdList;   // SumNodesPerNodeSet (L)
00799   float *NodeSetDistributionFactors; // SumDistFactPerNodeSet (L)
00800 
00801   // Node Sets - values or arrays that the class computes
00802 
00803   int SumNodesPerNodeSet;
00804   int SumDistFactPerNodeSet;
00805 
00806   int *NodeSetNodeIdListIndex;           // NumberOfNodeSets
00807   int *NodeSetDistributionFactorIndex;   // NumberOfNodeSets
00808 
00809   // Side Sets - input to class with Set*
00810 
00811   int NumberOfSideSets; // (G)
00812   
00813   int *SideSetIds;                          // NumberOfSideSets (G)
00814   int *SideSetSize;                         // NumberOfSideSets (L)
00815   int *SideSetNumberOfDistributionFactors;  // NSS (L) (SSNDF[i] = 0 or NumNodesInSide)
00816   int *SideSetElementList;               // SumSidesPerSideSet (L)
00817   int *SideSetSideList;                  // SumSidesPerSideSet (L)
00818   int *SideSetNumDFPerSide;              // SumSidesPerSideSet (L)
00819   float *SideSetDistributionFactors;     // SumDistFactPerSideSet (L)
00820 
00821   // Side Sets - calculated by class
00822 
00823   int SumSidesPerSideSet;
00824   int SumDistFactPerSideSet;
00825 
00826   int *SideSetListIndex;                 // NumberOfSideSets
00827   int *SideSetDistributionFactorIndex;   // NumberOfSideSets
00828 
00829   // Other properties, provided as input with Set*
00830 
00831   int NumberOfBlockProperties; // (G)
00832   char **BlockPropertyNames;   // one per property (G)
00833   int *BlockPropertyValue;     // NumBlocks * NumBlockProperties (G)
00834 
00835   int NumberOfNodeSetProperties; // (G)
00836   char **NodeSetPropertyNames;   // one per property (G)
00837   int *NodeSetPropertyValue;     // NumNodeSets * NumNodeSetProperties (G)
00838 
00839   int NumberOfSideSetProperties; // (G)
00840   char **SideSetPropertyNames;   // one per property (G)
00841   int *SideSetPropertyValue;     // NumSideSets * NumSideSetProperties (G)
00842 
00843   // Global variables, 1 value per time step per variable.  We store
00844   // these as floats, even if they are doubles in the file.  The values
00845   // are global in the sense that they apply to the whole data set, but
00846   // the are local in the sense that they can change with each time step.
00847   // For the purpose of this object, which represents a particular
00848   // time step, they are therefore considered "local".  (Since they need
00849   // to be updated everytime another read is done from the file.)
00850 
00851   int NumberOfGlobalVariables;   // (G)
00852   char **GlobalVariableNames;    // (G) NumberOfGlobalVariables
00853   float *GlobalVariableValue;   // (G) NumberOfGlobalVariables
00854 
00855   // The element and node arrays in the file were all scalar arrays.
00856   // Those with similar names were combined into vectors in VTK.  Here
00857   // are all the original names from the Exodus file, the names given
00858   // the variables in the VTK ugrid, and a mapping from the VTK names
00859   // to the Exodus names.
00860 
00861   int OriginalNumberOfElementVariables;    // (G)
00862   char **OriginalElementVariableNames;     // (G) OriginalNumberOfElementVariables
00863   int NumberOfElementVariables;            // (G)
00864   int MaxNumberOfElementVariables;         // (G)
00865   char **ElementVariableNames;             // (G) MaxNumberOfElementVariables
00866   int *ElementVariableNumberOfComponents;  // (G) MaxNumberOfElementVariables
00867   int *MapToOriginalElementVariableNames;  // (G) MaxNumberOfElementVariables
00868 
00869   int OriginalNumberOfNodeVariables;       // (G)
00870   char **OriginalNodeVariableNames;        // (G) OriginalNumberOfNodeVariables
00871   int NumberOfNodeVariables;               // (G)
00872   int MaxNumberOfNodeVariables;            // (G)
00873   char **NodeVariableNames;                // (G) NumberOfNodeVariables
00874   int *NodeVariableNumberOfComponents;     // (G) NumberOfNodeVariables
00875   int *MapToOriginalNodeVariableNames;     // (G) NumberOfNodeVariables
00876 
00877   int *ElementVariableTruthTable;  // (G) NumBlocks*OrigNumberOfElementVariables
00878   int AllVariablesDefinedInAllBlocks;
00879 
00880 private:
00881   vtkModelMetadata(const vtkModelMetadata&); // Not implemented
00882   void operator=(const vtkModelMetadata&); // Not implemented
00883 };
00884 #endif

Generated on Mon Jan 21 23:07:25 2008 for VTK by  doxygen 1.4.3-20050530