source: GTP/trunk/Lib/Vis/Preprocessing/src/ObjectsParserXerces.h @ 2115

Revision 2115, 4.7 KB checked in by mattausch, 17 years ago (diff)

changed pvs loading: loading objects in a first pass

RevLine 
[2115]1#ifndef _OBJECTS_PARSER_XERCES__H
2#define _OBJECTS_PARSER_XERCES__H
[2113]3
4// ---------------------------------------------------------------------------
5//  Includes
6// ---------------------------------------------------------------------------
7#include <xercesc/sax/HandlerBase.hpp>
8#include "Mesh.h"
9#include "BoundingBoxConverter.h"
10
11
12namespace GtpVisibilityPreprocessor {
13
14XERCES_CPP_NAMESPACE_USE
15XERCES_CPP_NAMESPACE_BEGIN
16class AttributeList;
17XERCES_CPP_NAMESPACE_END
18
[2115]19
[2113]20class BvhNode;
21class BvHierarchy;
22
23
[2114]24class ObjectsParseHandlers: public HandlerBase
[2113]25{
26public:
27
[2115]28        // -----------------------------------------------------------------------
29        //  Constructors and Destructor
30        // -----------------------------------------------------------------------
[2113]31
[2115]32        ObjectsParseHandlers(ObjectContainer &pvsObjects,
33                                                 const ObjectContainer &preprocessorObjects);
[2113]34
[2115]35        ~ObjectsParseHandlers();
[2113]36
37
[2115]38        // -----------------------------------------------------------------------
39        //  Getter methods
40        // -----------------------------------------------------------------------
[2113]41
[2115]42        unsigned int GetElementCount()
43        {
44                return mElementCount;
45        }
[2113]46
[2115]47        unsigned int GetAttrCount()
48        {
49                return mAttrCount;
50        }
[2113]51
[2115]52        unsigned int GetCharacterCount()
53        {
54                return mCharacterCount;
55        }
[2113]56
[2115]57        unsigned int GetSpaceCount()
58        {
59                return mSpaceCount;
60        }
[2113]61
62
[2115]63        // -----------------------------------------------------------------------
64        //  Handlers for the SAX DocumentHandler interface
65        // -----------------------------------------------------------------------
[2113]66
[2115]67        void endElement(const XMLCh* const name);
68        void startElement(const XMLCh* const name, AttributeList& attributes);
69        void characters(const XMLCh* const chars, const unsigned int length);
70        void ignorableWhitespace(const XMLCh* const chars, const unsigned int length);
71        void resetDocument();
[2113]72
[2115]73        void StartObjectSpaceHierarchyElement(const std::string &element,
74                                                                                  AttributeList& attributes);
[2113]75
[2115]76        /////////////////////////
[2113]77
[2115]78        int mUniqueObjectId;
[2113]79
[2115]80        vector<BvhLeaf *> mBvhLeaves;
81
82        const ObjectContainer &mPreprocessorObjects;
83        ObjectContainer &mPvsObjects;
84
85        /// current state of the parser
86        bool mIsObjectSpaceHierarchy;
87
88        enum {BVH};
89
90        ////////////
91        //-- Handlers for X3D
92
93        void StartBvhLeaf(AttributeList& attributes);
94        void StartBvhElement(string element, AttributeList& attributes);
95
96        void EndObjectSpaceHierarchy();
97
98        void StartBvhLeafObjects(ObjectContainer &objects, const char *ptr);
99
100        // -----------------------------------------------------------------------
101        //  Handlers for the SAX ErrorHandler interface
102        // -----------------------------------------------------------------------
103
104        void warning(const SAXParseException& exc);
105        void error(const SAXParseException& exc);
106        void fatalError(const SAXParseException& exc);
107
108
[2113]109private:
[2115]110        // -----------------------------------------------------------------------
111        //  Private data members
112        //
113        //  fAttrCount
114        //  fCharacterCount
115        //  fElementCount
116        //  fSpaceCount
117        //      These are just counters that are run upwards based on the input
118        //      from the document handlers.
119        // -----------------------------------------------------------------------
120        unsigned int    mAttrCount;
121        unsigned int    mCharacterCount;
122        unsigned int    mElementCount;
123        unsigned int    mSpaceCount;
[2113]124};
125
126// ---------------------------------------------------------------------------
127//  This is a simple class that lets us do easy (though not terribly efficient)
128//  trancoding of XMLCh data to local code page for display.
129// ---------------------------------------------------------------------------
130class StrX
131{
132public :
[2115]133        // -----------------------------------------------------------------------
134        //  Constructors and Destructor
135        // -----------------------------------------------------------------------
136        StrX(const XMLCh* const toTranscode)
137        {
138                // Call the private transcoding method
139                mLocalForm = XMLString::transcode(toTranscode);
140        }
141
142        ~StrX()
143        {
144                XMLString::release(&mLocalForm);
145        }
146
147        // -----------------------------------------------------------------------
148        //  Getter methods
149        // -----------------------------------------------------------------------
150        const char* LocalForm() const
151        {
152                return mLocalForm;
153        }
154
[2113]155private :
[2115]156        // -----------------------------------------------------------------------
157        //  Private data members
158        //
159        //  fLocalForm
160        //      This is the local code page form of the string.
161        // -----------------------------------------------------------------------
162        char*   mLocalForm;
[2113]163};
164
165inline XERCES_STD_QUALIFIER ostream&
166operator<<(XERCES_STD_QUALIFIER ostream& target, const StrX& toDump)
167{
[2115]168        target << toDump.LocalForm();
169        return target;
[2113]170}
171}
172
173#endif
Note: See TracBrowser for help on using the repository browser.