VTK
dox/Chemistry/vtkBlueObeliskDataParser.h
Go to the documentation of this file.
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 "vtkXMLParser.h"
00039 
00040 #include <vtkSmartPointer.h> // For vtkSmartPointer
00041 
00042 class vtkAbstractArray;
00043 class vtkBlueObeliskData;
00044 class vtkFloatArray;
00045 class vtkStdString;
00046 class vtkStringArray;
00047 class vtkUnsignedShortArray;
00048 
00049 class VTK_CHEMISTRY_EXPORT vtkBlueObeliskDataParser : public vtkXMLParser
00050 {
00051  public:
00052   vtkTypeMacro(vtkBlueObeliskDataParser, vtkXMLParser);
00053   static vtkBlueObeliskDataParser * New();
00054 
00057   virtual void SetTarget(vtkBlueObeliskData *bodr);
00058 
00060   virtual int Parse();
00061 
00063 
00066   virtual int Parse(const char *);
00067   virtual int Parse(const char *, unsigned int);
00069 
00070 protected:
00071   vtkBlueObeliskDataParser();
00072   ~vtkBlueObeliskDataParser();
00073 
00074   void StartElement(const char *name, const char **attr);
00075   void EndElement(const char *name);
00076 
00077   void CharacterDataHandler(const char *data, int length);
00078 
00079   void SetCurrentValue(const char *data, int length);
00080   void SetCurrentValue(const char *data);
00081 
00082   vtkBlueObeliskData *Target;
00083 
00084   bool IsProcessingAtom;
00085   void NewAtomStarted(const char **attr);
00086   void NewAtomFinished();
00087 
00088   bool IsProcessingValue;
00089   void NewValueStarted(const char **attr);
00090   void NewValueFinished();
00091 
00092   enum AtomValueType {
00093     None = 0,
00094     AtomicNumber,
00095     Symbol,
00096     Name,
00097     PeriodicTableBlock,
00098     ElectronicConfiguration,
00099     Family,
00100     Mass,
00101     ExactMass,
00102     IonizationEnergy,
00103     ElectronAffinity,
00104     PaulingElectronegativity,
00105     CovalentRadius,
00106     VDWRadius,
00107     DefaultColor,
00108     BoilingPoint,
00109     MeltingPoint,
00110     Period,
00111     Group
00112   } CurrentValueType;
00113 
00114   int CurrentAtomicNumber;
00115   vtkStdString *CurrentSymbol;
00116   vtkStdString *CurrentName;
00117   vtkStdString *CurrentPeriodicTableBlock;
00118   vtkStdString *CurrentElectronicConfiguration;
00119   vtkStdString *CurrentFamily;
00120   float CurrentMass;
00121   float CurrentExactMass;
00122   float CurrentIonizationEnergy;
00123   float CurrentElectronAffinity;
00124   float CurrentPaulingElectronegativity;
00125   float CurrentCovalentRadius;
00126   float CurrentVDWRadius;
00127   float CurrentDefaultColor[3];
00128   float CurrentBoilingPoint;
00129   float CurrentMeltingPoint;
00130   unsigned int CurrentPeriod;
00131   unsigned int CurrentGroup;
00132 
00133 private:
00134   // Not implemented
00135   vtkBlueObeliskDataParser(const vtkBlueObeliskDataParser&);
00136   void operator=(const vtkBlueObeliskDataParser&);
00137 
00139 
00140   static void ResizeArrayIfNeeded(vtkAbstractArray *arr, vtkIdType ind);
00141   static void ResizeAndSetValue(vtkStdString *val,
00142                                 vtkStringArray *arr,
00143                                 vtkIdType ind);
00144   static void ResizeAndSetValue(float val,
00145                                 vtkFloatArray *arr,
00146                                 vtkIdType ind);
00147   static void ResizeAndSetValue(unsigned short val,
00148                                 vtkUnsignedShortArray *arr,
00149                                 vtkIdType ind);
00151 
00153 
00154   static int parseInt(const char *);
00155   static float parseFloat(const char *);
00156   static void parseFloat3(const char * str, float[3]);
00157   static unsigned short parseUnsignedShort(const char *);
00159 
00161 
00163   static vtkStdString * ToLower(vtkStdString *);
00164 };
00166 
00167 #endif