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

Revision 1287, 7.1 KB checked in by mattausch, 18 years ago (diff)

implemented bv hierarchy

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