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

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