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