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

Revision 1201, 6.2 KB checked in by mattausch, 18 years ago (diff)

added loader for osp trees

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;
26
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
78  BspTree *mBspTree;
79  ViewCellsTree *mViewCellsTree;
80
81  BspNode *mCurrentBspNode;
82  VspNode *mCurrentVspNode;
83  ViewCell *mCurrentViewCell;
84  KdNode *mCurrentKdNode;
85
86  ViewCellContainer mViewCells;
87  ViewCellsManager *mViewCellsManager;
88  ObjectContainer *mObjects;
89  BoundingBoxConverter *mBoundingBoxConverter;
90  AxisAlignedBox3 mViewSpaceBox;
91  IndexedBoundingBoxContainer mIBoundingBoxes;
92 
93  /// current task for the parser
94  int mCurrentTask;
95
96  enum {PARSE_OPTIONS, PARSE_VIEWCELLS, PARSE_VSP, PARSE_OSP};
97
98  // Handlers for X3D
99  void StartBspLeaf(AttributeList& attributes);
100  void StartBspInterior(AttributeList& attributes);
101  void EndBspInterior();
102
103  void StartVspLeaf(AttributeList& attributes);
104  void StartVspInterior(AttributeList& attributes);
105  void EndVspInterior();
106
107  void StartViewCell(ViewCell *viewCell, AttributeList&  attributes);
108  void EndViewCells();
109  void EndBoundingBoxes();
110       
111  void StartHierarchy(AttributeList& attributes);
112
113  void StartBspElement(string element, AttributeList& attributes);
114  void StartVspElement(string element, AttributeList& attributes);
115
116  void StartViewSpaceBox(AttributeList&  attributes);
117
118  void StartBoundingBox(AttributeList& attributes);
119  void StartViewCellLeaf(AttributeList& attributes);
120  void StartViewCellInterior(AttributeList& attributes);
121  void EndViewCellInterior();
122
123  void StartViewSpacePartitionElement(const std::string &element, AttributeList& attributes);
124  void StartObjectSpacePartitionElement(const std::string &element, AttributeList& attributes);
125  void StartViewCellHierarchyElement(const std::string &element, AttributeList& attributes);
126
127  void StartOspElement(string element, AttributeList& attributes);
128
129  void StartOspLeaf(AttributeList& attributes);
130  void StartOspInterior(AttributeList& attributes);
131
132
133  // -----------------------------------------------------------------------
134  //  Handlers for the SAX ErrorHandler interface
135  // -----------------------------------------------------------------------
136
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}
204}
205
206#endif
Note: See TracBrowser for help on using the repository browser.