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

Revision 1233, 6.2 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;
[508]26
[1022]27
[508]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
[575]71  void CreateViewCellsManager(const char *name);
72
73
[508]74  VspBspTree *mVspBspTree;
[1022]75  VspTree *mVspTree;
76  OspTree *mOspTree;
77
[575]78  BspTree *mBspTree;
[651]79  ViewCellsTree *mViewCellsTree;
80
[590]81  BspNode *mCurrentBspNode;
[1201]82  VspNode *mCurrentVspNode;
[651]83  ViewCell *mCurrentViewCell;
[1201]84  KdNode *mCurrentKdNode;
[651]85
[508]86  ViewCellContainer mViewCells;
87  ViewCellsManager *mViewCellsManager;
88  ObjectContainer *mObjects;
[931]89  BoundingBoxConverter *mBoundingBoxConverter;
[577]90  AxisAlignedBox3 mViewSpaceBox;
[931]91  IndexedBoundingBoxContainer mIBoundingBoxes;
[1004]92 
[1201]93  /// current task for the parser
94  int mCurrentTask;
[651]95
[1201]96  enum {PARSE_OPTIONS, PARSE_VIEWCELLS, PARSE_VSP, PARSE_OSP};
97
[508]98  // Handlers for X3D
[575]99  void StartBspLeaf(AttributeList& attributes);
100  void StartBspInterior(AttributeList& attributes);
101  void EndBspInterior();
[1201]102
103  void StartVspLeaf(AttributeList& attributes);
104  void StartVspInterior(AttributeList& attributes);
105  void EndVspInterior();
106
[651]107  void StartViewCell(ViewCell *viewCell, AttributeList&  attributes);
[508]108  void EndViewCells();
[931]109  void EndBoundingBoxes();
[651]110       
[575]111  void StartHierarchy(AttributeList& attributes);
112
[1201]113  void StartBspElement(string element, AttributeList& attributes);
114  void StartVspElement(string element, AttributeList& attributes);
115
[577]116  void StartViewSpaceBox(AttributeList&  attributes);
[651]117
[931]118  void StartBoundingBox(AttributeList& attributes);
[651]119  void StartViewCellLeaf(AttributeList& attributes);
120  void StartViewCellInterior(AttributeList& attributes);
121  void EndViewCellInterior();
122
[1233]123  void StartViewSpaceHierarchyElement(const std::string &element, AttributeList& attributes);
124  void StartObjectSpaceHierarchyElement(const std::string &element, AttributeList& attributes);
[1201]125  void StartViewCellHierarchyElement(const std::string &element, AttributeList& attributes);
[651]126
[1201]127  void StartOspElement(string element, AttributeList& attributes);
128
129  void StartOspLeaf(AttributeList& attributes);
130  void StartOspInterior(AttributeList& attributes);
131
132
[508]133  // -----------------------------------------------------------------------
134  //  Handlers for the SAX ErrorHandler interface
135  // -----------------------------------------------------------------------
[651]136
[508]137  void warning(const SAXParseException& exc);
138  void error(const SAXParseException& exc);
139  void fatalError(const SAXParseException& exc);
140 
141 
142private:
143  // -----------------------------------------------------------------------
144  //  Private data members
145  //
146  //  fAttrCount
147  //  fCharacterCount
148  //  fElementCount
149  //  fSpaceCount
150  //      These are just counters that are run upwards based on the input
151  //      from the document handlers.
152  // -----------------------------------------------------------------------
153  unsigned int    mAttrCount;
154  unsigned int    mCharacterCount;
155  unsigned int    mElementCount;
156  unsigned int    mSpaceCount;
157};
158
159// ---------------------------------------------------------------------------
160//  This is a simple class that lets us do easy (though not terribly efficient)
161//  trancoding of XMLCh data to local code page for display.
162// ---------------------------------------------------------------------------
163class StrX
164{
165public :
166  // -----------------------------------------------------------------------
167  //  Constructors and Destructor
168  // -----------------------------------------------------------------------
169  StrX(const XMLCh* const toTranscode)
170  {
171          // Call the private transcoding method
172          mLocalForm = XMLString::transcode(toTranscode);
173  }
174 
175  ~StrX()
176  {
177          XMLString::release(&mLocalForm);
178  }
179 
180  // -----------------------------------------------------------------------
181  //  Getter methods
182  // -----------------------------------------------------------------------
183  const char* LocalForm() const
184  {
185    return mLocalForm;
186  }
187 
188private :
189  // -----------------------------------------------------------------------
190  //  Private data members
191  //
192  //  fLocalForm
193  //      This is the local code page form of the string.
194  // -----------------------------------------------------------------------
195  char*   mLocalForm;
196};
197
198inline XERCES_STD_QUALIFIER ostream&
199operator<<(XERCES_STD_QUALIFIER ostream& target, const StrX& toDump)
200{
201  target << toDump.LocalForm();
202  return target;
203}
[860]204}
205
[508]206#endif
Note: See TracBrowser for help on using the repository browser.