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