From 20e27d1b00a398f5b6b18a23a111e77262fa97e3 Mon Sep 17 00:00:00 2001 From: jpr Date: Wed, 15 Nov 2006 15:54:15 +0000 Subject: [PATCH] To please Python, add accesors on each Orientation cosine --- src/gdcmFile.cxx | 84 ++++++++++++++++++++++++++++++++++++++--- src/gdcmFile.h | 13 +++++-- src/gdcmOrientation.cxx | 6 +-- 3 files changed, 91 insertions(+), 12 deletions(-) diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index 23c97b24..38282e94 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.cxx,v $ Language: C++ - Date: $Date: 2006/11/08 17:03:38 $ - Version: $Revision: 1.326 $ + Date: $Date: 2006/11/15 15:54:15 $ + Version: $Revision: 1.327 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -999,6 +999,77 @@ bool File::GetImageOrientationPatient( float iop[6] ) return false; } +/** + * \brief gets the cosine of image X axis, against patient X axis + * (Sorry, but Python needs it :-( ) + * @return cosine of image X axis, against patient X axis + */ +float File::GetXCosineOnX() +{ + float iop[6]; + GetImageOrientationPatient( iop ); + return(iop[0]); +} + +/** + * \brief gets the cosine of image X axis, against patient Y axis + * (Sorry, but Python needs it :-( ) + * @return cosine of image X axis, against patient Y axis + */ +float File::GetXCosineOnY() +{ + float iop[6]; + GetImageOrientationPatient( iop ); + return(iop[1]); +} + +/** + * \brief gets the cosine of image X axis, against patient Z axis + * (Sorry, but Python needs it :-( ) + * @return cosine of image X axis, against patient Z axis + */ +float File::GetXCosineOnZ() +{ + float iop[6]; + GetImageOrientationPatient( iop ); + return(iop[2]); +} + +/** + * \brief gets the cosine of image Y axis, against patient X axis + * (Sorry, but Python needs it :-( ) + * @return cosine of image Y axis, against patient X axis + */ +float File::GetYCosineOnX() +{ + float iop[6]; + GetImageOrientationPatient( iop ); + return(iop[3]); +} + +/** + * \brief gets the cosine of image Y axis, against patient Y axis + * (Sorry, but Python needs it :-( ) + * @return cosine of image Y axis, against patient Y axis + */ +float File::GetYCosineOnY() +{ + float iop[6]; + GetImageOrientationPatient( iop ); + return(iop[4]); +} + +/** + * \brief gets the cosine of image Y axis, against patient Z axis + * (Sorry, but Python needs it :-( ) + * @return cosine of image Y axis, against patient Z axis + */ +float File::GetYCosineOnZ() +{ + float iop[6]; + GetImageOrientationPatient( iop ); + return(iop[5]); +} /** * \brief gets the info from 0020,0032 : Image Position Patient * or from 0020 0030 : Image Position (RET) @@ -1012,13 +1083,14 @@ bool File::GetImageOrientationPatient( float iop[6] ) bool File::GetImagePositionPatient( float ipp[3] ) { std::string strImPosiPat; - //iop is supposed to be float[3] + //ipp is supposed to be float[3] ipp[0] = ipp[1] = ipp[2] = 0.; // 0020 0032 DS REL Image Position (Patient) - if ( (strImPosiPat = GetEntryString(0x0020,0x0032)) != GDCM_UNFOUND ) + strImPosiPat = GetEntryString(0x0020,0x0032); + if ( strImPosiPat != GDCM_UNFOUND ) { - if ( sscanf( strImPosiPat.c_str(), "%f \\ %f \\%f", + if ( sscanf( strImPosiPat.c_str(), "%f \\ %f \\%f ", &ipp[0], &ipp[1], &ipp[2]) != 3 ) { gdcmWarningMacro( "Wrong Image Position Patient (0020,0032)." @@ -1034,7 +1106,7 @@ bool File::GetImagePositionPatient( float ipp[3] ) if ( sscanf( strImPosiPat.c_str(), "%f \\ %f \\%f ", &ipp[0], &ipp[1], &ipp[2]) != 3 ) { - gdcmWarningMacro( "wrong Image Position Patient (0020,0035). " + gdcmWarningMacro( "wrong Image Position Patient (0020,0030). " << "Less than 3 values were found." ); return false; } diff --git a/src/gdcmFile.h b/src/gdcmFile.h index dd42b0b2..1eb3efc2 100644 --- a/src/gdcmFile.h +++ b/src/gdcmFile.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.h,v $ Language: C++ - Date: $Date: 2006/11/08 17:03:38 $ - Version: $Revision: 1.129 $ + Date: $Date: 2006/11/15 15:54:15 $ + Version: $Revision: 1.130 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -128,7 +128,14 @@ public: float GetXOrigin(); float GetYOrigin(); float GetZOrigin(); - + + float GetXCosineOnX(); + float GetXCosineOnY(); + float GetXCosineOnZ(); + float GetYCosineOnX(); + float GetYCosineOnY(); + float GetYCosineOnZ(); + bool GetImageOrientationPatient( float iop[6] ); bool GetImagePositionPatient( float ipp[3] ); diff --git a/src/gdcmOrientation.cxx b/src/gdcmOrientation.cxx index 397fbff0..c22325d8 100644 --- a/src/gdcmOrientation.cxx +++ b/src/gdcmOrientation.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmOrientation.cxx,v $ Language: C++ - Date: $Date: 2006/01/19 11:46:46 $ - Version: $Revision: 1.23 $ + Date: $Date: 2006/11/15 15:54:15 $ + Version: $Revision: 1.24 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -88,7 +88,7 @@ OrientationType Orientation::GetOrientationType( File *f ) bool succ = f->GetImageOrientationPatient( iop ); if ( !succ ) { - gdcmErrorMacro( "No Image Orientation (0020,0037)/(0020,0032) found in the file, cannot proceed." ) + gdcmWarningMacro( "No Image Orientation (0020,0037)/(0020,0032) found in the file, cannot proceed." ) return NotApplicable; } vector3D ori1; -- 2.48.1