16 #include <vtkImageData.h> 17 #include <vtkMetaImageReader.h> 18 #include <vtkSmartPointer.h> 19 #include <vtkMetaImageWriter.h> 21 #include <vtkPolyData.h> 22 #include <vtkPolyDataReader.h> 23 #include <vtkXMLPolyDataReader.h> 24 #include <vtkPolyDataWriter.h> 25 #include <vtkSTLReader.h> 26 #include <vtkImageChangeInformation.h> 27 #include "vtkMINCImageReader.h" 28 #include "vtkTransform.h" 29 #include "vtkCommand.h" 30 #include <vtkPNGReader.h> 31 #include <vtkNIFTIImageReader.h> 32 #include <vtkNIFTIImageHeader.h> 35 #include <QDomDocument> 38 #include <QTextStream> 65 reader->ReleaseDataFlagOn();
71 zeroer->SetInputConnection(reader->GetOutputPort());
72 zeroer->SetOutputOrigin(0, 0, 0);
74 return zeroer->GetOutput();
79 return this->
readInto(boost::dynamic_pointer_cast<Image>(data), filename);
94 image->setVtkImageData(raw);
95 image->get_rMd_History()->setRegistration(rMd);
96 image->setModality(customReader->readModality());
97 image->setImageType(customReader->readImageType());
101 double level = customReader->readKey(
"WindowLevel").toDouble(&ok1);
102 double window = customReader->readKey(
"WindowWidth").toDouble(&ok2);
106 image->setInitialWindowLevel(window, level);
107 image->resetTransferFunctions();
124 writer->SetInputData(image->getBaseVtkImageData());
125 writer->SetFileDimensionality(3);
127 QDir().mkpath(QFileInfo(filename).path());
131 writer->SetCompression(
false);
138 customReader->setTransform(image->get_rMd());
139 customReader->setModality(image->getModality());
140 customReader->setImageType(image->getImageType());
141 customReader->setKey(
"WindowLevel",
qstring_cast(image->getInitialWindowLevel()));
142 customReader->setKey(
"WindowWidth",
qstring_cast(image->getInitialWindowWidth()));
143 customReader->setKey(
"Creator", QString(
"CustusX_%1").arg(CustusX_VERSION_STRING));
153 sform_matrix = vtkMatrix4x4Ptr::New();
166 image->setVtkImageData(raw);
167 image->get_rMd_History()->setRegistration(rMd);
174 return this->
readInto(boost::dynamic_pointer_cast<Image>(data), filename);
188 reader->ReleaseDataFlagOn();
202 sform_matrix = reader->GetSFormMatrix();
207 return reader->GetOutput();
217 return this->
readInto(boost::dynamic_pointer_cast<Image>(data), filename);
227 image->setVtkImageData(raw);
241 pngReader->SetFileName(filename.toStdString().c_str());
243 return pngReader->GetOutput();
252 return this->
readInto(boost::dynamic_pointer_cast<Mesh>(data), filename);
262 mesh->setVtkPolyData(raw);
292 return this->
readInto(boost::dynamic_pointer_cast<Mesh>(data), filename);
302 mesh->setVtkPolyData(raw);
332 return this->
readInto(boost::dynamic_pointer_cast<Mesh>(data), filename);
342 mesh->setVtkPolyData(raw);
381 DataReaderPtr DataReaderWriter::findReader(
const QString& path,
const QString& type)
383 for (DataReadersType::iterator iter = mDataReaders.begin(); iter != mDataReaders.end(); ++iter)
385 if ((*iter)->canLoad(type, path))
395 return reader->loadVtkImageData(filename);
403 return reader->loadVtkPolyData(filename);
411 return reader->canLoadDataType();
417 DataReaderPtr reader = this->findReader(path, data->getType());
419 reader->readInto(data, path);
425 data->setFilename(path);
QString qstring_cast(const T &val)
virtual vtkPolyDataPtr loadVtkPolyData(QString filename)
QString findDataTypeFromFile(QString filename)
virtual DataPtr load(const QString &uid, const QString &filename)
virtual bool readInto(DataPtr data, QString path)
virtual bool readInto(DataPtr data, QString path)
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
virtual vtkPolyDataPtr loadVtkPolyData(QString filename)
boost::shared_ptr< class Image > ImagePtr
vtkSmartPointer< vtkImageChangeInformation > vtkImageChangeInformationPtr
vtkSmartPointer< class vtkXMLPolyDataReader > vtkXMLPolyDataReaderPtr
cstring_cast_Placeholder cstring_cast(const T &val)
virtual DataPtr load(const QString &uid, const QString &filename)
boost::shared_ptr< DataReader > DataReaderPtr
vtkPolyDataPtr loadVtkPolyData(QString filename)
boost::shared_ptr< class Data > DataPtr
virtual DataPtr load(const QString &uid, const QString &filename)
vtkSmartPointer< class vtkMetaImageReader > vtkMetaImageReaderPtr
boost::shared_ptr< class CustomMetaImage > CustomMetaImagePtr
virtual bool readInto(DataPtr data, QString path)
vtkSmartPointer< class vtkSTLReader > vtkSTLReaderPtr
virtual vtkPolyDataPtr loadVtkPolyData(QString filename)
vtkSmartPointer< class vtkPNGReader > vtkPNGReaderPtr
vtkSmartPointer< class vtkMetaImageWriter > vtkMetaImageWriterPtr
vtkSmartPointer< class vtkNIFTIImageReader > vtkNIFTIImageReaderPtr
virtual bool readInto(DataPtr data, QString path)
vtkSmartPointer< vtkPolyData > vtkPolyDataPtr
virtual DataPtr load(const QString &uid, const QString &filename)
virtual vtkImageDataPtr loadVtkImageData(QString filename)
QString changeExtension(QString name, QString ext)
void readInto(DataPtr data, QString path)
virtual vtkImageDataPtr loadVtkImageData(QString filename)
static bool checkedRead(vtkSmartPointer< vtkAlgorithm > reader, QString filename)
Reader for portable network graphics .png files.
vtkSmartPointer< class vtkPolyDataReader > vtkPolyDataReaderPtr
virtual bool readInto(DataPtr data, QString path)
boost::shared_ptr< class Mesh > MeshPtr
vtkImageDataPtr loadVtkImageData(QString filename)
virtual vtkPolyDataPtr loadVtkPolyData(QString filename)
Interface for Data file readers.
Namespace for all CustusX production code.
virtual DataPtr load(const QString &uid, const QString &filename)