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=========================================================================*/
23#ifndef vtkExodusIIReaderParser_h
24#define vtkExodusIIReaderParser_h
25
26#include "vtkIOExodusModule.h" // For export macro
27#include "vtkXMLParser.h"
28#include "vtkSmartPointer.h"
29
30#include <sstream>
31#include <map>
32#include <vector>
33#include <set>
34#include <string>
35
37class vtkStringArray;
39
40class VTKIOEXODUS_EXPORT vtkExodusIIReaderParser : public vtkXMLParser
41{
42public:
45 void PrintSelf(ostream& os, vtkIndent indent);
46
48
52 vtkGetObjectMacro(SIL, vtkMutableDirectedGraph);
54
58 void Go(const char* filename);
59
60 // Returns if the parser has some information about the block with given "id".
61 // This is valid only after Go().
63 {
64 return (this->BlockID_To_VertexID.find(id) != this->BlockID_To_VertexID.end());
65 }
66
72
74
78 void GetBlockIds(std::set<int>& blockIdsSet)
79 {
80 std::map<int, vtkIdType>::iterator iter;
81 for (iter = this->BlockID_To_VertexID.begin();
82 iter != this->BlockID_To_VertexID.end();
83 ++iter)
84 {
85 blockIdsSet.insert(iter->first);
86 }
87 }
89
90protected:
93
94 virtual void StartElement( const char* tagName, const char** attrs);
95 virtual void EndElement(const char* tagName);
97
98 const char* GetValue(const char* attr,const char** attrs)
99 {
100 int i;
101 for (i=0;attrs[i];i+=2)
102 {
103 const char* name=strrchr(attrs[i],':');
104 if (!name)
105 {
106 name=attrs[i];
107 }
108 else
109 {
110 name++;
111 }
112 if (strcmp(attr,name)==0)
113 {
114 return attrs[i+1];
115 }
116 }
117 return NULL;
118 }
119
120 // Convenience methods to add vertices/edges to the SIL.
124
130 vtkIdType GetPartVertex(const char* part_number_instance_string);
131
132 // For each of the blocks, this maps the "id" attribute in the XML to the
133 // vertex id for the block in the SIL.
134 std::map<int, vtkIdType> BlockID_To_VertexID;
135
136
137 // Maps block "id"s to material names.
138 std::map<int, std::string> BlockID_To_MaterialName;
139
140 // Maps material name to vertex id.
141 // This will be build only if <material-list> is present in the XML.
142 std::map<std::string, vtkIdType> MaterialName_To_VertexID;
143
144 std::map<vtkIdType, std::string> PartVertexID_To_Descriptions;
145
146 // These save the values read from <material-specification /> element present
147 // withint the <part /> elements.
148 // key: part vertex id
149 // value: material name = (desp + spec)
150 std::map<vtkIdType, std::string> MaterialSpecifications;
151
152 // Maps the "{part-number} Instance: {part-instance}" key for the vertex id
153 // for the part vertex in the Assemblies hierarchy.
154 std::map<std::string, vtkIdType> Part_To_VertexID;
155
156 // Maps a block-id to the "{part-number} Instance: {part-instance}" string.
157 std::map<int, std::string> BlockID_To_Part;
158
162
164
169 std::vector<vtkIdType> CurrentVertex;
170
173
174private:
175 vtkExodusIIReaderParser(const vtkExodusIIReaderParser&) VTK_DELETE_FUNCTION;
176 void operator=(const vtkExodusIIReaderParser&) VTK_DELETE_FUNCTION;
177
178};
179
180#endif
181
182// VTK-HeaderTest-Exclude: vtkExodusIIReaderParser.h
internal parser used by vtkExodusIIReader.
vtkIdType AddVertexToSIL(const char *name)
std::map< vtkIdType, std::string > PartVertexID_To_Descriptions
std::map< vtkIdType, std::string > MaterialSpecifications
void Go(const char *filename)
Trigger parsing of the XML file.
std::map< int, std::string > BlockID_To_Part
virtual void EndElement(const char *tagName)
std::map< int, std::string > BlockID_To_MaterialName
const char * GetValue(const char *attr, const char **attrs)
vtkIdType GetPartVertex(const char *part_number_instance_string)
Returns the vertex id for the "part" with given part_number_instance_string formed as "{part-number} ...
std::map< std::string, vtkIdType > Part_To_VertexID
vtkSmartPointer< vtkUnsignedCharArray > CrossEdgesArray
std::vector< vtkIdType > CurrentVertex
std::string GetBlockName(int id)
Given a block "id" return the name as determined from the xml.
virtual void StartElement(const char *tagName, const char **attrs)
vtkMutableDirectedGraph * SIL
vtkIdType AddCrossEdgeToSIL(vtkIdType src, vtkIdType dst)
vtkSmartPointer< vtkStringArray > NamesArray
std::map< int, vtkIdType > BlockID_To_VertexID
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
std::map< std::string, vtkIdType > MaterialName_To_VertexID
vtkIdType AddChildEdgeToSIL(vtkIdType src, vtkIdType dst)
void GetBlockIds(std::set< int > &blockIdsSet)
Fills up the blockIdsSet with the block ids referred to by the XML.
static vtkExodusIIReaderParser * New()
a simple class to control print indentation
Definition: vtkIndent.h:40
An editable directed graph.
a vtkAbstractArray subclass for strings
dynamic, self-adjusting array of unsigned char
Parse XML to handle element tags and attributes.
Definition: vtkXMLParser.h:43
@ name
Definition: vtkX3D.h:219
@ string
Definition: vtkX3D.h:490
int vtkIdType
Definition: vtkType.h:287