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

Revision 2115, 7.3 KB checked in by mattausch, 17 years ago (diff)

changed pvs loading: loading objects in a first pass

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