source: trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsParserXerces.h @ 577

Revision 577, 4.7 KB checked in by mattausch, 18 years ago (diff)

fixed loading function: the view cell manager is chosen depending on
the type in the file. the view space box is saved with the file

Line 
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"
9
10XERCES_CPP_NAMESPACE_USE
11XERCES_CPP_NAMESPACE_BEGIN
12class AttributeList;
13XERCES_CPP_NAMESPACE_END
14
15class VspBspTree;
16class BspTree;
17class ViewCellsManager;
18
19class ViewCellsParseHandlers: public HandlerBase
20{
21public:
22  // -----------------------------------------------------------------------
23  //  Constructors and Destructor
24  // -----------------------------------------------------------------------
25  ViewCellsParseHandlers(ObjectContainer *objects);
26  ~ViewCellsParseHandlers();
27 
28 
29  // -----------------------------------------------------------------------
30  //  Getter methods
31  // -----------------------------------------------------------------------
32  unsigned int GetElementCount()
33  {
34    return mElementCount;
35  }
36 
37  unsigned int GetAttrCount()
38  {
39    return mAttrCount;
40  }
41 
42  unsigned int GetCharacterCount()
43  {
44    return mCharacterCount;
45  }
46 
47  unsigned int GetSpaceCount()
48  {
49    return mSpaceCount;
50  }
51
52
53  // -----------------------------------------------------------------------
54  //  Handlers for the SAX DocumentHandler interface
55  // -----------------------------------------------------------------------
56  void endElement(const XMLCh* const name);
57  void startElement(const XMLCh* const name, AttributeList& attributes);
58  void characters(const XMLCh* const chars, const unsigned int length);
59  void ignorableWhitespace(const XMLCh* const chars, const unsigned int length);
60  void resetDocument();
61
62  void CreateViewCellsManager(const char *name);
63
64
65  VspBspTree *mVspBspTree;
66  BspTree *mBspTree;
67 
68  BspNode *mCurrentNode;
69  ViewCellContainer mViewCells;
70  ViewCellsManager *mViewCellsManager;
71  ObjectContainer *mObjects;
72
73  AxisAlignedBox3 mViewSpaceBox;
74
75  // Handlers for X3D
76  void StartBspLeaf(AttributeList& attributes);
77  void StartBspInterior(AttributeList& attributes);
78  void EndBspInterior();
79 
80  void StartViewCell(AttributeList&  attributes);
81  void EndViewCells();
82
83  void StartHierarchy(AttributeList& attributes);
84
85  void startBspElement(string element, AttributeList& attributes);
86  void StartViewSpaceBox(AttributeList&  attributes);
87  // -----------------------------------------------------------------------
88  //  Handlers for the SAX ErrorHandler interface
89  // -----------------------------------------------------------------------
90  void warning(const SAXParseException& exc);
91  void error(const SAXParseException& exc);
92  void fatalError(const SAXParseException& exc);
93 
94 
95private:
96  // -----------------------------------------------------------------------
97  //  Private data members
98  //
99  //  fAttrCount
100  //  fCharacterCount
101  //  fElementCount
102  //  fSpaceCount
103  //      These are just counters that are run upwards based on the input
104  //      from the document handlers.
105  // -----------------------------------------------------------------------
106  unsigned int    mAttrCount;
107  unsigned int    mCharacterCount;
108  unsigned int    mElementCount;
109  unsigned int    mSpaceCount;
110};
111
112// ---------------------------------------------------------------------------
113//  This is a simple class that lets us do easy (though not terribly efficient)
114//  trancoding of XMLCh data to local code page for display.
115// ---------------------------------------------------------------------------
116class StrX
117{
118public :
119  // -----------------------------------------------------------------------
120  //  Constructors and Destructor
121  // -----------------------------------------------------------------------
122  StrX(const XMLCh* const toTranscode)
123  {
124          // Call the private transcoding method
125          mLocalForm = XMLString::transcode(toTranscode);
126  }
127 
128  ~StrX()
129  {
130          XMLString::release(&mLocalForm);
131  }
132 
133  // -----------------------------------------------------------------------
134  //  Getter methods
135  // -----------------------------------------------------------------------
136  const char* LocalForm() const
137  {
138    return mLocalForm;
139  }
140 
141private :
142  // -----------------------------------------------------------------------
143  //  Private data members
144  //
145  //  fLocalForm
146  //      This is the local code page form of the string.
147  // -----------------------------------------------------------------------
148  char*   mLocalForm;
149};
150
151inline XERCES_STD_QUALIFIER ostream&
152operator<<(XERCES_STD_QUALIFIER ostream& target, const StrX& toDump)
153{
154  target << toDump.LocalForm();
155  return target;
156}
157
158#endif
Note: See TracBrowser for help on using the repository browser.