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

Revision 1264, 6.8 KB checked in by mattausch, 18 years ago (diff)
RevLine 
[508]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"
[931]9#include "BoundingBoxConverter.h"
[508]10
[1201]11
[860]12namespace GtpVisibilityPreprocessor {
13
[508]14XERCES_CPP_NAMESPACE_USE
15XERCES_CPP_NAMESPACE_BEGIN
16class AttributeList;
17XERCES_CPP_NAMESPACE_END
18
19class VspBspTree;
[575]20class BspTree;
[508]21class ViewCellsManager;
[651]22class ViewCellsTree;
[1022]23class VspTree;
24class OspTree;
[1201]25class VspNode;
[1263]26class BvHierarchy;
[508]27
28class ViewCellsParseHandlers: public HandlerBase
29{
30public:
31  // -----------------------------------------------------------------------
32  //  Constructors and Destructor
33  // -----------------------------------------------------------------------
[1004]34  ViewCellsParseHandlers(ObjectContainer *objects, BoundingBoxConverter *bconverter);
[508]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
[1263]71  void CreateViewCellsManager(/*const char *name*/);
[575]72
73
[508]74  VspBspTree *mVspBspTree;
[1022]75  VspTree *mVspTree;
76  OspTree *mOspTree;
[1263]77  BvHierarchy *mBvHierarchy;
[1022]78
[575]79  BspTree *mBspTree;
[651]80  ViewCellsTree *mViewCellsTree;
81
[590]82  BspNode *mCurrentBspNode;
[1201]83  VspNode *mCurrentVspNode;
[651]84  ViewCell *mCurrentViewCell;
[1201]85  KdNode *mCurrentKdNode;
[1263]86 
87  BspNode *mBspRoot;
88  VspNode *mVspRoot;
89  ViewCell *mViewCellRoot;
[651]90
[508]91  ViewCellContainer mViewCells;
92  ViewCellsManager *mViewCellsManager;
93  ObjectContainer *mObjects;
[931]94  BoundingBoxConverter *mBoundingBoxConverter;
[577]95  AxisAlignedBox3 mViewSpaceBox;
[931]96  IndexedBoundingBoxContainer mIBoundingBoxes;
[1004]97 
[1263]98  /// current state of the parser
99  int mCurrentState;
100 
[1264]101  enum {PARSE_OPTIONS, PARSE_VIEWCELLS, PARSE_VIEWSPACE_HIERARCHY, PARSE_OBJECTSPACE_HIERARCHY};
[1201]102
[1263]103  /// view space / object space hierarchy types
104  enum {BSP, VSP, OSP, BVH};
105
106  int mViewSpaceHierarchyType;
107  int mObjectSpaceHierarchyType;
108
[508]109  // Handlers for X3D
[575]110  void StartBspLeaf(AttributeList& attributes);
111  void StartBspInterior(AttributeList& attributes);
112  void EndBspInterior();
[1201]113
114  void StartVspLeaf(AttributeList& attributes);
115  void StartVspInterior(AttributeList& attributes);
116  void EndVspInterior();
117
[651]118  void StartViewCell(ViewCell *viewCell, AttributeList&  attributes);
[508]119  void EndViewCells();
[931]120  void EndBoundingBoxes();
[651]121       
[575]122  void StartHierarchy(AttributeList& attributes);
123
[1201]124  void StartBspElement(string element, AttributeList& attributes);
125  void StartVspElement(string element, AttributeList& attributes);
126
[1264]127  void StartViewSpaceHierarchy(AttributeList& attributes);
128  void StartObjectSpaceHierarchy(AttributeList& attributes);
[651]129
[931]130  void StartBoundingBox(AttributeList& attributes);
[651]131  void StartViewCellLeaf(AttributeList& attributes);
132  void StartViewCellInterior(AttributeList& attributes);
133  void EndViewCellInterior();
134
[1233]135  void StartViewSpaceHierarchyElement(const std::string &element, AttributeList& attributes);
136  void StartObjectSpaceHierarchyElement(const std::string &element, AttributeList& attributes);
[1201]137  void StartViewCellHierarchyElement(const std::string &element, AttributeList& attributes);
[651]138
[1201]139  void StartOspElement(string element, AttributeList& attributes);
140
141  void StartOspLeaf(AttributeList& attributes);
142  void StartOspInterior(AttributeList& attributes);
143
[1264]144  void CreateObjectSpaceHierarchy();
145  void CreateViewSpaceHierarchy();
[1201]146
[1264]147  void StartBvhLeaf(AttributeList& attributes);
148  void StartBvhInterior(AttributeList& attributes);
149  void StartBvhElement(string element, AttributeList& attributes);
150
151
[508]152  // -----------------------------------------------------------------------
153  //  Handlers for the SAX ErrorHandler interface
154  // -----------------------------------------------------------------------
[651]155
[508]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}
[860]223}
224
[508]225#endif
Note: See TracBrowser for help on using the repository browser.