diff --git a/Design/DICOMSegmentationConverter.puml b/Design/DICOMSegmentationConverter.puml index 0c4567c8..ee66d9af 100644 --- a/Design/DICOMSegmentationConverter.puml +++ b/Design/DICOMSegmentationConverter.puml @@ -45,7 +45,7 @@ package dcmqi { class Helper { + {static} tokenizeString(string str, vector &tokens, string delimiter): void + {static} splitString(string str, string &head, string &tail, string delimiter): void - + {static} floatToStrScientific(float f): string + + {static} floatToStr(float f): string --- + {static} stringToCodeSequenceMacro(std::string str): CodeSequenceMacro + {static} stringToDSRCodedEntryValue(std::string str): DSRCodedEntryValue @@ -96,4 +96,4 @@ class SegmentAttributes { + PrintSelf() : void } -@enduml \ No newline at end of file +@enduml diff --git a/include/dcmqi/Helper.h b/include/dcmqi/Helper.h index ca0db1f0..20245574 100644 --- a/include/dcmqi/Helper.h +++ b/include/dcmqi/Helper.h @@ -13,6 +13,8 @@ #include #include #include +#include +#include // DCMQI includes #include "dcmqi/Exceptions.h" @@ -45,7 +47,7 @@ namespace dcmqi { static vector getFileListRecursively(string directory); static vector loadDatasets(const vector& dicomImageFiles); - static string floatToStrScientific(float f); + static string floatToStr(float f); static void tokenizeString(string str, vector &tokens, string delimiter); static void splitString(string str, string &head, string &tail, string delimiter); diff --git a/libsrc/Helper.cpp b/libsrc/Helper.cpp index f2ee32f2..6c3e52fe 100644 --- a/libsrc/Helper.cpp +++ b/libsrc/Helper.cpp @@ -102,9 +102,13 @@ namespace dcmqi { } - string Helper::floatToStrScientific(float f) { + string Helper::floatToStr(float f) { ostringstream sstream; - sstream << scientific << f; + sstream.imbue(std::locale::classic()); + sstream.precision(9); + sstream << f; + //string f_str = sstream.str(); + //cout << "Formatted float (length): " << f_str << "(" << f_str.size() << ")" << endl; return sstream.str(); } diff --git a/libsrc/ImageSEGConverter.cpp b/libsrc/ImageSEGConverter.cpp index 1371d708..a621b487 100644 --- a/libsrc/ImageSEGConverter.cpp +++ b/libsrc/ImageSEGConverter.cpp @@ -66,12 +66,12 @@ namespace dcmqi { FGPlaneOrientationPatient *planor = FGPlaneOrientationPatient::createMinimal( - Helper::floatToStrScientific(labelDirMatrix[0][0]).c_str(), - Helper::floatToStrScientific(labelDirMatrix[1][0]).c_str(), - Helper::floatToStrScientific(labelDirMatrix[2][0]).c_str(), - Helper::floatToStrScientific(labelDirMatrix[0][1]).c_str(), - Helper::floatToStrScientific(labelDirMatrix[1][1]).c_str(), - Helper::floatToStrScientific(labelDirMatrix[2][1]).c_str()); + Helper::floatToStr(labelDirMatrix[0][0]).c_str(), + Helper::floatToStr(labelDirMatrix[1][0]).c_str(), + Helper::floatToStr(labelDirMatrix[2][0]).c_str(), + Helper::floatToStr(labelDirMatrix[0][1]).c_str(), + Helper::floatToStr(labelDirMatrix[1][1]).c_str(), + Helper::floatToStr(labelDirMatrix[2][1]).c_str()); CHECK_COND(segdoc->addForAllFrames(*planor)); } @@ -311,9 +311,9 @@ namespace dcmqi { segmentations[segFileNumber]->TransformIndexToPhysicalPoint(prevIndex, prevOrigin); } fgppp->setImagePositionPatient( - Helper::floatToStrScientific(sliceOriginPoint[0]).c_str(), - Helper::floatToStrScientific(sliceOriginPoint[1]).c_str(), - Helper::floatToStrScientific(sliceOriginPoint[2]).c_str()); + Helper::floatToStr(sliceOriginPoint[0]).c_str(), + Helper::floatToStr(sliceOriginPoint[1]).c_str(), + Helper::floatToStr(sliceOriginPoint[2]).c_str()); } /* Add frame that references this segment */ diff --git a/libsrc/ParaMapConverter.cpp b/libsrc/ParaMapConverter.cpp index f1acd235..a82ff317 100644 --- a/libsrc/ParaMapConverter.cpp +++ b/libsrc/ParaMapConverter.cpp @@ -99,12 +99,12 @@ namespace dcmqi { FGPlaneOrientationPatient *planor = FGPlaneOrientationPatient::createMinimal( - Helper::floatToStrScientific(labelDirMatrix[0][0]).c_str(), - Helper::floatToStrScientific(labelDirMatrix[1][0]).c_str(), - Helper::floatToStrScientific(labelDirMatrix[2][0]).c_str(), - Helper::floatToStrScientific(labelDirMatrix[0][1]).c_str(), - Helper::floatToStrScientific(labelDirMatrix[1][1]).c_str(), - Helper::floatToStrScientific(labelDirMatrix[2][1]).c_str()); + Helper::floatToStr(labelDirMatrix[0][0]).c_str(), + Helper::floatToStr(labelDirMatrix[1][0]).c_str(), + Helper::floatToStr(labelDirMatrix[2][0]).c_str(), + Helper::floatToStr(labelDirMatrix[0][1]).c_str(), + Helper::floatToStr(labelDirMatrix[1][1]).c_str(), + Helper::floatToStr(labelDirMatrix[2][1]).c_str()); //CHECK_COND(planor->setImageOrientationPatient(imageOrientationPatientStr)); CHECK_COND(pMapDoc->addForAllFrames(*planor)); @@ -174,7 +174,7 @@ namespace dcmqi { // initialize optional items, if available if(metaInfo.metaInfoRoot.isMember("MeasurementMethodCode")){ ContentItemMacro* measureMethod = new ContentItemMacro; - + CodeSequenceMacro* qCodeName = new CodeSequenceMacro("370129005", "SCT", "Measurement Method"); CodeSequenceMacro* qSpec = new CodeSequenceMacro( metaInfo.metaInfoRoot["MeasurementMethodCode"]["CodeValue"].asCString(), @@ -383,9 +383,9 @@ namespace dcmqi { FloatImageType::PointType sliceOriginPoint; parametricMapImage->TransformIndexToPhysicalPoint(sliceIndex, sliceOriginPoint); fgppp->setImagePositionPatient( - Helper::floatToStrScientific(sliceOriginPoint[0]).c_str(), - Helper::floatToStrScientific(sliceOriginPoint[1]).c_str(), - Helper::floatToStrScientific(sliceOriginPoint[2]).c_str()); + Helper::floatToStr(sliceOriginPoint[0]).c_str(), + Helper::floatToStr(sliceOriginPoint[1]).c_str(), + Helper::floatToStr(sliceOriginPoint[2]).c_str()); // Frame Content OFCondition result = fgfc->setDimensionIndexValues(sliceNumber+1 /* value within dimension */, 0 /* first dimension */); @@ -606,9 +606,9 @@ namespace dcmqi { FloatImageType::PointType sliceOriginPoint; parametricMapImage->TransformIndexToPhysicalPoint(sliceIndex, sliceOriginPoint); fgPlanePos->setImagePositionPatient( - Helper::floatToStrScientific(sliceOriginPoint[0]).c_str(), - Helper::floatToStrScientific(sliceOriginPoint[1]).c_str(), - Helper::floatToStrScientific(sliceOriginPoint[2]).c_str()); + Helper::floatToStr(sliceOriginPoint[0]).c_str(), + Helper::floatToStr(sliceOriginPoint[1]).c_str(), + Helper::floatToStr(sliceOriginPoint[2]).c_str()); // Frame Content OFCondition result = fgFracon->setDimensionIndexValues(frameNo+1 /* value within dimension */, 0 /* first dimension */);