diff --git a/Code/Common/otbVectorDataExtractROI.h b/Code/Common/otbVectorDataExtractROI.h index 4e544f5892cab5070157ea267b3f50f28ad4c976..bbeeef948bdacf87997e460132c4ce0b65376500 100644 --- a/Code/Common/otbVectorDataExtractROI.h +++ b/Code/Common/otbVectorDataExtractROI.h @@ -49,6 +49,7 @@ public: /** Image type information. */ typedef TVectorData VectorDataType; + typedef typename VectorDataType::DataTreeType DataTreeType; /** Get/Set Macro for ROI Column size */ itkGetMacro(SizeX, unsigned int); diff --git a/Code/Common/otbVectorDataExtractROI.txx b/Code/Common/otbVectorDataExtractROI.txx index 66457b8254a31a65cb80ecf33c57cc7f2faa34ed..f545a6c08dc41dbaae1cbbf2a95b11cb0f047b1a 100644 --- a/Code/Common/otbVectorDataExtractROI.txx +++ b/Code/Common/otbVectorDataExtractROI.txx @@ -20,6 +20,7 @@ #include "otbVectorDataExtractROI.h" #include "itkImageRegion.h" +#include "itkPreOrderTreeIterator.h" #include "itkIndex.h" #include "itkSize.h" @@ -77,18 +78,20 @@ VectorDataExtractROI<TVectorData> ::GenerateData(void) { /** Get The input and the outptut*/ - - + typename VectorDataType::ConstPointer input = this->GetInput(); + if(!input) + std::cout << " Probleme avec la recuperation du input"<<std::endl; /** Create a region with the right size*/ - const unsigned int Dimension = 2; + const unsigned int Dimension = 2; typedef itk::ImageRegion<Dimension> ImageRegionType; typedef itk::Index<Dimension> IndexType; typedef itk::Size<Dimension> SizeType; - - ImageRegionType roi; - IndexType index; - SizeType size; + + /** */ + ImageRegionType roi; + IndexType index; + SizeType size; /** Update the region information*/ index[0] = m_StartX; @@ -99,13 +102,31 @@ VectorDataExtractROI<TVectorData> /** Create the region*/ roi.SetSize(size); roi.SetIndex(index); - - std::cout << "ROI " << roi<<std::endl; - - /***/ - - + /** Loop in the vectorData file*/ + typedef itk::PreOrderTreeIterator<DataTreeType> TreeIteratorType; + TreeIteratorType it(input->GetDataTree()); + + it.GoToBegin(); + while (!it.IsAtEnd()) + { + + itk::PreOrderTreeIterator<DataTreeType> itParent = it; + bool goesOn = true; + + if (it.Get()->IsPolygonFeature()) + std::cout << " C'est un polygone et les coordonnees " << it.Get()->GetPolygonExteriorRing()->GetVertexList()->GetElement(0) << std::endl; + + if (it.Get()->IsLineFeature()) + std::cout << "Vertex List Size " << it.Get()->GetLine()->GetVertexList()->Size() <<std::endl; + + if (it.Get()->IsPointFeature()) + std::cout << " C'est un point" << std::endl; + + + ++it; + } + } diff --git a/Testing/Code/BasicFilters/CMakeLists.txt b/Testing/Code/BasicFilters/CMakeLists.txt index 9e50512b6c60317544a82ca231cf101c18be2356..cbb5b9a68c1251d81a2df8fd12dad9fe8f58a4e6 100644 --- a/Testing/Code/BasicFilters/CMakeLists.txt +++ b/Testing/Code/BasicFilters/CMakeLists.txt @@ -1025,7 +1025,7 @@ ADD_TEST(bfTvEdgeDensityImageFilter ${BASICFILTERS_TESTS9} otbEdgeDensityImageFilter ${INPUTDATA}/scene.png ${TEMP}/bfTvEdgeDensityImageFilterOutputImage.tif - 2 # radius + 1 # radius 15 3 1. 0.01 #Canny Parameters ) diff --git a/Testing/Code/Common/CMakeLists.txt b/Testing/Code/Common/CMakeLists.txt index 2158ab531cfc725acc834f154225adc075b9a1ed..fb56092e5fba57230b9d5a542bf1abe399d1c133 100644 --- a/Testing/Code/Common/CMakeLists.txt +++ b/Testing/Code/Common/CMakeLists.txt @@ -5,6 +5,11 @@ SET(BASELINE_FILES ${OTB_DATA_ROOT}/Baseline/OTB/Files) SET(INPUTDATA ${OTB_DATA_ROOT}/Input) SET(TEMP ${OTBTesting_BINARY_DIR}/Temporary) +#Remote sensing images (large images ) +IF(OTB_DATA_USE_LARGEINPUT) + SET(LARGEDATA ${OTB_DATA_LARGEINPUT_ROOT} ) +ENDIF(OTB_DATA_USE_LARGEINPUT) + #Tolerance sur diff pixel image SET(TOL 0.0) @@ -126,6 +131,21 @@ ADD_TEST(coTvExtractROI_RGB2 ${COMMON_TESTS2} ADD_TEST(coTuVectorDataExtractROINew ${COMMON_TESTS2} otbVectorDataExtractROINew) +IF(OTB_DATA_USE_LARGEINPUT) + +ADD_TEST(coTvVectorDataExtractROI ${COMMON_TESTS2} +# --compare-image ${TOL} +# ${BASELINE}/coVectorDataExtractROIOutput.shp +# ${TEMP}/coVectorDataExtractROIOutput.shp + otbVectorDataExtractROI + ${LARGEDATA}/TOULOUSE/QuickBird/GIS_FILES/000000128955_01_ORDER_SHAPE.shp + ${TEMP}/coVectorDataExtractROIOutput.shp + 10 10 50 50 + ) + +ENDIF(OTB_DATA_USE_LARGEINPUT) + + # ------- otb::MultiChannelExtractROI ------------------------------ @@ -596,6 +616,7 @@ otbMultiChannelExtractROI.cxx otbMultiChannelExtractROINew.cxx otbTestMultiExtractMultiUpdate.cxx otbVectorDataExtractROINew.cxx +otbVectorDataExtractROI.cxx ) SET(BasicCommon_SRCS3 otbMultiToMonoChannelExtractROI.cxx diff --git a/Testing/Code/Common/otbCommonTests2.cxx b/Testing/Code/Common/otbCommonTests2.cxx index 40c9d401861ee733c81a7a98e78205de117d2cf2..808364dae8bf8a0c2613ab4aef4ef14ce0ae5b01 100644 --- a/Testing/Code/Common/otbCommonTests2.cxx +++ b/Testing/Code/Common/otbCommonTests2.cxx @@ -35,4 +35,5 @@ void RegisterTests() REGISTER_TEST(otbMultiChannelExtractROINew ); REGISTER_TEST(otbTestMultiExtractMultiUpdate); REGISTER_TEST(otbVectorDataExtractROINew); + REGISTER_TEST(otbVectorDataExtractROI); } diff --git a/Testing/Code/Common/otbVectorDataExtractROI.cxx b/Testing/Code/Common/otbVectorDataExtractROI.cxx index 431cb4494ffbe209e1ec2e6365597c28a7e20bf5..b646a04193745d163ac1f3192ca49a8539ed760e 100644 --- a/Testing/Code/Common/otbVectorDataExtractROI.cxx +++ b/Testing/Code/Common/otbVectorDataExtractROI.cxx @@ -20,15 +20,34 @@ #include "otbVectorDataFileReader.h" -int otbVectorDataExtractROINew( int argc, char * argv[] ) +int otbVectorDataExtractROI( int argc, char * argv[] ) { + const char * infname = argv[1]; + + const unsigned int startX = atoi(argv[3]); + const unsigned int startY = atoi(argv[4]); + const unsigned int sizeX = atoi(argv[5]); + const unsigned int sizeY = atoi(argv[6]); + typedef otb::VectorData<> VectorDataType; typedef otb::VectorDataExtractROI< VectorDataType > FilterType; typedef otb::VectorDataFileReader<VectorDataType> VectorDataFileReaderType; - + /** */ FilterType::Pointer filter = FilterType::New(); + VectorDataFileReaderType::Pointer reader = VectorDataFileReaderType::New(); + + /** */ + reader->SetFileName(infname); + + filter->SetInput(reader->GetOutput()); + filter->SetSizeX(sizeX); + filter->SetSizeY(sizeY); + filter->SetStartX(startX); + filter->SetStartY(startY); + filter->Update(); + return EXIT_SUCCESS; }