#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 VspKdTree; class BspTree; class ViewCellsManager; class ViewCellsTree; class ViewCellsParseHandlers: public HandlerBase { public: // ----------------------------------------------------------------------- // Constructors and Destructor // ----------------------------------------------------------------------- ViewCellsParseHandlers(ObjectContainer *objects, BoundingBoxConverter *bconverter, Environment *env); ~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); VspBspTree *mVspBspTree; VspKdTree *mVspKdTree; BspTree *mBspTree; ViewCellsTree *mViewCellsTree; BspNode *mCurrentBspNode; ViewCell *mCurrentViewCell; ViewCellContainer mViewCells; ViewCellsManager *mViewCellsManager; ObjectContainer *mObjects; BoundingBoxConverter *mBoundingBoxConverter; AxisAlignedBox3 mViewSpaceBox; IndexedBoundingBoxContainer mIBoundingBoxes; Environment *mEnvironment; bool mParseViewCells; // Handlers for X3D void StartBspLeaf(AttributeList& attributes); void StartBspInterior(AttributeList& attributes); void EndBspInterior(); void StartViewCell(ViewCell *viewCell, AttributeList& attributes); void EndViewCells(); void EndBoundingBoxes(); void StartHierarchy(AttributeList& attributes); void startBspElement(string element, AttributeList& attributes); void StartViewSpaceBox(AttributeList& attributes); void StartBoundingBox(AttributeList& attributes); void StartViewCellLeaf(AttributeList& attributes); void StartViewCellInterior(AttributeList& attributes); void EndViewCellInterior(); // ----------------------------------------------------------------------- // 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