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

Revision 260, 6.9 KB checked in by mattausch, 19 years ago (diff)

added viewcell stuff

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