[Insight-users] MetaImage: absolute path in ElementDataFile not working
Luis Ibanez
luis.ibanez at kitware.com
Mon May 12 09:50:05 EDT 2008
Hi Florian,
Could you please post the *exact* absolute path that you were using
when you encounter this problem ?
We are able to read files with absolute path without any problem.
It is therefore likely that there is something special about the
path that you were using.
Also, please let us know what platform are you using.
Thanks
Luis
---------------------
Florian Pierron wrote:
> Dear ITK developer team,
>
> I noticed that having an absolute path in the ElementDataFile is not
> supported in ITK 3.4.0. I don't know if there is a good reason for that
> or if it's just by mistake but it seems that there is an easy fix to
> that (if I am not wrong...). I have changed the following lines in
> \Utilities\MetaIO\metaImage.cxx:
>
> - usePath = MET_GetFilePath(_headerName, pathName)
>
> by
>
> + usePath = !MET_GetFilePath(elementDataFileName.c_str(), pathName) &&
> + MET_GetFilePath(_headerName, pathName);
>
> So that usePath (which determines in fact if the path to the header /
> meta file should be append to the elementDataFileName) is used only if
> the elementDataFileName is not an absolute path and if there is a path
> for the header / meta file.
>
> Find attached the patch file.
>
> Regards,
> Florian
>
>
> ------------------------------------------------------------------------
>
> ### Eclipse Workspace Patch 1.0
> #P ITK_3_4_0
> Index: Utilities/MetaIO/metaImage.cxx
> ===================================================================
> RCS file: /cvsroot/Insight/Insight/Utilities/MetaIO/metaImage.cxx,v
> retrieving revision 1.76
> diff -u -r1.76 metaImage.cxx
> --- Utilities/MetaIO/metaImage.cxx 12 Sep 2007 11:46:05 -0000 1.76
> +++ Utilities/MetaIO/metaImage.cxx 12 May 2008 10:53:09 -0000
> @@ -3,7 +3,7 @@
> Program: MetaIO
> Module: $RCSfile: metaImage.cxx,v $
> Language: C++
> - Date: $Date: 2007-09-12 11:46:05 $
> + Date: $Date: 2007/09/12 11:46:05 $
> Version: $Revision: 1.76 $
>
> Copyright (c) Insight Software Consortium. All rights reserved.
> @@ -1118,10 +1118,6 @@
> return false;
> }
>
> - bool usePath;
> - char pathName[255];
> - usePath = MET_GetFilePath(_headerName, pathName);
> -
> char* buf = new char[8001];
> inputStream.read(buf,8000);
> unsigned long fileSize = inputStream.gcount();
> @@ -1139,6 +1135,10 @@
>
> std::string elementDataFileName = M_GetTagValue(header,"ElementDataFile");
>
> + char pathName[255];
> + bool usePath = !MET_GetFilePath(elementDataFileName.c_str(), pathName) &&
> + MET_GetFilePath(_headerName, pathName);
> +
> char* fName = new char[512];
>
> if(!strcmp("Local", elementDataFileName.c_str()) ||
> @@ -1375,10 +1375,10 @@
> }
>
> int i, j;
> - bool usePath;
> char pathName[255];
> char fName[255];
> - usePath = MET_GetFilePath(m_FileName, pathName);
> + bool usePath = !MET_GetFilePath(m_ElementDataFileName, pathName) &&
> + MET_GetFilePath(m_FileName, pathName);
>
> if(!strcmp("Local", m_ElementDataFileName) ||
> !strcmp("LOCAL", m_ElementDataFileName) ||
> @@ -1620,7 +1620,8 @@
> }
>
> char pathName[255];
> - bool usePath = MET_GetFilePath(m_FileName, pathName);
> + bool usePath = !MET_GetFilePath(m_ElementDataFileName, pathName) &&
> + MET_GetFilePath(m_FileName, pathName);
> if(usePath)
> {
> char elementPathName[255];
> @@ -2240,7 +2241,8 @@
> {
> char dataFileName[255];
> char pathName[255];
> - bool usePath = MET_GetFilePath(m_FileName, pathName);
> + bool usePath = !MET_GetFilePath(m_ElementDataFileName, pathName) &&
> + MET_GetFilePath(m_FileName, pathName);
> if(usePath)
> {
> sprintf(dataFileName, "%s%s", pathName, m_ElementDataFileName);
> @@ -2471,10 +2473,10 @@
> m_Quantity *= (_indexMax[i] - _indexMin[i] + 1);
> }
>
> - bool usePath;
> char pathName[255];
> char fName[255];
> - usePath = MET_GetFilePath(m_FileName, pathName);
> + bool usePath = !MET_GetFilePath(m_ElementDataFileName, pathName) &&
> + MET_GetFilePath(m_FileName, pathName);
>
> if(!strcmp("Local", m_ElementDataFileName) ||
> !strcmp("LOCAL", m_ElementDataFileName) ||
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
More information about the Insight-users
mailing list