source: trunk/VUT/GtpVisibilityPreprocessor/src/X3dParserXerces.h @ 312

Revision 312, 7.0 KB checked in by mattausch, 19 years ago (diff)

bsp split exporter added

Line 
1#ifndef _X3D_PARSER_XERCES__H
2#define _X3D_PARSER_XERCES__H
3
4// ---------------------------------------------------------------------------
5//  Includes
6// ---------------------------------------------------------------------------
7#include <xercesc/sax/HandlerBase.hpp>
8#include "Mesh.h"
9
10XERCES_CPP_NAMESPACE_USE
11XERCES_CPP_NAMESPACE_BEGIN
12class AttributeList;
13XERCES_CPP_NAMESPACE_END
14
15class SceneGraphNode;
16class Mesh;
17class Material;
18
19class X3dParseHandlers : public HandlerBase
20{
21public:
22  // -----------------------------------------------------------------------
23  //  Constructors and Destructor
24  // -----------------------------------------------------------------------
25  X3dParseHandlers(SceneGraphNode *root);
26  ~X3dParseHandlers();
27 
28 
29  // -----------------------------------------------------------------------
30  //  Getter methods
31  // -----------------------------------------------------------------------
32  unsigned int GetElementCount()
33  {
34    return mElementCount;
35  }
36 
37  unsigned int GetAttrCount()
38  {
39    return mAttrCount;
40  }
41 
42  unsigned int GetCharacterCount()
43  {
44    return mCharacterCount;
45  }
46 
47  unsigned int GetSpaceCount()
48  {
49    return mSpaceCount;
50  }
51
52
53  // -----------------------------------------------------------------------
54  //  Handlers for the SAX DocumentHandler interface
55  // -----------------------------------------------------------------------
56  void endElement(const XMLCh* const name);
57  void startElement(const XMLCh* const name, AttributeList& attributes);
58  void characters(const XMLCh* const chars, const unsigned int length);
59  void ignorableWhitespace(const XMLCh* const chars, const unsigned int length);
60  void resetDocument();
61
62  SceneGraphNode *mCurrentNode;
63  Mesh *mCurrentMesh;
64  Material *mCurrentMaterial;
65 
66  // Handlers for X3D
67  void
68  StartIndexedFaceSet(
69                      AttributeList&  attributes);
70 
71  void
72  EndShape();
73
74  void
75  StartCoordinate(
76                  AttributeList&  attributes);
77
78  void
79  StartMaterial(
80                AttributeList&  attributes);
81 
82 
83  // -----------------------------------------------------------------------
84  //  Handlers for the SAX ErrorHandler interface
85  // -----------------------------------------------------------------------
86  void warning(const SAXParseException& exc);
87  void error(const SAXParseException& exc);
88  void fatalError(const SAXParseException& exc);
89 
90 
91private:
92  // -----------------------------------------------------------------------
93  //  Private data members
94  //
95  //  fAttrCount
96  //  fCharacterCount
97  //  fElementCount
98  //  fSpaceCount
99  //      These are just counters that are run upwards based on the input
100  //      from the document handlers.
101  // -----------------------------------------------------------------------
102  unsigned int    mAttrCount;
103  unsigned int    mCharacterCount;
104  unsigned int    mElementCount;
105  unsigned int    mSpaceCount;
106};
107
108/** Parser handlers for view cell x3d files.
109*/
110class X3dViewCellsParseHandlers : public HandlerBase
111{
112public:
113  // -----------------------------------------------------------------------
114  //  Constructors and Destructor
115  // -----------------------------------------------------------------------
116  X3dViewCellsParseHandlers(ViewCellContainer *mViewCells, float viewCellHeight);
117  ~X3dViewCellsParseHandlers();
118 
119 
120  // -----------------------------------------------------------------------
121  //  Getter methods
122  // -----------------------------------------------------------------------
123  unsigned int GetElementCount()
124  {
125    return mElementCount;
126  }
127 
128  unsigned int GetAttrCount()
129  {
130    return mAttrCount;
131  }
132 
133  unsigned int GetCharacterCount()
134  {
135    return mCharacterCount;
136  }
137 
138  unsigned int GetSpaceCount()
139  {
140    return mSpaceCount;
141  }
142
143
144  // -----------------------------------------------------------------------
145  //  Handlers for the SAX DocumentHandler interface
146  // -----------------------------------------------------------------------
147  void endElement(const XMLCh* const name);
148  void startElement(const XMLCh* const name, AttributeList& attributes);
149  void characters(const XMLCh* const chars, const unsigned int length);
150  void ignorableWhitespace(const XMLCh* const chars, const unsigned int length);
151  void resetDocument();
152
153  ViewCellContainer *mViewCells;
154  float mViewCellHeight;
155
156  VertexIndexContainer mCurrentVertexIndices;
157
158  // Handlers for X3D
159  void
160  StartIndexedFaceSet(
161                      AttributeList&  attributes);
162 
163  void
164  EndShape();
165
166  void
167  StartCoordinate(
168                  AttributeList&  attributes);
169
170  void
171  StartMaterial(
172                AttributeList&  attributes);
173 
174 
175  // -----------------------------------------------------------------------
176  //  Handlers for the SAX ErrorHandler interface
177  // -----------------------------------------------------------------------
178  void warning(const SAXParseException& exc);
179  void error(const SAXParseException& exc);
180  void fatalError(const SAXParseException& exc);
181 
182 
183private:
184  // -----------------------------------------------------------------------
185  //  Private data members
186  //
187  //  fAttrCount
188  //  fCharacterCount
189  //  fElementCount
190  //  fSpaceCount
191  //      These are just counters that are run upwards based on the input
192  //      from the document handlers.
193  // -----------------------------------------------------------------------
194  unsigned int    mAttrCount;
195  unsigned int    mCharacterCount;
196  unsigned int    mElementCount;
197  unsigned int    mSpaceCount;
198};
199
200
201// ---------------------------------------------------------------------------
202//  This is a simple class that lets us do easy (though not terribly efficient)
203//  trancoding of XMLCh data to local code page for display.
204// ---------------------------------------------------------------------------
205class StrX
206{
207public :
208  // -----------------------------------------------------------------------
209  //  Constructors and Destructor
210  // -----------------------------------------------------------------------
211  StrX(const XMLCh* const toTranscode)
212  {
213    // Call the private transcoding method
214    mLocalForm = XMLString::transcode(toTranscode);
215  }
216 
217  ~StrX()
218  {
219    XMLString::release(&mLocalForm);
220  }
221 
222  // -----------------------------------------------------------------------
223  //  Getter methods
224  // -----------------------------------------------------------------------
225  const char* LocalForm() const
226  {
227    return mLocalForm;
228  }
229 
230private :
231  // -----------------------------------------------------------------------
232  //  Private data members
233  //
234  //  fLocalForm
235  //      This is the local code page form of the string.
236  // -----------------------------------------------------------------------
237  char*   mLocalForm;
238};
239
240inline XERCES_STD_QUALIFIER ostream&
241operator<<(XERCES_STD_QUALIFIER ostream& target, const StrX& toDump)
242{
243  target << toDump.LocalForm();
244  return target;
245}
246
247#endif
Note: See TracBrowser for help on using the repository browser.