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