diff --git a/Code/Common/otbQuickLookImageGenerator.h b/Code/Common/otbQuickLookImageGenerator.h new file mode 100755 index 0000000000000000000000000000000000000000..2a42e074ddaeed6b3d6cdde8280b8560e445e4df --- /dev/null +++ b/Code/Common/otbQuickLookImageGenerator.h @@ -0,0 +1,148 @@ +/*========================================================================= + +Program: ORFEO Toolbox +Language: C++ +Date: $Date$ +Version: $Revision$ + + +Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. +See OTBCopyright.txt for details. + + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef __otbQuickLookImageGenerator_h +#define __otbQuickLookImageGenerator_h + +#include "otbMath.h" +#include "itkImageToImageFilter.h" +#include "otbImage.h" +#include "otbPerBandVectorImageFilter.h" +#include "otbStreamingShrinkImageFilter.h" +#include "itkDiscreteGaussianImageFilter.h" + + +namespace otb +{ + /** \class QuickLookImageGenerator + * \brief This functor computes a quicklook using discrete gaussian transform + */ +template <class TInputImage, class TOutputImage> +class ITK_EXPORT QuickLookImageGenerator : +public itk::ImageToImageFilter< TInputImage, TOutputImage > +{ +public: + /** Standard class typedefs. */ + typedef QuickLookImageGenerator Self; + typedef TInputImage InputImageType; + typedef TOutputImage OutputImageType; + typedef typename InputImageType::PixelType InputPixelType; + typedef typename OutputImageType::PixelType OutputPixelType; + typedef typename itk::ImageToImageFilter<TInputImage, TOutputImage> Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + typedef Image<double, 2> InternSingleImageType; + typedef itk::DiscreteGaussianImageFilter<InternSingleImageType,InternSingleImageType> GaussianFilterType; + typedef typename GaussianFilterType::Pointer GaussianFilterPointerType; + typedef PerBandVectorImageFilter<InputImageType, InputImageType, GaussianFilterType> PerBandFilterType; + typedef typename PerBandFilterType::Pointer PerBandFilterPointerType; + typedef StreamingShrinkImageFilter<InputImageType, InputImageType> ShrinkImageFilterType; + typedef typename ShrinkImageFilterType::Pointer ShrinkImageFilterPointerType; + + + void SetVariance(double var) + { + m_Variance = var; + m_GaussianFilter->SetVariance(m_Variance); + this->Modified(); + }; + itkGetMacro(Variance, double); + + void UseImageSpacing(bool boo) + { + m_UseImageSpacing = boo; + if (boo) + m_GaussianFilter->SetUseImageSpacingOn(); + else + m_GaussianFilter->SetUseImageSpacingOff(); + + this->Modified(); + } + itkGetMacro(UseImageSpacing, bool); + + void SetMaximumKernelWidth(unsigned int width) + { + m_MaximumKernelWidth = width; + m_GaussianFilter->SetMaximumKernelWidth( m_MaximumKernelWidth ); + this->Modified(); + } + itkGetMacro(MaximumKernelWidth, unsigned int); + + void SetMaximumError(double error) + { + m_MaximumError = error; + m_GaussianFilter->SetMaximumError( m_MaximumError ); + this->Modified(); + } + itkGetMacro(MaximumError, double); + + void SetSampleRatio(unsigned int sr) + { + m_SampleRatio = sr; + m_ShrinkFilter->SetShrinkFactor( m_SampleRatio ); + this->Modified(); + } + itkGetMacro(SampleRatio, unsigned int); + + +protected: + QuickLookImageGenerator(); + virtual ~QuickLookImageGenerator(){}; + + /** Actually process the input */ + virtual void GenerateData(); + virtual void GenerateOutputInformation(); + + + /** Display */ + void PrintSelf( std::ostream& os, itk::Indent indent ) const; + +private: + QuickLookImageGenerator(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented + + /** Internal filters*/ + PerBandFilterPointerType m_PerBandFilter; + ShrinkImageFilterPointerType m_ShrinkFilter; + GaussianFilterPointerType m_GaussianFilter; + + /** Variance value for Gaussian filter*/ + double m_Variance; + /** Use spacing to compute Gaussain filter*/ + bool m_UseImageSpacing; + /** Maximum kernel width for Gaussian filter*/ + double m_MaximumError; + /** Maximum error tolerate for Gaussian filter*/ + unsigned int m_MaximumKernelWidth; + + /** Sample Ratio*/ + unsigned int m_SampleRatio; + + +}; + +}// End namespace otb +#ifndef OTB_MANUAL_INSTANTIATION +#include "otbQuickLookImageGenerator.txx" +#endif + +#endif diff --git a/Code/Common/otbQuickLookImageGenerator.txx b/Code/Common/otbQuickLookImageGenerator.txx new file mode 100755 index 0000000000000000000000000000000000000000..72f26ced793c11daf9269920e3170a8af6ec4255 --- /dev/null +++ b/Code/Common/otbQuickLookImageGenerator.txx @@ -0,0 +1,88 @@ +/*========================================================================= + +Program: ORFEO Toolbox +Language: C++ +Date: $Date$ +Version: $Revision$ + + +Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. +See OTBCopyright.txt for details. + + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "otbQuickLookImageGenerator.h" + +namespace otb +{ + +/** + * Constructor + */ +template <class TInputImage, class TOutputImage> +QuickLookImageGenerator<TInputImage, TOutputImage> +::QuickLookImageGenerator() +{ + m_SampleRatio = 1; + m_Variance = 0.3; + m_MaximumError = 0.01; + m_MaximumKernelWidth = 32; + m_UseImageSpacing = true; + + // Internal filter + m_PerBandFilter = PerBandFilterType::New(); + m_ShrinkFilter = ShrinkImageFilterType::New(); + m_GaussianFilter = GaussianFilterType::New(); + + m_PerBandFilter->SetFilter( m_GaussianFilter ); + m_ShrinkFilter->SetInput( m_PerBandFilter->GetOutput() ); +} + + +template <class TInputImage, class TOutputImage> +void +QuickLookImageGenerator<TInputImage,TOutputImage> +::GenerateOutputInformation() +{ + Superclass::GenerateOutputInformation(); + + m_PerBandFilter->SetInput(this->GetInput()); + m_PerBandFilter->GenerateOutputInformation(); + m_ShrinkFilter->GenerateOutputInformation(); + this->GetOutput()->SetLargestPossibleRegion( m_ShrinkFilter->GetOutput()->GetLargestPossibleRegion() ); +} + +template <class TInputImage, class TOutputImage> +void +QuickLookImageGenerator<TInputImage,TOutputImage> +::GenerateData() +{ + m_PerBandFilter->SetInput(this->GetInput()); + + m_ShrinkFilter->GraftOutput(this->GetOutput()); + + m_ShrinkFilter->Update(); + this->GraftOutput(m_ShrinkFilter->GetOutput()); +} + +template <class TInputImage, class TOutputImage> +void +QuickLookImageGenerator<TInputImage, TOutputImage>:: +PrintSelf( std::ostream& os, itk::Indent indent ) const +{ + Superclass::PrintSelf(os, indent); + + os << "Sample Ratio : "<< m_SampleRatio<<std::endl; + os << "Gaussian Filter Parameters : "<<std::endl; + os << "Variance : "<< m_Variance<<std::endl; + os << "Maximum Kernel Width : "<< m_MaximumKernelWidth<<std::endl; + os << "Maximum Error : "<< m_MaximumError<<std::endl; + os << "Use Image Spacing : "<< m_UseImageSpacing<<std::endl; +} + + +} // End namespace otb diff --git a/Code/Projections/otbVectorDataProjectionFilter.txx b/Code/Projections/otbVectorDataProjectionFilter.txx index 95b041d01b878ed58817dd5b21af9867f471f3f4..9302ec4a637176ba40634a53b397f6125e355632 100644 --- a/Code/Projections/otbVectorDataProjectionFilter.txx +++ b/Code/Projections/otbVectorDataProjectionFilter.txx @@ -206,7 +206,6 @@ VectorDataProjectionFilter<TInputVectorData,TOutputVectorData> point = m_Transform->TransformPoint(pointCoord); point[0] = (point[0] - m_OutputOrigin[0]) / m_OutputSpacing[0]; point[1] = (point[1] - m_OutputOrigin[1]) / m_OutputSpacing[1]; - return point; } @@ -262,14 +261,9 @@ VectorDataProjectionFilter<TInputVectorData,TOutputVectorData> itk::Point<double,2> point; itk::ContinuousIndex<double,2> index; typename PolygonType::VertexType pointCoord = it.Value(); - pointCoord[0] = pointCoord[0] * m_InputSpacing[0] + m_InputOrigin[0]; - pointCoord[1] = pointCoord[1] * m_InputSpacing[1] + m_InputOrigin[1]; point = m_Transform->TransformPoint(pointCoord); - point[0] = (point[0] - m_OutputOrigin[0]) / m_OutputSpacing[0]; - point[1] = (point[1] - m_OutputOrigin[1]) / m_OutputSpacing[1]; index[0]=point[0]; index[1]=point[1]; -// otbMsgDevMacro(<< "Converting: " << it.Value() << " -> " << pointCoord << " -> " << point << " -> " << index); newPolygon->AddVertex(index); it++; } @@ -340,7 +334,6 @@ VectorDataProjectionFilter<TInputVectorData,TOutputVectorData> m_Transform->SetOutputOrigin(m_OutputOrigin); m_Transform->InstanciateTransform(); - // retrieve the output projection ref // if it is not specified and end up beeing geographic, // only the m_Transform will know @@ -400,7 +393,7 @@ VectorDataProjectionFilter<TInputVectorData,TOutputVectorData> chrono.Start(); ProcessNode(inputRoot,outputRoot); chrono.Stop(); - std::cout<<"VectoDataProjectionFilter: features Processed in "<<chrono.GetMeanTime()<<" seconds."<<std::endl; + otbMsgDevMacro(<<"VectoDataProjectionFilter: features Processed in "<<chrono.GetMeanTime()<<" seconds."); } diff --git a/Code/Visu/otbGluPolygonDrawingHelper.cxx b/Code/Visu/otbGluPolygonDrawingHelper.cxx index 5ceb82609d0c7a90e8049d31387b6e2833647dd1..ab88eeb3b287c67a6a180fddcfbee5baf10a1c48 100644 --- a/Code/Visu/otbGluPolygonDrawingHelper.cxx +++ b/Code/Visu/otbGluPolygonDrawingHelper.cxx @@ -37,7 +37,7 @@ extern "C" { typedef void (CALLBACK * FunctionPointerType)(); - void __stdcall CombineCallback(GLdouble coords[3],GLdouble * data[4], GLfloat weights[4],GLdouble **dataOut) + void CALLBACK CombineCallback(GLdouble coords[3],GLdouble * data[4], GLfloat weights[4],GLdouble **dataOut) { GLdouble * vertex = new GLdouble[3]; vertex[0] = coords[0]; diff --git a/Code/Visualization/otbImageLayerRenderingModel.txx b/Code/Visualization/otbImageLayerRenderingModel.txx index adf28805cdf42b742b4c8d94be393284dbb7fe0f..cd1ccee4584131323ed705383460bf79a4c0583f 100644 --- a/Code/Visualization/otbImageLayerRenderingModel.txx +++ b/Code/Visualization/otbImageLayerRenderingModel.txx @@ -272,19 +272,19 @@ ImageLayerRenderingModel<TOutputImage> { RegionType lImageRegion; lImageRegion = this->GetLayer(0)->GetExtent(); - + SizeType lSize; lSize[0] = vcl_abs(stopIndex[0]-startIndex[0]); lSize[1] = vcl_abs(stopIndex[1]-startIndex[1]); - + IndexType lIndex; lIndex[0] = std::min(startIndex[0],stopIndex[0]); lIndex[1] = std::min(startIndex[1],stopIndex[1]); - + RegionType lRegion; lRegion.SetIndex(lIndex); lRegion.SetSize(lSize); - + if(lRegion.Crop(lImageRegion)) { m_ExtractRegion = lRegion; diff --git a/Code/Visualization/otbImageView.txx b/Code/Visualization/otbImageView.txx index 256ba0403ae742efd3e37bc5b2409f8e261033df..511c294df5a3d3f6361eaec617260ba218b89e41 100644 --- a/Code/Visualization/otbImageView.txx +++ b/Code/Visualization/otbImageView.txx @@ -159,7 +159,7 @@ ImageView<TViewerModel> ::UpdateFullWidget() { if(m_Model->GetHasExtract()) - { + { otbMsgDevMacro(<<"ImageView::UpdateFullWidget(): redrawing full widget"); m_FullWidget->ReadBuffer(m_Model->GetRasterizedExtract(),m_Model->GetRasterizedExtract() ->GetLargestPossibleRegion()); diff --git a/Code/Visualization/otbSelectAreaActionHandler.h b/Code/Visualization/otbSelectAreaActionHandler.h index 99cde1c8c8dc436ef376c84463c0cff8282f045b..f5487bfff9db408d635c4d347954c444a3ce4261 100644 --- a/Code/Visualization/otbSelectAreaActionHandler.h +++ b/Code/Visualization/otbSelectAreaActionHandler.h @@ -97,14 +97,19 @@ public: { m_FirstPush = false; m_StartIndex = lIndex; + // ImageView.txx hide the GlComponent when Update + m_RegionGlComponent->SetVisible(true); break; } case FL_RELEASE: { - m_FirstPush = true; - m_StopIndex = lIndex; - m_Model->SetExtractRegionByIndex(m_StartIndex,m_StopIndex); - m_Model->Update(); + if(m_StartIndex[0] != lIndex[0] && m_StartIndex[1] != lIndex[1]) + { + m_FirstPush = true; + m_StopIndex = lIndex; + m_Model->SetExtractRegionByIndex(m_StartIndex,m_StopIndex); + m_Model->Update(); + } break; } case FL_DRAG: diff --git a/Code/Visualization/otbStandardImageViewer.txx b/Code/Visualization/otbStandardImageViewer.txx index 7c5dc1df0ae91bbd277547e53e8ec7c6b4568769..a7679787c5ff94e39ffb048cf5c593976fc86f43 100644 --- a/Code/Visualization/otbStandardImageViewer.txx +++ b/Code/Visualization/otbStandardImageViewer.txx @@ -184,7 +184,9 @@ StandardImageViewer<TImage,TVectorData,TWidgetManager> // Reproject VectorData in image projection vproj = VectorDataProjectionFilterType::New(); vproj->SetInput(vdextract->GetOutput()); + vproj->SetInputProjectionRef(m_VectorData->GetProjectionRef()); vproj->SetOutputKeywordList(m_Image->GetImageKeywordlist()); + vproj->SetOutputProjectionRef(m_Image->GetProjectionRef()); vproj->SetOutputOrigin(m_Image->GetOrigin()); vproj->SetOutputSpacing(m_Image->GetSpacing()); vproj->SetDEMDirectory(m_DEMDirectory); diff --git a/Code/Visualization/otbVectorDataGlComponent.txx b/Code/Visualization/otbVectorDataGlComponent.txx index 358c5e80dd3944138e9d3f629f3e371674c19c49..7e7f597fd16899f04c6cfeadd3002007078be37d 100644 --- a/Code/Visualization/otbVectorDataGlComponent.txx +++ b/Code/Visualization/otbVectorDataGlComponent.txx @@ -69,7 +69,9 @@ VectorDataGlComponent<TVectorData> // nothing to render, return return; } - + + m_Spacing = m_VectorData->GetSpacing(); + m_Origin = m_VectorData->GetOrigin(); // Set up blending and color glEnable(GL_BLEND); @@ -91,7 +93,6 @@ VectorDataGlComponent<TVectorData> // Enabling line antialiasing glEnable(GL_LINE_SMOOTH); - // Trigger recursive rendering InternalTreeNodeType * inputRoot = const_cast<InternalTreeNodeType *>(m_VectorData->GetDataTree()->GetRoot()); @@ -99,7 +100,7 @@ VectorDataGlComponent<TVectorData> chrono.Start(); this->Render(inputRoot,extent,space2ScreenTransform); chrono.Stop(); - std::cout<<"VectorData component rendered in "<<chrono.GetMeanTime()<<" s."<<std::endl; + otbMsgDevMacro(<<"VectorData component rendered in "<<chrono.GetMeanTime()<<" s."); glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); @@ -114,8 +115,8 @@ VectorDataGlComponent<TVectorData> PointType spacePoint = p; spacePoint[0]*= m_Spacing[0]; spacePoint[1]*= m_Spacing[1]; - spacePoint[0]-= m_Origin[0]; - spacePoint[1]-=m_Origin[1]; + spacePoint[0]+= m_Origin[0]; + spacePoint[1]+=m_Origin[1]; // Transform to a screen point PointType screenPoint = transform->TransformPoint(spacePoint); @@ -145,8 +146,8 @@ VectorDataGlComponent<TVectorData> PointType spacePoint = vIt.Value(); spacePoint[0]*= m_Spacing[0]; spacePoint[1]*= m_Spacing[1]; - spacePoint[0]-= m_Origin[0]; - spacePoint[1]-= m_Origin[1]; + spacePoint[0]+= m_Origin[0]; + spacePoint[1]+= m_Origin[1]; // Transform to a screen point PointType screenPoint = transform->TransformPoint(spacePoint); @@ -183,8 +184,8 @@ VectorDataGlComponent<TVectorData> PointType spacePoint = vIt.Value(); spacePoint[0]*= m_Spacing[0]; spacePoint[1]*= m_Spacing[1]; - spacePoint[0]-= m_Origin[0]; - spacePoint[1]-= m_Origin[1]; + spacePoint[0]+= m_Origin[0]; + spacePoint[1]+= m_Origin[1]; // Transform to a screen point PointType screenPoint = transform->TransformPoint(spacePoint); @@ -222,8 +223,8 @@ VectorDataGlComponent<TVectorData> PointType spacePoint = vIt.Value(); spacePoint[0]*= m_Spacing[0]; spacePoint[1]*= m_Spacing[1]; - spacePoint[0]-= m_Origin[0]; - spacePoint[1]-= m_Origin[1]; + spacePoint[0]+= m_Origin[0]; + spacePoint[1]+= m_Origin[1]; // Transform to a screen point PointType screenPoint = transform->TransformPoint(spacePoint); diff --git a/Testing/Code/Common/CMakeLists.txt b/Testing/Code/Common/CMakeLists.txt old mode 100644 new mode 100755 index 7bad8b433cfc2893c0264b93e25fa4d1005fa648..92d6988debb61174ba0eb11bc8fa64f0895bc23a --- a/Testing/Code/Common/CMakeLists.txt +++ b/Testing/Code/Common/CMakeLists.txt @@ -23,6 +23,7 @@ SET(COMMON_TESTS4 ${CXX_TEST_PATH}/otbCommonTests4) SET(COMMON_TESTS5 ${CXX_TEST_PATH}/otbCommonTests5) SET(COMMON_TESTS6 ${CXX_TEST_PATH}/otbCommonTests6) SET(COMMON_TESTS7 ${CXX_TEST_PATH}/otbCommonTests7) +SET(COMMON_TESTS8 ${CXX_TEST_PATH}/otbCommonTests8) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ otbCommonTests1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -605,6 +606,32 @@ ADD_TEST(ioTvRemoteSensingRegion ${COMMON_TESTS7} 0. 0. # Point to check ) + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ otbCommonTests8 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# ------------- otb::QuickLookImageGenerator ---------------------------- +ADD_TEST(coTvQuickLookImageGeneratorNew ${COMMON_TESTS8} +otbQuickLookImageGeneratorNew +) + +ADD_TEST(coTuQuickLookImageGenerator ${COMMON_TESTS8} + --compare-image ${TOL} + ${BASELINE}/coTuQuickLookImageGenerator.tif + ${TEMP}/coTuQuickLookImageGenerator.tif + otbQuickLookImageGenerator + ${INPUTDATA}/qb_RoadExtract.img.hdr + ${TEMP}/coTuQuickLookImageGenerator.tif + 10 # sr + 2 # variance + 0.5 # max error + 4 # max kernel width + 1 # usespacing +) + + + # ------- Fichiers sources CXX ----------------------------------- SET(BasicCommon_SRCS1 otbSystemTest.cxx @@ -696,6 +723,10 @@ otbRemoteSensingRegionNew.cxx otbRemoteSensingRegion.cxx ) +SET(BasicCommon_SRCS8 +otbQuickLookImageGeneratorNew.cxx +otbQuickLookImageGenerator.cxx +) INCLUDE_DIRECTORIES("${OTBTesting_BINARY_DIR}") @@ -722,5 +753,7 @@ TARGET_LINK_LIBRARIES(otbCommonTests6 OTBIO) ADD_EXECUTABLE(otbCommonTests7 otbCommonTests7.cxx ${BasicCommon_SRCS7}) TARGET_LINK_LIBRARIES(otbCommonTests7 OTBIO) +ADD_EXECUTABLE(otbCommonTests8 otbCommonTests8.cxx ${BasicCommon_SRCS8}) +TARGET_LINK_LIBRARIES(otbCommonTests8 OTBIO) ENDIF( NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING ) diff --git a/Testing/Code/Common/otbCommonTests8.cxx b/Testing/Code/Common/otbCommonTests8.cxx new file mode 100644 index 0000000000000000000000000000000000000000..344b1714657b319c1bf969bd49b84a0a8a67f04c --- /dev/null +++ b/Testing/Code/Common/otbCommonTests8.cxx @@ -0,0 +1,31 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +// this file defines the otbCommonTest for the test driver +// and all it expects is that you have a function called RegisterTests +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#include "otbTestMain.h" + +void RegisterTests() +{ +REGISTER_TEST(otbQuickLookImageGeneratorNew); +REGISTER_TEST(otbQuickLookImageGenerator); +} diff --git a/Testing/Code/Common/otbQuickLookImageGenerator.cxx b/Testing/Code/Common/otbQuickLookImageGenerator.cxx new file mode 100755 index 0000000000000000000000000000000000000000..e9e21dd553bc41dbbf87d5d606c2fdad8d08732f --- /dev/null +++ b/Testing/Code/Common/otbQuickLookImageGenerator.cxx @@ -0,0 +1,59 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#include "itkExceptionObject.h" +#include "otbQuickLookImageGenerator.h" +#include "otbVectorImage.h" +#include "otbImageFileReader.h" +#include "otbImageFileWriter.h" + +int otbQuickLookImageGenerator(int argc, char* argv[]) +{ + const char * inputFileName = argv[1]; + const char * outputFileName = argv[2]; + + typedef otb::VectorImage<double, 2> ImageType; + typedef otb::ImageFileReader<ImageType> ReaderType; + typedef otb::ImageFileWriter<ImageType> WriterType; + typedef otb::QuickLookImageGenerator<ImageType, ImageType> FilterType; + + FilterType::Pointer filter = FilterType::New(); + ReaderType::Pointer reader = ReaderType::New(); + WriterType::Pointer writer = WriterType::New(); + + reader->SetFileName( inputFileName ); + + + filter->SetInput( reader->GetOutput() ); + filter->SetSampleRatio(atoi(argv[3])); + filter->SetVariance(atof(argv[4])); + filter->SetMaximumError(atof(argv[5])); + filter->SetMaximumKernelWidth(atoi(argv[6])); + filter->UseImageSpacing(atoi(argv[7])); + + writer->SetInput( filter->GetOutput() ); + writer->SetFileName( outputFileName ); + + writer->Update(); + + return EXIT_SUCCESS; +} diff --git a/Testing/Code/Common/otbQuickLookImageGeneratorNew.cxx b/Testing/Code/Common/otbQuickLookImageGeneratorNew.cxx new file mode 100755 index 0000000000000000000000000000000000000000..91159c44ffd1530a0a5ede8c1a20c19180b63b45 --- /dev/null +++ b/Testing/Code/Common/otbQuickLookImageGeneratorNew.cxx @@ -0,0 +1,36 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#include "itkExceptionObject.h" +#include "otbQuickLookImageGenerator.h" +#include "otbVectorImage.h" + + +int otbQuickLookImageGeneratorNew(int argc, char* argv[]) +{ + typedef otb::VectorImage<double, 2> ImageType; + typedef otb::QuickLookImageGenerator<ImageType, ImageType> FilterType; + + FilterType::Pointer filter = FilterType::New(); + + return EXIT_SUCCESS; +} diff --git a/Testing/Code/IO/CMakeLists.txt b/Testing/Code/IO/CMakeLists.txt index 813dc06bbed017876d2ecd7105a751c68cf9bcd2..0d5a5b77922163a11a27852a7d085066c7cae7cd 100755 --- a/Testing/Code/IO/CMakeLists.txt +++ b/Testing/Code/IO/CMakeLists.txt @@ -1538,6 +1538,17 @@ ADD_TEST(ioTvVectorDataFileWriterTwice ${IO_TESTS15} # If the file exists, try remove it to prevent test failure FILE(REMOVE ${TEMP}/ioTvVectorDataFileReaderWriterOutput.shp) + +ADD_TEST(ioTvVectorDataFileWriterPolygons ${IO_TESTS15} + otbVectorDataFileWriterPolygons + ${TEMP}/ioTvVectorDataFileWriterOutput.shp + ) + +# If the file exists, try remove it to prevent test failure +FILE(REMOVE ${TEMP}/ioTvVectorDataFileReaderWriterOutput.shp) + + + IF(OTB_DATA_USE_LARGEINPUT) ADD_TEST(ioTvVectorDataFileReaderWriter ${IO_TESTS15} --compare-n-binary 4 @@ -1824,6 +1835,7 @@ otbVectorDataFileReaderNew.cxx otbVectorDataFileReader.cxx otbVectorDataFileWriterNew.cxx otbVectorDataFileWriter.cxx +otbVectorDataFileWriterPolygons.cxx otbVectorDataFileReaderWriter.cxx otbVectorDataFileGeoReaderWriter.cxx otbSHPVectorDataIONew.cxx diff --git a/Testing/Code/IO/otbIOTests15.cxx b/Testing/Code/IO/otbIOTests15.cxx index 7a62aaa3d742bdcabae1586e3655f35f7928d2cc..b6b6f55dec15fc9a3c86c278d5a29c298652f1c1 100644 --- a/Testing/Code/IO/otbIOTests15.cxx +++ b/Testing/Code/IO/otbIOTests15.cxx @@ -33,6 +33,7 @@ void RegisterTests() REGISTER_TEST(otbVectorDataFileReader); REGISTER_TEST(otbVectorDataFileWriterNew); REGISTER_TEST(otbVectorDataFileWriter); + REGISTER_TEST(otbVectorDataFileWriterPolygons); REGISTER_TEST(otbVectorDataFileReaderWriter); REGISTER_TEST(otbVectorDataFileGeoReaderWriter); REGISTER_TEST(otbSHPVectorDataIONew); diff --git a/Testing/Code/IO/otbVectorDataFileWriterPolygons.cxx b/Testing/Code/IO/otbVectorDataFileWriterPolygons.cxx new file mode 100644 index 0000000000000000000000000000000000000000..9f0899ac48069b57d8dbe8e39efd786c02e95f75 --- /dev/null +++ b/Testing/Code/IO/otbVectorDataFileWriterPolygons.cxx @@ -0,0 +1,93 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "itkExceptionObject.h" +#include "otbMacro.h" + +#include "otbVectorData.h" +#include "otbVectorDataFileWriter.h" + +int otbVectorDataFileWriterPolygons(int argc, char * argv[]) +{ + + typedef otb::VectorData<double,2> VectorDataType; + typedef VectorDataType::DataNodeType DataNodeType; + typedef otb::VectorDataFileWriter<VectorDataType> WriterType; + typedef DataNodeType::PointType PointType; + typedef DataNodeType::LineType LineType; + typedef DataNodeType::PolygonType PolygonType; + typedef LineType::VertexType VertexType; + + //Instantiation + WriterType::Pointer writer = WriterType::New(); + VectorDataType::Pointer data = VectorDataType::New(); + + DataNodeType::Pointer document = DataNodeType::New(); + DataNodeType::Pointer folder = DataNodeType::New(); + + DataNodeType::Pointer polygon1 = DataNodeType::New(); + DataNodeType::Pointer polygon2 = DataNodeType::New(); + DataNodeType::Pointer polygon3 = DataNodeType::New(); + DataNodeType::Pointer polygon4 = DataNodeType::New(); + DataNodeType::Pointer polygon5 = DataNodeType::New(); + + document->SetNodeType(otb::DOCUMENT); + folder->SetNodeType(otb::FOLDER); + polygon1->SetNodeType(otb::FEATURE_POLYGON); + + document->SetNodeId("DOCUMENT"); + folder->SetNodeId("THE_FOLDER"); + polygon1->SetNodeId("FEATURE_POLYGON"); + + VertexType p1; + p1.Fill(5); + + VertexType p3; + p3.Fill(0); + + VertexType p2; + p2[0]=0; + p2[1]=10; + + + PolygonType::Pointer poly = PolygonType::New(); + poly->AddVertex(p1); + poly->AddVertex(p2); + poly->AddVertex(p3); + polygon1->SetLine(poly); + + polygon2=polygon1; + polygon3=polygon1; + polygon4=polygon1; + polygon5=polygon1; + + DataNodeType::Pointer root = data->GetDataTree()->GetRoot()->Get(); + + data->GetDataTree()->Add(document,root); + data->GetDataTree()->Add(folder,document); + data->GetDataTree()->Add(polygon1,folder); + data->GetDataTree()->Add(polygon2,folder); + data->GetDataTree()->Add(polygon3,folder); + data->GetDataTree()->Add(polygon4,folder); + data->GetDataTree()->Add(polygon5,folder); + + writer->SetFileName(argv[1]); + writer->SetInput(data); + writer->Update(); + + return EXIT_SUCCESS; +}