source: GTP/trunk/Lib/Vis/Preprocessing/src/ObjectsParserXerces.h @ 2114

Revision 2114, 5.3 KB checked in by mattausch, 17 years ago (diff)
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#include "BoundingBoxConverter.h"
10
11
12namespace GtpVisibilityPreprocessor {
13
14XERCES_CPP_NAMESPACE_USE
15XERCES_CPP_NAMESPACE_BEGIN
16class AttributeList;
17XERCES_CPP_NAMESPACE_END
18
19class VspBspTree;
20class BspTree;
21class ViewCellsManager;
22class ViewCellsTree;
23class VspTree;
24class OspTree;
25class VspNode;
26class BvhNode;
27class BvHierarchy;
28class HierarchyManager;
29
30
31class ObjectsParseHandlers: public HandlerBase
32{
33public:
34  // -----------------------------------------------------------------------
35  //  Constructors and Destructor
36  // -----------------------------------------------------------------------
37  ObjectsParseHandlers(ObjectContainer &pvsObjects,
38                                                 ObjectContainer &preprocessorObjects,
39                                                 BoundingBoxConverter *bconverter);
40  ~ObjectsParseHandlers();
41 
42 
43  // -----------------------------------------------------------------------
44  //  Getter methods
45  // -----------------------------------------------------------------------
46  unsigned int GetElementCount()
47  {
48    return mElementCount;
49  }
50 
51  unsigned int GetAttrCount()
52  {
53    return mAttrCount;
54  }
55 
56  unsigned int GetCharacterCount()
57  {
58    return mCharacterCount;
59  }
60 
61  unsigned int GetSpaceCount()
62  {
63    return mSpaceCount;
64  }
65
66
67  // -----------------------------------------------------------------------
68  //  Handlers for the SAX DocumentHandler interface
69  // -----------------------------------------------------------------------
70  void endElement(const XMLCh* const name);
71  void startElement(const XMLCh* const name, AttributeList& attributes);
72  void characters(const XMLCh* const chars, const unsigned int length);
73  void ignorableWhitespace(const XMLCh* const chars, const unsigned int length);
74  void resetDocument();
75
76  /////////////////////////
77
78  int mUniqueObjectId;
79  vector<BvhLeaf *> mBvhLeaves;
80  ObjectContainer &mPreprocessorObjects;
81
82  /// current state of the parser
83  int mCurrentState;
84 
85  enum {, BVH};
86
87  int mViewSpaceHierarchyType;
88  int mObjectSpaceHierarchyType;
89  int nViewCells;
90  int nObjects;
91 
92 
93  ////////////////////////////////
94
95
96  // Handlers for X3D
97 
98  void StartObjectSpaceHierarchy(AttributeList& attributes);
99
100  void StartObjectSpaceHierarchyElement(const std::string &element, AttributeList& attributes);
101
102  void StartBvhLeaf(AttributeList& attributes);
103  void StartBvhInterior(AttributeList& attributes);
104  void StartBvhElement(string element, AttributeList& attributes);
105
106  void EndObjectSpaceHierarchyInterior();
107
108  void EndBvhInterior();
109  void EndOspInterior();
110
111  void EndObjectSpaceHierarchy();
112
113  void StartBvhLeafObjects(ObjectContainer &objects, const char *ptr);
114
115  // -----------------------------------------------------------------------
116  //  Handlers for the SAX ErrorHandler interface
117  // -----------------------------------------------------------------------
118
119  void warning(const SAXParseException& exc);
120  void error(const SAXParseException& exc);
121  void fatalError(const SAXParseException& exc);
122 
123 
124private:
125  // -----------------------------------------------------------------------
126  //  Private data members
127  //
128  //  fAttrCount
129  //  fCharacterCount
130  //  fElementCount
131  //  fSpaceCount
132  //      These are just counters that are run upwards based on the input
133  //      from the document handlers.
134  // -----------------------------------------------------------------------
135  unsigned int    mAttrCount;
136  unsigned int    mCharacterCount;
137  unsigned int    mElementCount;
138  unsigned int    mSpaceCount;
139};
140
141// ---------------------------------------------------------------------------
142//  This is a simple class that lets us do easy (though not terribly efficient)
143//  trancoding of XMLCh data to local code page for display.
144// ---------------------------------------------------------------------------
145class StrX
146{
147public :
148  // -----------------------------------------------------------------------
149  //  Constructors and Destructor
150  // -----------------------------------------------------------------------
151  StrX(const XMLCh* const toTranscode)
152  {
153          // Call the private transcoding method
154          mLocalForm = XMLString::transcode(toTranscode);
155  }
156 
157  ~StrX()
158  {
159          XMLString::release(&mLocalForm);
160  }
161 
162  // -----------------------------------------------------------------------
163  //  Getter methods
164  // -----------------------------------------------------------------------
165  const char* LocalForm() const
166  {
167    return mLocalForm;
168  }
169 
170private :
171  // -----------------------------------------------------------------------
172  //  Private data members
173  //
174  //  fLocalForm
175  //      This is the local code page form of the string.
176  // -----------------------------------------------------------------------
177  char*   mLocalForm;
178};
179
180inline XERCES_STD_QUALIFIER ostream&
181operator<<(XERCES_STD_QUALIFIER ostream& target, const StrX& toDump)
182{
183  target << toDump.LocalForm();
184  return target;
185}
186}
187
188#endif
Note: See TracBrowser for help on using the repository browser.