diff --git a/Core/Code/Algorithms/mitkSurfaceToSurfaceFilter.cpp b/Core/Code/Algorithms/mitkSurfaceToSurfaceFilter.cpp index 5a08da2ef8..bb3b59670a 100644 --- a/Core/Code/Algorithms/mitkSurfaceToSurfaceFilter.cpp +++ b/Core/Code/Algorithms/mitkSurfaceToSurfaceFilter.cpp @@ -1,79 +1,90 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkSurfaceToSurfaceFilter.h" #include "mitkSurface.h" mitk::SurfaceToSurfaceFilter::SurfaceToSurfaceFilter() : SurfaceSource() { } mitk::SurfaceToSurfaceFilter::~SurfaceToSurfaceFilter() { } void mitk::SurfaceToSurfaceFilter::SetInput( const mitk::Surface* surface ) { this->SetInput( 0, const_cast( surface ) ); } void mitk::SurfaceToSurfaceFilter::SetInput( unsigned int idx, const mitk::Surface* surface ) { if ( this->GetInput(idx) != surface ) { this->SetNthInput( idx, const_cast( surface ) ); this->CreateOutputsForAllInputs(idx); this->Modified(); } } const mitk::Surface* mitk::SurfaceToSurfaceFilter::GetInput() { if (this->GetNumberOfInputs() < 1) return NULL; return static_cast(this->ProcessObject::GetInput(0)); } const mitk::Surface* mitk::SurfaceToSurfaceFilter::GetInput( unsigned int idx) { if (this->GetNumberOfInputs() < 1) return NULL; return static_cast(this->ProcessObject::GetInput(idx)); } void mitk::SurfaceToSurfaceFilter::CreateOutputsForAllInputs(unsigned int /*idx*/) { this->SetNumberOfIndexedOutputs( this->GetNumberOfIndexedInputs() ); for (unsigned int idx = 0; idx < this->GetNumberOfIndexedInputs(); ++idx) { if (this->GetOutput(idx) == NULL) { DataObjectPointer newOutput = this->MakeOutput(idx); this->SetNthOutput(idx, newOutput); } this->GetOutput( idx )->Graft( this->GetInput( idx) ); } this->Modified(); } + +void mitk::SurfaceToSurfaceFilter::RemoveInputs( mitk::Surface* surface ) +{ + for (unsigned int idx = 0; idx < this->GetNumberOfIndexedInputs(); ++idx) + { + if ( this->GetInput(idx) == surface ) + { + this->RemoveOutput(idx); + } + } +} diff --git a/Core/Code/Algorithms/mitkSurfaceToSurfaceFilter.h b/Core/Code/Algorithms/mitkSurfaceToSurfaceFilter.h index ba6bc04ece..1efef89f1f 100644 --- a/Core/Code/Algorithms/mitkSurfaceToSurfaceFilter.h +++ b/Core/Code/Algorithms/mitkSurfaceToSurfaceFilter.h @@ -1,65 +1,67 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKSURFACETOSURFACEFILTER_H_HEADER_INCLUDED_C10B4740 #define MITKSURFACETOSURFACEFILTER_H_HEADER_INCLUDED_C10B4740 #include "mitkSurfaceSource.h" namespace mitk { class Surface; //##Documentation //## @brief Superclass of all classes getting surfaces (instances of class //## Surface) as input and generating surfaces as output. //## //## In itk and vtk the generated result of a ProcessObject is only guaranteed //## to be up-to-date, when Update() of the ProcessObject or the generated //## DataObject is called immediately before access of the data stored in the //## DataObject. This is also true for subclasses of mitk::BaseProcess and thus //## for mitk::mitkSurfaceToSurfaceFilter. //## @ingroup Process class MITK_CORE_EXPORT SurfaceToSurfaceFilter : public mitk::SurfaceSource { public: mitkClassMacro(SurfaceToSurfaceFilter, mitk::SurfaceSource); itkNewMacro(Self); typedef itk::DataObject::Pointer DataObjectPointer; using itk::ProcessObject::SetInput; virtual void SetInput( const mitk::Surface* surface ); virtual void SetInput( unsigned int idx, const mitk::Surface* surface ); virtual const mitk::Surface* GetInput(); virtual const mitk::Surface* GetInput( unsigned int idx ); virtual void CreateOutputsForAllInputs(unsigned int idx); + virtual void RemoveInputs( mitk::Surface* surface ); + protected: SurfaceToSurfaceFilter(); virtual ~SurfaceToSurfaceFilter(); }; } // namespace mitk #endif /* MITKSURFACETOSURFACEFILTER_H_HEADER_INCLUDED_C10B4740 */