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