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 =========================================================================*/
35 #ifndef __vtkBlueObeliskDataParser_h
36 #define __vtkBlueObeliskDataParser_h
37 
38 #include "vtkXMLParser.h"
39 
40 #include <vtkSmartPointer.h> // For vtkSmartPointer
41 
42 class vtkAbstractArray;
43 class vtkBlueObeliskData;
44 class vtkFloatArray;
45 class vtkStdString;
46 class vtkStringArray;
48 
50 {
51  public:
53  static vtkBlueObeliskDataParser * New();
54 
57  virtual void SetTarget(vtkBlueObeliskData *bodr);
58 
60  virtual int Parse();
61 
63 
66  virtual int Parse(const char *);
67  virtual int Parse(const char *, unsigned int);
69 
70 protected:
73 
74  void StartElement(const char *name, const char **attr);
75  void EndElement(const char *name);
76 
77  void CharacterDataHandler(const char *data, int length);
78 
79  void SetCurrentValue(const char *data, int length);
80  void SetCurrentValue(const char *data);
81 
83 
85  void NewAtomStarted(const char **attr);
86  void NewAtomFinished();
87 
89  void NewValueStarted(const char **attr);
90  void NewValueFinished();
91 
93  None = 0,
112  } CurrentValueType;
113 
120  float CurrentMass;
127  float CurrentDefaultColor[3];
130  unsigned int CurrentPeriod;
131  unsigned int CurrentGroup;
132 
133 private:
134  // Not implemented
136  void operator=(const vtkBlueObeliskDataParser&);
137 
139 
140  static void ResizeArrayIfNeeded(vtkAbstractArray *arr, vtkIdType ind);
141  static void ResizeAndSetValue(vtkStdString *val,
142  vtkStringArray *arr,
143  vtkIdType ind);
144  static void ResizeAndSetValue(float val,
145  vtkFloatArray *arr,
146  vtkIdType ind);
147  static void ResizeAndSetValue(unsigned short val,
149  vtkIdType ind);
151 
153 
154  static int parseInt(const char *);
155  static float parseFloat(const char *);
156  static void parseFloat3(const char * str, float[3]);
157  static unsigned short parseUnsignedShort(const char *);
159 
161 
163  static vtkStdString * ToLower(vtkStdString *);
164 };
166 
167 #endif