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