Medical Imaging Interaction Toolkit  2018.4.99-b20efe7f
Medical Imaging Interaction Toolkit
mitkDataNodeSource.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 
13 #include "mitkDataNodeSource.h"
14 
16 {
17  // Create the output.
18  OutputType::Pointer output = static_cast<OutputType *>(this->MakeOutput(0).GetPointer());
19  this->SetNthOutput(0, output.GetPointer());
20 }
21 
23 {
24 }
25 
26 itk::ProcessObject::DataObjectPointer mitk::DataNodeSource::MakeOutput(DataObjectPointerArraySizeType /*idx*/)
27 {
28  return OutputType::New().GetPointer();
29 }
30 
31 itk::ProcessObject::DataObjectPointer mitk::DataNodeSource::MakeOutput(const DataObjectIdentifierType &name)
32 {
33  itkDebugMacro("MakeOutput(" << name << ")");
34  if (this->IsIndexedOutputName(name))
35  {
36  return this->MakeOutput(this->MakeIndexFromOutputName(name));
37  }
38  return static_cast<itk::DataObject *>(OutputType::New().GetPointer());
39 }
40 
42 {
43  return itkDynamicCastInDebugMode<OutputType *>(this->GetPrimaryOutput());
44 }
45 
47 {
48  return itkDynamicCastInDebugMode<const OutputType *>(this->GetPrimaryOutput());
49 }
50 
52 {
53  return static_cast<OutputType *>(Superclass::GetOutput(idx));
54 }
55 
56 const mitk::DataNodeSource::OutputType *mitk::DataNodeSource::GetOutput(DataObjectPointerArraySizeType idx) const
57 {
58  const auto *out = dynamic_cast<const OutputType *>(this->ProcessObject::GetOutput(idx));
59 
60  if (out == nullptr && this->ProcessObject::GetOutput(idx) != nullptr)
61  {
62  itkWarningMacro(<< "Unable to convert output number " << idx << " to type " << typeid(OutputType).name());
63  }
64  return out;
65 }
DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override
static Pointer New()
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57