VTK  9.1.0
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 "vtkSmartPointer.h" // for ivars
28#include "vtkXMLParser.h"
29
30#include <map> // for std::map
31#include <set> // for std::set
32#include <string> // for std::string
33#include <vector> // for std::vector
34
36class vtkStringArray;
38
39class VTKIOEXODUS_EXPORT vtkExodusIIReaderParser : public vtkXMLParser
40{
41public:
44 void PrintSelf(ostream& os, vtkIndent indent) override;
45
47
51 vtkGetObjectMacro(SIL, vtkMutableDirectedGraph);
53
57 void Go(VTK_FILEPATH const char* filename);
58
59 // Returns if the parser has some information about the block with given "id".
60 // This is valid only after Go().
62 {
63 return (this->BlockID_To_VertexID.find(id) != this->BlockID_To_VertexID.end());
64 }
65
71
73
77 void GetBlockIds(std::set<int>& blockIdsSet)
78 {
79 std::map<int, vtkIdType>::iterator iter;
80 for (iter = this->BlockID_To_VertexID.begin(); iter != this->BlockID_To_VertexID.end(); ++iter)
81 {
82 blockIdsSet.insert(iter->first);
83 }
84 }
86
87protected:
90
91 void StartElement(const char* tagName, const char** attrs) override;
92 void EndElement(const char* tagName) override;
94
95 const char* GetValue(const char* attr, const char** attrs)
96 {
97 int i;
98 for (i = 0; attrs[i]; i += 2)
99 {
100 const char* name = strrchr(attrs[i], ':');
101 if (!name)
102 {
103 name = attrs[i];
104 }
105 else
106 {
107 name++;
108 }
109 if (strcmp(attr, name) == 0)
110 {
111 return attrs[i + 1];
112 }
113 }
114 return nullptr;
115 }
116
117 // Convenience methods to add vertices/edges to the SIL.
121
127 vtkIdType GetPartVertex(const char* part_number_instance_string);
128
129 // For each of the blocks, this maps the "id" attribute in the XML to the
130 // vertex id for the block in the SIL.
131 std::map<int, vtkIdType> BlockID_To_VertexID;
132
133 // Maps block "id"s to material names.
134 std::map<int, std::string> BlockID_To_MaterialName;
135
136 // Maps material name to vertex id.
137 // This will be build only if <material-list> is present in the XML.
138 std::map<std::string, vtkIdType> MaterialName_To_VertexID;
139
140 std::map<vtkIdType, std::string> PartVertexID_To_Descriptions;
141
142 // These save the values read from <material-specification /> element present
143 // withint the <part /> elements.
144 // key: part vertex id
145 // value: material name = (desp + spec)
146 std::map<vtkIdType, std::string> MaterialSpecifications;
147
148 // Maps the "{part-number} Instance: {part-instance}" key for the vertex id
149 // for the part vertex in the Assemblies hierarchy.
150 std::map<std::string, vtkIdType> Part_To_VertexID;
151
152 // Maps a block-id to the "{part-number} Instance: {part-instance}" string.
153 std::map<int, std::string> BlockID_To_Part;
154
158
160
165 std::vector<vtkIdType> CurrentVertex;
166
169
170private:
172 void operator=(const vtkExodusIIReaderParser&) = delete;
173};
174
175#endif
internal parser used by vtkExodusIIReader.
vtkIdType AddVertexToSIL(const char *name)
std::map< vtkIdType, std::string > PartVertexID_To_Descriptions
std::map< vtkIdType, std::string > MaterialSpecifications
std::map< int, std::string > BlockID_To_Part
std::map< int, std::string > BlockID_To_MaterialName
void Go(VTK_FILEPATH const char *filename)
Trigger parsing of the XML file.
const char * GetValue(const char *attr, const char **attrs)
void StartElement(const char *tagName, const char **attrs) override
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.
vtkMutableDirectedGraph * SIL
vtkIdType AddCrossEdgeToSIL(vtkIdType src, vtkIdType dst)
vtkSmartPointer< vtkStringArray > NamesArray
~vtkExodusIIReaderParser() override
std::map< int, vtkIdType > BlockID_To_VertexID
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()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void EndElement(const char *tagName) override
a simple class to control print indentation
Definition: vtkIndent.h:113
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:40
@ name
Definition: vtkX3D.h:225
@ string
Definition: vtkX3D.h:496
int vtkIdType
Definition: vtkType.h:332
#define VTK_FILEPATH