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 |
|
---|
12 | namespace GtpVisibilityPreprocessor {
|
---|
13 |
|
---|
14 | XERCES_CPP_NAMESPACE_USE
|
---|
15 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
16 | class AttributeList;
|
---|
17 | XERCES_CPP_NAMESPACE_END
|
---|
18 |
|
---|
19 | class VspBspTree;
|
---|
20 | class BspTree;
|
---|
21 | class ViewCellsManager;
|
---|
22 | class ViewCellsTree;
|
---|
23 |
|
---|
24 | class ViewCellsParseHandlers: public HandlerBase
|
---|
25 | {
|
---|
26 | public:
|
---|
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 | BspTree *mBspTree;
|
---|
72 | ViewCellsTree *mViewCellsTree;
|
---|
73 |
|
---|
74 | BspNode *mCurrentBspNode;
|
---|
75 | ViewCell *mCurrentViewCell;
|
---|
76 |
|
---|
77 | ViewCellContainer mViewCells;
|
---|
78 | ViewCellsManager *mViewCellsManager;
|
---|
79 | ObjectContainer *mObjects;
|
---|
80 | BoundingBoxConverter *mBoundingBoxConverter;
|
---|
81 |
|
---|
82 | AxisAlignedBox3 mViewSpaceBox;
|
---|
83 |
|
---|
84 | IndexedBoundingBoxContainer mIBoundingBoxes;
|
---|
85 |
|
---|
86 | bool mParseViewCells;
|
---|
87 |
|
---|
88 | // Handlers for X3D
|
---|
89 | void StartBspLeaf(AttributeList& attributes);
|
---|
90 | void StartBspInterior(AttributeList& attributes);
|
---|
91 | void EndBspInterior();
|
---|
92 |
|
---|
93 | void StartViewCell(ViewCell *viewCell, AttributeList& attributes);
|
---|
94 | void EndViewCells();
|
---|
95 | void EndBoundingBoxes();
|
---|
96 |
|
---|
97 | void StartHierarchy(AttributeList& attributes);
|
---|
98 |
|
---|
99 | void startBspElement(string element, AttributeList& attributes);
|
---|
100 | void StartViewSpaceBox(AttributeList& attributes);
|
---|
101 |
|
---|
102 | void StartBoundingBox(AttributeList& attributes);
|
---|
103 | void StartViewCellLeaf(AttributeList& attributes);
|
---|
104 | void StartViewCellInterior(AttributeList& attributes);
|
---|
105 | void EndViewCellInterior();
|
---|
106 |
|
---|
107 |
|
---|
108 | // -----------------------------------------------------------------------
|
---|
109 | // Handlers for the SAX ErrorHandler interface
|
---|
110 | // -----------------------------------------------------------------------
|
---|
111 |
|
---|
112 | void warning(const SAXParseException& exc);
|
---|
113 | void error(const SAXParseException& exc);
|
---|
114 | void fatalError(const SAXParseException& exc);
|
---|
115 |
|
---|
116 |
|
---|
117 | private:
|
---|
118 | // -----------------------------------------------------------------------
|
---|
119 | // Private data members
|
---|
120 | //
|
---|
121 | // fAttrCount
|
---|
122 | // fCharacterCount
|
---|
123 | // fElementCount
|
---|
124 | // fSpaceCount
|
---|
125 | // These are just counters that are run upwards based on the input
|
---|
126 | // from the document handlers.
|
---|
127 | // -----------------------------------------------------------------------
|
---|
128 | unsigned int mAttrCount;
|
---|
129 | unsigned int mCharacterCount;
|
---|
130 | unsigned int mElementCount;
|
---|
131 | unsigned int mSpaceCount;
|
---|
132 | };
|
---|
133 |
|
---|
134 | // ---------------------------------------------------------------------------
|
---|
135 | // This is a simple class that lets us do easy (though not terribly efficient)
|
---|
136 | // trancoding of XMLCh data to local code page for display.
|
---|
137 | // ---------------------------------------------------------------------------
|
---|
138 | class StrX
|
---|
139 | {
|
---|
140 | public :
|
---|
141 | // -----------------------------------------------------------------------
|
---|
142 | // Constructors and Destructor
|
---|
143 | // -----------------------------------------------------------------------
|
---|
144 | StrX(const XMLCh* const toTranscode)
|
---|
145 | {
|
---|
146 | // Call the private transcoding method
|
---|
147 | mLocalForm = XMLString::transcode(toTranscode);
|
---|
148 | }
|
---|
149 |
|
---|
150 | ~StrX()
|
---|
151 | {
|
---|
152 | XMLString::release(&mLocalForm);
|
---|
153 | }
|
---|
154 |
|
---|
155 | // -----------------------------------------------------------------------
|
---|
156 | // Getter methods
|
---|
157 | // -----------------------------------------------------------------------
|
---|
158 | const char* LocalForm() const
|
---|
159 | {
|
---|
160 | return mLocalForm;
|
---|
161 | }
|
---|
162 |
|
---|
163 | private :
|
---|
164 | // -----------------------------------------------------------------------
|
---|
165 | // Private data members
|
---|
166 | //
|
---|
167 | // fLocalForm
|
---|
168 | // This is the local code page form of the string.
|
---|
169 | // -----------------------------------------------------------------------
|
---|
170 | char* mLocalForm;
|
---|
171 | };
|
---|
172 |
|
---|
173 | inline XERCES_STD_QUALIFIER ostream&
|
---|
174 | operator<<(XERCES_STD_QUALIFIER ostream& target, const StrX& toDump)
|
---|
175 | {
|
---|
176 | target << toDump.LocalForm();
|
---|
177 | return target;
|
---|
178 | }
|
---|
179 | }
|
---|
180 |
|
---|
181 | #endif
|
---|