diff --git a/Modules/Applications/AppTest/app/otbMemoryTestApplication.cxx b/Modules/Applications/AppTest/app/otbMemoryTestApplication.cxx deleted file mode 100644 index ef3f715560c7b5d89f9451a21fb13d8bcf707a3d..0000000000000000000000000000000000000000 --- a/Modules/Applications/AppTest/app/otbMemoryTestApplication.cxx +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) - * - * This file is part of Orfeo Toolbox - * - * https://www.orfeo-toolbox.org/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <numeric> - -#include "otbWrapperApplication.h" -#include "otbWrapperApplicationFactory.h" - -#include "otbMultiToMonoChannelExtractROI.h" - -namespace otb -{ -namespace Wrapper -{ - -class MemoryTest : public Application -{ -public: - /** Standard class typedefs. */ - typedef MemoryTest Self; - typedef Application Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - /** Standard macro */ - itkNewMacro(Self); - - itkTypeMacro(MemoryTest, otb::Application) - - typedef MultiToMonoChannelExtractROI<FloatVectorImageType::InternalPixelType, - FloatVectorImageType::InternalPixelType> ExtractROIFilterType; - - - -private: - - void DoInit() ITK_OVERRIDE - { - SetName("MemoryTest"); - SetDescription("This application is made for test"); - // Documentation - SetDocName("Memory Test"); - SetDocLongDescription(""); - SetDocLimitations("None"); - SetDocAuthors("OTB-Team"); - SetDocSeeAlso(""); - - AddParameter(ParameterType_InputImage, "in", "Input image"); - SetParameterDescription("in", "Input image"); - SetParameterString("in", "/home/antoine/dev/my_data/anaglyphInput2.tif"); - - AddParameter(ParameterType_OutputImage, "out", "Output Image"); - SetParameterDescription("out", "Output image"); - SetDefaultOutputPixelType("out",ImagePixelType_uint8); - SetParameterString("out", "/home/antoine/dev/my_data/anaglyphtestInput2.tif"); - - AddRAMParameter(); - - // Doc example parameter settings - SetDocExampleParameterValue("in", "input.tif"); - SetDocExampleParameterValue("out", "output.tif"); - - SetOfficialDocLink(); - } - - void DoUpdateParameters() ITK_OVERRIDE - { - } - - void DoExecute() ITK_OVERRIDE - { - #ifdef MEM_DEBUG - std::cout<<"Debug on input "<<std::endl; - GetParameterImage("in")->DebugOn(); - #endif - ExtractROIFilterType::Pointer extractor = ExtractROIFilterType::New(); - #ifdef MEM_DEBUG - extractor->DebugOn(); - #endif - // m_Filters.push_back(extractor.GetPointer()); - #ifdef MEM_DEBUG - std::cout<<"Debug on extractor "<<std::endl; - extractor->DebugOn(); - #endif - extractor->SetInput(GetParameterImage("in")); - extractor->SetChannel(1); - extractor->UpdateOutputInformation(); - #ifdef MEM_DEBUG - std::cout<<"Debug on extractor's output "<<std::endl; - extractor->GetOutput()->DebugOn(); - #endif - SetParameterOutputImage("out" , extractor->GetOutput() ); - std::cout<<"Registering"<<std::endl; - RegisterPipeline(); - std::cout<<"Registered"<<std::endl; - } - -}; - -} -} - -OTB_APPLICATION_EXPORT(otb::Wrapper::MemoryTest) - diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h index 29743f26dd9f585045bf6205c17c20144bc24fc9..658cff547312d2bed84de1640b356cbf9c132ab5 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h @@ -846,7 +846,6 @@ public: } void RegisterPipeline(); - std::set<itk::ProcessObject::Pointer> m_Filters; protected: /** Constructor */ @@ -993,6 +992,8 @@ private: itk::ProcessObject::Pointer m_ProgressSource; std::string m_ProgressSourceDescription; + std::set<itk::ProcessObject::Pointer> m_Filters; + /** Long name of the application (that can be displayed...) */ std::string m_DocName; /** Long and precise application description . */ diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index c97090f6e0d864b8d55b6142ff4f2a227f35a721..b283df7a2a338d8ee7df10261cf0e94d8f4ae41c 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -363,7 +363,6 @@ void Application::AfterExecuteAndWriteOutputs() void Application::RegisterPipeline() { - std::cout<<"Registering Pipeline"<<std::endl; std::stack< itk::DataObject * > dataStack; std::set< itk::DataObject * > inputData; std::vector<std::string> paramList = GetParametersKeys(true); @@ -447,17 +446,16 @@ Application::RegisterPipeline() else continue; } - std::cout<<"Beginning DFS"<<std::endl; + // DFS - std::set< itk::ProcessObject * > processSet; while ( !dataStack.empty() ) { - std::cout<<"one node (data) is processed"<<std::endl; itk::DataObject * current = dataStack.top(); dataStack.pop(); - if ( inputData.count( current ) || !current ) + // whether current = null or is an input data it has no source + if ( !current || inputData.count( current ) ) continue; - std::cout<<"it is not an input"<<std::endl; + // if current is a list push every of its members in datastack if ( dynamic_cast< ObjectListInterface *> (current) ) { ObjectListInterface * list = @@ -466,18 +464,19 @@ Application::RegisterPipeline() for ( int i = 0 ; i < length ; i++ ) { itk::DataObject * newData = list->GetNthDataObject(i); - if ( inputData.count( current ) || !current ) + if ( !current || inputData.count( current ) ) continue; dataStack.push( newData ); - } continue; + } } + // Finally get the current's process object source itk::ProcessObject * process = (current->GetSource()).GetPointer(); - if ( m_Filters.find( process ) != m_Filters.end() || !process ) + if ( !process || m_Filters.find( process ) != m_Filters.end() ) continue; - std::cout<<"add process to set : "<<process->GetNameOfClass()<<std::endl; m_Filters.insert( process ); std::vector< itk::DataObject::Pointer > inputs = process->GetInputs(); + // Push back all source's inputs in datastack for ( auto it : inputs ) { if ( inputData.count( it.GetPointer() ) ) @@ -539,7 +538,6 @@ int Application::Execute() int Application::ExecuteAndWriteOutput() { - std::cout<<"Executing..."<<std::endl; m_Chrono.Restart(); int status = this->Execute(); @@ -598,7 +596,6 @@ int Application::ExecuteAndWriteOutput() std::cout<<"Add Process and write"<<std::endl; AddProcess(outputParam->GetWriter(), progressId.str()); outputParam->Write(); - // ClearWriter in param(); } } else if (GetParameterType(key) == ParameterType_OutputVectorData @@ -650,11 +647,12 @@ int Application::ExecuteAndWriteOutput() this->AfterExecuteAndWriteOutputs(); m_Chrono.Stop(); - for ( auto filter : m_Filters ) - { - std::cout<<"For filter : "<<filter->GetNameOfClass()<< - " count : "<<filter->GetReferenceCount()<<std::endl; - } + + // for ( auto filter : m_Filters ) + // { + // std::cout<<"For filter : "<<filter->GetNameOfClass()<< + // " count : "<<filter->GetReferenceCount()<<std::endl; + // } m_Filters.clear(); return status;