From 06a0fef14384fff540b619069c11e9dfaae2bbc6 Mon Sep 17 00:00:00 2001 From: malaterre Date: Sat, 1 Oct 2005 19:39:14 +0000 Subject: [PATCH] ENH: Refactorize code, from PrintFile into the class, to allow user to reuse the code. --- Example/PrintFile.cxx | 33 +++------------- Testing/TestPrintAllDocument.cxx | 6 +-- src/gdcmOrientation.cxx | 67 ++++++++++++++++---------------- src/gdcmOrientation.h | 24 ++++++++++-- 4 files changed, 64 insertions(+), 66 deletions(-) diff --git a/Example/PrintFile.cxx b/Example/PrintFile.cxx index 3cdfabf9..f1868e72 100644 --- a/Example/PrintFile.cxx +++ b/Example/PrintFile.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: PrintFile.cxx,v $ Language: C++ - Date: $Date: 2005/09/30 17:42:17 $ - Version: $Revision: 1.60 $ + Date: $Date: 2005/10/01 19:39:14 $ + Version: $Revision: 1.61 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -207,21 +207,6 @@ int main(int argc, char *argv[]) // ----------- End Arguments Manager --------- - std::string tabOrientation[13] = { - "Not Applicable", - "Axial", - "Coronal", - "Sagital", - "Heart Axial", - "Heart Coronal", - "Heart Sagital", - "Axial invert", - "Coronal invert", - "Sagital invert", - "Heart Axial invert", - "Heart Coronal invert", - "Heart Sagital invert" - }; if (ddict) { @@ -353,13 +338,10 @@ int main(int argc, char *argv[]) strImageOrientationRET != gdcm::GDCM_UNFOUND ) { - double orient = o.TypeOrientation( f ); - int k = (int)orient; - if (k < 0) - k = -k + 6; + gdcm::OrientationType orient = o.GetOrientationType( f ); std::cout << "TypeOrientation = " << orient << " (-> " - << tabOrientation[k] << " )" << std::endl; + << o.GetOrientationTypeString(orient) << " )" << std::endl; } std::string ori = o.GetOrientation ( f ); @@ -521,13 +503,10 @@ int main(int argc, char *argv[]) if (ori != gdcm::GDCM_UNFOUND ) std::cout << "- Orientation [" << ori << "]" << std::endl; - double d = o.TypeOrientation( f ); - int k = (int)d; - if (k < 0) - k = -k + 6; + gdcm::OrientationType d = o.GetOrientationType( f ); std::cout << "TypeOrientation = " << d << " (-> " - << tabOrientation[k] << std::endl; + << o.GetOrientationTypeString(d) << std::endl; if (f->IsReadable()) std::cout <c_str()<<" is Readable"<GetImageOrientationPatient( iop ); if ( !succ ) { - gdcmErrorMacro( "No Image Orientation (0020,0037) found in the file, cannot proceed." ) - return 0; + gdcmErrorMacro( "No Image Orientation (0020,0037)/(0020,0032) found in the file, cannot proceed." ) + return NotApplicable; } -/* -std::cout << " iop : "; -for(int i=0;i<6;i++) - std::cout << iop[i] << " "; -std::cout << std::endl; -*/ vector3D ori1; vector3D ori2; @@ -103,18 +124,8 @@ std::cout << std::endl; res=VerfCriterion( i, CalculLikelyhood2Vec(refA,refB,ori1,ori2), res ); res=VerfCriterion( -i, CalculLikelyhood2Vec(refB,refA,ori1,ori2), res ); } - return res.first; -/* -// i=0 -// res=[0,99999] ## [ , ] -// for plane in dicPlane: -// i=i+1 -// refA=plane[0] -// refB=plane[1] -// res=self.VerfCriterion( i , self.CalculLikelyhood2Vec(refA,refB,ori1,ori2) , res ) -// res=self.VerfCriterion( -i , self.CalculLikelyhood2Vec(refB,refA,ori1,ori2) , res ) -// return res[0] -*/ + gdcmAssertMacro( res.first <= 6 && res.first >= -6); + return (OrientationType)res.first; } Res @@ -131,16 +142,6 @@ Orientation::VerfCriterion(int typeCriterion, double criterionNew, Res const &in res.first = type; res.second = criterion; return res; -/* -// type = res[0] -// criterion = res[1] -// # if criterionNew<0.1 and criterionNew