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

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