• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

dox/Graphics/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 vtkIdTypeArray;
00086 class vtkIntArray;
00087 class vtkFloatArray;
00088 class vtkIntArray;
00089 class vtkModelMetadataSTLCloak;
00090 
00091 class VTK_GRAPHICS_EXPORT vtkModelMetadata : public vtkObject
00092 { 
00093 public:
00094   vtkTypeRevisionMacro(vtkModelMetadata, vtkObject);
00095   virtual void PrintSelf(ostream &os, vtkIndent indent);
00096   static vtkModelMetadata *New();
00097 
00102   virtual void PrintGlobalInformation();
00103 
00114   virtual void PrintLocalInformation();
00115 
00117 
00118   vtkSetStringMacro(Title);
00119   myVtkGetStringMacro(Title);
00121 
00123   void SetInformationLines(int numLines, char **lines);
00124   
00126   void AddInformationLine(char *info);
00127 
00130   int GetInformationLines(char ***lines) const;
00131 
00133   myVtkGetMacro(NumberOfInformationLines, int);
00134 
00138   void SetQARecords(int numberOfRecords, char *QARecords[][4]); 
00139   
00143   void AddQARecord(char *name, char *version, char *date, char *time);
00144 
00146 
00147   void GetQARecord(int which, 
00148           char **name, char **version, char **date, char **time) const;
00150 
00152   myVtkGetMacro(NumberOfQARecords, int);
00153 
00155 
00158   vtkSetMacro(TimeStepIndex, int);
00159   myVtkGetMacro(TimeStepIndex, int);
00161 
00163 
00166   void SetTimeSteps(int numberOfTimeSteps, float *timeStepValues);
00167   myVtkGetMacro(NumberOfTimeSteps, int);
00169 
00171   float *GetTimeStepValues() const {return this->TimeStepValues;}
00172 
00174 
00175   void SetCoordinateNames(int dimension, char **);
00176   char **GetCoordinateNames() const {return this->CoordinateNames;}
00178 
00181   myVtkGetMacro(Dimension, int);
00182 
00184 
00186   vtkSetMacro(NumberOfBlocks, int);
00187   myVtkGetMacro(NumberOfBlocks, int);
00189 
00191 
00193   void SetBlockIds(int *);
00194   int *GetBlockIds() const {return this->BlockIds;}
00196 
00198 
00201   void SetBlockElementType(char **);
00202   char **GetBlockElementType() const {return this->BlockElementType;}
00204 
00206 
00209   int SetBlockNumberOfElements(int *nelts);
00210   int *GetBlockNumberOfElements()const{return this->BlockNumberOfElements;}
00212 
00214 
00217   void SetBlockNodesPerElement(int *);
00218   int *GetBlockNodesPerElement()const{return this->BlockNodesPerElement;}
00220 
00222 
00225   void SetBlockElementIdList(int *);
00226   int *GetBlockElementIdList() const {return this->BlockElementIdList;}
00228 
00230   myVtkGetMacro(SumElementsPerBlock, int);                                         
00231 
00234   int *GetBlockElementIdListIndex()const {return this->BlockElementIdListIndex;} 
00235 
00237 
00240   int SetBlockNumberOfAttributesPerElement(int *natts);
00241   int *GetBlockNumberOfAttributesPerElement()const {return this->BlockNumberOfAttributesPerElement;}
00243 
00245 
00248   void SetBlockAttributes(float *);
00249   float *GetBlockAttributes()const {return this->BlockAttributes;}
00251 
00253   myVtkGetMacro(SizeBlockAttributeArray, int);
00254 
00257   int *GetBlockAttributesIndex()const {return this->BlockAttributesIndex;};
00258 
00260 
00262   vtkSetMacro(NumberOfNodeSets, int);
00263   myVtkGetMacro(NumberOfNodeSets, int);
00265 
00267 
00270   void SetNodeSetIds(int *);
00271   int *GetNodeSetIds()const {return this->NodeSetIds;}
00273 
00275 
00278   int SetNodeSetSize(int *);
00279   int *GetNodeSetSize()const {return this->NodeSetSize;}
00281 
00283 
00287   void SetNodeSetNodeIdList(int *);
00288   int *GetNodeSetNodeIdList()const {return this->NodeSetNodeIdList;}
00290 
00292 
00296   int SetNodeSetNumberOfDistributionFactors(int *);
00297   int *GetNodeSetNumberOfDistributionFactors()const {return this->NodeSetNumberOfDistributionFactors;}
00299 
00301 
00304   void SetNodeSetDistributionFactors(float *);
00305   float *GetNodeSetDistributionFactors()const {return this->NodeSetDistributionFactors;}
00307 
00309   myVtkGetMacro(SumNodesPerNodeSet, int);     
00310 
00312   myVtkGetMacro(SumDistFactPerNodeSet, int);
00313 
00316   int *GetNodeSetNodeIdListIndex() const {return this->NodeSetNodeIdListIndex;}
00317 
00320   int *GetNodeSetDistributionFactorIndex() const {return this->NodeSetDistributionFactorIndex;}
00321 
00323 
00325   vtkSetMacro(NumberOfSideSets, int);
00326   myVtkGetMacro(NumberOfSideSets, int);
00328 
00330 
00332   void SetSideSetIds(int *);
00333   int *GetSideSetIds()const {return this->SideSetIds;}
00335 
00337 
00340   int SetSideSetSize(int *sizes);
00341   int *GetSideSetSize()const {return this->SideSetSize;}
00343 
00345 
00349   int SetSideSetNumberOfDistributionFactors(int *df);
00350   int *GetSideSetNumberOfDistributionFactors()const {return this->SideSetNumberOfDistributionFactors;}
00352 
00354 
00358   void SetSideSetElementList(int *);
00359   int *GetSideSetElementList()const {return this->SideSetElementList;}
00361 
00363 
00368   void SetSideSetSideList( int *);
00369   int *GetSideSetSideList()const {return this->SideSetSideList;}
00371 
00373 
00377   void SetSideSetNumDFPerSide(int *numNodes);
00378   int *GetSideSetNumDFPerSide()const {return this->SideSetNumDFPerSide;}
00380 
00382 
00390   void SetSideSetDistributionFactors(float *);
00391   float *GetSideSetDistributionFactors()const {return this->SideSetDistributionFactors;}
00393 
00395   myVtkGetMacro(SumSidesPerSideSet, int);
00396 
00398   myVtkGetMacro(SumDistFactPerSideSet, int);
00399 
00402   int *GetSideSetListIndex()const {return this->SideSetListIndex;}
00403 
00406   int *GetSideSetDistributionFactorIndex()const {return this->SideSetDistributionFactorIndex;}
00407 
00409   myVtkGetMacro(NumberOfBlockProperties, int);
00410 
00412 
00413   void SetBlockPropertyNames(int numProp, char **names);
00414   char **GetBlockPropertyNames()const {return this->BlockPropertyNames;}
00416 
00418 
00420   void SetBlockPropertyValue(int *);
00421   int *GetBlockPropertyValue()const {return this->BlockPropertyValue;}
00423 
00425   myVtkGetMacro(NumberOfNodeSetProperties, int);
00426 
00428 
00429   void SetNodeSetPropertyNames(int numProp, char **names);
00430   char **GetNodeSetPropertyNames()const {return this->NodeSetPropertyNames;}
00432 
00434 
00436   void SetNodeSetPropertyValue(int *);
00437   int *GetNodeSetPropertyValue()const {return this->NodeSetPropertyValue;}
00439 
00441   myVtkGetMacro(NumberOfSideSetProperties, int);
00442 
00444 
00445   void SetSideSetPropertyNames(int numProp, char **names);
00446   char **GetSideSetPropertyNames()const {return this->SideSetPropertyNames;}
00448 
00450 
00452   void SetSideSetPropertyValue(int *);
00453   int *GetSideSetPropertyValue()const {return this->SideSetPropertyValue;}
00455 
00457   myVtkGetMacro(NumberOfGlobalVariables, int);
00458 
00460 
00461   void SetGlobalVariableNames(int numVarNames, char **n);
00462   char **GetGlobalVariableNames()const {return this->GlobalVariableNames;}
00464 
00466 
00468   void SetGlobalVariableValue(float *f);
00469   float *GetGlobalVariableValue()const {return this->GlobalVariableValue;}
00471 
00473 
00482   void SetElementVariableInfo(int numOrigNames, char **origNames,
00483             int numNames, char **names,  int *numComp, int *map);
00485 
00487 
00496   void SetNodeVariableInfo(int numOrigNames, char **origNames,
00497             int numNames, char **names,  int *numComp, int *map);
00499 
00501 
00505   void SetElementVariableTruthTable(int *);
00506   int *GetElementVariableTruthTable()const {return this->ElementVariableTruthTable;}
00508 
00510 
00512   vtkSetMacro(AllVariablesDefinedInAllBlocks, int);
00513   myVtkGetMacro(AllVariablesDefinedInAllBlocks, int);
00514   vtkBooleanMacro(AllVariablesDefinedInAllBlocks, int);
00516 
00523   int ElementVariableIsDefinedInBlock(char *varname, int blockId);
00524 
00526 
00538   myVtkGetMacro(OriginalNumberOfElementVariables, int);
00539   char **GetOriginalElementVariableNames()const {return this->OriginalElementVariableNames;}
00540   myVtkGetMacro(NumberOfElementVariables, int);
00541   char **GetElementVariableNames()const {return this->ElementVariableNames;}
00542   int *GetElementVariableNumberOfComponents()const {return this->ElementVariableNumberOfComponents;}
00543   int *GetMapToOriginalElementVariableNames()const {return this->MapToOriginalElementVariableNames;}
00545 
00546   myVtkGetMacro(OriginalNumberOfNodeVariables, int);
00547   char **GetOriginalNodeVariableNames()const {return this->OriginalNodeVariableNames;}
00548   myVtkGetMacro(NumberOfNodeVariables, int);
00549   char **GetNodeVariableNames()const {return this->NodeVariableNames;}
00550   int *GetNodeVariableNumberOfComponents()const {return this->NodeVariableNumberOfComponents;}
00551   int *GetMapToOriginalNodeVariableNames()const {return this->MapToOriginalNodeVariableNames;}
00552 
00557   char *FindOriginalElementVariableName(const char *name, int component);
00558 
00563   char *FindOriginalNodeVariableName(const char *name, int component);
00564 
00567   static int HasMetadata(vtkDataSet *grid);
00568 
00571   static void RemoveMetadata(vtkDataSet *grid);
00572 
00574   void Pack(vtkDataSet *ugrid);
00575 
00580   int Unpack(vtkDataSet *ugrid, int deleteIt);
00581 
00583 
00594   int AddUGridElementVariable(char *ugridVarName, char *origName, int numComponents);
00595   int RemoveUGridElementVariable(char *ugridVarName);
00597 
00598   int AddUGridNodeVariable(char *ugridVarName, char *origName, int numComponents);
00599   int RemoveUGridNodeVariable(char *ugridVarName);
00600 
00609   int MergeModelMetadata(const vtkModelMetadata *em);
00610 
00614   int MergeGlobalInformation(const vtkModelMetadata *em);
00615 
00617 
00622   vtkModelMetadata *ExtractModelMetadata(vtkIdTypeArray *globalCellIdList,
00623                                          vtkDataSet *grid);
00625 
00628   vtkModelMetadata *ExtractGlobalMetadata();
00629 
00631 
00640   void FreeAllGlobalData();
00641   void FreeAllLocalData();
00642   void FreeBlockDependentData();
00643   void FreeOriginalElementVariableNames();
00644   void FreeOriginalNodeVariableNames();
00645   void FreeUsedElementVariableNames();
00646   void FreeUsedNodeVariableNames();
00647   void FreeUsedElementVariables();
00648   void FreeUsedNodeVariables();
00650 
00652   void Reset();
00653 
00656   int GetBlockLocalIndex(int id);
00657 
00658 protected:
00659   vtkModelMetadata();
00660   ~vtkModelMetadata();
00661 
00662 private:
00663   void InitializeAllMetadata();
00664   void InitializeAllIvars();
00665 
00666   void FreeAllMetadata();
00667   void FreeAllIvars();
00668 
00669   void FreeQARecords();
00670 
00671   int BuildBlockElementIdListIndex();
00672   int BuildBlockAttributesIndex();
00673   int BuildNodeSetNodeIdListIndex();
00674   int BuildNodeSetDistributionFactorIndex();
00675   int BuildSideSetListIndex();
00676   int BuildSideSetDistributionFactorIndex();
00677 
00678   int InitializeFromSizeArray(vtkIntArray *ia, int &maxStr, int &maxLine);
00679   vtkIntArray *PackSizeArray(int maxStr, int maxLine);
00680   int InitializeFromIntArray(vtkModelMetadata *sizes, vtkIntArray *ia);
00681   vtkIntArray *PackIntArray();
00682   int InitializeFromCharArray(vtkModelMetadata *sizes, 
00683                    vtkCharArray *uca, int maxStr, int maxLine);
00684   vtkCharArray *PackCharArray(int maxStr, int maxLine);
00685   int InitializeFromFloatArray(vtkFloatArray *fa);
00686   vtkFloatArray *PackFloatArray();
00687 
00688   static char *StrDupWithNew(const char *s);
00689 
00690   static char *WriteLines(char *p, int maxLines, int maxLen, char **lines);
00691   static char *ReadLines(char ***to, int maxLines, 
00692                             int maxLen, char *from);
00693   static char **CopyLines(char **lines, int num);
00694   static int *CopyInts(int *vals, int num);
00695 
00696   static int FindNameOnList(char *name, char **list, int listLen);
00697 
00698   int MergeIdLists(int numSubLists,
00699     int *id1, int *id1Idx, int id1Len,
00700       float *dist1, int *dist1Idx, int dist1Len,
00701     int *id2, int *id2Idx, int id2Len,
00702       float *dist2, int *dist2Idx, int dist2Len,
00703     int **idNew, int **idNewIdx, int *idNewLen,
00704       float **distNew, int **distNewIdx, int *distNewLen);
00705 
00706   int AppendFloatLists(int numSubLists,
00707     float *id1, int *id1Idx, int id1Len,
00708     float *id2, int *id2Idx, int id2Len,
00709     float **idNew, int **idNewIdx, int *idNewLen);
00710 
00711   int AppendIntegerLists(int numSubLists,
00712     int *id1, int *id1Idx, int id1Len,
00713     int *id2, int *id2Idx, int id2Len,
00714     int **idNew, int **idNewIdx, int *idNewLen);
00715 
00716   void ExtractCellsFromBlockData(vtkModelMetadataSTLCloak *idset, 
00717                                  vtkModelMetadata *mmd);
00718   void ExtractNodesFromNodeSetData(vtkModelMetadataSTLCloak *idset, 
00719                                    vtkModelMetadata *mmd);
00720   void ExtractSidesFromSideSetData(vtkModelMetadataSTLCloak *idset, 
00721                                    vtkModelMetadata *mmd);
00722 
00723   void ShowFloats(const char *what, int num, float *f);
00724   void ShowLines(const char *what, int num, char **l);
00725   void ShowIntArray(const char *what, int numx, int numy, int *id);
00726   void ShowInts(const char *what, int num, int *id);
00727   void ShowListsOfInts(const char *what, int *list,
00728                        int nlists, int *idx, int len, int verbose);
00729   void ShowListsOfFloats(const char *what, float *list,
00730                          int nlists, int *idx, int len, int verbose);
00731 
00732   void SetOriginalElementVariableNames(int nvars, char **names);
00733   void SetElementVariableNames(int nvars, char **names);
00734   void SetElementVariableNumberOfComponents(int *comp);
00735   void SetMapToOriginalElementVariableNames(int *map);
00736 
00737   void SetOriginalNodeVariableNames(int nvars, char **names);
00738   void SetNodeVariableNames(int nvars, char **names);
00739   void SetNodeVariableNumberOfComponents(int *comp);
00740   void SetMapToOriginalNodeVariableNames(int *map);
00741 
00742   int CalculateMaximumLengths(int &maxString, int &maxLine);
00743 
00744   // Fields in Exodus II file and their size (defined in exodusII.h)
00745   //   (G - global fields, relevant to entire file or file set)
00746   //   (L - local fields, they differ depending on which cells and nodes are
00747   //        in a file of a partitioned set, or are read in from file)
00748 
00749   char *Title;                 // (G)
00750 
00751   int NumberOfQARecords;       // (G)
00752 //BTX
00753   char *(*QARecord)[4];        // NumberOfQARecords * 4 (G)
00754 //ETX
00755 
00756   int NumberOfInformationLines; // (G)
00757   char **InformationLine;       // (G)
00758 
00759   int Dimension;            // (G)
00760   char **CoordinateNames;   // (at most 3 of these) (G)
00761 
00762   // Time steps
00763 
00764   int TimeStepIndex;     // starting at 0 (Exodus file starts at 1) 
00765   int NumberOfTimeSteps; // (G)
00766   float *TimeStepValues; // (G)
00767 
00768   // Block information - arrays that are input with Set*
00769 
00770   int NumberOfBlocks;       // (G)
00771 
00772   int *BlockIds;               // NumberOfBlocks (G) (start at 1)
00773   char **BlockElementType;     // NumberOfBlocks (G)
00774   int *BlockNumberOfElements;  // NumberOfBlocks (L)
00775   int *BlockNodesPerElement;   // NumberOfBlocks (G)
00776   int *BlockNumberOfAttributesPerElement;// NumberOfBlocks (G)
00777   int *BlockElementIdList;     // SumElementsPerBlock     (L)
00778   float *BlockAttributes;      // SizeBlockAttributeArray (L)
00779 
00780   // Block information - values that we calculate
00781 
00782   int SumElementsPerBlock;                                         
00783   int SizeBlockAttributeArray;
00784 
00785   int *BlockElementIdListIndex;          // NumberOfBlocks         
00786   int *BlockAttributesIndex;             // NumberOfBlocks
00787 
00788   vtkModelMetadataSTLCloak *BlockIdIndex;    // computed map
00789 
00790   // Node Sets - arrays that are input to the class with Set*
00791 
00792   int NumberOfNodeSets; // (G)
00793 
00794   int *NodeSetIds;             // NumberOfNodeSets (G)
00795   int *NodeSetSize;            // NumberOfNodeSets (L)
00796   int *NodeSetNumberOfDistributionFactors;  // NNS (L) (NSNDF[i] is 0 or NSS[i])
00797   int *NodeSetNodeIdList;   // SumNodesPerNodeSet (L)
00798   float *NodeSetDistributionFactors; // SumDistFactPerNodeSet (L)
00799 
00800   // Node Sets - values or arrays that the class computes
00801 
00802   int SumNodesPerNodeSet;
00803   int SumDistFactPerNodeSet;
00804 
00805   int *NodeSetNodeIdListIndex;           // NumberOfNodeSets
00806   int *NodeSetDistributionFactorIndex;   // NumberOfNodeSets
00807 
00808   // Side Sets - input to class with Set*
00809 
00810   int NumberOfSideSets; // (G)
00811   
00812   int *SideSetIds;                          // NumberOfSideSets (G)
00813   int *SideSetSize;                         // NumberOfSideSets (L)
00814   int *SideSetNumberOfDistributionFactors;  // NSS (L) (SSNDF[i] = 0 or NumNodesInSide)
00815   int *SideSetElementList;               // SumSidesPerSideSet (L)
00816   int *SideSetSideList;                  // SumSidesPerSideSet (L)
00817   int *SideSetNumDFPerSide;              // SumSidesPerSideSet (L)
00818   float *SideSetDistributionFactors;     // SumDistFactPerSideSet (L)
00819 
00820   // Side Sets - calculated by class
00821 
00822   int SumSidesPerSideSet;
00823   int SumDistFactPerSideSet;
00824 
00825   int *SideSetListIndex;                 // NumberOfSideSets
00826   int *SideSetDistributionFactorIndex;   // NumberOfSideSets
00827 
00828   // Other properties, provided as input with Set*
00829 
00830   int NumberOfBlockProperties; // (G)
00831   char **BlockPropertyNames;   // one per property (G)
00832   int *BlockPropertyValue;     // NumBlocks * NumBlockProperties (G)
00833 
00834   int NumberOfNodeSetProperties; // (G)
00835   char **NodeSetPropertyNames;   // one per property (G)
00836   int *NodeSetPropertyValue;     // NumNodeSets * NumNodeSetProperties (G)
00837 
00838   int NumberOfSideSetProperties; // (G)
00839   char **SideSetPropertyNames;   // one per property (G)
00840   int *SideSetPropertyValue;     // NumSideSets * NumSideSetProperties (G)
00841 
00842   // Global variables, 1 value per time step per variable.  We store
00843   // these as floats, even if they are doubles in the file.  The values
00844   // are global in the sense that they apply to the whole data set, but
00845   // the are local in the sense that they can change with each time step.
00846   // For the purpose of this object, which represents a particular
00847   // time step, they are therefore considered "local".  (Since they need
00848   // to be updated everytime another read is done from the file.)
00849 
00850   int NumberOfGlobalVariables;   // (G)
00851   char **GlobalVariableNames;    // (G) NumberOfGlobalVariables
00852   float *GlobalVariableValue;   // (G) NumberOfGlobalVariables
00853 
00854   // The element and node arrays in the file were all scalar arrays.
00855   // Those with similar names were combined into vectors in VTK.  Here
00856   // are all the original names from the Exodus file, the names given
00857   // the variables in the VTK ugrid, and a mapping from the VTK names
00858   // to the Exodus names.
00859 
00860   int OriginalNumberOfElementVariables;    // (G)
00861   char **OriginalElementVariableNames;     // (G) OriginalNumberOfElementVariables
00862   int NumberOfElementVariables;            // (G)
00863   int MaxNumberOfElementVariables;         // (G)
00864   char **ElementVariableNames;             // (G) MaxNumberOfElementVariables
00865   int *ElementVariableNumberOfComponents;  // (G) MaxNumberOfElementVariables
00866   int *MapToOriginalElementVariableNames;  // (G) MaxNumberOfElementVariables
00867 
00868   int OriginalNumberOfNodeVariables;       // (G)
00869   char **OriginalNodeVariableNames;        // (G) OriginalNumberOfNodeVariables
00870   int NumberOfNodeVariables;               // (G)
00871   int MaxNumberOfNodeVariables;            // (G)
00872   char **NodeVariableNames;                // (G) NumberOfNodeVariables
00873   int *NodeVariableNumberOfComponents;     // (G) NumberOfNodeVariables
00874   int *MapToOriginalNodeVariableNames;     // (G) NumberOfNodeVariables
00875 
00876   int *ElementVariableTruthTable;  // (G) NumBlocks*OrigNumberOfElementVariables
00877   int AllVariablesDefinedInAllBlocks;
00878 
00879 private:
00880   vtkModelMetadata(const vtkModelMetadata&); // Not implemented
00881   void operator=(const vtkModelMetadata&); // Not implemented
00882 };
00883 #endif

Generated by  doxygen 1.7.1