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

Line 
1#ifndef _OBJECTS_PARSER_XERCES__H
2#define _OBJECTS_PARSER_XERCES__H
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
19
20class BvhNode;
21class BvHierarchy;
22
23
24class ObjectsParseHandlers: public HandlerBase
25{
26public:
27
28        // -----------------------------------------------------------------------
29        //  Constructors and Destructor
30        // -----------------------------------------------------------------------
31
32        ObjectsParseHandlers(ObjectContainer &pvsObjects,
33                                                 const ObjectContainer &preprocessorObjects);
34
35        ~ObjectsParseHandlers();
36
37
38        // -----------------------------------------------------------------------
39        //  Getter methods
40        // -----------------------------------------------------------------------
41
42        unsigned int GetElementCount()
43        {
44                return mElementCount;
45        }
46
47        unsigned int GetAttrCount()
48        {
49                return mAttrCount;
50        }
51
52        unsigned int GetCharacterCount()
53        {
54                return mCharacterCount;
55        }
56
57        unsigned int GetSpaceCount()
58        {
59                return mSpaceCount;
60        }
61
62
63        // -----------------------------------------------------------------------
64        //  Handlers for the SAX DocumentHandler interface
65        // -----------------------------------------------------------------------
66
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();
72
73        void StartObjectSpaceHierarchyElement(const std::string &element,
74                                                                                  AttributeList& attributes);
75
76        /////////////////////////
77
78        int mUniqueObjectId;
79
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
109private:
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;
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 :
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
155private :
156        // -----------------------------------------------------------------------
157        //  Private data members
158        //
159        //  fLocalForm
160        //      This is the local code page form of the string.
161        // -----------------------------------------------------------------------
162        char*   mLocalForm;
163};
164
165inline XERCES_STD_QUALIFIER ostream&
166operator<<(XERCES_STD_QUALIFIER ostream& target, const StrX& toDump)
167{
168        target << toDump.LocalForm();
169        return target;
170}
171}
172
173#endif
Note: See TracBrowser for help on using the repository browser.