From 5e32bd79cd313cc82f5a9538f278bf5527e46f79 Mon Sep 17 00:00:00 2001 From: teodorescu Date: Tue, 7 Jun 2011 12:47:28 +0000 Subject: [PATCH] export contours data --- .../ParserOsirix/OsirixParser.cxx | 16 +++++++++++-- .../ParserOsirix/OsirixParser.h | 23 ++++++++++++++++++- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/lib/kernel_ManagerContour_NDimensions/ParserOsirix/OsirixParser.cxx b/lib/kernel_ManagerContour_NDimensions/ParserOsirix/OsirixParser.cxx index 0305904..447c9dd 100644 --- a/lib/kernel_ManagerContour_NDimensions/ParserOsirix/OsirixParser.cxx +++ b/lib/kernel_ManagerContour_NDimensions/ParserOsirix/OsirixParser.cxx @@ -3,7 +3,6 @@ // Class definition include //---------------------------------------------------------------------------------------------------------------- #include "OsirixParser.h" - #include @@ -22,6 +21,7 @@ OsirixParser::OsirixParser(std::string xsdfile, double* spacing, int* extent) OSIRIX_POINT_MM = "Point_mm"; OSIRIX_POINT_PX = "Point_px"; OSIRIX_STRING = "string"; + OSIRIX_NAME = "Name"; if(spacing != NULL){ _spacing[0] = spacing[0]; @@ -232,6 +232,8 @@ void OsirixParser::parseOSIRIX_DICT(DOMNodeList* list){ imageindex = OSIRIX_IMAGEINDEX; osirixinteger = OSIRIX_INTEGER; + std::string osirixstring = OSIRIX_STRING; + std::string osirixname = OSIRIX_NAME; for(i = 0; i < (int)(list->getLength()); i++){ @@ -259,6 +261,13 @@ void OsirixParser::parseOSIRIX_DICT(DOMNodeList* list){ if(childnode1 != NULL && osirixinteger.compare(XMLString::transcode(childnode1->getNodeName())) == 0){ _imageindex = atoi(XMLString::transcode(childnode1->getTextContent())); } + } else if(osirixname.compare(temp) == 0) { + // keep information about the name of the ROI + childnode1 = childlist->item(j+2); + if(childnode1 != NULL && osirixstring.compare(XMLString::transcode(childnode1->getNodeName())) == 0){ + char* roiname = XMLString::transcode(childnode1->getTextContent()); + _roiname = string(roiname); + } } } } @@ -308,6 +317,7 @@ void OsirixParser::parseOSIRIX_POINT_MM(DOMNodeList* list){ vectorxyz.push_back(*vectory); vectorxyz.push_back(*vectorz); contoursmapMM.insert(pair(contoursmapMM.size(), vectorxyz)); + contoursnameMM.insert(pair(contoursnameMM.size(), _roiname)); } } @@ -351,6 +361,7 @@ void OsirixParser::parseOSIRIX_POINT_PX(DOMNodeList* list){ vectorxyz.push_back(*vectory); vectorxyz.push_back(*vectorz); contoursmapPX.insert(pair(contoursmapPX.size(), vectorxyz)); + contoursnamePX.insert(pair(contoursnamePX.size(), _roiname)); } } @@ -420,7 +431,8 @@ void OsirixParser::writeContours(FILE* pFile){ fprintf(pFile, CREACONTOUR_NUMBEROFCONTROLPOINTS); fprintf(pFile, " %d\n", vectz.size()); for(i = 0; i < vectx.size(); i++){ - fprintf(pFile, "%f %f 900.00\n", vectx[i]/ _spacing[0],dimy - vecty[i]/ _spacing[1]); + fprintf(pFile, "%f %f 900.00\n", vectx[i]/ _spacing[0], dimy - vecty[i]/ _spacing[1]); + // fprintf(pFile, "%f %f %f\n", vectx[i] , vecty[i], vectz[i]); } fprintf(pFile, CREACONTOUR_TYPEVIEW); fprintf(pFile, " 1\n"); diff --git a/lib/kernel_ManagerContour_NDimensions/ParserOsirix/OsirixParser.h b/lib/kernel_ManagerContour_NDimensions/ParserOsirix/OsirixParser.h index 2b19e44..346cd7a 100644 --- a/lib/kernel_ManagerContour_NDimensions/ParserOsirix/OsirixParser.h +++ b/lib/kernel_ManagerContour_NDimensions/ParserOsirix/OsirixParser.h @@ -59,6 +59,22 @@ public: std::string getContoursFileName(); + // Return ROI as lists of points + const std::map > >& getContoursMapMM() { + return contoursmapMM; + } + const std::map > >& getContoursMapPX() { + return contoursmapPX; + } + + // Return ROI names + const std::map& getContoursNameMM() { + return contoursnameMM; + } + const std::map& getContoursNamePX() { + return contoursnamePX; + } + private: std::string schema; @@ -66,6 +82,7 @@ private: std::string errorline; int _imageindex; + std::string _roiname; const char* OSIRIX_DICT; const char* OSIRIX_KEY; @@ -78,7 +95,8 @@ private: const char* OSIRIX_POINT_MM; const char* OSIRIX_POINT_PX; const char* OSIRIX_STRING; - + const char* OSIRIX_NAME; + const char* CREACONTOUR; const char* CREACONTOUR_VERSION; const char* CREACONTOUR_IMAGEDIMENSIONS; @@ -101,6 +119,9 @@ private: std::map contoursmapMM; std::map contoursmapPX; + std::map contoursnameMM; + std::map contoursnamePX; + void saveCreaContoursFormat(); void writeHeader(FILE* pFile); -- 2.47.1