diff --git a/Modules/Simulation/mitkSimulationObjectFactory.cpp b/Modules/Simulation/mitkSimulationObjectFactory.cpp index 3e5ce228ea..a3495376c5 100644 --- a/Modules/Simulation/mitkSimulationObjectFactory.cpp +++ b/Modules/Simulation/mitkSimulationObjectFactory.cpp @@ -1,131 +1,133 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkIndexROI.h" #include "mitkSimulation.h" #include "mitkSimulationObjectFactory.h" #include "mitkSimulationVtkMapper2D.h" #include "mitkSimulationVtkMapper3D.h" #include "mitkVtkModel.h" #include +#include #include #include #include #include #include static void InitializeSofa() { int argc = 0; glutInit(&argc, NULL); sofa::component::init(); sofa::simulation::xml::initXml(); sofa::core::visual::VisualParams::defaultInstance()->setSupported(sofa::core::visual::API_OpenGL); } static void RegisterSofaClasses() { using sofa::core::ObjectFactory; using sofa::core::RegisterObject; int IndexROIClass = RegisterObject("").add(); int VtkModelClass = RegisterObject("").add(); + boost::ignore_unused(IndexROIClass, VtkModelClass); ObjectFactory::AddAlias("VisualModel", "VtkModel", true); ObjectFactory::AddAlias("OglModel", "VtkModel", true); } mitk::SimulationObjectFactory::SimulationObjectFactory() { InitializeSofa(); RegisterSofaClasses(); } mitk::SimulationObjectFactory::~SimulationObjectFactory() { } mitk::Mapper::Pointer mitk::SimulationObjectFactory::CreateMapper(mitk::DataNode* node, MapperSlotId slotId) { Mapper::Pointer mapper; if (dynamic_cast(node->GetData()) != NULL) { if (slotId == BaseRenderer::Standard2D) { mapper = SimulationVtkMapper2D::New(); } else if (slotId == BaseRenderer::Standard3D) { mapper = SimulationVtkMapper3D::New(); } if (mapper.IsNotNull()) mapper->SetDataNode(node); } return mapper; } const char* mitk::SimulationObjectFactory::GetDescription() const { return "Simulation Object Factory"; } const char* mitk::SimulationObjectFactory::GetFileExtensions() { return NULL; } mitk::CoreObjectFactoryBase::MultimapType mitk::SimulationObjectFactory::GetFileExtensionsMap() { return MultimapType(); } const char* mitk::SimulationObjectFactory::GetSaveFileExtensions() { return NULL; } mitk::CoreObjectFactoryBase::MultimapType mitk::SimulationObjectFactory::GetSaveFileExtensionsMap() { return MultimapType(); } void mitk::SimulationObjectFactory::SetDefaultProperties(mitk::DataNode* node) { if (node == NULL) return; if (dynamic_cast(node->GetData()) != NULL) { SimulationVtkMapper2D::SetDefaultProperties(node); SimulationVtkMapper3D::SetDefaultProperties(node); } } void mitk::RegisterSimulationObjectFactory() { static bool alreadyRegistered = false; if (!alreadyRegistered) { CoreObjectFactory::GetInstance()->RegisterExtraFactory(SimulationObjectFactory::New()); alreadyRegistered = true; } } diff --git a/Plugins/org.mitk.simulation/src/internal/org_mitk_simulation_Activator.cpp b/Plugins/org.mitk.simulation/src/internal/org_mitk_simulation_Activator.cpp index 1d74aa9eaa..5876ea06d8 100644 --- a/Plugins/org.mitk.simulation/src/internal/org_mitk_simulation_Activator.cpp +++ b/Plugins/org.mitk.simulation/src/internal/org_mitk_simulation_Activator.cpp @@ -1,109 +1,111 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "org_mitk_simulation_Activator.h" #include #include #include #include #include #include #include +#include #include #include #include static void RegisterSofaClasses() { int MeshMitkLoaderClass = sofa::core::RegisterObject("").add(); + boost::ignore_unused(MeshMitkLoaderClass); } static void LoadSofaPlugins() { berry::IPreferences::Pointer preferences = mitk::GetSimulationPreferences(); if (preferences.IsNull()) return; QString plugins = preferences->GetByteArray("plugins", "").c_str(); if (plugins.isEmpty()) return; QStringList pluginList = plugins.split(';', QString::SkipEmptyParts); QStringListIterator it(pluginList); typedef sofa::helper::system::PluginManager PluginManager; PluginManager& pluginManager = PluginManager::getInstance(); while (it.hasNext()) { std::string plugin = it.next().toStdString(); std::ostringstream errlog; pluginManager.loadPlugin(plugin, &errlog); if (errlog.str().empty()) pluginManager.getPluginMap()[plugin].initExternalModule(); } } static void AddPropertyFilters() { mitk::IPropertyFilters* filters = mitk::org_mitk_simulation_Activator::GetService(); if (filters == NULL) return; mitk::PropertyFilter filter; filter.AddEntry("layer", mitk::PropertyFilter::Blacklist); filter.AddEntry("name", mitk::PropertyFilter::Blacklist); filter.AddEntry("path", mitk::PropertyFilter::Blacklist); filter.AddEntry("selected", mitk::PropertyFilter::Blacklist); filter.AddEntry("visible", mitk::PropertyFilter::Blacklist); filters->AddFilter(filter, "Simulation"); } ctkPluginContext* mitk::org_mitk_simulation_Activator::Context = NULL; void mitk::org_mitk_simulation_Activator::start(ctkPluginContext* context) { Context = context; RegisterSimulationObjectFactory(); RegisterSofaClasses(); LoadSofaPlugins(); AddPropertyFilters(); QmitkNodeDescriptorManager* nodeDescriptorManager = QmitkNodeDescriptorManager::GetInstance(); if (nodeDescriptorManager != NULL) { mitk::NodePredicateDataType::Pointer simulationPredicate = mitk::NodePredicateDataType::New("Simulation"); nodeDescriptorManager->AddDescriptor(new QmitkNodeDescriptor("Simulation", ":/Simulation/SOFAIcon.png", simulationPredicate, nodeDescriptorManager)); } } void mitk::org_mitk_simulation_Activator::stop(ctkPluginContext*) { Context = NULL; } #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) Q_EXPORT_PLUGIN2(org_mitk_simulation, mitk::org_mitk_simulation_Activator) #endif