1 #ifndef __OsirixParser__
2 #define __OsirixParser__
7 #ifdef kernelParserOsirix_BUILD_SHARED
8 #define kernelParserOsirix_EXPORT __declspec( dllexport )
10 #define kernelParserOsirix_EXPORT __declspec( dllimport )
12 #define kernelParserOsirix_CDECL __cdecl
14 #define kernelParserOsirix_EXPORT
15 #define kernelParserOsirix_CDECL
16 #endif // defined(_WIN32)
18 //------------------------------------------------------------------------------------------------------------
20 //------------------------------------------------------------------------------------------------------------
25 #include <xercesc/parsers/XercesDOMParser.hpp>
26 #include <xercesc/dom/DOM.hpp>
27 #include <xercesc/dom/DOMErrorHandler.hpp>
28 #include <xercesc/dom/DOMLocator.hpp>
29 #include <xercesc/sax/HandlerBase.hpp>
30 #include <xercesc/util/XMLString.hpp>
31 #include <xercesc/util/PlatformUtils.hpp>
35 using namespace xercesc;
41 //------------------------------------------------------------------------------------------------------------
42 // Constructors & Destructors
43 //------------------------------------------------------------------------------------------------------------
47 ** Constructor for the parser, with the information of the pixel spacing and image dimensions
49 OsirixParser(std::string xsdfile = "", double* spacing = NULL, int* extent = NULL);
51 ** Desctructor by defect
55 int ParseFile(const char* xmlfile);
58 std::string getErrorLine();
60 std::string getContoursFileName();
62 // Return ROI as lists of points
63 const std::map<int, vector< vector<double> > >& getContoursMapMM() {
66 const std::map<int, vector< vector<double> > >& getContoursMapPX() {
71 const std::map<int, std::string>& getContoursNameMM() {
72 return contoursnameMM;
74 const std::map<int, std::string>& getContoursNamePX() {
75 return contoursnamePX;
82 std::string errorline;
87 const char* OSIRIX_DICT;
88 const char* OSIRIX_KEY;
89 const char* OSIRIX_IMAGES;
90 const char* OSIRIX_ARRAY;
91 const char* OSIRIX_IMAGEINDEX;
92 const char* OSIRIX_INTEGER;
93 const char* OSIRIX_NUMBEROFROIS;
94 const char* OSIRIX_ROIS;
95 const char* OSIRIX_POINT_MM;
96 const char* OSIRIX_POINT_PX;
97 const char* OSIRIX_STRING;
98 const char* OSIRIX_NAME;
100 const char* CREACONTOUR;
101 const char* CREACONTOUR_VERSION;
102 const char* CREACONTOUR_IMAGEDIMENSIONS;
103 const char* CREACONTOUR_IMAGESPACING;
104 const char* CREACONTOUR_NUMBEROFCONTOURS;
106 const char* CREACONTOUR_INSTANT;
107 const char* CREACONTOUR_TYPEMODEL;
108 const char* CREACONTOUR_NUMBEROFCONTROLPOINTS;
109 const char* CREACONTOUR_TYPEVIEW;
111 const char* CREACONTOUR_NUMBEROFCONTOURSSTATIC;
113 std::string TEMPIMPORTOSIRIXFILE;
118 typedef vector< vector<double> > vectorXYZ;
119 std::map<int, vectorXYZ> contoursmapMM;
120 std::map<int, vectorXYZ> contoursmapPX;
122 std::map<int, std::string> contoursnameMM;
123 std::map<int, std::string> contoursnamePX;
125 void saveCreaContoursFormat();
127 void writeHeader(FILE* pFile);
128 void writeContours(FILE* pFile);
129 void writeContoursStatic(FILE* pFile);
131 void setErrorLine(DOMNodeList* list);
133 void getUserData(DOMElement* element);
135 void getData(DOMNodeList* list, std::vector<std::string>& vect, std::string tagname);
137 DOMNode* getLastNode(DOMNodeList* list);
139 void parseOSIRIX_DICT(DOMNodeList* list);
140 void parseOSIRIX_POINT_MM(DOMNodeList* list);
141 void parseOSIRIX_POINT_PX(DOMNodeList* list);
148 class OsirixParserErrorHandler : public ErrorHandler{
150 //------------------------------------------------------------------------------------------------------------
151 // Constructors & Destructors
152 //------------------------------------------------------------------------------------------------------------
156 ** Default Constructor
158 OsirixParserErrorHandler();
160 ** Desctructor by defect
162 ~OsirixParserErrorHandler();
164 virtual void warning (const SAXParseException &exc);
166 virtual void error (const SAXParseException &exc);
168 virtual void fatalError (const SAXParseException &exc);
170 virtual void resetErrors ();
172 std::string getErrorMsg();
177 std::string errormsg;