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