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
mitkSimulationObjectFactory.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 
17 #include "mitkIndexROI.h"
18 #include "mitkSimulation.h"
22 #include "mitkVtkModel.h"
23 #include <mitkCoreObjectFactory.h>
24 #include <boost/core/ignore_unused.hpp>
25 #include <sofa/helper/system/glut.h>
26 #include <sofa/component/init.h>
27 #include <sofa/core/ObjectFactory.h>
28 #include <sofa/core/visual/VisualParams.h>
29 #include <sofa/simulation/common/xml/initXml.h>
30 
31 static void InitializeSofa()
32 {
33  int argc = 0;
34  glutInit(&argc, NULL);
35 
36  sofa::component::init();
37  sofa::simulation::xml::initXml();
38 
39  sofa::core::visual::VisualParams::defaultInstance()->setSupported(sofa::core::visual::API_OpenGL);
40 }
41 
42 static void RegisterSofaClasses()
43 {
44  using sofa::core::ObjectFactory;
45  using sofa::core::RegisterObject;
46 
47  int IndexROIClass = RegisterObject("").add<mitk::IndexROI>();
48  int VtkModelClass = RegisterObject("").add<mitk::VtkModel>();
49  boost::ignore_unused(IndexROIClass, VtkModelClass);
50 
51  ObjectFactory::AddAlias("VisualModel", "VtkModel", true);
52  ObjectFactory::AddAlias("OglModel", "VtkModel", true);
53 }
54 
55 mitk::SimulationObjectFactory::SimulationObjectFactory()
56 {
59 }
60 
61 mitk::SimulationObjectFactory::~SimulationObjectFactory()
62 {
63 }
64 
66 {
67  Mapper::Pointer mapper;
68 
69  if (dynamic_cast<Simulation*>(node->GetData()) != NULL)
70  {
71  if (slotId == BaseRenderer::Standard2D)
72  {
73  mapper = SimulationVtkMapper2D::New();
74  }
75  else if (slotId == BaseRenderer::Standard3D)
76  {
77  mapper = SimulationVtkMapper3D::New();
78  }
79 
80  if (mapper.IsNotNull())
81  mapper->SetDataNode(node);
82  }
83 
84  return mapper;
85 }
86 
88 {
89  return "Simulation Object Factory";
90 }
91 
93 {
94  return NULL;
95 }
96 
98 {
99  return MultimapType();
100 }
101 
103 {
104  return NULL;
105 }
106 
108 {
109  return MultimapType();
110 }
111 
113 {
114  if (node == NULL)
115  return;
116 
117  if (dynamic_cast<Simulation*>(node->GetData()) != NULL)
118  {
121  }
122 }
123 
125 {
126  static bool alreadyRegistered = false;
127 
128  if (!alreadyRegistered)
129  {
131  alreadyRegistered = true;
132  }
133 }
static void InitializeSofa()
std::multimap< std::string, std::string > MultimapType
static void SetDefaultProperties(DataNode *node, BaseRenderer *renderer=NULL, bool overwrite=false)
Mapper::Pointer CreateMapper(DataNode *node, MapperSlotId slotId) override
void SetDefaultProperties(DataNode *node) override
const char * GetDescription() const override
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
MultimapType GetSaveFileExtensionsMap() override
static void RegisterSofaClasses()
MITKSIMULATION_EXPORT void RegisterSimulationObjectFactory()
unsigned int MapperSlotId
Definition: mitkCommon.h:37
std::multimap< std::string, std::string > MultimapType
static void SetDefaultProperties(DataNode *node, BaseRenderer *renderer=NULL, bool overwrite=false)
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66