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