From bf6d0c20031ef470b0b7ace4a794558ea7947510 Mon Sep 17 00:00:00 2001 From: Emmanuel Christophe <emmanuel.christophe@orfeo-toolbox.org> Date: Sat, 9 Jul 2011 19:53:49 -0700 Subject: [PATCH] STYLE: fix indentation --- Utils/otbDEMConvert.cxx | 157 ++++++++++++++++++++-------------------- 1 file changed, 78 insertions(+), 79 deletions(-) diff --git a/Utils/otbDEMConvert.cxx b/Utils/otbDEMConvert.cxx index 4ff2a3b813..48c9b71847 100644 --- a/Utils/otbDEMConvert.cxx +++ b/Utils/otbDEMConvert.cxx @@ -42,7 +42,6 @@ namespace otb { - template<typename TPixelType> int generic_convert_to_tif(otb::ApplicationOptionsResult* parseResult, std::string tempFilename) { @@ -101,119 +100,119 @@ int DEMConvert::Execute(otb::ApplicationOptionsResult* parseResult) std::string componentTypeInfo(reader->GetImageIO()->GetComponentTypeInfo().name()); if( componentTypeInfo == typeid(unsigned char).name()) { - generic_convert_to_tif<unsigned char>(parseResult, tempFilename); + generic_convert_to_tif<unsigned char>(parseResult, tempFilename); } else if( componentTypeInfo == typeid(char).name()) { - generic_convert_to_tif<char>(parseResult, tempFilename); + generic_convert_to_tif<char>(parseResult, tempFilename); } else if( componentTypeInfo == typeid(unsigned short).name()) { - generic_convert_to_tif<unsigned short>(parseResult, tempFilename); + generic_convert_to_tif<unsigned short>(parseResult, tempFilename); } else if( componentTypeInfo == typeid(short).name()) { - generic_convert_to_tif<short>(parseResult, tempFilename); + generic_convert_to_tif<short>(parseResult, tempFilename); } else if( componentTypeInfo == typeid(unsigned int).name()) { - generic_convert_to_tif<unsigned int>(parseResult, tempFilename); + generic_convert_to_tif<unsigned int>(parseResult, tempFilename); } else if( componentTypeInfo == typeid(int).name()) { - generic_convert_to_tif<int>(parseResult, tempFilename); + generic_convert_to_tif<int>(parseResult, tempFilename); } else if( componentTypeInfo == typeid(unsigned long).name()) { - generic_convert_to_tif<unsigned long>(parseResult, tempFilename); + generic_convert_to_tif<unsigned long>(parseResult, tempFilename); } else if( componentTypeInfo == typeid(long).name()) { - generic_convert_to_tif<long>(parseResult, tempFilename); + generic_convert_to_tif<long>(parseResult, tempFilename); } else if( componentTypeInfo == typeid(float).name()) { - generic_convert_to_tif<float>(parseResult, tempFilename); + generic_convert_to_tif<float>(parseResult, tempFilename); } else if( componentTypeInfo == typeid(double).name()) { - generic_convert_to_tif<double>(parseResult, tempFilename); + generic_convert_to_tif<double>(parseResult, tempFilename); } else { - itkExceptionMacro("This appication doesn't support image pixel type " << componentTypeInfo); - return EXIT_FAILURE; + itkExceptionMacro("This appication doesn't support image pixel type " << componentTypeInfo); + return EXIT_FAILURE; } // Keyword list to initialize image writers with. - ossimKeywordlist kwl; - const char* PREFIX = "imagewriter."; - // Define the output file type - const ossimString output_type("general_raster_bsq_envi"); - kwl.add(PREFIX, ossimKeywordNames::TYPE_KW, output_type.c_str(), true); + ossimKeywordlist kwl; + const char* PREFIX = "imagewriter."; + // Define the output file type + const ossimString output_type("general_raster_bsq_envi"); + kwl.add(PREFIX, ossimKeywordNames::TYPE_KW, output_type.c_str(), true); - // Get an image handler for the input file. - ossimRefPtr<ossimImageHandler> ih = ossimImageHandlerRegistry::instance()->open(ossimString(tempFilename)); + // Get an image handler for the input file. + ossimRefPtr<ossimImageHandler> ih = ossimImageHandlerRegistry::instance()->open(ossimString(tempFilename)); - // Initialize the - if (ih->getErrorStatus() == ossimErrorCodes::OSSIM_ERROR) - { - itkExceptionMacro("Error reading image: " << input_file << "Exiting application..."); - return EXIT_FAILURE; - } + // Initialize the + if (ih->getErrorStatus() == ossimErrorCodes::OSSIM_ERROR) + { + itkExceptionMacro("Error reading image: " << input_file << "Exiting application..."); + return EXIT_FAILURE; + } - ih->initialize(); + ih->initialize(); - ossimRefPtr<ossimImageSource> source = ih.get(); - ossimRefPtr<ossimBandSelector> bs = 0; + ossimRefPtr<ossimImageSource> source = ih.get(); + ossimRefPtr<ossimBandSelector> bs = 0; - // Get the image rectangle for the rrLevel selected. - ossimIrect output_rect; - output_rect = source->getBoundingRect(0); + // Get the image rectangle for the rrLevel selected. + ossimIrect output_rect; + output_rect = source->getBoundingRect(0); - ossimRefPtr<ossimImageFileWriter> writer = - ossimImageWriterFactoryRegistry::instance()->createWriter(kwl, PREFIX); + ossimRefPtr<ossimImageFileWriter> writer = + ossimImageWriterFactoryRegistry::instance()->createWriter(kwl, PREFIX); - writer->connectMyInputTo(0, source.get()); - writer->open(ossimFilename(parseResult->GetParameterString("OutputPath"))+".ras"); + writer->connectMyInputTo(0, source.get()); + writer->open(ossimFilename(parseResult->GetParameterString("OutputPath"))+".ras"); - // Add a listener to get percent complete. - ossimStdOutProgress prog(0, true); - writer->addListener(&prog); - - if (writer->getErrorStatus() == ossimErrorCodes::OSSIM_OK) - { - if( (ih->getOutputScalarType() != OSSIM_UCHAR) && - (PTR_CAST(ossimJpegWriter, writer.get()) ) ) + // Add a listener to get percent complete. + ossimStdOutProgress prog(0, true); + writer->addListener(&prog); + + if (writer->getErrorStatus() == ossimErrorCodes::OSSIM_OK) + { + if( (ih->getOutputScalarType() != OSSIM_UCHAR) && + (PTR_CAST(ossimJpegWriter, writer.get()) ) ) { - writer->setScaleToEightBitFlag(true); + writer->setScaleToEightBitFlag(true); } - ossimRefPtr<ossimCacheTileSource> cache = new ossimCacheTileSource; - ossimIpt tileWidthHeight(ih->getImageTileWidth(), - ih->getImageTileHeight()); - // only use the cache if its stripped - if(static_cast<ossim_uint32>(tileWidthHeight.x) == - ih->getBoundingRect().width()) + ossimRefPtr<ossimCacheTileSource> cache = new ossimCacheTileSource; + ossimIpt tileWidthHeight(ih->getImageTileWidth(), + ih->getImageTileHeight()); + // only use the cache if its stripped + if(static_cast<ossim_uint32>(tileWidthHeight.x) == + ih->getBoundingRect().width()) { - cache->connectMyInputTo(0, source.get()); - cache->setTileSize(tileWidthHeight); - writer->connectMyInputTo(0, cache.get()); + cache->connectMyInputTo(0, source.get()); + cache->setTileSize(tileWidthHeight); + writer->connectMyInputTo(0, cache.get()); } - else + else { - writer->connectMyInputTo(0, source.get()); + writer->connectMyInputTo(0, source.get()); } - writer->initialize(); - writer->setAreaOfInterest(output_rect); // Set the output rectangle. + writer->initialize(); + writer->setAreaOfInterest(output_rect); // Set the output rectangle. - try + try { - writer->execute(); + writer->execute(); } - catch(std::exception& e) + catch(std::exception& e) { std::cerr << "std::exception thrown:" << std::endl; std::cerr << e.what() << std::endl; @@ -221,24 +220,24 @@ int DEMConvert::Execute(otb::ApplicationOptionsResult* parseResult) return EXIT_FAILURE; } - } - else - { - itkExceptionMacro("Error detected in the image writer..."); - return EXIT_FAILURE; - } - - - if ( parseResult->IsOptionPresent("KeepTif") == false) - { - bool resRemove = itksys::SystemTools::RemoveFile(tempFilename.c_str()); - if( resRemove == false ) - { - std::cout<<"Enable to erase the output temporary file "<<tempFilename<<"."<<std::endl; - } - } - - return EXIT_SUCCESS; + } + else + { + itkExceptionMacro("Error detected in the image writer..."); + return EXIT_FAILURE; + } + + + if ( parseResult->IsOptionPresent("KeepTif") == false) + { + bool resRemove = itksys::SystemTools::RemoveFile(tempFilename.c_str()); + if( resRemove == false ) + { + std::cout<<"Enable to erase the output temporary file "<<tempFilename<<"."<<std::endl; + } + } + + return EXIT_SUCCESS; } -- GitLab