source: GTP/trunk/Lib/Vis/Preprocessing/src/ObjectsParserXerces.h @ 2113

Revision 2113, 7.4 KB checked in by mattausch, 17 years ago (diff)

warning: debug version

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