source: GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParserXerces.h @ 1264

Revision 1264, 6.8 KB checked in by mattausch, 18 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 BvHierarchy;
27
28class ViewCellsParseHandlers: public HandlerBase
29{
30public:
31  // -----------------------------------------------------------------------
32  //  Constructors and Destructor
33  // -----------------------------------------------------------------------
34  ViewCellsParseHandlers(ObjectContainer *objects, BoundingBoxConverter *bconverter);
35  ~ViewCellsParseHandlers();
36 
37 
38  // -----------------------------------------------------------------------
39  //  Getter methods
40  // -----------------------------------------------------------------------
41  unsigned int GetElementCount()
42  {
43    return mElementCount;
44  }
45 
46  unsigned int GetAttrCount()
47  {
48    return mAttrCount;
49  }
50 
51  unsigned int GetCharacterCount()
52  {
53    return mCharacterCount;
54  }
55 
56  unsigned int GetSpaceCount()
57  {
58    return mSpaceCount;
59  }
60
61
62  // -----------------------------------------------------------------------
63  //  Handlers for the SAX DocumentHandler interface
64  // -----------------------------------------------------------------------
65  void endElement(const XMLCh* const name);
66  void startElement(const XMLCh* const name, AttributeList& attributes);
67  void characters(const XMLCh* const chars, const unsigned int length);
68  void ignorableWhitespace(const XMLCh* const chars, const unsigned int length);
69  void resetDocument();
70
71  void CreateViewCellsManager(/*const char *name*/);
72
73
74  VspBspTree *mVspBspTree;
75  VspTree *mVspTree;
76  OspTree *mOspTree;
77  BvHierarchy *mBvHierarchy;
78
79  BspTree *mBspTree;
80  ViewCellsTree *mViewCellsTree;
81
82  BspNode *mCurrentBspNode;
83  VspNode *mCurrentVspNode;
84  ViewCell *mCurrentViewCell;
85  KdNode *mCurrentKdNode;
86 
87  BspNode *mBspRoot;
88  VspNode *mVspRoot;
89  ViewCell *mViewCellRoot;
90
91  ViewCellContainer mViewCells;
92  ViewCellsManager *mViewCellsManager;
93  ObjectContainer *mObjects;
94  BoundingBoxConverter *mBoundingBoxConverter;
95  AxisAlignedBox3 mViewSpaceBox;
96  IndexedBoundingBoxContainer mIBoundingBoxes;
97 
98  /// current state of the parser
99  int mCurrentState;
100 
101  enum {PARSE_OPTIONS, PARSE_VIEWCELLS, PARSE_VIEWSPACE_HIERARCHY, PARSE_OBJECTSPACE_HIERARCHY};
102
103  /// view space / object space hierarchy types
104  enum {BSP, VSP, OSP, BVH};
105
106  int mViewSpaceHierarchyType;
107  int mObjectSpaceHierarchyType;
108
109  // Handlers for X3D
110  void StartBspLeaf(AttributeList& attributes);
111  void StartBspInterior(AttributeList& attributes);
112  void EndBspInterior();
113
114  void StartVspLeaf(AttributeList& attributes);
115  void StartVspInterior(AttributeList& attributes);
116  void EndVspInterior();
117
118  void StartViewCell(ViewCell *viewCell, AttributeList&  attributes);
119  void EndViewCells();
120  void EndBoundingBoxes();
121       
122  void StartHierarchy(AttributeList& attributes);
123
124  void StartBspElement(string element, AttributeList& attributes);
125  void StartVspElement(string element, AttributeList& attributes);
126
127  void StartViewSpaceHierarchy(AttributeList& attributes);
128  void StartObjectSpaceHierarchy(AttributeList& attributes);
129
130  void StartBoundingBox(AttributeList& attributes);
131  void StartViewCellLeaf(AttributeList& attributes);
132  void StartViewCellInterior(AttributeList& attributes);
133  void EndViewCellInterior();
134
135  void StartViewSpaceHierarchyElement(const std::string &element, AttributeList& attributes);
136  void StartObjectSpaceHierarchyElement(const std::string &element, AttributeList& attributes);
137  void StartViewCellHierarchyElement(const std::string &element, AttributeList& attributes);
138
139  void StartOspElement(string element, AttributeList& attributes);
140
141  void StartOspLeaf(AttributeList& attributes);
142  void StartOspInterior(AttributeList& attributes);
143
144  void CreateObjectSpaceHierarchy();
145  void CreateViewSpaceHierarchy();
146
147  void StartBvhLeaf(AttributeList& attributes);
148  void StartBvhInterior(AttributeList& attributes);
149  void StartBvhElement(string element, AttributeList& attributes);
150
151
152  // -----------------------------------------------------------------------
153  //  Handlers for the SAX ErrorHandler interface
154  // -----------------------------------------------------------------------
155
156  void warning(const SAXParseException& exc);
157  void error(const SAXParseException& exc);
158  void fatalError(const SAXParseException& exc);
159 
160 
161private:
162  // -----------------------------------------------------------------------
163  //  Private data members
164  //
165  //  fAttrCount
166  //  fCharacterCount
167  //  fElementCount
168  //  fSpaceCount
169  //      These are just counters that are run upwards based on the input
170  //      from the document handlers.
171  // -----------------------------------------------------------------------
172  unsigned int    mAttrCount;
173  unsigned int    mCharacterCount;
174  unsigned int    mElementCount;
175  unsigned int    mSpaceCount;
176};
177
178// ---------------------------------------------------------------------------
179//  This is a simple class that lets us do easy (though not terribly efficient)
180//  trancoding of XMLCh data to local code page for display.
181// ---------------------------------------------------------------------------
182class StrX
183{
184public :
185  // -----------------------------------------------------------------------
186  //  Constructors and Destructor
187  // -----------------------------------------------------------------------
188  StrX(const XMLCh* const toTranscode)
189  {
190          // Call the private transcoding method
191          mLocalForm = XMLString::transcode(toTranscode);
192  }
193 
194  ~StrX()
195  {
196          XMLString::release(&mLocalForm);
197  }
198 
199  // -----------------------------------------------------------------------
200  //  Getter methods
201  // -----------------------------------------------------------------------
202  const char* LocalForm() const
203  {
204    return mLocalForm;
205  }
206 
207private :
208  // -----------------------------------------------------------------------
209  //  Private data members
210  //
211  //  fLocalForm
212  //      This is the local code page form of the string.
213  // -----------------------------------------------------------------------
214  char*   mLocalForm;
215};
216
217inline XERCES_STD_QUALIFIER ostream&
218operator<<(XERCES_STD_QUALIFIER ostream& target, const StrX& toDump)
219{
220  target << toDump.LocalForm();
221  return target;
222}
223}
224
225#endif
Note: See TracBrowser for help on using the repository browser.