[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"
|
---|
[508] | 10 |
|
---|
[860] | 11 | namespace GtpVisibilityPreprocessor {
|
---|
| 12 |
|
---|
[508] | 13 | XERCES_CPP_NAMESPACE_USE
|
---|
| 14 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
| 15 | class AttributeList;
|
---|
| 16 | XERCES_CPP_NAMESPACE_END
|
---|
| 17 |
|
---|
| 18 | class VspBspTree;
|
---|
[590] | 19 | class VspKdTree;
|
---|
[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 | // -----------------------------------------------------------------------
|
---|
[938] | 30 | ViewCellsParseHandlers(ObjectContainer *objects, BoundingBoxConverter *bconverter, Environment *env);
|
---|
[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;
|
---|
[590] | 71 | VspKdTree *mVspKdTree;
|
---|
[575] | 72 | BspTree *mBspTree;
|
---|
[651] | 73 | ViewCellsTree *mViewCellsTree;
|
---|
| 74 |
|
---|
[590] | 75 | BspNode *mCurrentBspNode;
|
---|
[651] | 76 | ViewCell *mCurrentViewCell;
|
---|
| 77 |
|
---|
[508] | 78 | ViewCellContainer mViewCells;
|
---|
| 79 | ViewCellsManager *mViewCellsManager;
|
---|
| 80 | ObjectContainer *mObjects;
|
---|
[931] | 81 | BoundingBoxConverter *mBoundingBoxConverter;
|
---|
[508] | 82 |
|
---|
[577] | 83 | AxisAlignedBox3 mViewSpaceBox;
|
---|
| 84 |
|
---|
[931] | 85 | IndexedBoundingBoxContainer mIBoundingBoxes;
|
---|
[938] | 86 | Environment *mEnvironment;
|
---|
[931] | 87 |
|
---|
[651] | 88 | bool mParseViewCells;
|
---|
| 89 |
|
---|
[508] | 90 | // Handlers for X3D
|
---|
[575] | 91 | void StartBspLeaf(AttributeList& attributes);
|
---|
| 92 | void StartBspInterior(AttributeList& attributes);
|
---|
| 93 | void EndBspInterior();
|
---|
[508] | 94 |
|
---|
[651] | 95 | void StartViewCell(ViewCell *viewCell, AttributeList& attributes);
|
---|
[508] | 96 | void EndViewCells();
|
---|
[931] | 97 | void EndBoundingBoxes();
|
---|
[651] | 98 |
|
---|
[575] | 99 | void StartHierarchy(AttributeList& attributes);
|
---|
| 100 |
|
---|
| 101 | void startBspElement(string element, AttributeList& attributes);
|
---|
[577] | 102 | void StartViewSpaceBox(AttributeList& attributes);
|
---|
[651] | 103 |
|
---|
[931] | 104 | void StartBoundingBox(AttributeList& attributes);
|
---|
[651] | 105 | void StartViewCellLeaf(AttributeList& attributes);
|
---|
| 106 | void StartViewCellInterior(AttributeList& attributes);
|
---|
| 107 | void EndViewCellInterior();
|
---|
| 108 |
|
---|
| 109 |
|
---|
[508] | 110 | // -----------------------------------------------------------------------
|
---|
| 111 | // Handlers for the SAX ErrorHandler interface
|
---|
| 112 | // -----------------------------------------------------------------------
|
---|
[651] | 113 |
|
---|
[508] | 114 | void warning(const SAXParseException& exc);
|
---|
| 115 | void error(const SAXParseException& exc);
|
---|
| 116 | void fatalError(const SAXParseException& exc);
|
---|
| 117 |
|
---|
| 118 |
|
---|
| 119 | private:
|
---|
| 120 | // -----------------------------------------------------------------------
|
---|
| 121 | // Private data members
|
---|
| 122 | //
|
---|
| 123 | // fAttrCount
|
---|
| 124 | // fCharacterCount
|
---|
| 125 | // fElementCount
|
---|
| 126 | // fSpaceCount
|
---|
| 127 | // These are just counters that are run upwards based on the input
|
---|
| 128 | // from the document handlers.
|
---|
| 129 | // -----------------------------------------------------------------------
|
---|
| 130 | unsigned int mAttrCount;
|
---|
| 131 | unsigned int mCharacterCount;
|
---|
| 132 | unsigned int mElementCount;
|
---|
| 133 | unsigned int mSpaceCount;
|
---|
| 134 | };
|
---|
| 135 |
|
---|
| 136 | // ---------------------------------------------------------------------------
|
---|
| 137 | // This is a simple class that lets us do easy (though not terribly efficient)
|
---|
| 138 | // trancoding of XMLCh data to local code page for display.
|
---|
| 139 | // ---------------------------------------------------------------------------
|
---|
| 140 | class StrX
|
---|
| 141 | {
|
---|
| 142 | public :
|
---|
| 143 | // -----------------------------------------------------------------------
|
---|
| 144 | // Constructors and Destructor
|
---|
| 145 | // -----------------------------------------------------------------------
|
---|
| 146 | StrX(const XMLCh* const toTranscode)
|
---|
| 147 | {
|
---|
| 148 | // Call the private transcoding method
|
---|
| 149 | mLocalForm = XMLString::transcode(toTranscode);
|
---|
| 150 | }
|
---|
| 151 |
|
---|
| 152 | ~StrX()
|
---|
| 153 | {
|
---|
| 154 | XMLString::release(&mLocalForm);
|
---|
| 155 | }
|
---|
| 156 |
|
---|
| 157 | // -----------------------------------------------------------------------
|
---|
| 158 | // Getter methods
|
---|
| 159 | // -----------------------------------------------------------------------
|
---|
| 160 | const char* LocalForm() const
|
---|
| 161 | {
|
---|
| 162 | return mLocalForm;
|
---|
| 163 | }
|
---|
| 164 |
|
---|
| 165 | private :
|
---|
| 166 | // -----------------------------------------------------------------------
|
---|
| 167 | // Private data members
|
---|
| 168 | //
|
---|
| 169 | // fLocalForm
|
---|
| 170 | // This is the local code page form of the string.
|
---|
| 171 | // -----------------------------------------------------------------------
|
---|
| 172 | char* mLocalForm;
|
---|
| 173 | };
|
---|
| 174 |
|
---|
| 175 | inline XERCES_STD_QUALIFIER ostream&
|
---|
| 176 | operator<<(XERCES_STD_QUALIFIER ostream& target, const StrX& toDump)
|
---|
| 177 | {
|
---|
| 178 | target << toDump.LocalForm();
|
---|
| 179 | return target;
|
---|
| 180 | }
|
---|
| 181 |
|
---|
[860] | 182 | }
|
---|
| 183 |
|
---|
[508] | 184 | #endif
|
---|