[Insight-users] Re : File names containing space

Syrine Sahmim syrine.sahmim at yahoo.fr
Thu Jun 11 10:59:05 EDT 2009


the c make file is as follow:
CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
IF(COMMAND CMAKE_POLICY)
  CMAKE_POLICY(SET CMP0003 NEW)
ENDIF(COMMAND CMAKE_POLICY)

PROJECT(ImageExamples)
FIND_PACKAGE(ITK REQUIRED)
INCLUDE(${ITK_USE_FILE})
INCLUDE_REGULAR_EXPRESSION("^.*$")

SET(TEMP ${ITK_BINARY_DIR}/Testing/Temporary)

ADD_EXECUTABLE(Image2 Image2.cxx )
TARGET_LINK_LIBRARIES(Image2 ITKIO)

SET(IMAGE_EXAMPLES2 ${CXX_TEST_PATH}/ImageExamples2)
IF( NOT ITK_DISABLE_CXX_TESTING )

IF(BUILD_TESTING)

IF(NOT BORLAND)
  ADD_TEST(Image2Test ${IMAGE_EXAMPLES}
    Image2Test ${ITK_SOURCE_DIR}/Examples/Data/BrainMidSagittalSlice.png
  )
ENDIF(NOT BORLAND)
ENDIF(BUILD_TESTING)
ENDIF( NOT ITK_DISABLE_CXX_TESTING )

and the image2.cxx file is :
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif
#include "itkImage.h"

#include "itkImageFileReader.h"
int main( int , char * argv[])
{typedef unsigned char          PixelType;
  const unsigned int             Dimension = 3;

  typedef itk::Image< PixelType, Dimension >   ImageType;
typedef itk::ImageFileReader< ImageType >  ReaderType;
ReaderType::Pointer reader = ReaderType::New();
const char * filename = argv[1];
  reader->SetFileName( filename );
reader->Update();
ImageType::Pointer image = reader->GetOutput();
 return 0;}



________________________________
De : Jean-Pierre Roux <jpr at creatis.insa-lyon.fr>
À : insight-users at itk.org
Envoyé le : Jeudi, 11 Juin 2009, 14h42mn 52s
Objet : [Insight-users] File names containing space

Hi, everybody!

I've got some DICOM files whose name contains a blank space (e.g. : IM0025 .dcm)

Even if I replace the " "  by  "\ "  , with the following code :

     std::string temp = dirName + d_name;
     std::string::size_type  spacePosition = temp.find_first_of(' ');
     if (spacePosition != std::string::npos);
              temp.insert(spacePosition, "\\");

the programs hangs :

itk::ImageIOBase::Pointer genericReader =
     itk::ImageIOFactory::CreateImageIO(temp.c_str(),
                    itk::ImageIOFactory::ReadMode);
   if (!genericReader)
     {
     bbtkError("File format unknown (while reading [" << filename << "])");
     }

When file name doesn't contain any space, it runs OK.
Did I missed anything?

Thx

Jean-Pierre
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ITK FAQ at: http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-users



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090611/b3e68494/attachment.htm>


More information about the Insight-users mailing list