VTK: Domains/Chemistry/vtkBlueObeliskDataParser.h Source File

| VTK 9.3.1

vtkBlueObeliskDataParser.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
24 #ifndef vtkBlueObeliskDataParser_h
25 #define vtkBlueObeliskDataParser_h
26
27 #include "vtkDomainsChemistryModule.h" // For export macro
28 #include "vtkXMLParser.h"
29
30 #include "vtkSmartPointer.h" // For vtkSmartPointer
31
32 VTK_ABI_NAMESPACE_BEGIN
33 class vtkAbstractArray;
34 class vtkBlueObeliskData;
35 class vtkFloatArray;
36 class vtkStringArray;
37 class vtkUnsignedShortArray;
38
39 class VTKDOMAINSCHEMISTRY_EXPORT vtkBlueObeliskDataParser : public vtkXMLParser
40 {
41 public:
42 vtkTypeMacro(vtkBlueObeliskDataParser, vtkXMLParser);
43 void PrintSelf(ostream& os, vtkIndent indent) override;
44
45 static vtkBlueObeliskDataParser* New();
46
51 virtual void SetTarget(vtkBlueObeliskData* bodr);
52
56 int Parse() override;
57
59
64 int Parse(const char*) override;
65 int Parse(const char*, unsigned int) override;
67
68 protected:
69 vtkBlueObeliskDataParser();
70 ~vtkBlueObeliskDataParser() override;
71
72 void StartElement(const char* name, const char** attr) override;
73 void EndElement(const char* name) override;
74
75 void CharacterDataHandler(const char* data, int length) override;
76
77 void SetCurrentValue(const char* data, int length);
78 void SetCurrentValue(const char* data);
79
80 vtkBlueObeliskData* Target;
81
82 bool IsProcessingAtom;
83 void NewAtomStarted(const char** attr);
84 void NewAtomFinished();
85
86 bool IsProcessingValue;
87 void NewValueStarted(const char** attr);
88 void NewValueFinished();
89
90 std::string CharacterDataValueBuffer;
91
92 enum AtomValueType
93 {
94 None = 0,
95 AtomicNumber,
96 Symbol,
97 Name,
98 PeriodicTableBlock,
99 ElectronicConfiguration,
100 Family,
101 Mass,
102 ExactMass,
103 IonizationEnergy,
104 ElectronAffinity,
105 PaulingElectronegativity,
106 CovalentRadius,
107 VDWRadius,
108 DefaultColor,
109 BoilingPoint,
110 MeltingPoint,
111 Period,
112 Group
113 } CurrentValueType;
114
115 int CurrentAtomicNumber;
116 std::string* CurrentSymbol;
117 std::string* CurrentName;
118 std::string* CurrentPeriodicTableBlock;
119 std::string* CurrentElectronicConfiguration;
120 std::string* CurrentFamily;
121 float CurrentMass;
122 float CurrentExactMass;
123 float CurrentIonizationEnergy;
124 float CurrentElectronAffinity;
125 float CurrentPaulingElectronegativity;
126 float CurrentCovalentRadius;
127 float CurrentVDWRadius;
128 float CurrentDefaultColor[3];
129 float CurrentBoilingPoint;
130 float CurrentMeltingPoint;
131 unsigned int CurrentPeriod;
132 unsigned int CurrentGroup;
133
134 private:
135 vtkBlueObeliskDataParser(const vtkBlueObeliskDataParser&) = delete;
136 void operator=(const vtkBlueObeliskDataParser&) = delete;
137
139
142 static void ResizeArrayIfNeeded(vtkAbstractArray* arr, vtkIdType ind);
143 static void ResizeAndSetValue(std::string* val, vtkStringArray* arr, vtkIdType ind);
144 static void ResizeAndSetValue(float val, vtkFloatArray* arr, vtkIdType ind);
145 static void ResizeAndSetValue(unsigned short val, vtkUnsignedShortArray* arr, vtkIdType ind);
147
149
152 static int parseInt(const char*);
153 static float parseFloat(const char*);
154 static void parseFloat3(const char* str, float[3]);
155 static unsigned short parseUnsignedShort(const char*);
157
159
163 static std::string* ToLower(std::string*);
165 };
166
167 VTK_ABI_NAMESPACE_END
168 #endif
vtkAbstractArray
Abstract superclass for all arrays.
Definition: vtkAbstractArray.h:76
vtkBlueObeliskDataParser
Fill a vtkBlueObeliskData container with data from the BODR XML dataset.
Definition: vtkBlueObeliskDataParser.h:40
vtkBlueObeliskDataParser::CharacterDataValueBuffer
std::string CharacterDataValueBuffer
Definition: vtkBlueObeliskDataParser.h:90
vtkBlueObeliskDataParser::CurrentCovalentRadius
float CurrentCovalentRadius
Definition: vtkBlueObeliskDataParser.h:126
vtkBlueObeliskDataParser::CurrentFamily
std::string * CurrentFamily
Definition: vtkBlueObeliskDataParser.h:120
vtkBlueObeliskDataParser::IsProcessingValue
bool IsProcessingValue
Definition: vtkBlueObeliskDataParser.h:86
vtkBlueObeliskDataParser::NewAtomFinished
void NewAtomFinished()
vtkBlueObeliskDataParser::CurrentAtomicNumber
int CurrentAtomicNumber
Definition: vtkBlueObeliskDataParser.h:115
vtkBlueObeliskDataParser::AtomValueType
AtomValueType
Definition: vtkBlueObeliskDataParser.h:93
vtkBlueObeliskDataParser::PeriodicTableBlock
@ PeriodicTableBlock
Definition: vtkBlueObeliskDataParser.h:98
vtkBlueObeliskDataParser::DefaultColor
@ DefaultColor
Definition: vtkBlueObeliskDataParser.h:108
vtkBlueObeliskDataParser::Name
@ Name
Definition: vtkBlueObeliskDataParser.h:97
vtkBlueObeliskDataParser::VDWRadius
@ VDWRadius
Definition: vtkBlueObeliskDataParser.h:107
vtkBlueObeliskDataParser::ElectronicConfiguration
@ ElectronicConfiguration
Definition: vtkBlueObeliskDataParser.h:99
vtkBlueObeliskDataParser::IonizationEnergy
@ IonizationEnergy
Definition: vtkBlueObeliskDataParser.h:103
vtkBlueObeliskDataParser::PaulingElectronegativity
@ PaulingElectronegativity
Definition: vtkBlueObeliskDataParser.h:105
vtkBlueObeliskDataParser::Symbol
@ Symbol
Definition: vtkBlueObeliskDataParser.h:96
vtkBlueObeliskDataParser::Family
@ Family
Definition: vtkBlueObeliskDataParser.h:100
vtkBlueObeliskDataParser::MeltingPoint
@ MeltingPoint
Definition: vtkBlueObeliskDataParser.h:110
vtkBlueObeliskDataParser::CovalentRadius
@ CovalentRadius
Definition: vtkBlueObeliskDataParser.h:106
vtkBlueObeliskDataParser::Period
@ Period
Definition: vtkBlueObeliskDataParser.h:111
vtkBlueObeliskDataParser::Mass
@ Mass
Definition: vtkBlueObeliskDataParser.h:101
vtkBlueObeliskDataParser::ElectronAffinity
@ ElectronAffinity
Definition: vtkBlueObeliskDataParser.h:104
vtkBlueObeliskDataParser::BoilingPoint
@ BoilingPoint
Definition: vtkBlueObeliskDataParser.h:109
vtkBlueObeliskDataParser::ExactMass
@ ExactMass
Definition: vtkBlueObeliskDataParser.h:102
vtkBlueObeliskDataParser::AtomicNumber
@ AtomicNumber
Definition: vtkBlueObeliskDataParser.h:95
vtkBlueObeliskDataParser::CurrentMeltingPoint
float CurrentMeltingPoint
Definition: vtkBlueObeliskDataParser.h:130
vtkBlueObeliskDataParser::EndElement
void EndElement(const char *name) override
vtkBlueObeliskDataParser::CurrentElectronicConfiguration
std::string * CurrentElectronicConfiguration
Definition: vtkBlueObeliskDataParser.h:119
vtkBlueObeliskDataParser::vtkBlueObeliskDataParser
vtkBlueObeliskDataParser()
vtkBlueObeliskDataParser::NewAtomStarted
void NewAtomStarted(const char **attr)
vtkBlueObeliskDataParser::IsProcessingAtom
bool IsProcessingAtom
Definition: vtkBlueObeliskDataParser.h:82
vtkBlueObeliskDataParser::CurrentName
std::string * CurrentName
Definition: vtkBlueObeliskDataParser.h:117
vtkBlueObeliskDataParser::CurrentPeriod
unsigned int CurrentPeriod
Definition: vtkBlueObeliskDataParser.h:131
vtkBlueObeliskDataParser::CurrentBoilingPoint
float CurrentBoilingPoint
Definition: vtkBlueObeliskDataParser.h:129
vtkBlueObeliskDataParser::StartElement
void StartElement(const char *name, const char **attr) override
vtkBlueObeliskDataParser::NewValueStarted
void NewValueStarted(const char **attr)
vtkBlueObeliskDataParser::~vtkBlueObeliskDataParser
~vtkBlueObeliskDataParser() override
vtkBlueObeliskDataParser::SetCurrentValue
void SetCurrentValue(const char *data)
vtkBlueObeliskDataParser::CurrentPaulingElectronegativity
float CurrentPaulingElectronegativity
Definition: vtkBlueObeliskDataParser.h:125
vtkBlueObeliskDataParser::CurrentMass
float CurrentMass
Definition: vtkBlueObeliskDataParser.h:121
vtkBlueObeliskDataParser::New
static vtkBlueObeliskDataParser * New()
vtkBlueObeliskDataParser::CurrentPeriodicTableBlock
std::string * CurrentPeriodicTableBlock
Definition: vtkBlueObeliskDataParser.h:118
vtkBlueObeliskDataParser::CurrentSymbol
std::string * CurrentSymbol
Definition: vtkBlueObeliskDataParser.h:116
vtkBlueObeliskDataParser::SetTarget
virtual void SetTarget(vtkBlueObeliskData *bodr)
Set the target vtkBlueObeliskData object that this parser will populate.
vtkBlueObeliskDataParser::NewValueFinished
void NewValueFinished()
vtkBlueObeliskDataParser::Parse
int Parse(const char *, unsigned int) override
These are only implemented to prevent compiler warnings about hidden virtual overloads.
vtkBlueObeliskDataParser::CurrentVDWRadius
float CurrentVDWRadius
Definition: vtkBlueObeliskDataParser.h:127
vtkBlueObeliskDataParser::CurrentElectronAffinity
float CurrentElectronAffinity
Definition: vtkBlueObeliskDataParser.h:124
vtkBlueObeliskDataParser::CurrentGroup
unsigned int CurrentGroup
Definition: vtkBlueObeliskDataParser.h:132
vtkBlueObeliskDataParser::CurrentExactMass
float CurrentExactMass
Definition: vtkBlueObeliskDataParser.h:122
vtkBlueObeliskDataParser::Parse
int Parse() override
Start parsing.
vtkBlueObeliskDataParser::CurrentIonizationEnergy
float CurrentIonizationEnergy
Definition: vtkBlueObeliskDataParser.h:123
vtkBlueObeliskDataParser::Parse
int Parse(const char *) override
These are only implemented to prevent compiler warnings about hidden virtual overloads.
vtkBlueObeliskDataParser::Target
vtkBlueObeliskData * Target
Definition: vtkBlueObeliskDataParser.h:80
vtkBlueObeliskDataParser::CharacterDataHandler
void CharacterDataHandler(const char *data, int length) override
vtkBlueObeliskDataParser::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkBlueObeliskDataParser::SetCurrentValue
void SetCurrentValue(const char *data, int length)
vtkBlueObeliskData
Contains chemical data from the Blue Obelisk Data Repository.
Definition: vtkBlueObeliskData.h:46
vtkFloatArray
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:40
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkStringArray
a vtkAbstractArray subclass for strings
Definition: vtkStringArray.h:41
vtkUnsignedShortArray
dynamic, self-adjusting array of unsigned short
Definition: vtkUnsignedShortArray.h:32
vtkXMLParser
Parse XML to handle element tags and attributes.
Definition: vtkXMLParser.h:29
vtkX3D::Group
@ Group
Definition: vtkX3D.h:51
vtkX3D::length
@ length
Definition: vtkX3D.h:393
vtkX3D::name
@ name
Definition: vtkX3D.h:219
vtkX3D::data
@ data
Definition: vtkX3D.h:315
vtkX3D::string
@ string
Definition: vtkX3D.h:490
vtkSmartPointer.h
vtkIdType
int vtkIdType
Definition: vtkType.h:315
vtkXMLParser.h