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  None = 0,
124  } CurrentValueType;
125 
132  float CurrentMass;
139  float CurrentDefaultColor[3];
142  unsigned int CurrentPeriod;
143  unsigned int CurrentGroup;
144 
145 private:
147  void operator=(const vtkBlueObeliskDataParser&) = delete;
148 
150 
153  static void ResizeArrayIfNeeded(vtkAbstractArray *arr, vtkIdType ind);
154  static void ResizeAndSetValue(vtkStdString *val,
155  vtkStringArray *arr,
156  vtkIdType ind);
157  static void ResizeAndSetValue(float val,
158  vtkFloatArray *arr,
159  vtkIdType ind);
160  static void ResizeAndSetValue(unsigned short val,
162  vtkIdType ind);
164 
166 
169  static int parseInt(const char *);
170  static float parseFloat(const char *);
171  static void parseFloat3(const char * str, float[3]);
172  static unsigned short parseUnsignedShort(const char *);
174 
176 
180  static vtkStdString * ToLower(vtkStdString *);
181 };
183 
184 #endif
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:40
virtual int Parse()
Parse the XML input.
Parse XML to handle element tags and attributes.
Definition: vtkXMLParser.h:42
Abstract superclass for all arrays.
virtual void StartElement(const char *name, const char **atts)
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:41
a vtkAbstractArray subclass for strings
int vtkIdType
Definition: vtkType.h:347
virtual void CharacterDataHandler(const char *data, int length)
a simple class to control print indentation
Definition: vtkIndent.h:39
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void EndElement(const char *name)
static vtkXMLParser * New()
Fill a vtkBlueObeliskData container with data from the BODR XML dataset.
dynamic, self-adjusting array of unsigned short
Contains chemical data from the Blue Obelisk Data Repository.