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

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

added vview cell manager functionality

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