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

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