22 #include "mapRegistration.h"
23 #include "mapRegistrationFileWriter.h"
24 #include "mapRegistrationFileReader.h"
25 #include "mapLazyFileFieldKernelLoader.h"
41 : m_OldLocale(
std::setlocale(LC_ALL, NULL))
42 , m_NewLocale(newLocale)
44 if (m_OldLocale == NULL)
48 else if (m_NewLocale != m_OldLocale)
51 if (std::setlocale(LC_ALL, m_NewLocale.c_str()) == NULL)
53 MITK_INFO <<
"Could not set locale " << m_NewLocale;
61 if (m_OldLocale != NULL && std::setlocale(LC_ALL, m_OldLocale) == NULL)
63 MITK_INFO <<
"Could not reset locale " << m_OldLocale;
68 const char* m_OldLocale;
69 const std::string m_NewLocale;
77 template<
unsigned int i,
unsigned int j,
template <
unsigned int,
unsigned int>
class TFunctor>
83 if (TFunctor<i,j>::Execute(obj, data))
87 return DimHelperSub<i,j-1,TFunctor>::Execute(obj, data);
94 template<
unsigned int i,
template <
unsigned int,
unsigned int>
class TFunctor>
95 class DimHelperSub<i,1,TFunctor >
113 template<
unsigned int i,
unsigned int j,
template <
unsigned int,
unsigned int>
class TFunctor>
118 if (DimHelperSub<i,j,TFunctor>::Execute(obj, data))
122 return DimHelper<i-1,j,TFunctor>::Execute(obj, data);
129 template<
unsigned int j,
template <
unsigned int,
unsigned int>
class TFunctor>
130 class DimHelper<1,j, TFunctor >
143 template<
unsigned int i,
unsigned int j>
151 result =
dynamic_cast<const map::core::Registration<i,j> *
>(obj->
GetRegistration()) != NULL;
159 template<
unsigned int i,
unsigned int j>
165 const map::core::Registration<i,j>* pReg =
dynamic_cast<const map::core::Registration<i,j>*
>(obj->
GetRegistration());
171 typedef map::io::RegistrationFileWriter<i,j> WriterType;
174 writer->setExpandLazyKernels(
false);
178 writer->write(pReg,data);
180 catch (itk::ExceptionObject e)
182 std::cout << e << std::endl;
191 : AbstractFileIO(other)
197 std::string category =
"MatchPoint Registration File";
216 bool success =
false;
220 mitkThrow() <<
"Cannot write data. Data pointer is NULL.";
226 mitkThrow() <<
"Cannot write data. Data pointer is not a Registration wrapper.";
241 success = DimHelper<3,3,WriteReg>::Execute(wrapper, fileName);
243 catch (
const std::exception& e)
250 mitkThrow() <<
"Cannot write registration. Currently only registrations up to 4D are supported.";
258 if (regWrapper == NULL)
264 if (! DimHelper<3,3,CanWrite>::Execute(regWrapper))
274 std::vector<BaseData::Pointer > result;
279 if ( fileName.empty() )
281 mitkThrow() <<
"Cannot read file. Filename has not been set!";
286 map::io::RegistrationFileReader::LoaderStackType::unregisterProvider(map::io::LazyFileFieldKernelLoader<2,2>::getStaticProviderName());
287 map::io::RegistrationFileReader::LoaderStackType::unregisterProvider(map::io::LazyFileFieldKernelLoader<3,3>::getStaticProviderName());
290 spReader->setPreferLazyLoading(
true);
293 spRegWrapper->SetRegistration(spReg);
295 result.push_back(spRegWrapper.GetPointer());
304 std::ifstream
in( fileName.c_str() );
itk::SmartPointer< Self > Pointer
virtual void Write()
Write the base data to the specified location or output stream.
Base of all data objects.
MAPRegistrationWrapperIO()
DataCollection - Class to facilitate loading/accessing structured data.
MAPRegistrationWrapper Wrapper class to allow the handling of MatchPoint registration objects as mitk...
virtual std::vector< itk::SmartPointer< BaseData > > Read()
Reads a path or stream and creates a list of BaseData objects.
std::string GetLocalFileName() const
Get a local file name for reading.
void SetMimeType(const CustomMimeType &mimeType)
The CustomMimeType class represents a custom mime-type which may be registered as a service object...
virtual ConfidenceLevel GetWriterConfidenceLevel() const
map::core::RegistrationBase * GetRegistration()
Convenience class to temporarily change the current locale.
std::pair< us::ServiceRegistration< IFileReader >, us::ServiceRegistration< IFileWriter > > RegisterService(us::ModuleContext *context=us::GetModuleContext())
void SetDescription(const std::string &description)
virtual const BaseData * GetInput() const override
Get the input data set via SetInput().
static const char * GetStaticNameOfClass()
void AddExtension(const std::string &extension)
LocaleSwitch(const std::string &newLocale)
void SetCategory(const std::string &category)
static bool in(Reader::Char c, Reader::Char c1, Reader::Char c2, Reader::Char c3, Reader::Char c4)
virtual ConfidenceLevel GetReaderConfidenceLevel() const
virtual std::ostream * GetOutputStream() const override
Get the output stream.
void SetMimeType(const CustomMimeType &mimeType)
virtual std::string GetOutputLocation() const override
Get the current output location.
ConfidenceLevel
A confidence level describing the confidence of the reader or writer in handling the given data...
Abstract class for implementing a reader and writer.
void SetDescription(const std::string &description)
Sets a human readable description of this writer.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.