VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkBlueObeliskDataParser.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00035 #ifndef __vtkBlueObeliskDataParser_h 00036 #define __vtkBlueObeliskDataParser_h 00037 00038 #include "vtkDomainsChemistryModule.h" // For export macro 00039 #include "vtkXMLParser.h" 00040 00041 #include <vtkSmartPointer.h> // For vtkSmartPointer 00042 00043 class vtkAbstractArray; 00044 class vtkBlueObeliskData; 00045 class vtkFloatArray; 00046 class vtkStdString; 00047 class vtkStringArray; 00048 class vtkUnsignedShortArray; 00049 00050 class VTKDOMAINSCHEMISTRY_EXPORT vtkBlueObeliskDataParser : public vtkXMLParser 00051 { 00052 public: 00053 vtkTypeMacro(vtkBlueObeliskDataParser, vtkXMLParser); 00054 static vtkBlueObeliskDataParser * New(); 00055 00058 virtual void SetTarget(vtkBlueObeliskData *bodr); 00059 00061 virtual int Parse(); 00062 00064 00067 virtual int Parse(const char *); 00068 virtual int Parse(const char *, unsigned int); 00070 00071 protected: 00072 vtkBlueObeliskDataParser(); 00073 ~vtkBlueObeliskDataParser(); 00074 00075 void StartElement(const char *name, const char **attr); 00076 void EndElement(const char *name); 00077 00078 void CharacterDataHandler(const char *data, int length); 00079 00080 void SetCurrentValue(const char *data, int length); 00081 void SetCurrentValue(const char *data); 00082 00083 vtkBlueObeliskData *Target; 00084 00085 bool IsProcessingAtom; 00086 void NewAtomStarted(const char **attr); 00087 void NewAtomFinished(); 00088 00089 bool IsProcessingValue; 00090 void NewValueStarted(const char **attr); 00091 void NewValueFinished(); 00092 00093 std::string CharacterDataValueBuffer; 00094 00095 enum AtomValueType { 00096 None = 0, 00097 AtomicNumber, 00098 Symbol, 00099 Name, 00100 PeriodicTableBlock, 00101 ElectronicConfiguration, 00102 Family, 00103 Mass, 00104 ExactMass, 00105 IonizationEnergy, 00106 ElectronAffinity, 00107 PaulingElectronegativity, 00108 CovalentRadius, 00109 VDWRadius, 00110 DefaultColor, 00111 BoilingPoint, 00112 MeltingPoint, 00113 Period, 00114 Group 00115 } CurrentValueType; 00116 00117 int CurrentAtomicNumber; 00118 vtkStdString *CurrentSymbol; 00119 vtkStdString *CurrentName; 00120 vtkStdString *CurrentPeriodicTableBlock; 00121 vtkStdString *CurrentElectronicConfiguration; 00122 vtkStdString *CurrentFamily; 00123 float CurrentMass; 00124 float CurrentExactMass; 00125 float CurrentIonizationEnergy; 00126 float CurrentElectronAffinity; 00127 float CurrentPaulingElectronegativity; 00128 float CurrentCovalentRadius; 00129 float CurrentVDWRadius; 00130 float CurrentDefaultColor[3]; 00131 float CurrentBoilingPoint; 00132 float CurrentMeltingPoint; 00133 unsigned int CurrentPeriod; 00134 unsigned int CurrentGroup; 00135 00136 private: 00137 // Not implemented 00138 vtkBlueObeliskDataParser(const vtkBlueObeliskDataParser&); 00139 void operator=(const vtkBlueObeliskDataParser&); 00140 00142 00143 static void ResizeArrayIfNeeded(vtkAbstractArray *arr, vtkIdType ind); 00144 static void ResizeAndSetValue(vtkStdString *val, 00145 vtkStringArray *arr, 00146 vtkIdType ind); 00147 static void ResizeAndSetValue(float val, 00148 vtkFloatArray *arr, 00149 vtkIdType ind); 00150 static void ResizeAndSetValue(unsigned short val, 00151 vtkUnsignedShortArray *arr, 00152 vtkIdType ind); 00154 00156 00157 static int parseInt(const char *); 00158 static float parseFloat(const char *); 00159 static void parseFloat3(const char * str, float[3]); 00160 static unsigned short parseUnsignedShort(const char *); 00162 00164 00166 static vtkStdString * ToLower(vtkStdString *); 00167 }; 00169 00170 #endif