[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 |
|
---|
[1201] | 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;
|
---|
[1201] | 25 | class VspNode;
|
---|
[1286] | 26 | class BvhNode;
|
---|
[1263] | 27 | class BvHierarchy;
|
---|
[1278] | 28 | class HierarchyManager;
|
---|
[508] | 29 |
|
---|
[1278] | 30 |
|
---|
[508] | 31 | class ViewCellsParseHandlers: public HandlerBase
|
---|
| 32 | {
|
---|
| 33 | public:
|
---|
| 34 | // -----------------------------------------------------------------------
|
---|
| 35 | // Constructors and Destructor
|
---|
| 36 | // -----------------------------------------------------------------------
|
---|
[1004] | 37 | ViewCellsParseHandlers(ObjectContainer *objects, BoundingBoxConverter *bconverter);
|
---|
[508] | 38 | ~ViewCellsParseHandlers();
|
---|
| 39 |
|
---|
| 40 |
|
---|
| 41 | // -----------------------------------------------------------------------
|
---|
| 42 | // Getter methods
|
---|
| 43 | // -----------------------------------------------------------------------
|
---|
| 44 | unsigned int GetElementCount()
|
---|
| 45 | {
|
---|
| 46 | return mElementCount;
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | unsigned int GetAttrCount()
|
---|
| 50 | {
|
---|
| 51 | return mAttrCount;
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | unsigned int GetCharacterCount()
|
---|
| 55 | {
|
---|
| 56 | return mCharacterCount;
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | unsigned int GetSpaceCount()
|
---|
| 60 | {
|
---|
| 61 | return mSpaceCount;
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 |
|
---|
| 65 | // -----------------------------------------------------------------------
|
---|
| 66 | // Handlers for the SAX DocumentHandler interface
|
---|
| 67 | // -----------------------------------------------------------------------
|
---|
| 68 | void endElement(const XMLCh* const name);
|
---|
| 69 | void startElement(const XMLCh* const name, AttributeList& attributes);
|
---|
| 70 | void characters(const XMLCh* const chars, const unsigned int length);
|
---|
| 71 | void ignorableWhitespace(const XMLCh* const chars, const unsigned int length);
|
---|
| 72 | void resetDocument();
|
---|
| 73 |
|
---|
[1263] | 74 | void CreateViewCellsManager(/*const char *name*/);
|
---|
[575] | 75 |
|
---|
| 76 |
|
---|
[1551] | 77 | /////////////////////////
|
---|
| 78 |
|
---|
[508] | 79 | VspBspTree *mVspBspTree;
|
---|
[1278] | 80 | HierarchyManager *mHierarchyManager;
|
---|
[1551] | 81 |
|
---|
[575] | 82 | BspTree *mBspTree;
|
---|
[651] | 83 | ViewCellsTree *mViewCellsTree;
|
---|
[1278] | 84 | VspTree *mVspTree;
|
---|
[651] | 85 |
|
---|
[590] | 86 | BspNode *mCurrentBspNode;
|
---|
[1286] | 87 | BvhNode *mCurrentBvhNode;
|
---|
| 88 | KdNode *mCurrentOspNode;
|
---|
[1201] | 89 | VspNode *mCurrentVspNode;
|
---|
[1551] | 90 |
|
---|
[651] | 91 | ViewCell *mCurrentViewCell;
|
---|
[1286] | 92 |
|
---|
[1263] | 93 | BspNode *mBspRoot;
|
---|
| 94 | VspNode *mVspRoot;
|
---|
| 95 | ViewCell *mViewCellRoot;
|
---|
[651] | 96 |
|
---|
[1551] | 97 | typedef map<int, ViewCell *> ViewCellsMap;
|
---|
| 98 | ViewCellsMap mViewCells;
|
---|
| 99 |
|
---|
[508] | 100 | ViewCellsManager *mViewCellsManager;
|
---|
| 101 | ObjectContainer *mObjects;
|
---|
[931] | 102 | BoundingBoxConverter *mBoundingBoxConverter;
|
---|
[577] | 103 | AxisAlignedBox3 mViewSpaceBox;
|
---|
[931] | 104 | IndexedBoundingBoxContainer mIBoundingBoxes;
|
---|
[1004] | 105 |
|
---|
[1263] | 106 | /// current state of the parser
|
---|
| 107 | int mCurrentState;
|
---|
| 108 |
|
---|
[1286] | 109 | enum {
|
---|
| 110 | PARSE_OPTIONS,
|
---|
| 111 | PARSE_VIEWCELLS,
|
---|
| 112 | PARSE_VIEWSPACE_HIERARCHY,
|
---|
| 113 | PARSE_OBJECTSPACE_HIERARCHY};
|
---|
[1201] | 114 |
|
---|
[1263] | 115 | /// view space / object space hierarchy types
|
---|
| 116 | enum {BSP, VSP, OSP, BVH};
|
---|
| 117 |
|
---|
| 118 | int mViewSpaceHierarchyType;
|
---|
| 119 | int mObjectSpaceHierarchyType;
|
---|
| 120 |
|
---|
[1551] | 121 | ////////////////////////////////
|
---|
| 122 |
|
---|
| 123 |
|
---|
[508] | 124 | // Handlers for X3D
|
---|
[1551] | 125 | ViewCell *GetOrCreateViewCell(const int id, const bool isLeaf);
|
---|
| 126 |
|
---|
[575] | 127 | void StartBspLeaf(AttributeList& attributes);
|
---|
| 128 | void StartBspInterior(AttributeList& attributes);
|
---|
| 129 | void EndBspInterior();
|
---|
[1201] | 130 |
|
---|
| 131 | void StartVspLeaf(AttributeList& attributes);
|
---|
| 132 | void StartVspInterior(AttributeList& attributes);
|
---|
| 133 | void EndVspInterior();
|
---|
| 134 |
|
---|
[1551] | 135 | void StartViewCellPvs(ObjectPvs &pvs, const char *ptr);
|
---|
| 136 |
|
---|
[508] | 137 | void EndViewCells();
|
---|
[931] | 138 | void EndBoundingBoxes();
|
---|
[575] | 139 |
|
---|
[1201] | 140 | void StartBspElement(string element, AttributeList& attributes);
|
---|
| 141 | void StartVspElement(string element, AttributeList& attributes);
|
---|
| 142 |
|
---|
[1264] | 143 | void StartViewSpaceHierarchy(AttributeList& attributes);
|
---|
| 144 | void StartObjectSpaceHierarchy(AttributeList& attributes);
|
---|
[651] | 145 |
|
---|
[931] | 146 | void StartBoundingBox(AttributeList& attributes);
|
---|
[1551] | 147 | void StartViewCell(AttributeList& attributes, const bool isLeaf);
|
---|
[651] | 148 | void EndViewCellInterior();
|
---|
| 149 |
|
---|
[1233] | 150 | void StartViewSpaceHierarchyElement(const std::string &element, AttributeList& attributes);
|
---|
| 151 | void StartObjectSpaceHierarchyElement(const std::string &element, AttributeList& attributes);
|
---|
[1201] | 152 | void StartViewCellHierarchyElement(const std::string &element, AttributeList& attributes);
|
---|
[651] | 153 |
|
---|
[1201] | 154 | void StartOspElement(string element, AttributeList& attributes);
|
---|
| 155 |
|
---|
| 156 | void StartOspLeaf(AttributeList& attributes);
|
---|
| 157 | void StartOspInterior(AttributeList& attributes);
|
---|
| 158 |
|
---|
[1264] | 159 | void CreateViewSpaceHierarchy();
|
---|
[1201] | 160 |
|
---|
[1264] | 161 | void StartBvhLeaf(AttributeList& attributes);
|
---|
| 162 | void StartBvhInterior(AttributeList& attributes);
|
---|
| 163 | void StartBvhElement(string element, AttributeList& attributes);
|
---|
| 164 |
|
---|
[1286] | 165 | void EndViewSpaceHierarchyInterior();
|
---|
| 166 | void EndObjectSpaceHierarchyInterior();
|
---|
[1264] | 167 |
|
---|
[1286] | 168 | void EndBvhInterior();
|
---|
| 169 | void EndOspInterior();
|
---|
| 170 |
|
---|
| 171 | void EndObjectSpaceHierarchy();
|
---|
| 172 |
|
---|
| 173 | void StartBvhLeafObjects(ObjectContainer &objects, const char *ptr);
|
---|
| 174 |
|
---|
[508] | 175 | // -----------------------------------------------------------------------
|
---|
| 176 | // Handlers for the SAX ErrorHandler interface
|
---|
| 177 | // -----------------------------------------------------------------------
|
---|
[651] | 178 |
|
---|
[508] | 179 | void warning(const SAXParseException& exc);
|
---|
| 180 | void error(const SAXParseException& exc);
|
---|
| 181 | void fatalError(const SAXParseException& exc);
|
---|
| 182 |
|
---|
| 183 |
|
---|
| 184 | private:
|
---|
| 185 | // -----------------------------------------------------------------------
|
---|
| 186 | // Private data members
|
---|
| 187 | //
|
---|
| 188 | // fAttrCount
|
---|
| 189 | // fCharacterCount
|
---|
| 190 | // fElementCount
|
---|
| 191 | // fSpaceCount
|
---|
| 192 | // These are just counters that are run upwards based on the input
|
---|
| 193 | // from the document handlers.
|
---|
| 194 | // -----------------------------------------------------------------------
|
---|
| 195 | unsigned int mAttrCount;
|
---|
| 196 | unsigned int mCharacterCount;
|
---|
| 197 | unsigned int mElementCount;
|
---|
| 198 | unsigned int mSpaceCount;
|
---|
| 199 | };
|
---|
| 200 |
|
---|
| 201 | // ---------------------------------------------------------------------------
|
---|
| 202 | // This is a simple class that lets us do easy (though not terribly efficient)
|
---|
| 203 | // trancoding of XMLCh data to local code page for display.
|
---|
| 204 | // ---------------------------------------------------------------------------
|
---|
| 205 | class StrX
|
---|
| 206 | {
|
---|
| 207 | public :
|
---|
| 208 | // -----------------------------------------------------------------------
|
---|
| 209 | // Constructors and Destructor
|
---|
| 210 | // -----------------------------------------------------------------------
|
---|
| 211 | StrX(const XMLCh* const toTranscode)
|
---|
| 212 | {
|
---|
| 213 | // Call the private transcoding method
|
---|
| 214 | mLocalForm = XMLString::transcode(toTranscode);
|
---|
| 215 | }
|
---|
| 216 |
|
---|
| 217 | ~StrX()
|
---|
| 218 | {
|
---|
| 219 | XMLString::release(&mLocalForm);
|
---|
| 220 | }
|
---|
| 221 |
|
---|
| 222 | // -----------------------------------------------------------------------
|
---|
| 223 | // Getter methods
|
---|
| 224 | // -----------------------------------------------------------------------
|
---|
| 225 | const char* LocalForm() const
|
---|
| 226 | {
|
---|
| 227 | return mLocalForm;
|
---|
| 228 | }
|
---|
| 229 |
|
---|
| 230 | private :
|
---|
| 231 | // -----------------------------------------------------------------------
|
---|
| 232 | // Private data members
|
---|
| 233 | //
|
---|
| 234 | // fLocalForm
|
---|
| 235 | // This is the local code page form of the string.
|
---|
| 236 | // -----------------------------------------------------------------------
|
---|
| 237 | char* mLocalForm;
|
---|
| 238 | };
|
---|
| 239 |
|
---|
| 240 | inline XERCES_STD_QUALIFIER ostream&
|
---|
| 241 | operator<<(XERCES_STD_QUALIFIER ostream& target, const StrX& toDump)
|
---|
| 242 | {
|
---|
| 243 | target << toDump.LocalForm();
|
---|
| 244 | return target;
|
---|
| 245 | }
|
---|
[860] | 246 | }
|
---|
| 247 |
|
---|
[508] | 248 | #endif
|
---|