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