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

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

environment as a singleton

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