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

Revision 1263, 6.4 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_VSP, PARSE_OSP};
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 StartViewSpaceBox(AttributeList&  attributes);
128
129  void StartBoundingBox(AttributeList& attributes);
130  void StartViewCellLeaf(AttributeList& attributes);
131  void StartViewCellInterior(AttributeList& attributes);
132  void EndViewCellInterior();
133
134  void StartViewSpaceHierarchyElement(const std::string &element, AttributeList& attributes);
135  void StartObjectSpaceHierarchyElement(const std::string &element, AttributeList& attributes);
136  void StartViewCellHierarchyElement(const std::string &element, AttributeList& attributes);
137
138  void StartOspElement(string element, AttributeList& attributes);
139
140  void StartOspLeaf(AttributeList& attributes);
141  void StartOspInterior(AttributeList& attributes);
142
143
144  // -----------------------------------------------------------------------
145  //  Handlers for the SAX ErrorHandler interface
146  // -----------------------------------------------------------------------
147
148  void warning(const SAXParseException& exc);
149  void error(const SAXParseException& exc);
150  void fatalError(const SAXParseException& exc);
151 
152 
153private:
154  // -----------------------------------------------------------------------
155  //  Private data members
156  //
157  //  fAttrCount
158  //  fCharacterCount
159  //  fElementCount
160  //  fSpaceCount
161  //      These are just counters that are run upwards based on the input
162  //      from the document handlers.
163  // -----------------------------------------------------------------------
164  unsigned int    mAttrCount;
165  unsigned int    mCharacterCount;
166  unsigned int    mElementCount;
167  unsigned int    mSpaceCount;
168};
169
170// ---------------------------------------------------------------------------
171//  This is a simple class that lets us do easy (though not terribly efficient)
172//  trancoding of XMLCh data to local code page for display.
173// ---------------------------------------------------------------------------
174class StrX
175{
176public :
177  // -----------------------------------------------------------------------
178  //  Constructors and Destructor
179  // -----------------------------------------------------------------------
180  StrX(const XMLCh* const toTranscode)
181  {
182          // Call the private transcoding method
183          mLocalForm = XMLString::transcode(toTranscode);
184  }
185 
186  ~StrX()
187  {
188          XMLString::release(&mLocalForm);
189  }
190 
191  // -----------------------------------------------------------------------
192  //  Getter methods
193  // -----------------------------------------------------------------------
194  const char* LocalForm() const
195  {
196    return mLocalForm;
197  }
198 
199private :
200  // -----------------------------------------------------------------------
201  //  Private data members
202  //
203  //  fLocalForm
204  //      This is the local code page form of the string.
205  // -----------------------------------------------------------------------
206  char*   mLocalForm;
207};
208
209inline XERCES_STD_QUALIFIER ostream&
210operator<<(XERCES_STD_QUALIFIER ostream& target, const StrX& toDump)
211{
212  target << toDump.LocalForm();
213  return target;
214}
215}
216
217#endif
Note: See TracBrowser for help on using the repository browser.