fluidvis
SXParser.h
1 #ifndef _SX_SXPARSER_H_
2 #define _SX_SXPARSER_H_
3 
9 #include <export/Export.h>
10 #include <string>
11 #include <map>
12 #include <vector>
13 #include <sx/SXMath.h>
14 using namespace std;
15 
16 namespace sx {
17 
18  namespace parserInternal {
19 
23  enum _XTYPE_ {
24  _XTEXT_ ,
25  _XTAG_ ,
26  _S_ATTRIB_,
27  _R_ATTRIB_
28  };
29 
34  struct _XNODE_ {
35 
39  int type;
40 
44  string text;
45 
49  string name;
50  vector<_XNODE_> nodes;
51 
55  string strID;
56  string strAttrib;
57 
61  string rID;
62  double rAttrib;
63 
70  string eat;
71 
72  };
73 
78  struct _XMLNODE_ {
79 
83  int type;
84 
88  string text;
89 
93  string name;
94  string endname;
95  vector<_XMLNODE_> nodes;
96  vector<_XMLNODE_> ats;
97 
101  string strID;
102  string strAttrib;
103 
110  string eat;
111 
112  };
113 
117  enum _TYPE_ {
118  T_CHAR,
119  T_UCHAR,
120  T_SHORT,
121  T_USHORT,
122  T_INT,
123  T_UINT,
124  T_LONG,
125  T_ULONG,
126  T_FLOAT,
127  T_DOUBLE
128  };
129 
134  enum _MULTIPLICITY_ {
135  M_SINGLE,
136  M_LIST
137  };
138 
142  struct _PROPERTY_ {
143 
147  string name;
148 
157 
161  vector<int> types;
162 
163  };
164 
171  struct _ELEMENT_ {
172 
176  string name;
177 
182  unsigned int count;
183 
187  vector<_PROPERTY_> properties;
188 
189  };
190 
194  struct _XMESH_ {
195 
201  vector<_ELEMENT_> elements;
202 
211  vector<vector<double>> data;
212 
213  };
214 
215  void parseNumbers(const string &numberList, vector<double> &numbers);
216 
217  void parseStrings(const string &stringList, vector<string> &strings);
218 
219  void parseSXdata1(const string &data, string &output);
220 
221  void parseSXdata2(string &filteredIterable, parserInternal::_XNODE_ &output);
222 
223  void parseXMLdata(const string &data, parserInternal::_XMLNODE_ &output);
224 
225  void parsePLYdata1(const string &data, string &output);
226 
227  void parsePLYdata2(string &filteredIterable, parserInternal::_XMESH_ &output);
228 
229  }
230 
239  EXPA vector<double> parseNumbers(const string &numberList);
240 
248  EXPA vector<string> parseStrings(const string &stringList);
249 
260  EXPA string readFile(string filename);
261 
266  struct XNode {
267  private:
268 
272  XNode(const XNode &);
273 
277  XNode &operator = (const XNode &);
278 
279  protected:
280 
285  EXPA XNode();
286 
287  public:
288 
292  EXPA virtual ~XNode();
293 
294  };
295 
300  struct XText: public XNode {
301  private:
302 
306  XText(const XText &);
307 
311  XText &operator = (const XText &);
312 
313  public:
314 
318  string text;
319 
323  EXPA XText();
324 
328  EXPA ~XText();
329 
330  };
331 
337  struct XTag: public XNode {
338  private:
339 
343  XTag(const XTag &);
344 
348  XTag &operator = (const XTag &);
349 
350  public:
351 
355  string name;
356 
364  map<string,string> stringAttribs;
365 
372  map<string,double> realAttribs;
373 
377  vector<XNode *> nodes;
378 
383  EXPA XTag();
384 
390  EXPA ~XTag();
391 
408  EXPA void getTags(string location, vector<XTag *> &nodes);
409 
427  EXPA XTag *getFirst(string location);
428 
434  EXPA XTag *getFirst();
435 
443  EXPA string getStrAttribute(string ID);
444 
452  EXPA double getRealAttribute(string ID);
453 
460  EXPA void getDirectTexts(vector<string> &texts);
461 
468  EXPA void getTexts(vector<string> &texts);
469 
476  EXPA string getDirectTexts();
477 
484  EXPA string getTexts();
485 
506  EXPA void flattenTag(XTag &tag, map<string,vector<double>> &ambiguousReals, map<string,vector<string>> &ambiguousStrings);
507 
508  };
509 
520  EXPA XTag *parseSXdata(const string &data);
521 
534  EXPA XTag *parseSXFile(const string path);
535 
546  EXPA XTag *parseXMLdata(const string &data);
547 
560  EXPA XTag *parseXMLFile(const string path);
561 
565  struct XBuffer {
566  private:
567 
571  XBuffer(const XBuffer &);
572 
576  XBuffer &operator = (const XBuffer &);
577 
578  public:
579 
583  string name;
584 
589  unsigned int attributeSize;
590 
595  vector<double> vertexAttributes;
596 
600  EXPA XBuffer();
601 
605  EXPA ~XBuffer();
606  };
607 
613  struct XMesh {
614  private:
615 
619  XMesh(const XMesh &);
620 
624  XMesh &operator = (const XMesh &);
625 
626  public:
627 
634  unsigned int faceSize;
635 
639  map<string,XBuffer *> buffers;
640 
644  EXPA XMesh();
645 
649  EXPA ~XMesh();
650  };
651 
665  EXPA XMesh *parsePLYdata(const string &data);
666 
683  EXPA XMesh *parsePLYFile(const string path);
684 
690  struct Bone {
691 
696  string ID;
697 
706 
712 
716  vector<Bone> bones;
717 
721  EXPA Bone(const Bone &);
722 
726  EXPA Bone();
727 
728  };
729 
742  EXPA pair<vector<Bone>,Matrix> parseColladaSkeleton(XTag &collada);
743 
756  EXPA pair<vector<Bone>,Matrix> parseColladaSkeleton(const string &data);
757 
771  EXPA pair<vector<Bone>,Matrix> parseColladaSkeletonFile(const string &path);
772 
785  EXPA XMesh *parseColladaData(XTag &data);
786 
799  EXPA XMesh *parseColladaData(const string &data);
800 
814  EXPA XMesh *parseColladaFile(const string path);
815 
819  class Bitmap {
820  private:
821 
832  unsigned char *data;
833 
837  unsigned int width;
838 
842  unsigned int height;
843 
847  unsigned int bytesPerPixel;
848 
852  Bitmap(const Bitmap &);
853 
857  Bitmap &operator = (const Bitmap &);
858 
859  public:
860 
865  EXPA Bitmap(unsigned int width, unsigned int height);
866 
872  EXPA Bitmap(unsigned int width, unsigned int height, unsigned int bytesPerPixel);
873 
886  EXPA Bitmap(const string filename);
887 
891  EXPA ~Bitmap();
892 
904  EXPA void save(const string filename);
905 
909  EXPA unsigned int getWidth() const;
910 
914  EXPA unsigned int getHeight() const;
915 
920  EXPA unsigned int getPixelSize() const;
921 
934  EXPA unsigned char *getData();
935 
936  };
937 
938 }
939 
940 #endif
vector< _PROPERTY_ > properties
Definition: SXParser.h:187
string name
Definition: SXParser.h:176
Definition: SXParser.h:565
vector< int > types
Definition: SXParser.h:161
vector< XNode * > nodes
Definition: SXParser.h:377
vector< double > vertexAttributes
Definition: SXParser.h:595
string name
Definition: SXParser.h:93
EXPA XMesh * parsePLYdata(const string &data)
string strID
Definition: SXParser.h:101
EXPA XTag * parseSXdata(const string &data)
EXPA XTag * parseSXFile(const string path)
Definition: SXParser.h:34
map< string, string > stringAttribs
Definition: SXParser.h:364
map< string, XBuffer * > buffers
Definition: SXParser.h:639
string text
Definition: SXParser.h:318
Definition: SXParser.h:78
Definition: SXMath.h:285
string text
Definition: SXParser.h:88
EXPA XMesh * parseColladaData(XTag &data)
map< string, double > realAttribs
Definition: SXParser.h:372
Definition: SXParser.h:613
Definition: SXParser.h:171
string name
Definition: SXParser.h:583
string name
Definition: SXParser.h:355
Definition: SXParser.h:266
Definition: SXParser.h:690
string strID
Definition: SXParser.h:55
int type
Definition: SXParser.h:39
Definition: SXParser.h:194
EXPA XTag * parseXMLFile(const string path)
Definition: SXParser.h:142
string eat
Definition: SXParser.h:110
unsigned int attributeSize
Definition: SXParser.h:589
EXPA XMesh * parsePLYFile(const string path)
Definition: SXParser.h:819
vector< _ELEMENT_ > elements
Definition: SXParser.h:201
Definition: SXParser.h:300
EXPA XMesh * parseColladaFile(const string path)
EXPA pair< vector< Bone >, Matrix > parseColladaSkeleton(XTag &collada)
vector< vector< double > > data
Definition: SXParser.h:211
unsigned int faceSize
Definition: SXParser.h:634
string name
Definition: SXParser.h:147
string name
Definition: SXParser.h:49
Matrix parentTransform
Definition: SXParser.h:705
vector< Bone > bones
Definition: SXParser.h:716
EXPA pair< vector< Bone >, Matrix > parseColladaSkeletonFile(const string &path)
string text
Definition: SXParser.h:44
int type
Definition: SXParser.h:83
string eat
Definition: SXParser.h:70
int multiplicity
Definition: SXParser.h:156
unsigned int count
Definition: SXParser.h:182
Matrix inverseBindPoseMatrix
Definition: SXParser.h:711
string ID
Definition: SXParser.h:696
EXPA string readFile(string filename)
string rID
Definition: SXParser.h:61
Definition: SXParser.h:337
Definition: Exception.h:13