VTK  9.0.3
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"
28 #include "vtkXMLParser.h"
29 
30 #include <map>
31 #include <set>
32 #include <sstream>
33 #include <string>
34 #include <vector>
35 
37 class vtkStringArray;
39 
40 class VTKIOEXODUS_EXPORT vtkExodusIIReaderParser : public vtkXMLParser
41 {
42 public:
45  void PrintSelf(ostream& os, vtkIndent indent) override;
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(); iter != this->BlockID_To_VertexID.end(); ++iter)
82  {
83  blockIdsSet.insert(iter->first);
84  }
85  }
87 
88 protected:
91 
92  void StartElement(const char* tagName, const char** attrs) override;
93  void EndElement(const char* tagName) override;
95 
96  const char* GetValue(const char* attr, const char** attrs)
97  {
98  int i;
99  for (i = 0; attrs[i]; i += 2)
100  {
101  const char* name = strrchr(attrs[i], ':');
102  if (!name)
103  {
104  name = attrs[i];
105  }
106  else
107  {
108  name++;
109  }
110  if (strcmp(attr, name) == 0)
111  {
112  return attrs[i + 1];
113  }
114  }
115  return nullptr;
116  }
117 
118  // Convenience methods to add vertices/edges to the SIL.
122 
128  vtkIdType GetPartVertex(const char* part_number_instance_string);
129 
130  // For each of the blocks, this maps the "id" attribute in the XML to the
131  // vertex id for the block in the SIL.
132  std::map<int, vtkIdType> BlockID_To_VertexID;
133 
134  // Maps block "id"s to material names.
135  std::map<int, std::string> BlockID_To_MaterialName;
136 
137  // Maps material name to vertex id.
138  // This will be build only if <material-list> is present in the XML.
139  std::map<std::string, vtkIdType> MaterialName_To_VertexID;
140 
141  std::map<vtkIdType, std::string> PartVertexID_To_Descriptions;
142 
143  // These save the values read from <material-specification /> element present
144  // withint the <part /> elements.
145  // key: part vertex id
146  // value: material name = (desp + spec)
147  std::map<vtkIdType, std::string> MaterialSpecifications;
148 
149  // Maps the "{part-number} Instance: {part-instance}" key for the vertex id
150  // for the part vertex in the Assemblies hierarchy.
151  std::map<std::string, vtkIdType> Part_To_VertexID;
152 
153  // Maps a block-id to the "{part-number} Instance: {part-instance}" string.
154  std::map<int, std::string> BlockID_To_Part;
155 
159 
161 
166  std::vector<vtkIdType> CurrentVertex;
167 
168  bool InBlocks;
170 
171 private:
173  void operator=(const vtkExodusIIReaderParser&) = delete;
174 };
175 
176 #endif
177 
178 // 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
std::map< int, std::string > BlockID_To_MaterialName
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.
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
static vtkExodusIIReaderParser * New()
a simple class to control print indentation
Definition: vtkIndent.h:34
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:338