Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkSegmentationObjectFactory.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 
15 #include "mitkBaseRenderer.h"
16 #include "mitkCoreObjectFactory.h"
17 #include "mitkDataNode.h"
18 #include "mitkProperties.h"
19 
20 #include "mitkContour.h"
21 #include "mitkContourMapper2D.h"
22 #include "mitkContourSetMapper2D.h"
24 #include "mitkContourVtkMapper3D.h"
25 
26 #include <mitkVtkGLMapperWrapper.h>
27 
29 {
30  static bool alreadyDone = false;
31  if (!alreadyDone)
32  {
33  MITK_DEBUG << "SegmentationObjectFactory c'tor" << std::endl;
34 
36 
37  alreadyDone = true;
38  }
39 }
40 
42 {
43  mitk::Mapper::Pointer newMapper = nullptr;
44  mitk::BaseData *data = node->GetData();
45 
47  {
48  std::string classname("ContourModel");
49  if (dynamic_cast<mitk::Contour *>(node->GetData()) != nullptr)
50  {
51  newMapper = mitk::ContourMapper2D::New();
52  newMapper->SetDataNode(node);
53  }
54  else if (dynamic_cast<mitk::ContourSet *>(node->GetData()) != nullptr)
55  {
56  newMapper = mitk::ContourSetMapper2D::New();
57  newMapper->SetDataNode(node);
58  }
59  }
60  else if (id == mitk::BaseRenderer::Standard3D)
61  {
62  if ((dynamic_cast<Contour *>(data) != nullptr))
63  {
64  newMapper = mitk::ContourVtkMapper3D::New();
65  newMapper->SetDataNode(node);
66  }
67  else if ((dynamic_cast<ContourSet *>(data) != nullptr))
68  {
70  newMapper->SetDataNode(node);
71  }
72  }
73  return newMapper;
74 }
75 
77 {
78  if (node == nullptr)
79  return;
80 
81  mitk::DataNode::Pointer nodePointer = node;
82 
83  // mitk::Image::Pointer image = dynamic_cast<mitk::Image*>(node->GetData());
84  // if(image.IsNotNull() && image->IsInitialized())
85  // {
86  // mitk::GPUVolumeMapper3D::SetDefaultProperties(node);
87  // }
88  //
89  // if (dynamic_cast<mitk::UnstructuredGrid*>(node->GetData()))
90  // {
91  // mitk::UnstructuredGridVtkMapper3D::SetDefaultProperties(node);
92  // }
93 }
94 
96 {
97  std::string fileExtension;
98  this->CreateFileExtensions(m_FileExtensionsMap, fileExtension);
99  return fileExtension.c_str();
100 }
101 
103 {
104  return m_FileExtensionsMap;
105 }
106 
108 {
110 }
111 
113 {
114 }
115 
117 {
118  std::string fileExtension;
119  this->CreateFileExtensions(m_SaveFileExtensionsMap, fileExtension);
120  return fileExtension.c_str();
121 }
122 
124 {
125 }
126 
127 struct RegisterSegmentationObjectFactory
128 {
129  RegisterSegmentationObjectFactory() : m_Factory(mitk::SegmentationObjectFactory::New())
130  {
131  mitk::CoreObjectFactory::GetInstance()->RegisterExtraFactory(m_Factory);
132  }
133 
134  ~RegisterSegmentationObjectFactory() { mitk::CoreObjectFactory::GetInstance()->UnRegisterExtraFactory(m_Factory); }
136 };
137 
138 static RegisterSegmentationObjectFactory registerSegmentationObjectFactory;
mitk::CoreObjectFactoryBase::MultimapType GetFileExtensionsMap() override
static Pointer New()
Base of all data objects.
Definition: mitkBaseData.h:37
#define MITK_DEBUG
Definition: mitkLogMacros.h:22
static Pointer New()
static Pointer New()
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
mitk::CoreObjectFactoryBase::MultimapType GetSaveFileExtensionsMap() override
void SetDefaultProperties(mitk::DataNode *node) override
static void CreateFileExtensions(MultimapType fileExtensionsMap, std::string &fileExtensions)
create a string from a map that contains the file extensions
static RegisterSegmentationObjectFactory registerSegmentationObjectFactory
Mapper::Pointer CreateMapper(mitk::DataNode *node, MapperSlotId slotId) override
unsigned int MapperSlotId
Definition: mitkCommon.h:33
std::multimap< std::string, std::string > MultimapType
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57