Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkSurfaceToSurfaceFilter.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
14 #include "mitkSurface.h"
15 
17 {
18 }
19 
21 {
22 }
23 
25 {
26  this->SetInput(0, surface);
27 }
28 
29 void mitk::SurfaceToSurfaceFilter::SetInput(unsigned int idx, const mitk::Surface *surface)
30 {
31  if (this->GetInput(idx) != surface)
32  {
33  this->SetNthInput(idx, const_cast<mitk::Surface *>(surface));
34  this->CreateOutputForInput(idx);
35  this->Modified();
36  }
37 }
38 
40 {
41  if (this->GetNumberOfInputs() < 1)
42  return nullptr;
43 
44  return static_cast<const mitk::Surface *>(this->ProcessObject::GetInput(0));
45 }
46 
48 {
49  if (this->GetNumberOfInputs() < 1)
50  return nullptr;
51 
52  return static_cast<const mitk::Surface *>(this->ProcessObject::GetInput(idx));
53 }
54 
56 {
57  if (this->GetNumberOfIndexedInputs() < idx || this->GetInput(idx) == nullptr)
58  {
59  mitkThrow() << "Error creating output for input [" << idx << "]. Input does not exists!";
60  }
61 
62  if (this->GetNumberOfIndexedOutputs() <= idx)
63  this->SetNumberOfIndexedOutputs(idx + 1);
64 
65  if (this->GetOutput(idx) == nullptr)
66  {
67  DataObjectPointer newOutput = this->MakeOutput(idx);
68  this->SetNthOutput(idx, newOutput);
69  }
70  this->GetOutput(idx)->Graft(this->GetInput(idx));
71  this->Modified();
72 }
73 
75 {
76  this->SetNumberOfIndexedOutputs(this->GetNumberOfIndexedInputs());
77  for (unsigned int idx = 0; idx < this->GetNumberOfIndexedInputs(); ++idx)
78  {
79  if (this->GetOutput(idx) == nullptr)
80  {
81  DataObjectPointer newOutput = this->MakeOutput(idx);
82  this->SetNthOutput(idx, newOutput);
83  }
84  this->GetOutput(idx)->Graft(this->GetInput(idx));
85  }
86  this->Modified();
87 }
88 
90 {
91  for (unsigned int idx = 0; idx < this->GetNumberOfIndexedInputs(); ++idx)
92  {
93  if (this->GetInput(idx) == surface)
94  {
95  this->RemoveOutput(idx);
96  }
97  }
98 }
Superclass of all classes generating surfaces (instances of class Surface) as output.
Class for storing surfaces (vtkPolyData).
Definition: mitkSurface.h:28
OutputType * GetOutput()
virtual const mitk::Surface * GetInput()
void Graft(const DataObject *) override
virtual void RemoveInputs(mitk::Surface *surface)
#define mitkThrow()
virtual void CreateOutputsForAllInputs()
Creates outputs for all existing inputs.
itk::DataObject::Pointer MakeOutput(DataObjectPointerArraySizeType idx) override
virtual void CreateOutputForInput(unsigned int idx)
Create a new output for the input at idx.
itk::DataObject::Pointer DataObjectPointer
virtual void SetInput(const mitk::Surface *surface)