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

Revision 931, 5.3 KB checked in by mattausch, 18 years ago (diff)

added bounding boxes to xml description

Line 
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"
9#include "BoundingBoxConverter.h"
10
11namespace GtpVisibilityPreprocessor {
12
13XERCES_CPP_NAMESPACE_USE
14XERCES_CPP_NAMESPACE_BEGIN
15class AttributeList;
16XERCES_CPP_NAMESPACE_END
17
18class VspBspTree;
19class VspKdTree;
20class BspTree;
21class ViewCellsManager;
22class ViewCellsTree;
23
24class ViewCellsParseHandlers: public HandlerBase
25{
26public:
27  // -----------------------------------------------------------------------
28  //  Constructors and Destructor
29  // -----------------------------------------------------------------------
30  ViewCellsParseHandlers(ObjectContainer *objects, BoundingBoxConverter *bconverter);
31  ~ViewCellsParseHandlers();
32 
33 
34  // -----------------------------------------------------------------------
35  //  Getter methods
36  // -----------------------------------------------------------------------
37  unsigned int GetElementCount()
38  {
39    return mElementCount;
40  }
41 
42  unsigned int GetAttrCount()
43  {
44    return mAttrCount;
45  }
46 
47  unsigned int GetCharacterCount()
48  {
49    return mCharacterCount;
50  }
51 
52  unsigned int GetSpaceCount()
53  {
54    return mSpaceCount;
55  }
56
57
58  // -----------------------------------------------------------------------
59  //  Handlers for the SAX DocumentHandler interface
60  // -----------------------------------------------------------------------
61  void endElement(const XMLCh* const name);
62  void startElement(const XMLCh* const name, AttributeList& attributes);
63  void characters(const XMLCh* const chars, const unsigned int length);
64  void ignorableWhitespace(const XMLCh* const chars, const unsigned int length);
65  void resetDocument();
66
67  void CreateViewCellsManager(const char *name);
68
69
70  VspBspTree *mVspBspTree;
71  VspKdTree *mVspKdTree;
72  BspTree *mBspTree;
73  ViewCellsTree *mViewCellsTree;
74
75  BspNode *mCurrentBspNode;
76  ViewCell *mCurrentViewCell;
77
78  ViewCellContainer mViewCells;
79  ViewCellsManager *mViewCellsManager;
80  ObjectContainer *mObjects;
81  BoundingBoxConverter *mBoundingBoxConverter;
82
83  AxisAlignedBox3 mViewSpaceBox;
84
85  IndexedBoundingBoxContainer mIBoundingBoxes;
86
87  bool mParseViewCells;
88
89  // Handlers for X3D
90  void StartBspLeaf(AttributeList& attributes);
91  void StartBspInterior(AttributeList& attributes);
92  void EndBspInterior();
93 
94  void StartViewCell(ViewCell *viewCell, AttributeList&  attributes);
95  void EndViewCells();
96  void EndBoundingBoxes();
97       
98  void StartHierarchy(AttributeList& attributes);
99
100  void startBspElement(string element, AttributeList& attributes);
101  void StartViewSpaceBox(AttributeList&  attributes);
102
103  void StartBoundingBox(AttributeList& attributes);
104  void StartViewCellLeaf(AttributeList& attributes);
105  void StartViewCellInterior(AttributeList& attributes);
106  void EndViewCellInterior();
107
108
109  // -----------------------------------------------------------------------
110  //  Handlers for the SAX ErrorHandler interface
111  // -----------------------------------------------------------------------
112
113  void warning(const SAXParseException& exc);
114  void error(const SAXParseException& exc);
115  void fatalError(const SAXParseException& exc);
116 
117 
118private:
119  // -----------------------------------------------------------------------
120  //  Private data members
121  //
122  //  fAttrCount
123  //  fCharacterCount
124  //  fElementCount
125  //  fSpaceCount
126  //      These are just counters that are run upwards based on the input
127  //      from the document handlers.
128  // -----------------------------------------------------------------------
129  unsigned int    mAttrCount;
130  unsigned int    mCharacterCount;
131  unsigned int    mElementCount;
132  unsigned int    mSpaceCount;
133};
134
135// ---------------------------------------------------------------------------
136//  This is a simple class that lets us do easy (though not terribly efficient)
137//  trancoding of XMLCh data to local code page for display.
138// ---------------------------------------------------------------------------
139class StrX
140{
141public :
142  // -----------------------------------------------------------------------
143  //  Constructors and Destructor
144  // -----------------------------------------------------------------------
145  StrX(const XMLCh* const toTranscode)
146  {
147          // Call the private transcoding method
148          mLocalForm = XMLString::transcode(toTranscode);
149  }
150 
151  ~StrX()
152  {
153          XMLString::release(&mLocalForm);
154  }
155 
156  // -----------------------------------------------------------------------
157  //  Getter methods
158  // -----------------------------------------------------------------------
159  const char* LocalForm() const
160  {
161    return mLocalForm;
162  }
163 
164private :
165  // -----------------------------------------------------------------------
166  //  Private data members
167  //
168  //  fLocalForm
169  //      This is the local code page form of the string.
170  // -----------------------------------------------------------------------
171  char*   mLocalForm;
172};
173
174inline XERCES_STD_QUALIFIER ostream&
175operator<<(XERCES_STD_QUALIFIER ostream& target, const StrX& toDump)
176{
177  target << toDump.LocalForm();
178  return target;
179}
180
181}
182
183#endif
Note: See TracBrowser for help on using the repository browser.