diff --git a/Modules/DICOMQI/mitkDICOMQIIOMimeTypes.cpp b/Modules/DICOMQI/mitkDICOMQIIOMimeTypes.cpp index 182579d095..1dca975da2 100644 --- a/Modules/DICOMQI/mitkDICOMQIIOMimeTypes.cpp +++ b/Modules/DICOMQI/mitkDICOMQIIOMimeTypes.cpp @@ -1,218 +1,218 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkDICOMQIIOMimeTypes.h" #include "mitkIOMimeTypes.h" #include #include #include #include #include namespace mitk { std::vector MitkDICOMQIIOMimeTypes::Get() { std::vector mimeTypes; // order matters here (descending rank for mime types) mimeTypes.push_back(DICOMSEG_MIMETYPE().Clone()); mimeTypes.push_back(DICOMPM_MIMETYPE().Clone()); - return mimeTypes; } + // Mime Types //======= Mime Type DICOM SEG ======= MitkDICOMQIIOMimeTypes::MitkDICOMSEGMimeType::MitkDICOMSEGMimeType() : CustomMimeType(DICOMSEG_MIMETYPE_NAME()) { this->AddExtension("dcm"); this->SetCategory(IOMimeTypes::CATEGORY_IMAGES()); this->SetComment("DICOM SEG"); } + bool MitkDICOMQIIOMimeTypes::MitkDICOMSEGMimeType::AppliesTo(const std::string &path) const { std::ifstream myfile; myfile.open(path, std::ios::binary); // myfile.seekg (128); char *buffer = new char[128]; myfile.read(buffer, 128); myfile.read(buffer, 4); if (std::string(buffer).compare("DICM") != 0) { delete[] buffer; return false; } delete[] buffer; bool canRead(CustomMimeType::AppliesTo(path)); // fix for bug 18572 // Currently this function is called for writing as well as reading, in that case // the image information can of course not be read // This is a bug, this function should only be called for reading. if (!itksys::SystemTools::FileExists(path.c_str())) { return canRead; } // end fix for bug 18572 DcmFileFormat dcmFileFormat; OFCondition status = dcmFileFormat.loadFile(path.c_str()); if (status.bad()) { canRead = false; } if (!canRead) { return canRead; } OFString modality; OFString sopClassUID; if (dcmFileFormat.getDataset()->findAndGetOFString(DCM_Modality, modality).good() && dcmFileFormat.getDataset()->findAndGetOFString(DCM_SOPClassUID, sopClassUID).good()) { if (modality.compare("SEG") == 0) {//atm we could read SegmentationStorage files. Other storage classes with "SEG" modality, e.g. SurfaceSegmentationStorage (1.2.840.10008.5.1.4.1.1.66.5), are not supported yet. if (sopClassUID.compare("1.2.840.10008.5.1.4.1.1.66.4") == 0) { canRead = true; } else { canRead = false; } } else { canRead = false; } } return canRead; } MitkDICOMQIIOMimeTypes::MitkDICOMSEGMimeType *MitkDICOMQIIOMimeTypes::MitkDICOMSEGMimeType::Clone() const { return new MitkDICOMSEGMimeType(*this); } MitkDICOMQIIOMimeTypes::MitkDICOMSEGMimeType MitkDICOMQIIOMimeTypes::DICOMSEG_MIMETYPE() { return MitkDICOMSEGMimeType(); } std::string MitkDICOMQIIOMimeTypes::DICOMSEG_MIMETYPE_NAME() { // create a unique and sensible name for this mime type static std::string name = IOMimeTypes::DEFAULT_BASE_NAME() + ".image.dicom.seg"; return name; } //======= Mime Type DICOM PM ======= - //... MitkDICOMQIIOMimeTypes::MitkDICOMPMMimeType::MitkDICOMPMMimeType() : CustomMimeType(DICOMPM_MIMETYPE_NAME()) { this->AddExtension("dcm"); this->SetCategory(IOMimeTypes::CATEGORY_IMAGES()); this->SetComment("DICOM PM"); } bool MitkDICOMQIIOMimeTypes::MitkDICOMPMMimeType::AppliesTo(const std::string &path) const { std::ifstream myfile; myfile.open(path, std::ios::binary); // myfile.seekg (128); char *buffer = new char[128]; myfile.read(buffer, 128); myfile.read(buffer, 4); if (std::string(buffer).compare("DICM") != 0) { delete[] buffer; return false; } delete[] buffer; bool canRead(CustomMimeType::AppliesTo(path)); // fix for bug 18572 // Currently this function is called for writing as well as reading, in that case // the image information can of course not be read // This is a bug, this function should only be called for reading. if (!itksys::SystemTools::FileExists(path.c_str())) { return canRead; } // end fix for bug 18572 DcmFileFormat dcmFileFormat; OFCondition status = dcmFileFormat.loadFile(path.c_str()); if (status.bad()) { canRead = false; } if (!canRead) { return canRead; } OFString modality; if (dcmFileFormat.getDataset()->findAndGetOFString(DCM_Modality, modality).good()) { if (modality.compare("RWV") == 0) { canRead = true; } else { canRead = false; } } return canRead; } MitkDICOMQIIOMimeTypes::MitkDICOMPMMimeType *MitkDICOMQIIOMimeTypes::MitkDICOMPMMimeType::Clone() const { return new MitkDICOMPMMimeType(*this); } MitkDICOMQIIOMimeTypes::MitkDICOMPMMimeType MitkDICOMQIIOMimeTypes::DICOMPM_MIMETYPE() { return MitkDICOMPMMimeType(); } - + // Names std::string MitkDICOMQIIOMimeTypes::DICOMPM_MIMETYPE_NAME() { // create a unique and sensible name for this mime type static std::string name = IOMimeTypes::DEFAULT_BASE_NAME() + ".image.dicom.pm"; return name; } } diff --git a/Modules/DICOMQI/mitkDICOMQIIOMimeTypes.h b/Modules/DICOMQI/mitkDICOMQIIOMimeTypes.h index e3faaf6c33..3b1b5bb1d2 100644 --- a/Modules/DICOMQI/mitkDICOMQIIOMimeTypes.h +++ b/Modules/DICOMQI/mitkDICOMQIIOMimeTypes.h @@ -1,71 +1,72 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKDICOMQIIOMIMETYPES_H #define MITKDICOMQIIOMIMETYPES_H #include "mitkCustomMimeType.h" #include #include namespace mitk { /// Provides the custom mime types for dicom qi objects loaded with DCMQI class MITKDICOMQI_EXPORT MitkDICOMQIIOMimeTypes { public: /** Mime type that parses dicom files to determine whether they are dicom segmentation objects. */ class MITKDICOMQI_EXPORT MitkDICOMSEGMimeType : public CustomMimeType { public: MitkDICOMSEGMimeType(); bool AppliesTo(const std::string &path) const override; MitkDICOMSEGMimeType *Clone() const override; }; static MitkDICOMSEGMimeType DICOMSEG_MIMETYPE(); static std::string DICOMSEG_MIMETYPE_NAME(); + /** Mime type that parses dicom files to determine whether they are dicom pm objects. */ - + class MITKDICOMQI_EXPORT MitkDICOMPMMimeType : public CustomMimeType { public: MitkDICOMPMMimeType(); virtual bool AppliesTo(const std::string &path) const override; virtual MitkDICOMPMMimeType *Clone() const override; }; static MitkDICOMPMMimeType DICOMPM_MIMETYPE(); static std::string DICOMPM_MIMETYPE_NAME(); - + // Get all Mime Types static std::vector Get(); private: // purposely not implemented MitkDICOMQIIOMimeTypes(); MitkDICOMQIIOMimeTypes(const MitkDICOMQIIOMimeTypes &); }; } #endif // MITKDICOMQIIOMIMETYPES_H diff --git a/Modules/Pharmacokinetics/autoload/DICOMPMIO/mitkDICOMPMIOMimeTypes.cpp b/Modules/Pharmacokinetics/autoload/DICOMPMIO/mitkDICOMPMIOMimeTypes.cpp deleted file mode 100644 index aaf8a51174..0000000000 --- a/Modules/Pharmacokinetics/autoload/DICOMPMIO/mitkDICOMPMIOMimeTypes.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkDICOMPMIOMimeTypes.h" -#include "mitkIOMimeTypes.h" - -#include - -#include - -#include - -// dcmqi -//IKO: TO DO -#include -#include - -namespace mitk -{ - std::vector MitkDICOMPMIOMimeTypes::Get() - { - std::vector mimeTypes; - - // order matters here (descending rank for mime types) - - mimeTypes.push_back(DICOMPM_MIMETYPE().Clone()); - - return mimeTypes; - } - - // Mime Types - - MitkDICOMPMIOMimeTypes::MitkDICOMPMMimeType::MitkDICOMPMMimeType() : CustomMimeType(DICOMPM_MIMETYPE_NAME()) - { - this->AddExtension("dcm"); - this->SetCategory(IOMimeTypes::CATEGORY_IMAGES()); - this->SetComment("DICOM PM"); - } - - bool MitkDICOMPMIOMimeTypes::MitkDICOMPMMimeType::AppliesTo(const std::string &path) const - { - std::ifstream myfile; - myfile.open (path, std::ios::binary); -// myfile.seekg (128); - char *buffer = new char [128]; - myfile.read (buffer,128); - myfile.read (buffer,4); - if (std::string(buffer).compare("DICM")!=0) - { - delete[] buffer; - return false; - } - delete[] buffer; - - bool canRead(CustomMimeType::AppliesTo(path)); - - // fix for bug 18572 - // Currently this function is called for writing as well as reading, in that case - // the image information can of course not be read - // This is a bug, this function should only be called for reading. - if (!itksys::SystemTools::FileExists(path.c_str())) - { - return canRead; - } - // end fix for bug 18572 - DcmFileFormat dcmFileFormat; - OFCondition status = dcmFileFormat.loadFile(path.c_str()); - - if (status.bad()) - { - canRead = false; - } - - if (!canRead) - { - return canRead; - } - - - - OFString modality; - if (dcmFileFormat.getDataset()->findAndGetOFString(DCM_Modality, modality).good()) - { - if (modality.compare("RWV") == 0) - { - canRead = true; - } - else - { - canRead = false; - } - } - - return canRead; - } - - MitkDICOMPMIOMimeTypes::MitkDICOMPMMimeType *MitkDICOMPMIOMimeTypes::MitkDICOMPMMimeType::Clone() const - { - return new MitkDICOMPMMimeType(*this); - } - - MitkDICOMPMIOMimeTypes::MitkDICOMPMMimeType MitkDICOMPMIOMimeTypes::DICOMPM_MIMETYPE() - { - return MitkDICOMPMMimeType(); - } - - // Names - std::string MitkDICOMPMIOMimeTypes::DICOMPM_MIMETYPE_NAME() - { - // create a unique and sensible name for this mime type - static std::string name = IOMimeTypes::DEFAULT_BASE_NAME() + ".image.dicom.pm"; - return name; - } -} diff --git a/Modules/Pharmacokinetics/autoload/DICOMPMIO/mitkDICOMPMIOMimeTypes.h b/Modules/Pharmacokinetics/autoload/DICOMPMIO/mitkDICOMPMIOMimeTypes.h deleted file mode 100644 index 3112731e3a..0000000000 --- a/Modules/Pharmacokinetics/autoload/DICOMPMIO/mitkDICOMPMIOMimeTypes.h +++ /dev/null @@ -1,53 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef MITKDICOMOMIOMIMETYPES_H -#define MITKDICOMPMIOMIMETYPES_H - -#include "mitkCustomMimeType.h" - -#include - -namespace mitk -{ - /// Provides the custom mime types for dicom segmentation objects loaded with DCMQI - class MitkDICOMPMIOMimeTypes - { - public: - /** Mime type that parses dicom files to determine whether they are dicom segmentation objects. - */ - class MitkDICOMPMMimeType : public CustomMimeType - { - public: - MitkDICOMPMMimeType(); - virtual bool AppliesTo(const std::string &path) const override; - virtual MitkDICOMPMMimeType *Clone() const override; - }; - - static MitkDICOMPMMimeType DICOMPM_MIMETYPE(); - static std::string DICOMPM_MIMETYPE_NAME(); - - // Get all Mime Types - static std::vector Get(); - - private: - // purposely not implemented - MitkDICOMPMIOMimeTypes(); - MitkDICOMPMIOMimeTypes(const MitkDICOMPMIOMimeTypes &); - }; -} - -#endif // MITKDICOMQIIOMIMETYPES_H