20 #include <itkGDCMImageIO.h> 21 #include <itksys/SystemTools.hxx> 23 #include <dcmtk/dcmdata/dcfilefo.h> 24 #include <dcmtk/dcmdata/dcdeftag.h> 30 std::vector<CustomMimeType *> mimeTypes;
55 if (!itksys::SystemTools::FileExists(path.c_str()))
61 const std::size_t
offset = 128;
62 const std::size_t bufferSize = 4;
64 std::ifstream myfile(path, std::ifstream::binary);
66 if (!myfile.is_open())
69 myfile.seekg(0, std::ifstream::end);
70 const auto fileSize =
static_cast<std::size_t
>(myfile.tellg());
72 if (fileSize < offset + bufferSize)
76 std::array<char, bufferSize> buffer;
77 myfile.read(buffer.data(), bufferSize);
79 if (0 != std::string(buffer.data(), bufferSize).
compare(
"DICM"))
82 DcmFileFormat dcmFileFormat;
83 OFCondition status = dcmFileFormat.loadFile(path.c_str());
97 if (dcmFileFormat.getDataset()->findAndGetOFString(DCM_Modality, modality).good() && dcmFileFormat.getDataset()->findAndGetOFString(DCM_SOPClassUID, sopClassUID).good())
99 if (modality.compare(
"SEG") == 0)
101 if (sopClassUID.compare(
"1.2.840.10008.5.1.4.1.1.66.4") == 0)
DataCollection - Class to facilitate loading/accessing structured data.
virtual bool AppliesTo(const std::string &path) const
Checks if the MimeType can handle file at the given location.
void SetComment(const std::string &comment)
The CustomMimeType class represents a custom mime-type which may be registered as a service object...
static std::string CATEGORY_IMAGES()
static std::string DEFAULT_BASE_NAME()
static MitkDICOMSEGMimeType DICOMSEG_MIMETYPE()
bool compare(std::pair< double, int > i, std::pair< double, int > j)
void AddExtension(const std::string &extension)
bool AppliesTo(const std::string &path) const override
Checks if the MimeType can handle file at the given location.
void SetCategory(const std::string &category)
MitkDICOMSEGMimeType * Clone() const override
static std::string DICOMSEG_MIMETYPE_NAME()
static std::vector< CustomMimeType * > Get()