7 #include "ioData/SplineReaderService.hpp" 9 #include <fwCore/base.hpp> 11 #include <fwDataTools/fieldHelper/Image.hpp> 13 #include <fwIO/IReader.hpp> 15 #include <fwRuntime/ConfigurationElement.hpp> 17 #include <fwServices/macros.hpp> 19 #include <boost/lexical_cast.hpp> 39 _sstream <<
" spline reader" << std::endl;
46 std::vector< std::string > extensions;
47 extensions.push_back(
".spline");
67 if ((*iter)->getName() ==
"spline")
69 if((*iter)->hasAttribute(
"id"))
71 m_idSpline = boost::lexical_cast<
int >((*iter)->getExistingAttributeValue(
"id").c_str());
72 SLM_INFO((*iter)->getExistingAttributeValue(
"id"));
74 if((*iter)->hasAttribute(
"nbSides"))
76 m_nbSides = boost::lexical_cast<
int >((*iter)->getExistingAttributeValue(
"nbSides").c_str());
77 SLM_INFO((*iter)->getExistingAttributeValue(
"nbSides"));
79 if((*iter)->hasAttribute(
"radius"))
81 m_radius = boost::lexical_cast<
double >((*iter)->getExistingAttributeValue(
"radius").c_str());
82 SLM_INFO((*iter)->getExistingAttributeValue(
"radius"));
84 if((*iter)->hasAttribute(
"matrix"))
86 objectMatrix = loadObjectTransformationMatrix3D((*iter)->getExistingAttributeValue(
"matrix"));
88 OSLM_INFO(
"spline matrix: " << (*iter)->getExistingAttributeValue(
"matrix"));
92 ::fwRuntime::ConfigurationElement::sptr m_configuration2 =
m_configuration->findConfigurationElement(
94 for (iter2 = m_configuration2->begin(); iter2 != m_configuration2->end(); ++iter2)
96 if ((*iter2)->getName() ==
"point" 97 && (*iter2)->hasAttribute(
"id"))
100 pt.
id = boost::lexical_cast<
int >((*iter2)->getExistingAttributeValue(
"id").c_str());
101 SLM_INFO((*iter2)->getExistingAttributeValue(
"id"));
102 pt.
p[0] = pt.
id * 100.0;
106 m_points.push_back( pt );
119 ::fwData::Spline::sptr spline = this->getObject< ::fwData::Spline >( );
121 spline->points() = m_points;
122 spline->setRadius(m_radius);
123 spline->setNbSides(m_nbSides);
124 spline->setIdSpline(m_idSpline);
142 ::fwData::TransformationMatrix3D::sptr SplineReaderService::loadObjectTransformationMatrix3D(std::string m_file)
144 ::fwData::TransformationMatrix3D::sptr matrix = ::fwData::TransformationMatrix3D::New();
145 ::boost::filesystem::path location(m_file);
148 file.open(location.string().c_str(), std::fstream::in);
151 OSLM_WARN(
"Object Matrix file loading error for " + location.string());
155 for(
int l = 0; l < 4; l++ )
157 for(
int c = 0; c < 4; c++ )
160 matrix->setCoefficient(l, c, val);
Class allowing to block a Connection.
#define SLM_TRACE_FUNC()
Trace contextual function signature.
#define OSLM_INFO(message)
virtual IODATA_API void configuring() override
Configure service. This method is called by configure() from base service ( fwServices::IService ) ...
UpdateSlotType::sptr m_slotUpdate
Slot to call update method.
bool isVisible
Flag if point is visible.
IODATA_API void updating() override
Updating method. This method is called by update() from base service ( fwServices::IService ) ...
Reader service API. It manages extension points definition and extension configuration.
#define OSLM_WARN(message)
::fwRuntime::ConfigurationElement::sptr m_configuration
Configuration element used to configure service internal state using a generic XML like structure TOD...
virtual IODATA_API void info(std::ostream &_sstream) override
Info method.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_MODIFIED_SIG
Key in m_signals map of signal m_sigModified.
IODATA_API ~SplineReaderService() noexcept
Destructor.
#define SLM_INFO(message)
The namespace ioData contains reader and writer services for basic fwData::Object which doesn't need ...
IODATA_API SplineReaderService()
Constructor.
Container::iterator Iterator
Defines the configuration element container type.
double p[3]
Point coordinates.
This class defines a spline object.
Defines a 3D point for a spline.
virtual IODATA_API std::vector< std::string > getSupportedExtensions() override
returns (filename) extension
virtual FWSERVICES_API void info(std::ostream &_sstream)
Write information in a stream.