VTK  9.4.20250113
vtkExodusIIReaderParser.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-FileCopyrightText: Copyright (c) Kitware, Inc.
3// SPDX-License-Identifier: BSD-3-Clause
12#ifndef vtkExodusIIReaderParser_h
13#define vtkExodusIIReaderParser_h
14
15#include "vtkIOExodusModule.h" // For export macro
16#include "vtkSmartPointer.h" // for ivars
17#include "vtkXMLParser.h"
18
19#include <map> // for std::map
20#include <set> // for std::set
21#include <string> // for std::string
22#include <vector> // for std::vector
23
24VTK_ABI_NAMESPACE_BEGIN
26class vtkStringArray;
28
29class VTKIOEXODUS_EXPORT vtkExodusIIReaderParser : public vtkXMLParser
30{
31public:
34 void PrintSelf(ostream& os, vtkIndent indent) override;
35
37
41 vtkGetObjectMacro(SIL, vtkMutableDirectedGraph);
43
47 void Go(VTK_FILEPATH const char* filename);
48
49 // Returns if the parser has some information about the block with given "id".
50 // This is valid only after Go().
52 {
53 return (this->BlockID_To_VertexID.find(id) != this->BlockID_To_VertexID.end());
54 }
55
60 std::string GetBlockName(int id);
61
63
67 void GetBlockIds(std::set<int>& blockIdsSet)
68 {
69 std::map<int, vtkIdType>::iterator iter;
70 for (iter = this->BlockID_To_VertexID.begin(); iter != this->BlockID_To_VertexID.end(); ++iter)
71 {
72 blockIdsSet.insert(iter->first);
73 }
74 }
76
77protected:
80
81 void StartElement(const char* tagName, const char** attrs) override;
82 void EndElement(const char* tagName) override;
84
85 const char* GetValue(const char* attr, const char** attrs)
86 {
87 int i;
88 for (i = 0; attrs[i]; i += 2)
89 {
90 const char* name = strrchr(attrs[i], ':');
91 if (!name)
92 {
93 name = attrs[i];
94 }
95 else
96 {
97 name++;
98 }
99 if (strcmp(attr, name) == 0)
100 {
101 return attrs[i + 1];
102 }
103 }
104 return nullptr;
105 }
106
107 // Convenience methods to add vertices/edges to the SIL.
108 vtkIdType AddVertexToSIL(const char* name);
111
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 std::map<int, vtkIdType> BlockID_To_VertexID;
122
123 // Maps block "id"s to material names.
124 std::map<int, std::string> BlockID_To_MaterialName;
125
126 // Maps material name to vertex id.
127 // This will be build only if <material-list> is present in the XML.
128 std::map<std::string, vtkIdType> MaterialName_To_VertexID;
129
130 std::map<vtkIdType, std::string> PartVertexID_To_Descriptions;
131
132 // These save the values read from <material-specification /> element present
133 // withint the <part /> elements.
134 // key: part vertex id
135 // value: material name = (desp + spec)
136 std::map<vtkIdType, std::string> MaterialSpecifications;
137
138 // Maps the "{part-number} Instance: {part-instance}" key for the vertex id
139 // for the part vertex in the Assemblies hierarchy.
140 std::map<std::string, vtkIdType> Part_To_VertexID;
141
142 // Maps a block-id to the "{part-number} Instance: {part-instance}" string.
143 std::map<int, std::string> BlockID_To_Part;
144
148
150
155 std::vector<vtkIdType> CurrentVertex;
156
159
160private:
162 void operator=(const vtkExodusIIReaderParser&) = delete;
163};
164
165VTK_ABI_NAMESPACE_END
166#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:108
An editable directed graph.
Hold a reference to a vtkObjectBase instance.
a vtkAbstractArray subclass for strings
dynamic, self-adjusting array of unsigned char
Parse XML to handle element tags and attributes.
int vtkIdType
Definition vtkType.h:315
#define VTK_FILEPATH