7 #include "TutoTrianConverterCtrl/Plugin.hpp" 9 #include <fwRuntime/EConfigurationElement.hpp> 10 #include <fwRuntime/profile/Profile.hpp> 11 #include <fwRuntime/utils/GenericExecutableFactoryRegistrar.hpp> 13 #include <fwServices/op/Add.hpp> 14 #include <fwServices/registry/AppConfig.hpp> 15 #include <fwServices/registry/ObjectService.hpp> 16 #include <fwServices/registry/ServiceFactory.hpp> 18 #include <boost/program_options/options_description.hpp> 19 #include <boost/program_options/parsers.hpp> 20 #include <boost/program_options/positional_options.hpp> 21 #include <boost/program_options/variables_map.hpp> 26 static ::fwRuntime::utils::GenericExecutableFactoryRegistrar<Plugin> registrar(
"::TutoTrianConverterCtrl::Plugin");
50 namespace po = boost::program_options;
52 ::fwRuntime::profile::Profile::sptr profile = ::fwRuntime::profile::getCurrentProfile();
53 SLM_ASSERT(
"Profile is not initialized", profile);
54 ::fwRuntime::profile::Profile::ParamsContainer params = profile->getParams();
56 std::string trianMeshPath;
57 std::string vtkMeshPath;
59 po::options_description cmdline_options(
"TutoTrianConverterCtrl options");
60 cmdline_options.add_options()
61 (
"trian", po::value(&trianMeshPath)->required(),
"Path of trian mesh file to convert")
62 (
"vtk", po::value(&vtkMeshPath)->required(),
"Path of created vtk mesh file")
65 po::positional_options_description p;
73 po::store(po::command_line_parser(params)
74 .options(cmdline_options)
82 std::cerr << cmdline_options << std::endl << e.what() << std::endl;
88 m_mesh = ::fwData::Mesh::New();
91 m_readerSrv = srvFactory->create(
"::ioData::STrianMeshReader");
93 ::fwServices::OSR::registerService(m_mesh,
"data", ::fwServices::IService::AccessType::INOUT, m_readerSrv);
95 ::fwRuntime::EConfigurationElement::sptr readerCfg = ::fwRuntime::EConfigurationElement::New(
"service" );
96 ::fwRuntime::EConfigurationElement::sptr readerFilenameCfg = ::fwRuntime::EConfigurationElement::New(
"file" );
97 readerFilenameCfg->setValue(trianMeshPath);
98 readerCfg->addConfigurationElement(readerFilenameCfg);
99 m_readerSrv->setConfiguration( readerCfg );
100 m_readerSrv->configure();
103 m_writerSrv = srvFactory->create(
"::ioVTK::SMeshWriter");
105 ::fwServices::OSR::registerService(m_mesh,
"data", ::fwServices::IService::AccessType::INPUT, m_writerSrv);
107 ::fwRuntime::EConfigurationElement::sptr writerCfg = ::fwRuntime::EConfigurationElement::New(
"service" );
108 ::fwRuntime::EConfigurationElement::sptr writerFilenameCfg = ::fwRuntime::EConfigurationElement::New(
"file" );
109 writerFilenameCfg->setValue(vtkMeshPath);
110 writerCfg->addConfigurationElement(writerFilenameCfg);
111 m_writerSrv->setConfiguration( writerCfg );
112 m_writerSrv->configure();
114 m_readerSrv->start();
115 m_writerSrv->start();
116 m_readerSrv->update();
117 m_writerSrv->update();
133 ::fwServices::OSR::unregisterService( m_writerSrv );
138 ::fwServices::OSR::unregisterService( m_readerSrv );
TUTOTRIANCONVERTERCTRL_API void initialize()
Notifies the plugin about its initialisation.
TUTOTRIANCONVERTERCTRL_API void stop() noexcept
Overrides stop method. Do nothing.
TUTOTRIANCONVERTERCTRL_API Plugin() noexcept
Constructor.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
static FWSERVICES_API ServiceFactory::sptr getDefault()
Return the unique Instance, create it if required at first access.
TUTOTRIANCONVERTERCTRL_API void start()
Overrides start method. .
TUTOTRIANCONVERTERCTRL_API void uninitialize() noexcept
Notifies the plugin about its uninitialisation.
TUTOTRIANCONVERTERCTRL_API ~Plugin() noexcept
Destructor. Do nothing.