VTK
vtkBlueObeliskDataParser.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkBlueObeliskDataParser.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm 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 =========================================================================*/
36 #ifndef vtkBlueObeliskDataParser_h
37 #define vtkBlueObeliskDataParser_h
38 
39 #include "vtkDomainsChemistryModule.h" // For export macro
40 #include "vtkXMLParser.h"
41 
42 #include "vtkSmartPointer.h" // For vtkSmartPointer
43 
44 class vtkAbstractArray;
45 class vtkBlueObeliskData;
46 class vtkFloatArray;
47 class vtkStdString;
48 class vtkStringArray;
50 
51 class VTKDOMAINSCHEMISTRY_EXPORT vtkBlueObeliskDataParser : public vtkXMLParser
52 {
53 public:
55  void PrintSelf(ostream& os, vtkIndent indent) override;
56 
57  static vtkBlueObeliskDataParser* New();
58 
63  virtual void SetTarget(vtkBlueObeliskData* bodr);
64 
68  int Parse() override;
69 
71 
76  int Parse(const char*) override;
77  int Parse(const char*, unsigned int) override;
79 
80 protected:
82  ~vtkBlueObeliskDataParser() override;
83 
84  void StartElement(const char* name, const char** attr) override;
85  void EndElement(const char* name) override;
86 
87  void CharacterDataHandler(const char* data, int length) override;
88 
89  void SetCurrentValue(const char* data, int length);
90  void SetCurrentValue(const char* data);
91 
93 
95  void NewAtomStarted(const char** attr);
96  void NewAtomFinished();
97 
99  void NewValueStarted(const char** attr);
100  void NewValueFinished();
101 
103 
105  {
106  None = 0,
125  } CurrentValueType;
126 
133  float CurrentMass;
140  float CurrentDefaultColor[3];
143  unsigned int CurrentPeriod;
144  unsigned int CurrentGroup;
145 
146 private:
148  void operator=(const vtkBlueObeliskDataParser&) = delete;
149 
151 
154  static void ResizeArrayIfNeeded(vtkAbstractArray* arr, vtkIdType ind);
155  static void ResizeAndSetValue(vtkStdString* val, vtkStringArray* arr, vtkIdType ind);
156  static void ResizeAndSetValue(float val, vtkFloatArray* arr, vtkIdType ind);
157  static void ResizeAndSetValue(unsigned short val, vtkUnsignedShortArray* arr, vtkIdType ind);
159 
161 
164  static int parseInt(const char*);
165  static float parseFloat(const char*);
166  static void parseFloat3(const char* str, float[3]);
167  static unsigned short parseUnsignedShort(const char*);
169 
171 
175  static vtkStdString* ToLower(vtkStdString*);
177 };
178 
179 #endif
vtkBlueObeliskDataParser::IsProcessingValue
bool IsProcessingValue
Definition: vtkBlueObeliskDataParser.h:98
vtkBlueObeliskDataParser::Period
Definition: vtkBlueObeliskDataParser.h:123
vtkBlueObeliskDataParser::Mass
Definition: vtkBlueObeliskDataParser.h:113
vtkBlueObeliskDataParser::CurrentBoilingPoint
float CurrentBoilingPoint
Definition: vtkBlueObeliskDataParser.h:141
vtkBlueObeliskDataParser::CurrentSymbol
vtkStdString * CurrentSymbol
Definition: vtkBlueObeliskDataParser.h:128
vtkBlueObeliskDataParser::CurrentGroup
unsigned int CurrentGroup
Definition: vtkBlueObeliskDataParser.h:144
vtkBlueObeliskDataParser::CurrentElectronAffinity
float CurrentElectronAffinity
Definition: vtkBlueObeliskDataParser.h:136
vtkXMLParser
Parse XML to handle element tags and attributes.
Definition: vtkXMLParser.h:39
vtkBlueObeliskDataParser::CurrentMeltingPoint
float CurrentMeltingPoint
Definition: vtkBlueObeliskDataParser.h:142
vtkBlueObeliskDataParser::CurrentPeriod
unsigned int CurrentPeriod
Definition: vtkBlueObeliskDataParser.h:143
vtkIdType
int vtkIdType
Definition: vtkType.h:349
vtkUnsignedShortArray
dynamic, self-adjusting array of unsigned short
Definition: vtkUnsignedShortArray.h:39
vtkFloatArray
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:35
vtkX3D::data
Definition: vtkX3D.h:321
vtkBlueObeliskDataParser::CurrentName
vtkStdString * CurrentName
Definition: vtkBlueObeliskDataParser.h:129
vtkBlueObeliskDataParser::BoilingPoint
Definition: vtkBlueObeliskDataParser.h:121
vtkBlueObeliskDataParser::CurrentAtomicNumber
int CurrentAtomicNumber
Definition: vtkBlueObeliskDataParser.h:127
vtkBlueObeliskDataParser::PeriodicTableBlock
Definition: vtkBlueObeliskDataParser.h:110
vtkBlueObeliskDataParser::ElectronicConfiguration
Definition: vtkBlueObeliskDataParser.h:111
vtkBlueObeliskDataParser::CurrentFamily
vtkStdString * CurrentFamily
Definition: vtkBlueObeliskDataParser.h:132
vtkXMLParser.h
vtkX3D::length
Definition: vtkX3D.h:399
vtkBlueObeliskDataParser::AtomicNumber
Definition: vtkBlueObeliskDataParser.h:107
vtkBlueObeliskDataParser::CurrentPeriodicTableBlock
vtkStdString * CurrentPeriodicTableBlock
Definition: vtkBlueObeliskDataParser.h:130
vtkBlueObeliskDataParser
Fill a vtkBlueObeliskData container with data from the BODR XML dataset.
Definition: vtkBlueObeliskDataParser.h:51
vtkBlueObeliskDataParser::Family
Definition: vtkBlueObeliskDataParser.h:112
vtkX3D::Group
Definition: vtkX3D.h:57
vtkBlueObeliskDataParser::DefaultColor
Definition: vtkBlueObeliskDataParser.h:120
vtkBlueObeliskDataParser::AtomValueType
AtomValueType
Definition: vtkBlueObeliskDataParser.h:104
vtkBlueObeliskDataParser::CurrentElectronicConfiguration
vtkStdString * CurrentElectronicConfiguration
Definition: vtkBlueObeliskDataParser.h:131
vtkBlueObeliskDataParser::CurrentExactMass
float CurrentExactMass
Definition: vtkBlueObeliskDataParser.h:134
vtkBlueObeliskDataParser::CurrentCovalentRadius
float CurrentCovalentRadius
Definition: vtkBlueObeliskDataParser.h:138
vtkXMLParser::New
static vtkXMLParser * New()
vtkBlueObeliskDataParser::PaulingElectronegativity
Definition: vtkBlueObeliskDataParser.h:117
vtkBlueObeliskData
Contains chemical data from the Blue Obelisk Data Repository.
Definition: vtkBlueObeliskData.h:52
vtkBlueObeliskDataParser::CurrentIonizationEnergy
float CurrentIonizationEnergy
Definition: vtkBlueObeliskDataParser.h:135
vtkBlueObeliskDataParser::CurrentVDWRadius
float CurrentVDWRadius
Definition: vtkBlueObeliskDataParser.h:139
vtkBlueObeliskDataParser::VDWRadius
Definition: vtkBlueObeliskDataParser.h:119
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkBlueObeliskDataParser::MeltingPoint
Definition: vtkBlueObeliskDataParser.h:122
vtkSmartPointer.h
vtkXMLParser::Parse
virtual int Parse()
Parse the XML input.
vtkXMLParser::EndElement
virtual void EndElement(const char *name)
vtkBlueObeliskDataParser::Target
vtkBlueObeliskData * Target
Definition: vtkBlueObeliskDataParser.h:92
vtkX3D::name
Definition: vtkX3D.h:225
vtkAbstractArray
Abstract superclass for all arrays.
Definition: vtkAbstractArray.h:75
vtkBlueObeliskDataParser::IonizationEnergy
Definition: vtkBlueObeliskDataParser.h:115
vtkX3D::string
Definition: vtkX3D.h:496
vtkBlueObeliskDataParser::ExactMass
Definition: vtkBlueObeliskDataParser.h:114
vtkBlueObeliskDataParser::CurrentMass
float CurrentMass
Definition: vtkBlueObeliskDataParser.h:133
vtkBlueObeliskDataParser::IsProcessingAtom
bool IsProcessingAtom
Definition: vtkBlueObeliskDataParser.h:94
vtkXMLParser::StartElement
virtual void StartElement(const char *name, const char **atts)
vtkBlueObeliskDataParser::CovalentRadius
Definition: vtkBlueObeliskDataParser.h:118
vtkBlueObeliskDataParser::CurrentPaulingElectronegativity
float CurrentPaulingElectronegativity
Definition: vtkBlueObeliskDataParser.h:137
vtkBlueObeliskDataParser::CharacterDataValueBuffer
std::string CharacterDataValueBuffer
Definition: vtkBlueObeliskDataParser.h:102
vtkStringArray
a vtkAbstractArray subclass for strings
Definition: vtkStringArray.h:36
vtkXMLParser::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:34
vtkBlueObeliskDataParser::Symbol
Definition: vtkBlueObeliskDataParser.h:108
vtkXMLParser::CharacterDataHandler
virtual void CharacterDataHandler(const char *data, int length)
vtkBlueObeliskDataParser::ElectronAffinity
Definition: vtkBlueObeliskDataParser.h:116
vtkBlueObeliskDataParser::Name
Definition: vtkBlueObeliskDataParser.h:109