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