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