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

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

warning: debug version

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,
126          PARSE_OBJECTSPACE_HIERARCHY};
[1201]127
[1263]128  /// view space / object space hierarchy types
129  enum {BSP, VSP, OSP, BVH};
130
131  int mViewSpaceHierarchyType;
132  int mObjectSpaceHierarchyType;
[2048]133  int nViewCells;
134  int nObjects;
135 
136 
[1551]137  ////////////////////////////////
138
139
[508]140  // Handlers for X3D
[2093]141 
[575]142  void StartBspLeaf(AttributeList& attributes);
143  void StartBspInterior(AttributeList& attributes);
144  void EndBspInterior();
[1201]145
146  void StartVspLeaf(AttributeList& attributes);
147  void StartVspInterior(AttributeList& attributes);
148  void EndVspInterior();
149
[1551]150  void StartViewCellPvs(ObjectPvs &pvs, const char *ptr);
151
[508]152  void EndViewCells();
[931]153  void EndBoundingBoxes();
[575]154
[1201]155  void StartBspElement(string element, AttributeList& attributes);
156  void StartVspElement(string element, AttributeList& attributes);
157
[1264]158  void StartViewSpaceHierarchy(AttributeList& attributes);
159  void StartObjectSpaceHierarchy(AttributeList& attributes);
[651]160
[931]161  void StartBoundingBox(AttributeList& attributes);
[1551]162  void StartViewCell(AttributeList& attributes, const bool isLeaf);
[651]163  void EndViewCellInterior();
164
[1233]165  void StartViewSpaceHierarchyElement(const std::string &element, AttributeList& attributes);
166  void StartObjectSpaceHierarchyElement(const std::string &element, AttributeList& attributes);
[1201]167  void StartViewCellHierarchyElement(const std::string &element, AttributeList& attributes);
[651]168
[1201]169  void StartOspElement(string element, AttributeList& attributes);
170
171  void StartOspLeaf(AttributeList& attributes);
172  void StartOspInterior(AttributeList& attributes);
173
[1264]174  void CreateViewSpaceHierarchy();
[1201]175
[1264]176  void StartBvhLeaf(AttributeList& attributes);
177  void StartBvhInterior(AttributeList& attributes);
178  void StartBvhElement(string element, AttributeList& attributes);
179
[1286]180  void EndViewSpaceHierarchyInterior();
181  void EndObjectSpaceHierarchyInterior();
[1264]182
[1286]183  void EndBvhInterior();
184  void EndOspInterior();
185
186  void EndObjectSpaceHierarchy();
187
188  void StartBvhLeafObjects(ObjectContainer &objects, const char *ptr);
189
[508]190  // -----------------------------------------------------------------------
191  //  Handlers for the SAX ErrorHandler interface
192  // -----------------------------------------------------------------------
[651]193
[508]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}
[860]261}
262
[508]263#endif
Note: See TracBrowser for help on using the repository browser.