00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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 vtkTypeMacro(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
00745
00746
00747
00748
00749 char *Title;
00750
00751 int NumberOfQARecords;
00752
00753 char *(*QARecord)[4];
00754
00755
00756 int NumberOfInformationLines;
00757 char **InformationLine;
00758
00759 int Dimension;
00760 char **CoordinateNames;
00761
00762
00763
00764 int TimeStepIndex;
00765 int NumberOfTimeSteps;
00766 float *TimeStepValues;
00767
00768
00769
00770 int NumberOfBlocks;
00771
00772 int *BlockIds;
00773 char **BlockElementType;
00774 int *BlockNumberOfElements;
00775 int *BlockNodesPerElement;
00776 int *BlockNumberOfAttributesPerElement;
00777 int *BlockElementIdList;
00778 float *BlockAttributes;
00779
00780
00781
00782 int SumElementsPerBlock;
00783 int SizeBlockAttributeArray;
00784
00785 int *BlockElementIdListIndex;
00786 int *BlockAttributesIndex;
00787
00788 vtkModelMetadataSTLCloak *BlockIdIndex;
00789
00790
00791
00792 int NumberOfNodeSets;
00793
00794 int *NodeSetIds;
00795 int *NodeSetSize;
00796 int *NodeSetNumberOfDistributionFactors;
00797 int *NodeSetNodeIdList;
00798 float *NodeSetDistributionFactors;
00799
00800
00801
00802 int SumNodesPerNodeSet;
00803 int SumDistFactPerNodeSet;
00804
00805 int *NodeSetNodeIdListIndex;
00806 int *NodeSetDistributionFactorIndex;
00807
00808
00809
00810 int NumberOfSideSets;
00811
00812 int *SideSetIds;
00813 int *SideSetSize;
00814 int *SideSetNumberOfDistributionFactors;
00815 int *SideSetElementList;
00816 int *SideSetSideList;
00817 int *SideSetNumDFPerSide;
00818 float *SideSetDistributionFactors;
00819
00820
00821
00822 int SumSidesPerSideSet;
00823 int SumDistFactPerSideSet;
00824
00825 int *SideSetListIndex;
00826 int *SideSetDistributionFactorIndex;
00827
00828
00829
00830 int NumberOfBlockProperties;
00831 char **BlockPropertyNames;
00832 int *BlockPropertyValue;
00833
00834 int NumberOfNodeSetProperties;
00835 char **NodeSetPropertyNames;
00836 int *NodeSetPropertyValue;
00837
00838 int NumberOfSideSetProperties;
00839 char **SideSetPropertyNames;
00840 int *SideSetPropertyValue;
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850 int NumberOfGlobalVariables;
00851 char **GlobalVariableNames;
00852 float *GlobalVariableValue;
00853
00854
00855
00856
00857
00858
00859
00860 int OriginalNumberOfElementVariables;
00861 char **OriginalElementVariableNames;
00862 int NumberOfElementVariables;
00863 int MaxNumberOfElementVariables;
00864 char **ElementVariableNames;
00865 int *ElementVariableNumberOfComponents;
00866 int *MapToOriginalElementVariableNames;
00867
00868 int OriginalNumberOfNodeVariables;
00869 char **OriginalNodeVariableNames;
00870 int NumberOfNodeVariables;
00871 int MaxNumberOfNodeVariables;
00872 char **NodeVariableNames;
00873 int *NodeVariableNumberOfComponents;
00874 int *MapToOriginalNodeVariableNames;
00875
00876 int *ElementVariableTruthTable;
00877 int AllVariablesDefinedInAllBlocks;
00878
00879 private:
00880 vtkModelMetadata(const vtkModelMetadata&);
00881 void operator=(const vtkModelMetadata&);
00882 };
00883 #endif