#ifndef _X3D_PARSER_XERCES__H #define _X3D_PARSER_XERCES__H // --------------------------------------------------------------------------- // Includes // --------------------------------------------------------------------------- #include #include "Mesh.h" #include "BoundingBoxConverter.h" namespace GtpVisibilityPreprocessor { XERCES_CPP_NAMESPACE_USE XERCES_CPP_NAMESPACE_BEGIN class AttributeList; XERCES_CPP_NAMESPACE_END class VspBspTree; class BspTree; class ViewCellsManager; class ViewCellsTree; class VspTree; class OspTree; class VspNode; class BvhNode; class BvHierarchy; class HierarchyManager; class ViewCellsParseHandlers: public HandlerBase { public: // ----------------------------------------------------------------------- // Constructors and Destructor // ----------------------------------------------------------------------- ViewCellsParseHandlers(ObjectContainer &pvsObjects, ObjectContainer &preprocessorObjects, BoundingBoxConverter *bconverter); ~ViewCellsParseHandlers(); // ----------------------------------------------------------------------- // Getter methods // ----------------------------------------------------------------------- unsigned int GetElementCount() { return mElementCount; } unsigned int GetAttrCount() { return mAttrCount; } unsigned int GetCharacterCount() { return mCharacterCount; } unsigned int GetSpaceCount() { return mSpaceCount; } // ----------------------------------------------------------------------- // Handlers for the SAX DocumentHandler interface // ----------------------------------------------------------------------- void endElement(const XMLCh* const name); void startElement(const XMLCh* const name, AttributeList& attributes); void characters(const XMLCh* const chars, const unsigned int length); void ignorableWhitespace(const XMLCh* const chars, const unsigned int length); void resetDocument(); void CreateViewCellsManager(/*const char *name*/); void ReplacePvs(); void ReplaceBvhPvs(ViewCell *vc); ///////////////////////// VspBspTree *mVspBspTree; HierarchyManager *mHierarchyManager; BspTree *mBspTree; ViewCellsTree *mViewCellsTree; VspTree *mVspTree; BspNode *mCurrentBspNode; BvhNode *mCurrentBvhNode; KdNode *mCurrentOspNode; VspNode *mCurrentVspNode; ViewCell *mCurrentViewCell; BspNode *mBspRoot; VspNode *mVspRoot; ViewCell *mViewCellRoot; int mUniqueObjectId; vector mBvhLeaves; //typedef map ViewCellsMap; //ViewCellsMap mViewCells; ViewCellContainer mViewCells; ViewCellsManager *mViewCellsManager; ObjectContainer &mPvsObjects; ObjectContainer &mPreprocessorObjects; bool mCreatePvsObjects; BoundingBoxConverter *mBoundingBoxConverter; AxisAlignedBox3 mViewSpaceBox; IndexedBoundingBoxContainer mIBoundingBoxes; /// current state of the parser int mCurrentState; enum { PARSE_OPTIONS, PARSE_VIEWCELLS, PARSE_VIEWSPACE_HIERARCHY, PARSE_OBJECTSPACE_HIERARCHY}; /// view space / object space hierarchy types enum {BSP, VSP, OSP, BVH}; int mViewSpaceHierarchyType; int mObjectSpaceHierarchyType; int nViewCells; int nObjects; //////////////////////////////// // Handlers for X3D void StartBspLeaf(AttributeList& attributes); void StartBspInterior(AttributeList& attributes); void EndBspInterior(); void StartVspLeaf(AttributeList& attributes); void StartVspInterior(AttributeList& attributes); void EndVspInterior(); void StartViewCellPvs(ObjectPvs &pvs, const char *ptr); void EndViewCells(); void EndBoundingBoxes(); void StartBspElement(string element, AttributeList& attributes); void StartVspElement(string element, AttributeList& attributes); void StartViewSpaceHierarchy(AttributeList& attributes); void StartObjectSpaceHierarchy(AttributeList& attributes); void StartBoundingBox(AttributeList& attributes); void StartViewCell(AttributeList& attributes, const bool isLeaf); void EndViewCellInterior(); void StartViewSpaceHierarchyElement(const std::string &element, AttributeList& attributes); void StartObjectSpaceHierarchyElement(const std::string &element, AttributeList& attributes); void StartViewCellHierarchyElement(const std::string &element, AttributeList& attributes); void StartOspElement(string element, AttributeList& attributes); void StartOspLeaf(AttributeList& attributes); void StartOspInterior(AttributeList& attributes); void CreateViewSpaceHierarchy(); void StartBvhLeaf(AttributeList& attributes); void StartBvhInterior(AttributeList& attributes); void StartBvhElement(string element, AttributeList& attributes); void EndViewSpaceHierarchyInterior(); void EndObjectSpaceHierarchyInterior(); void EndBvhInterior(); void EndOspInterior(); void EndObjectSpaceHierarchy(); void StartBvhLeafObjects(ObjectContainer &objects, const char *ptr); // ----------------------------------------------------------------------- // Handlers for the SAX ErrorHandler interface // ----------------------------------------------------------------------- void warning(const SAXParseException& exc); void error(const SAXParseException& exc); void fatalError(const SAXParseException& exc); private: // ----------------------------------------------------------------------- // Private data members // // fAttrCount // fCharacterCount // fElementCount // fSpaceCount // These are just counters that are run upwards based on the input // from the document handlers. // ----------------------------------------------------------------------- unsigned int mAttrCount; unsigned int mCharacterCount; unsigned int mElementCount; unsigned int mSpaceCount; }; // --------------------------------------------------------------------------- // This is a simple class that lets us do easy (though not terribly efficient) // trancoding of XMLCh data to local code page for display. // --------------------------------------------------------------------------- class StrX { public : // ----------------------------------------------------------------------- // Constructors and Destructor // ----------------------------------------------------------------------- StrX(const XMLCh* const toTranscode) { // Call the private transcoding method mLocalForm = XMLString::transcode(toTranscode); } ~StrX() { XMLString::release(&mLocalForm); } // ----------------------------------------------------------------------- // Getter methods // ----------------------------------------------------------------------- const char* LocalForm() const { return mLocalForm; } private : // ----------------------------------------------------------------------- // Private data members // // fLocalForm // This is the local code page form of the string. // ----------------------------------------------------------------------- char* mLocalForm; }; inline XERCES_STD_QUALIFIER ostream& operator<<(XERCES_STD_QUALIFIER ostream& target, const StrX& toDump) { target << toDump.LocalForm(); return target; } } #endif