7 #include "fwGdcmIO/helper/DicomDataTools.hpp" 9 #include "fwGdcmIO/helper/Encoding.hpp" 11 #include <fwCore/base.hpp> 13 #include <fwTools/IntrinsicTypes.hpp> 15 #include <gdcmGlobal.h> 16 #include <gdcmPhotometricInterpretation.h> 17 #include <gdcmPixelFormat.h> 26 typedef std::map< ::fwTools::Type, ::gdcm::PixelFormat::ScalarType > PixelTypeConversionMapType;
28 static const PixelTypeConversionMapType s_PIXEL_TYPE_CONVERSION_MAP = {
29 {::fwTools::Type::create(
"uint8"), ::gdcm::PixelFormat::UINT8},
30 {::fwTools::Type::create(
"int8"), ::gdcm::PixelFormat::INT8},
33 {::fwTools::Type::create(
"uint16"), ::gdcm::PixelFormat::UINT16},
34 {::fwTools::Type::create(
"int16"), ::gdcm::PixelFormat::INT16},
35 {::fwTools::Type::create(
"uint32"), ::gdcm::PixelFormat::UINT32},
36 {::fwTools::Type::create(
"int32"), ::gdcm::PixelFormat::INT32},
38 {::fwTools::Type::create(
"float"), ::gdcm::PixelFormat::FLOAT32},
39 {::fwTools::Type::create(
"double"), ::gdcm::PixelFormat::FLOAT64}
46 auto it = s_PIXEL_TYPE_CONVERSION_MAP.find(image->getType());
47 if(it != s_PIXEL_TYPE_CONVERSION_MAP.end())
51 return ::gdcm::PixelFormat::UNKNOWN;
56 const ::gdcm::PhotometricInterpretation
59 ::gdcm::PhotometricInterpretation pi;
60 const size_t components = image->getNumberOfComponents();
66 pi = ::gdcm::PhotometricInterpretation::MONOCHROME2;
69 pi = ::gdcm::PhotometricInterpretation::RGB;
72 pi = ::gdcm::PhotometricInterpretation::ARGB;
75 SLM_ERROR(
"Photometric interpretation not found");
76 pi = ::gdcm::PhotometricInterpretation::UNKNOWN;
88 switch (representationMode)
90 case ::fwData::Material::SURFACE:
91 return ::gdcm::Surface::SURFACE;
93 case ::fwData::Material::POINT:
94 return ::gdcm::Surface::POINTS;
96 case ::fwData::Material::WIREFRAME:
97 return ::gdcm::Surface::WIREFRAME;
100 SLM_WARN(
"Representation type not handle (changed to : SURFACE)");
101 return ::gdcm::Surface::SURFACE;
108 ::gdcm::Surface::VIEWType presentationType)
110 switch (presentationType)
112 case ::gdcm::Surface::SURFACE:
113 return ::fwData::Material::SURFACE;
115 case ::gdcm::Surface::WIREFRAME:
116 return ::fwData::Material::WIREFRAME;
118 case ::gdcm::Surface::POINTS:
119 return ::fwData::Material::POINT;
122 SLM_WARN(
"Presentation type not handle (changed to : SURFACE)");
123 return ::fwData::Material::SURFACE;
130 const ::fwData::Point::csptr&
point)
134 const double zSpacing = (image->getNumberOfDimensions() > 2) ? (image->getSpacing()[2]) : 1;
137 const double zOrigin = (image->getNumberOfDimensions() > 2) ? (image->getOrigin()[2]) : 0;
140 const double zCoordinate =
static_cast<double>(
point->getCoord()[2]);
143 const std::size_t frameNumber =
static_cast<std::size_t
>(floor((zCoordinate - zOrigin) / zSpacing + 0.5)) + 1;
145 frameNumber < 1 || frameNumber > image->getSize()[2]);
153 const std::size_t frameNumber)
157 const double zSpacing = (image->getNumberOfDimensions() > 2) ? (image->getSpacing()[2]) : 1;
160 const double zOrigin = (image->getNumberOfDimensions() > 2) ? (image->getOrigin()[2]) : 0;
163 const std::size_t frameIndex = (frameNumber-1);
165 frameIndex >= image->getSize()[2]);
166 const double zCoordinate = zOrigin +
static_cast<double>(frameIndex) * zSpacing;
The namespace fwGdcmIO contains reader, writer and helper for dicom data.
#define SLM_WARN(message)
#define SLM_ERROR(message)
Implements a failed exception class for fwGdcmIO.
RepresentationType
Representation models.