VTK
vtkExodusIIReaderParser.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: vtkExodusIIReaderParser.h
5 
6  Copyright (c) Kitware, Inc.
7  All rights reserved.
8  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
22 #ifndef __vtkExodusIIReaderParser_h
23 #define __vtkExodusIIReaderParser_h
24 
25 #include "vtkXMLParser.h"
26 #include "vtkSmartPointer.h"
27 
28 #include <vtksys/ios/sstream>
29 #include <vtkstd/map>
30 #include <vtkstd/vector>
31 #include <vtkstd/set>
32 #include <vtkstd/string>
33 
35 class vtkStringArray;
37 
39 {
40 public:
41  static vtkExodusIIReaderParser* New();
43  void PrintSelf(ostream& os, vtkIndent indent);
44 
46 
47  vtkGetObjectMacro(SIL, vtkMutableDirectedGraph);
49 
51  void Go(const char* filename);
52 
53  // Returns if the parser has some information about the block with given "id".
54  // This is valid only after Go().
55  bool HasInformationAboutBlock(int id)
56  {
57  return (this->BlockID_To_VertexID.find(id) != this->BlockID_To_VertexID.end());
58  }
59 
62  vtkstd::string GetBlockName(int id);
63 
65 
67  void GetBlockIds(vtkstd::set<int>& blockIdsSet)
68  {
69  vtkstd::map<int, vtkIdType>::iterator iter;
70  for (iter = this->BlockID_To_VertexID.begin();
71  iter != this->BlockID_To_VertexID.end();
72  ++iter)
73  {
74  blockIdsSet.insert(iter->first);
75  }
76  }
77 //BTX
78 protected:
82 
83  virtual void StartElement( const char* tagName, const char** attrs);
84  virtual void EndElement(const char* tagName);
85  void FinishedParsing();
86 
87  const char* GetValue(const char* attr,const char** attrs)
88  {
89  int i;
90  for (i=0;attrs[i];i+=2)
91  {
92  const char* name=strrchr(attrs[i],':');
93  if (!name)
94  {
95  name=attrs[i];
96  }
97  else
98  {
99  name++;
100  }
101  if (strcmp(attr,name)==0)
102  {
103  return attrs[i+1];
104  }
105  }
106  return NULL;
107  }
108 
109  // Convenience methods to add vertices/edges to the SIL.
110  vtkIdType AddVertexToSIL(const char* name);
111  vtkIdType AddChildEdgeToSIL(vtkIdType src, vtkIdType dst);
112  vtkIdType AddCrossEdgeToSIL(vtkIdType src, vtkIdType dst);
113 
117  vtkIdType GetPartVertex(const char* part_number_instance_string);
118 
119  // For each of the blocks, this maps the "id" attribute in the XML to the
120  // vertex id for the block in the SIL.
121  vtkstd::map<int, vtkIdType> BlockID_To_VertexID;
122 
123 
124  // Maps block "id"s to material names.
125  vtkstd::map<int, vtkstd::string> BlockID_To_MaterialName;
126 
127  // Maps material name to vertex id.
128  // This will be build only if <material-list> is present in the XML.
129  vtkstd::map<vtkstd::string, vtkIdType> MaterialName_To_VertexID;
130 
131  vtkstd::map<vtkIdType, vtkstd::string> PartVertexID_To_Descriptions;
132 
133  // These save the values read from <material-specification /> element present
134  // withint the <part /> elements.
135  // key: part vertex id
136  // value: material name = (desp + spec)
137  vtkstd::map<vtkIdType, vtkstd::string> MaterialSpecifications;
138 
139  // Maps the "{part-number} Instance: {part-instance}" key for the vertex id
140  // for the part vertex in the Assemblies hierarchy.
141  vtkstd::map<vtkstd::string, vtkIdType> Part_To_VertexID;
142 
143  // Maps a block-id to the "{part-number} Instance: {part-instance}" string.
144  vtkstd::map<int, vtkstd::string> BlockID_To_Part;
145 
149 
151 
156  vtkstd::vector<vtkIdType> CurrentVertex;
157 
158  bool InBlocks;
160 
161 private:
162  vtkExodusIIReaderParser(const vtkExodusIIReaderParser&); // Not implemented
163  void operator=(const vtkExodusIIReaderParser&); // Not implemented
164 //ETX
165 };
166 
167 #endif
168