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 "vtkIOExodusModule.h" // For export macro
26 #include "vtkXMLParser.h"
27 #include "vtkSmartPointer.h"
28 
29 #include <vtksys/ios/sstream>
30 #include <map>
31 #include <vector>
32 #include <set>
33 #include <string>
34 
36 class vtkStringArray;
38 
40 {
41 public:
42  static vtkExodusIIReaderParser* New();
44  void PrintSelf(ostream& os, vtkIndent indent);
45 
47 
48  vtkGetObjectMacro(SIL, vtkMutableDirectedGraph);
50 
52  void Go(const char* filename);
53 
54  // Returns if the parser has some information about the block with given "id".
55  // This is valid only after Go().
57  {
58  return (this->BlockID_To_VertexID.find(id) != this->BlockID_To_VertexID.end());
59  }
60 
63  std::string GetBlockName(int id);
64 
66 
68  void GetBlockIds(std::set<int>& blockIdsSet)
69  {
70  std::map<int, vtkIdType>::iterator iter;
71  for (iter = this->BlockID_To_VertexID.begin();
72  iter != this->BlockID_To_VertexID.end();
73  ++iter)
74  {
75  blockIdsSet.insert(iter->first);
76  }
77  }
78 //BTX
79 protected:
83 
84  virtual void StartElement( const char* tagName, const char** attrs);
85  virtual void EndElement(const char* tagName);
86  void FinishedParsing();
87 
88  const char* GetValue(const char* attr,const char** attrs)
89  {
90  int i;
91  for (i=0;attrs[i];i+=2)
92  {
93  const char* name=strrchr(attrs[i],':');
94  if (!name)
95  {
96  name=attrs[i];
97  }
98  else
99  {
100  name++;
101  }
102  if (strcmp(attr,name)==0)
103  {
104  return attrs[i+1];
105  }
106  }
107  return NULL;
108  }
109 
110  // Convenience methods to add vertices/edges to the SIL.
111  vtkIdType AddVertexToSIL(const char* name);
112  vtkIdType AddChildEdgeToSIL(vtkIdType src, vtkIdType dst);
113  vtkIdType AddCrossEdgeToSIL(vtkIdType src, vtkIdType dst);
114 
118  vtkIdType GetPartVertex(const char* part_number_instance_string);
119 
120  // For each of the blocks, this maps the "id" attribute in the XML to the
121  // vertex id for the block in the SIL.
122  std::map<int, vtkIdType> BlockID_To_VertexID;
123 
124 
125  // Maps block "id"s to material names.
126  std::map<int, std::string> BlockID_To_MaterialName;
127 
128  // Maps material name to vertex id.
129  // This will be build only if <material-list> is present in the XML.
130  std::map<std::string, vtkIdType> MaterialName_To_VertexID;
131 
132  std::map<vtkIdType, std::string> PartVertexID_To_Descriptions;
133 
134  // These save the values read from <material-specification /> element present
135  // withint the <part /> elements.
136  // key: part vertex id
137  // value: material name = (desp + spec)
138  std::map<vtkIdType, std::string> MaterialSpecifications;
139 
140  // Maps the "{part-number} Instance: {part-instance}" key for the vertex id
141  // for the part vertex in the Assemblies hierarchy.
142  std::map<std::string, vtkIdType> Part_To_VertexID;
143 
144  // Maps a block-id to the "{part-number} Instance: {part-instance}" string.
145  std::map<int, std::string> BlockID_To_Part;
146 
150 
152 
157  std::vector<vtkIdType> CurrentVertex;
158 
159  bool InBlocks;
161 
162 private:
163  vtkExodusIIReaderParser(const vtkExodusIIReaderParser&); // Not implemented
164  void operator=(const vtkExodusIIReaderParser&); // Not implemented
165 //ETX
166 };
167 
168 #endif
169 
170 // VTK-HeaderTest-Exclude: vtkExodusIIReaderParser.h
std::map< vtkIdType, std::string > MaterialSpecifications
vtkSmartPointer< vtkStringArray > NamesArray
Parse XML to handle element tags and attributes.
Definition: vtkXMLParser.h:41
virtual void StartElement(const char *name, const char **atts)
std::vector< vtkIdType > CurrentVertex
a vtkAbstractArray subclass for strings
int vtkIdType
Definition: vtkType.h:275
std::map< int, vtkIdType > BlockID_To_VertexID
vtkSmartPointer< vtkUnsignedCharArray > CrossEdgesArray
vtkMutableDirectedGraph * SIL
std::map< vtkIdType, std::string > PartVertexID_To_Descriptions
std::map< int, std::string > BlockID_To_MaterialName
const char * GetValue(const char *attr, const char **attrs)
a simple class to control print indentation
Definition: vtkIndent.h:38
std::map< std::string, vtkIdType > Part_To_VertexID
void PrintSelf(ostream &os, vtkIndent indent)
An editable directed graph.
#define VTKIOEXODUS_EXPORT
dynamic, self-adjusting array of unsigned char
std::map< std::string, vtkIdType > MaterialName_To_VertexID
internal parser used by vtkExodusIIReader.
void GetBlockIds(std::set< int > &blockIdsSet)
std::map< int, std::string > BlockID_To_Part
virtual void EndElement(const char *name)
static vtkXMLParser * New()