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