59 MITK_DEBUG <<
"CoreObjectFactory: registering extra factory of type " << factory->GetNameOfClass();
62 this->RegisterLegacyReaders(factory);
63 this->RegisterLegacyWriters(factory);
68 MITK_DEBUG <<
"CoreObjectFactory: un-registering extra factory of type " << factory->GetNameOfClass();
69 this->UnRegisterLegacyWriters(factory);
70 this->UnRegisterLegacyReaders(factory);
73 m_ExtraFactories.erase(factory);
75 catch (std::exception
const &e)
77 MITK_ERROR <<
"Caugt exception while unregistering: " << e.what();
84 if (instance.IsNull())
94 m_LegacyReaders.begin();
95 iter != m_LegacyReaders.end();
98 for (
auto &elem : iter->second)
105 m_LegacyWriters.begin();
106 iter != m_LegacyWriters.end();
109 for (
auto &elem : iter->second)
124 if (image.IsNotNull() && image->IsInitialized())
130 if (planeGeometry.IsNotNull())
136 if (surface.IsNotNull())
143 if (pointSet.IsNotNull())
148 for (ExtraFactoriesContainer::iterator it = m_ExtraFactories.begin(); it != m_ExtraFactories.end(); ++it)
150 (*it)->SetDefaultProperties(node);
156 static bool alreadyDone =
false;
159 CreateFileExtensionsMap();
174 for (ExtraFactoriesContainer::iterator it = m_ExtraFactories.begin(); it != m_ExtraFactories.end(); ++it)
176 tmpMapper = (*it)->CreateMapper(node,
id);
177 if (tmpMapper.IsNotNull())
178 newMapper = tmpMapper;
181 if (newMapper.IsNull())
187 if ((dynamic_cast<Image *>(data) != NULL))
190 newMapper->SetDataNode(node);
192 else if ((dynamic_cast<PlaneGeometryData *>(data) != NULL))
195 newMapper->SetDataNode(node);
197 else if ((dynamic_cast<Surface *>(data) != NULL))
204 else if ((dynamic_cast<PointSet *>(data) != NULL))
207 newMapper->SetDataNode(node);
212 if ((dynamic_cast<PlaneGeometryData *>(data) != NULL))
215 newMapper->SetDataNode(node);
217 else if ((dynamic_cast<Surface *>(data) != NULL))
220 newMapper->SetDataNode(node);
222 else if ((dynamic_cast<PointSet *>(data) != NULL))
225 newMapper->SetDataNode(node);
236 for (ExtraFactoriesContainer::iterator it = m_ExtraFactories.begin(); it != m_ExtraFactories.end(); ++it)
238 aMap = (*it)->GetFileExtensionsMap();
239 this->MergeFileExtensions(m_FileExtensionsMap, aMap);
241 this->CreateFileExtensions(m_FileExtensionsMap, m_FileExtensions);
242 return m_FileExtensions.c_str();
247 std::pair<MultimapType::iterator, MultimapType::iterator> pairOfIter;
248 for (MultimapType::iterator it = inputMap.begin(); it != inputMap.end(); ++it)
250 bool duplicateFound =
false;
251 pairOfIter = fileExtensionsMap.equal_range((*it).first);
252 for (MultimapType::iterator it2 = pairOfIter.first; it2 != pairOfIter.second; ++it2)
255 std::string aString = (*it2).second;
256 if (aString.compare((*it).second) == 0)
259 duplicateFound =
true;
265 fileExtensionsMap.insert(std::pair<std::string, std::string>((*it).first, (*it).second));
272 return m_FileExtensionsMap;
293 for (ExtraFactoriesContainer::iterator it = m_ExtraFactories.begin(); it != m_ExtraFactories.end(); ++it)
295 aMap = (*it)->GetSaveFileExtensionsMap();
296 this->MergeFileExtensions(m_SaveFileExtensionsMap, aMap);
298 this->CreateFileExtensions(m_SaveFileExtensionsMap, m_SaveFileExtensions);
299 return m_SaveFileExtensions.c_str();
304 return m_SaveFileExtensionsMap;
309 FileWriterList allWriters = m_FileWriters;
311 typedef std::set<mitk::FileWriterWithInformation::Pointer> FileWriterSet;
312 FileWriterSet fileWritersSet;
314 fileWritersSet.insert(allWriters.begin(), allWriters.end());
317 for (ExtraFactoriesContainer::iterator it = m_ExtraFactories.begin(); it != m_ExtraFactories.end(); ++it)
319 FileWriterList list2 = (*it)->GetFileWriters();
322 fileWritersSet.insert(list2.begin(), list2.end());
327 allWriters.insert(allWriters.end(), fileWritersSet.begin(), fileWritersSet.end());
338 std::multimap<std::string, std::string> fileExtensionMap = GetSaveFileExtensionsMap();
339 for (std::multimap<std::string, std::string>::iterator it = fileExtensionMap.begin(); it != fileExtensionMap.end();
341 if (it->first == extension)
352 std::map<std::string, std::vector<std::string>> extensionsByCategories;
354 for (std::multimap<std::string, std::string>::iterator it = fileExtensionMap.begin(); it != fileExtensionMap.end();
357 std::string extension = it->first;
359 extension = extension.erase(0, 2);
361 extensionsByCategories[it->second].push_back(extension);
364 for (
auto &extensionsByCategorie : extensionsByCategories)
366 m_LegacyReaders[factory].push_back(
373 std::map<mitk::CoreObjectFactoryBase *, std::list<mitk::LegacyFileReaderService *>>::iterator iter =
374 m_LegacyReaders.find(factory);
375 if (iter != m_LegacyReaders.end())
377 for (
auto &elem : iter->second)
382 m_LegacyReaders.erase(iter);
397 for (mitk::CoreObjectFactory::FileWriterList::iterator it = writers.begin(); it != writers.end(); ++it)
399 std::vector<std::string> extensions = (*it)->GetPossibleFileExtensions();
400 if (extensions.empty())
403 std::string description;
404 for (std::vector<std::string>::iterator ext = extensions.begin(); ext != extensions.end(); ++ext)
409 std::string extension = *ext;
410 std::string extensionWithStar = extension;
411 if (extension.find_first_of(
'*') == 0)
414 extension = extension.substr(0, extension.size() - 2);
418 extensionWithStar.insert(extensionWithStar.begin(),
'*');
421 for (MultimapType::iterator fileExtensionIter = fileExtensionMap.begin();
422 fileExtensionIter != fileExtensionMap.end();
425 if (fileExtensionIter->first == extensionWithStar)
427 description = fileExtensionIter->second;
431 if (!description.empty())
434 if (description.empty())
436 description = std::string(
"Legacy ") + (*it)->GetNameOfClass() +
" Reader";
441 m_LegacyWriters[factory].push_back(lfws);
447 std::map<mitk::CoreObjectFactoryBase *, std::list<mitk::LegacyFileWriterService *>>::iterator iter =
448 m_LegacyWriters.find(factory);
449 if (iter != m_LegacyWriters.end())
451 for (
auto &elem : iter->second)
456 m_LegacyWriters.erase(iter);
Vtk-based mapper for cutting 2D slices out of Surfaces.
std::multimap< std::string, std::string > MultimapType
Class for storing surfaces (vtkPolyData).
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=NULL, bool overwrite=false)
Set the default properties for general image rendering.
virtual void MapEvent(const mitk::Event *event, const int eventID)
ExtraFactoriesContainer m_ExtraFactories
FileWriterList GetFileWriters()
Base of all data objects.
virtual MultimapType GetFileExtensionsMap()=0
virtual const char * GetSaveFileExtensions() override
This method gets the supported (save) file extensions as string.
static Pointer GetInstance()
virtual const char * GetFileExtensions() override
This method gets the supported (open) file extensions as string.
virtual void UnRegisterExtraFactory(CoreObjectFactoryBase *factory)
std::string GetDescriptionForExtension(const std::string &extension)
virtual MultimapType GetSaveFileExtensionsMap()=0
virtual void SetDataNode(DataNode *_arg)
Set the DataNode containing the data to map.
virtual void SetDefaultProperties(mitk::DataNode *node) override
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
virtual MultimapType GetFileExtensionsMap() override
get the defined (open) file extension map
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=NULL, bool overwrite=false)
set the default properties for this mapper
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=NULL, bool overwrite=false)
set the default properties for this mapper
Data structure which stores a set of points. Superclass of mitk::Mesh.
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=NULL, bool overwrite=false)
void CreateFileExtensionsMap()
initialize the file extension entries for open and save
virtual MultimapType GetSaveFileExtensionsMap() override
get the defined (save) file extension map
Image class for storing images.
virtual void RegisterExtraFactory(CoreObjectFactoryBase *factory)
virtual const char * GetFileExtensions()=0
Data class containing PlaneGeometry objects.
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=NULL, bool overwrite=false)
set the default properties for this mapper
virtual FileWriterList GetFileWriters()
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=NULL, bool overwrite=false)
MITKMATCHPOINTREGISTRATION_EXPORT ResultImageType::Pointer map(const InputImageType *input, const RegistrationType *registration, bool throwOnOutOfInputAreaError=false, const double &paddingValue=0, const ResultImageGeometryType *resultGeometry=NULL, bool throwOnMappingError=true, const double &errorValue=0, mitk::ImageMappingInterpolator::Type interpolatorType=mitk::ImageMappingInterpolator::Linear)
virtual const char * GetSaveFileExtensions()=0
virtual Mapper::Pointer CreateMapper(mitk::DataNode *node, MapperSlotId slotId) override
void MergeFileExtensions(MultimapType &fileExtensionsMap, MultimapType inputMap)
Merge the input map into the fileExtensionsMap. Duplicate entries are removed.
unsigned int MapperSlotId
std::multimap< std::string, std::string > MultimapType
std::list< mitk::FileWriterWithInformation::Pointer > FileWriterList
Class for nodes of the DataTree.