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 
36 class vtkStringArray;
38 
39 class VTKIOEXODUS_EXPORT vtkExodusIIReaderParser : public vtkXMLParser
40 {
41 public:
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 
87 protected:
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 
167  bool InBlocks;
169 
170 private:
172  void operator=(const vtkExodusIIReaderParser&) = delete;
173 };
174 
175 #endif
vtkExodusIIReaderParser
internal parser used by vtkExodusIIReader.
Definition: vtkExodusIIReaderParser.h:40
vtkExodusIIReaderParser::CurrentVertex
std::vector< vtkIdType > CurrentVertex
Definition: vtkExodusIIReaderParser.h:165
vtkMutableDirectedGraph
An editable directed graph.
Definition: vtkMutableDirectedGraph.h:155
vtkExodusIIReaderParser::NamesArray
vtkSmartPointer< vtkStringArray > NamesArray
Definition: vtkExodusIIReaderParser.h:156
vtkExodusIIReaderParser::BlockPartNumberString
std::string BlockPartNumberString
Definition: vtkExodusIIReaderParser.h:159
vtkXMLParser
Parse XML to handle element tags and attributes.
Definition: vtkXMLParser.h:40
VTK_FILEPATH
#define VTK_FILEPATH
Definition: vtkWrappingHints.h:46
vtkIdType
int vtkIdType
Definition: vtkType.h:332
vtkExodusIIReaderParser::StartElement
void StartElement(const char *tagName, const char **attrs) override
vtkExodusIIReaderParser::BlockID_To_VertexID
std::map< int, vtkIdType > BlockID_To_VertexID
Definition: vtkExodusIIReaderParser.h:131
vtkExodusIIReaderParser::AddChildEdgeToSIL
vtkIdType AddChildEdgeToSIL(vtkIdType src, vtkIdType dst)
vtkExodusIIReaderParser::MaterialsVertex
vtkIdType MaterialsVertex
Definition: vtkExodusIIReaderParser.h:164
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:145
vtkSmartPointer< vtkStringArray >
vtkExodusIIReaderParser::GetPartVertex
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} ...
vtkXMLParser.h
vtkExodusIIReaderParser::New
static vtkExodusIIReaderParser * New()
vtkExodusIIReaderParser::AddCrossEdgeToSIL
vtkIdType AddCrossEdgeToSIL(vtkIdType src, vtkIdType dst)
vtkExodusIIReaderParser::InBlocks
bool InBlocks
Definition: vtkExodusIIReaderParser.h:167
vtkExodusIIReaderParser::HasInformationAboutBlock
bool HasInformationAboutBlock(int id)
Definition: vtkExodusIIReaderParser.h:61
vtkExodusIIReaderParser::CrossEdgesArray
vtkSmartPointer< vtkUnsignedCharArray > CrossEdgesArray
Definition: vtkExodusIIReaderParser.h:157
vtkExodusIIReaderParser::SIL
vtkMutableDirectedGraph * SIL
Definition: vtkExodusIIReaderParser.h:155
vtkExodusIIReaderParser::BlockID_To_MaterialName
std::map< int, std::string > BlockID_To_MaterialName
Definition: vtkExodusIIReaderParser.h:134
vtkExodusIIReaderParser::PartVertexID_To_Descriptions
std::map< vtkIdType, std::string > PartVertexID_To_Descriptions
Definition: vtkExodusIIReaderParser.h:140
vtkExodusIIReaderParser::GetValue
const char * GetValue(const char *attr, const char **attrs)
Definition: vtkExodusIIReaderParser.h:95
vtkExodusIIReaderParser::InMaterialAssignments
bool InMaterialAssignments
Definition: vtkExodusIIReaderParser.h:168
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkExodusIIReaderParser::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkSmartPointer.h
vtkExodusIIReaderParser::~vtkExodusIIReaderParser
~vtkExodusIIReaderParser() override
vtkExodusIIReaderParser::RootVertex
vtkIdType RootVertex
Definition: vtkExodusIIReaderParser.h:161
vtkExodusIIReaderParser::MaterialName_To_VertexID
std::map< std::string, vtkIdType > MaterialName_To_VertexID
Definition: vtkExodusIIReaderParser.h:138
vtkExodusIIReaderParser::GetBlockName
std::string GetBlockName(int id)
Given a block "id" return the name as determined from the xml.
vtkX3D::name
@ name
Definition: vtkX3D.h:225
vtkExodusIIReaderParser::Part_To_VertexID
std::map< std::string, vtkIdType > Part_To_VertexID
Definition: vtkExodusIIReaderParser.h:150
vtkExodusIIReaderParser::BlockID_To_Part
std::map< int, std::string > BlockID_To_Part
Definition: vtkExodusIIReaderParser.h:153
vtkExodusIIReaderParser::vtkExodusIIReaderParser
vtkExodusIIReaderParser()
vtkExodusIIReaderParser::FinishedParsing
void FinishedParsing()
vtkX3D::string
@ string
Definition: vtkX3D.h:496
vtkExodusIIReaderParser::GetBlockIds
void GetBlockIds(std::set< int > &blockIdsSet)
Fills up the blockIdsSet with the block ids referred to by the XML.
Definition: vtkExodusIIReaderParser.h:77
vtkExodusIIReaderParser::AddVertexToSIL
vtkIdType AddVertexToSIL(const char *name)
vtkExodusIIReaderParser::AssembliesVertex
vtkIdType AssembliesVertex
Definition: vtkExodusIIReaderParser.h:163
vtkStringArray
a vtkAbstractArray subclass for strings
Definition: vtkStringArray.h:146
vtkExodusIIReaderParser::BlocksVertex
vtkIdType BlocksVertex
Definition: vtkExodusIIReaderParser.h:162
vtkExodusIIReaderParser::EndElement
void EndElement(const char *tagName) override
vtkExodusIIReaderParser::MaterialSpecifications
std::map< vtkIdType, std::string > MaterialSpecifications
Definition: vtkExodusIIReaderParser.h:146
vtkExodusIIReaderParser::Go
void Go(VTK_FILEPATH const char *filename)
Trigger parsing of the XML file.