Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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,
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 
19 #include "mitkBaseRenderer.h"
20 #include "mitkCoreObjectFactory.h"
21 #include "mitkDataNode.h"
22 #include "mitkProperties.h"
23 
24 #include "mitkContour.h"
25 #include "mitkContourMapper2D.h"
26 #include "mitkContourSetMapper2D.h"
28 #include "mitkContourVtkMapper3D.h"
29 
30 #include <mitkVtkGLMapperWrapper.h>
31 
33 {
34  static bool alreadyDone = false;
35  if (!alreadyDone)
36  {
37  MITK_DEBUG << "SegmentationObjectFactory c'tor" << std::endl;
38 
40 
41  alreadyDone = true;
42  }
43 }
44 
46 {
47  mitk::Mapper::Pointer newMapper = NULL;
48  mitk::BaseData *data = node->GetData();
49 
51  {
52  std::string classname("ContourModel");
53  if (dynamic_cast<mitk::Contour *>(node->GetData()) != NULL)
54  {
56  newMapper->SetDataNode(node);
57  }
58  else if (dynamic_cast<mitk::ContourSet *>(node->GetData()) != NULL)
59  {
61  newMapper->SetDataNode(node);
62  }
63  }
64  else if (id == mitk::BaseRenderer::Standard3D)
65  {
66  if ((dynamic_cast<Contour *>(data) != NULL))
67  {
68  newMapper = mitk::ContourVtkMapper3D::New();
69  newMapper->SetDataNode(node);
70  }
71  else if ((dynamic_cast<ContourSet *>(data) != NULL))
72  {
74  newMapper->SetDataNode(node);
75  }
76  }
77  return newMapper;
78 }
79 
81 {
82  if (node == NULL)
83  return;
84 
85  mitk::DataNode::Pointer nodePointer = node;
86 
87  // mitk::Image::Pointer image = dynamic_cast<mitk::Image*>(node->GetData());
88  // if(image.IsNotNull() && image->IsInitialized())
89  // {
90  // mitk::GPUVolumeMapper3D::SetDefaultProperties(node);
91  // }
92  //
93  // if (dynamic_cast<mitk::UnstructuredGrid*>(node->GetData()))
94  // {
95  // mitk::UnstructuredGridVtkMapper3D::SetDefaultProperties(node);
96  // }
97 }
98 
100 {
101  std::string fileExtension;
102  this->CreateFileExtensions(m_FileExtensionsMap, fileExtension);
103  return fileExtension.c_str();
104 }
105 
107 {
108  return m_FileExtensionsMap;
109 }
110 
112 {
113  return m_SaveFileExtensionsMap;
114 }
115 
117 {
118 }
119 
121 {
122  std::string fileExtension;
123  this->CreateFileExtensions(m_SaveFileExtensionsMap, fileExtension);
124  return fileExtension.c_str();
125 }
126 
128 {
129 }
130 
131 struct RegisterSegmentationObjectFactory
132 {
133  RegisterSegmentationObjectFactory() : m_Factory(mitk::SegmentationObjectFactory::New())
134  {
135  mitk::CoreObjectFactory::GetInstance()->RegisterExtraFactory(m_Factory);
136  }
137 
138  ~RegisterSegmentationObjectFactory() { mitk::CoreObjectFactory::GetInstance()->UnRegisterExtraFactory(m_Factory); }
140 };
141 
142 static RegisterSegmentationObjectFactory registerSegmentationObjectFactory;
virtual mitk::CoreObjectFactoryBase::MultimapType GetFileExtensionsMap() override
static Pointer New()
Base of all data objects.
Definition: mitkBaseData.h:39
virtual const char * GetFileExtensions() override
#define MITK_DEBUG
Definition: mitkLogMacros.h:26
DataCollection - Class to facilitate loading/accessing structured data.
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
static Pointer New()
static Pointer New()
virtual const char * GetSaveFileExtensions() override
virtual mitk::CoreObjectFactoryBase::MultimapType GetSaveFileExtensionsMap() override
virtual void SetDefaultProperties(mitk::DataNode *node) override
static RegisterSegmentationObjectFactory registerSegmentationObjectFactory
virtual Mapper::Pointer CreateMapper(mitk::DataNode *node, MapperSlotId slotId) override
unsigned int MapperSlotId
Definition: mitkCommon.h:37
std::multimap< std::string, std::string > MultimapType
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.