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

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