7 #include "ctrlCamp/SExtractMeshByType.hpp" 9 #include <fwData/Mesh.hpp> 10 #include <fwData/mt/ObjectWriteLock.hpp> 11 #include <fwData/Reconstruction.hpp> 13 #include <fwMedData/ModelSeries.hpp> 15 #include <fwRuntime/ConfigurationElement.hpp> 17 #include <fwServices/registry/ObjectService.hpp> 19 #include <boost/algorithm/string.hpp> 20 #include <boost/regex.hpp> 43 typedef ::fwRuntime::ConfigurationElement::sptr ConfigType;
45 const ConfigType inoutCfg =
m_configuration->findConfigurationElement(
"inout");
46 SLM_ASSERT(
"At one 'inout' tag is required.", inoutCfg);
48 const std::vector< ConfigType > extractCfg = inoutCfg->find(
"extract");
49 SLM_ASSERT(
"At least one 'extract' tag is required.", !extractCfg.empty());
54 for (
const auto& cfg : outCfg)
56 if(cfg->hasAttribute(
"group"))
58 if(cfg->getAttributeValue(
"group") ==
"target")
60 const std::vector< ConfigType > keyCfg = cfg->find(
"key");
62 "You must have as many 'extract' tags as 'out' keys." << extractCfg.size() <<
" " << keyCfg.size(),
63 extractCfg.size() == keyCfg.size());
68 SLM_ASSERT(
"Missing 'target' output keys", ok);
70 for(ConfigType cfg : extractCfg)
72 const std::string type = cfg->getAttributeValue(
"type");
73 const std::string regex = cfg->getAttributeValue(
"matching");
75 m_extract.push_back(std::make_pair(type, regex));
89 ::fwMedData::ModelSeries::sptr modelSeries = this->getInOut< ::fwMedData::ModelSeries>(
"source");
93 for(
const auto& elt : m_extract)
95 const std::string type = elt.first;
96 const std::string regex = elt.second;
99 const ::fwMedData::ModelSeries::ReconstructionVectorType recs = modelSeries->getReconstructionDB();
100 for(const ::fwData::Reconstruction::csptr element : recs)
102 if(element->getStructureType() == type)
104 const ::boost::regex regSurface(regex);
105 ::boost::smatch match;
106 const std::string name = element->getOrganName();
108 if(regex.empty() || ::boost::regex_match(name, match, regSurface))
110 ::fwData::Mesh::sptr obj = element->getMesh();
121 "Mesh with organ name matching '" << regex <<
"' and structure type'" << type <<
"' didn't find",
#define OSLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
The namespace ctrlCamp contains services using camp.
FWSERVICES_API void setOutput(const ::fwServices::IService::KeyType &key, const ::fwData::Object::sptr &object, size_t index=0)
Register an output object at a given key in the OSR, replacing it if it already exists.
This interface defines service API. It can be considered as a default type for services using fwCamp...
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
::fwRuntime::ConfigurationElement::sptr m_configuration
Configuration element used to configure service internal state using a generic XML like structure TOD...
size_t getKeyGroupSize(const KeyType &keybase) const
Return the number of key in a group of keys.
#define OSLM_ERROR_IF(message, cond)