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

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

implemented hashpvs

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