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