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

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