Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkContourObjectFactory.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 "mitkContourModel.h"
24 #include "mitkContourModelSet.h"
28 #include "mitkContourModelWriter.h"
29 
31 {
32  static bool alreadyDone = false;
33  if (!alreadyDone)
34  {
35  MITK_DEBUG << "ContourObjectFactory c'tor" << std::endl;
36 
37  alreadyDone = true;
38  }
39 }
40 
42 {
43 }
44 
46 {
47  mitk::Mapper::Pointer newMapper = nullptr;
48 
50  {
51  std::string classname("ContourModel");
52  if (dynamic_cast<mitk::ContourModel *>(node->GetData()) != nullptr)
53  {
55  newMapper->SetDataNode(node);
56  }
57  else if (dynamic_cast<mitk::ContourModelSet *>(node->GetData()) != nullptr)
58  {
60  newMapper->SetDataNode(node);
61  }
62  }
63  else if (id == mitk::BaseRenderer::Standard3D)
64  {
65  if (dynamic_cast<mitk::ContourModel *>(node->GetData()) != nullptr)
66  {
67  newMapper = mitk::ContourModelMapper3D::New();
68  newMapper->SetDataNode(node);
69  }
70  else if (dynamic_cast<mitk::ContourModelSet *>(node->GetData()) != nullptr)
71  {
73  newMapper->SetDataNode(node);
74  }
75  }
76  return newMapper;
77 }
78 
80 {
81  if (node == nullptr)
82  return;
83 
84  mitk::DataNode::Pointer nodePointer = node;
85 
86  if (node->GetData() == nullptr)
87  return;
88 
89  if (dynamic_cast<mitk::ContourModel *>(node->GetData()) != nullptr)
90  {
93  }
94  else if (dynamic_cast<mitk::ContourModelSet *>(node->GetData()) != nullptr)
95  {
98  }
99 }
100 
102 {
103  std::string fileExtension;
104  this->CreateFileExtensions(m_FileExtensionsMap, fileExtension);
105  return fileExtension.c_str();
106 };
107 
109 {
110  return m_FileExtensionsMap;
111 }
112 
114 {
116 }
117 
119 {
120 }
121 
123 {
124  std::string fileExtension;
125  this->CreateFileExtensions(m_SaveFileExtensionsMap, fileExtension);
126  return fileExtension.c_str();
127 }
128 
130 {
131 }
132 
133 struct RegisterContourObjectFactory
134 {
135  RegisterContourObjectFactory() : m_Factory(mitk::ContourObjectFactory::New())
136  {
137  mitk::CoreObjectFactory::GetInstance()->RegisterExtraFactory(m_Factory);
138  }
139 
140  ~RegisterContourObjectFactory() { mitk::CoreObjectFactory::GetInstance()->UnRegisterExtraFactory(m_Factory); }
142 };
143 
144 static RegisterContourObjectFactory registerContourObjectFactory;
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=nullptr, bool overwrite=false)
#define MITK_DEBUG
Definition: mitkLogMacros.h:22
Mapper::Pointer CreateMapper(mitk::DataNode *node, MapperSlotId slotId) override
mitk::CoreObjectFactoryBase::MultimapType GetFileExtensionsMap() override
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
static void CreateFileExtensions(MultimapType fileExtensionsMap, std::string &fileExtensions)
create a string from a map that contains the file extensions
const char * GetSaveFileExtensions() override
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=nullptr, bool overwrite=false)
Set the default properties for general image rendering.
mitk::CoreObjectFactoryBase::MultimapType GetSaveFileExtensionsMap() override
static RegisterContourObjectFactory registerContourObjectFactory
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=nullptr, bool overwrite=false)
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=nullptr, bool overwrite=false)
Set the default properties for general image rendering.
void SetDefaultProperties(mitk::DataNode *node) override
unsigned int MapperSlotId
Definition: mitkCommon.h:33
std::multimap< std::string, std::string > MultimapType
const char * GetFileExtensions() override
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57