Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
18 #include "mitkSurface.h"
19 
21 {
22 }
23 
25 {
26 }
27 
29 {
30  this->SetInput(0, const_cast<mitk::Surface *>(surface));
31 }
32 
33 void mitk::SurfaceToSurfaceFilter::SetInput(unsigned int idx, const mitk::Surface *surface)
34 {
35  if (this->GetInput(idx) != surface)
36  {
37  this->SetNthInput(idx, const_cast<mitk::Surface *>(surface));
38  this->CreateOutputForInput(idx);
39  this->Modified();
40  }
41 }
42 
44 {
45  if (this->GetNumberOfInputs() < 1)
46  return nullptr;
47 
48  return static_cast<const mitk::Surface *>(this->ProcessObject::GetInput(0));
49 }
50 
52 {
53  if (this->GetNumberOfInputs() < 1)
54  return nullptr;
55 
56  return static_cast<const mitk::Surface *>(this->ProcessObject::GetInput(idx));
57 }
58 
60 {
61  if (this->GetNumberOfIndexedInputs() < idx || this->GetInput(idx) == nullptr)
62  {
63  mitkThrow() << "Error creating output for input [" << idx << "]. Input does not exists!";
64  }
65 
66  if (this->GetNumberOfIndexedOutputs() <= idx)
67  this->SetNumberOfIndexedOutputs(idx + 1);
68 
69  if (this->GetOutput(idx) == nullptr)
70  {
71  DataObjectPointer newOutput = this->MakeOutput(idx);
72  this->SetNthOutput(idx, newOutput);
73  }
74  this->GetOutput(idx)->Graft(this->GetInput(idx));
75  this->Modified();
76 }
77 
79 {
80  this->SetNumberOfIndexedOutputs(this->GetNumberOfIndexedInputs());
81  for (unsigned int idx = 0; idx < this->GetNumberOfIndexedInputs(); ++idx)
82  {
83  if (this->GetOutput(idx) == nullptr)
84  {
85  DataObjectPointer newOutput = this->MakeOutput(idx);
86  this->SetNthOutput(idx, newOutput);
87  }
88  this->GetOutput(idx)->Graft(this->GetInput(idx));
89  }
90  this->Modified();
91 }
92 
94 {
95  for (unsigned int idx = 0; idx < this->GetNumberOfIndexedInputs(); ++idx)
96  {
97  if (this->GetInput(idx) == surface)
98  {
99  this->RemoveOutput(idx);
100  }
101  }
102 }
Superclass of all classes generating surfaces (instances of class Surface) as output.
Class for storing surfaces (vtkPolyData).
Definition: mitkSurface.h:32
virtual const mitk::Surface * GetInput()
virtual void RemoveInputs(mitk::Surface *surface)
#define mitkThrow()
virtual void CreateOutputsForAllInputs()
Creates outputs for all existing inputs.
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)