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

Revision 1286, 7.1 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 BvhNode;
27class BvHierarchy;
28class HierarchyManager;
29
30
31class ViewCellsParseHandlers: public HandlerBase
32{
33public:
34  // -----------------------------------------------------------------------
35  //  Constructors and Destructor
36  // -----------------------------------------------------------------------
37  ViewCellsParseHandlers(ObjectContainer *objects, BoundingBoxConverter *bconverter);
38  ~ViewCellsParseHandlers();
39 
40 
41  // -----------------------------------------------------------------------
42  //  Getter methods
43  // -----------------------------------------------------------------------
44  unsigned int GetElementCount()
45  {
46    return mElementCount;
47  }
48 
49  unsigned int GetAttrCount()
50  {
51    return mAttrCount;
52  }
53 
54  unsigned int GetCharacterCount()
55  {
56    return mCharacterCount;
57  }
58 
59  unsigned int GetSpaceCount()
60  {
61    return mSpaceCount;
62  }
63
64
65  // -----------------------------------------------------------------------
66  //  Handlers for the SAX DocumentHandler interface
67  // -----------------------------------------------------------------------
68  void endElement(const XMLCh* const name);
69  void startElement(const XMLCh* const name, AttributeList& attributes);
70  void characters(const XMLCh* const chars, const unsigned int length);
71  void ignorableWhitespace(const XMLCh* const chars, const unsigned int length);
72  void resetDocument();
73
74  void CreateViewCellsManager(/*const char *name*/);
75
76
77  VspBspTree *mVspBspTree;
78  HierarchyManager *mHierarchyManager;
79  BvHierarchy *mBvHierarchy;
80
81  BspTree *mBspTree;
82  ViewCellsTree *mViewCellsTree;
83  VspTree *mVspTree;
84
85  BspNode *mCurrentBspNode;
86  BvhNode *mCurrentBvhNode;
87  KdNode *mCurrentOspNode;
88  VspNode *mCurrentVspNode;
89  //KdNode *mCurrentKdNode;
90
91  ViewCell *mCurrentViewCell;
92   
93  BspNode *mBspRoot;
94  VspNode *mVspRoot;
95  ViewCell *mViewCellRoot;
96
97  ViewCellContainer mViewCells;
98  ViewCellsManager *mViewCellsManager;
99  ObjectContainer *mObjects;
100  BoundingBoxConverter *mBoundingBoxConverter;
101  AxisAlignedBox3 mViewSpaceBox;
102  IndexedBoundingBoxContainer mIBoundingBoxes;
103 
104  /// current state of the parser
105  int mCurrentState;
106 
107  enum {
108          PARSE_OPTIONS,
109          PARSE_VIEWCELLS,
110          PARSE_VIEWSPACE_HIERARCHY,
111          PARSE_OBJECTSPACE_HIERARCHY};
112
113  /// view space / object space hierarchy types
114  enum {BSP, VSP, OSP, BVH};
115
116  int mViewSpaceHierarchyType;
117  int mObjectSpaceHierarchyType;
118
119  // Handlers for X3D
120  void StartBspLeaf(AttributeList& attributes);
121  void StartBspInterior(AttributeList& attributes);
122  void EndBspInterior();
123
124  void StartVspLeaf(AttributeList& attributes);
125  void StartVspInterior(AttributeList& attributes);
126  void EndVspInterior();
127
128  void StartViewCellPvs(ViewCell *viewCell, AttributeList&  attributes);
129  void EndViewCells();
130  void EndBoundingBoxes();
131       
132  void StartHierarchy(AttributeList& attributes);
133
134  void StartBspElement(string element, AttributeList& attributes);
135  void StartVspElement(string element, AttributeList& attributes);
136
137  void StartViewSpaceHierarchy(AttributeList& attributes);
138  void StartObjectSpaceHierarchy(AttributeList& attributes);
139
140  void StartBoundingBox(AttributeList& attributes);
141  void StartViewCellLeaf(AttributeList& attributes);
142  void StartViewCellInterior(AttributeList& attributes);
143  void EndViewCellInterior();
144
145  void StartViewSpaceHierarchyElement(const std::string &element, AttributeList& attributes);
146  void StartObjectSpaceHierarchyElement(const std::string &element, AttributeList& attributes);
147  void StartViewCellHierarchyElement(const std::string &element, AttributeList& attributes);
148
149  void StartOspElement(string element, AttributeList& attributes);
150
151  void StartOspLeaf(AttributeList& attributes);
152  void StartOspInterior(AttributeList& attributes);
153
154  void CreateViewSpaceHierarchy();
155
156  void StartBvhLeaf(AttributeList& attributes);
157  void StartBvhInterior(AttributeList& attributes);
158  void StartBvhElement(string element, AttributeList& attributes);
159
160  void EndViewSpaceHierarchyInterior();
161  void EndObjectSpaceHierarchyInterior();
162
163  void EndBvhInterior();
164  void EndOspInterior();
165
166  void EndObjectSpaceHierarchy();
167
168  void StartBvhLeafObjects(ObjectContainer &objects, const char *ptr);
169
170  // -----------------------------------------------------------------------
171  //  Handlers for the SAX ErrorHandler interface
172  // -----------------------------------------------------------------------
173
174  void warning(const SAXParseException& exc);
175  void error(const SAXParseException& exc);
176  void fatalError(const SAXParseException& exc);
177 
178 
179private:
180  // -----------------------------------------------------------------------
181  //  Private data members
182  //
183  //  fAttrCount
184  //  fCharacterCount
185  //  fElementCount
186  //  fSpaceCount
187  //      These are just counters that are run upwards based on the input
188  //      from the document handlers.
189  // -----------------------------------------------------------------------
190  unsigned int    mAttrCount;
191  unsigned int    mCharacterCount;
192  unsigned int    mElementCount;
193  unsigned int    mSpaceCount;
194};
195
196// ---------------------------------------------------------------------------
197//  This is a simple class that lets us do easy (though not terribly efficient)
198//  trancoding of XMLCh data to local code page for display.
199// ---------------------------------------------------------------------------
200class StrX
201{
202public :
203  // -----------------------------------------------------------------------
204  //  Constructors and Destructor
205  // -----------------------------------------------------------------------
206  StrX(const XMLCh* const toTranscode)
207  {
208          // Call the private transcoding method
209          mLocalForm = XMLString::transcode(toTranscode);
210  }
211 
212  ~StrX()
213  {
214          XMLString::release(&mLocalForm);
215  }
216 
217  // -----------------------------------------------------------------------
218  //  Getter methods
219  // -----------------------------------------------------------------------
220  const char* LocalForm() const
221  {
222    return mLocalForm;
223  }
224 
225private :
226  // -----------------------------------------------------------------------
227  //  Private data members
228  //
229  //  fLocalForm
230  //      This is the local code page form of the string.
231  // -----------------------------------------------------------------------
232  char*   mLocalForm;
233};
234
235inline XERCES_STD_QUALIFIER ostream&
236operator<<(XERCES_STD_QUALIFIER ostream& target, const StrX& toDump)
237{
238  target << toDump.LocalForm();
239  return target;
240}
241}
242
243#endif
Note: See TracBrowser for help on using the repository browser.