ImFusion SDK 4.3
DicomExtensionExample2.cpp
#include <ImFusion/Base/SharedImageSet.h>
#include <ImFusion/Dicom/DicomElement.h>
#include <ImFusion/Dicom/DicomIOD.h>
#include <ImFusion/Dicom/Extension.h>
#include <dcmtk/dcmdata/dctk.h>
using namespace ImFusion;
class ExtensionExample2 : public Dicom::Extension
{
public:
std::string name() const override { return "Extension Example2"; }
{
if (auto enhanced = dynamic_cast<Dicom::EnhancedMultiFrameImageIOD*>(frame.iod))
{
// In enhanced DICOM tags can be either shared for a frames in the
// sharedSequence or individual for each frame in the perFrameSequence
bool hasShared = false;
if (enhanced->sharedSequence.count() >= 1)
{
auto& shared = enhanced->sharedSequence.item(0);
Windowing windowing(shared.dataset());
if (windowing.exists())
{
windowing.load(sis);
hasShared = true;
}
}
if (!hasShared && frame.index < enhanced->perFrameSequence.count())
{
auto& perFrame = enhanced->perFrameSequence.item(frame.index);
Windowing windowing(perFrame.dataset());
if (windowing.exists())
windowing.load(sis);
}
}
else
{
Windowing windowing(frame.iod->dataset());
if (windowing.exists())
windowing.load(sis);
}
return {}; // If you loaded some additional data e.g. from private tags, you can return it here.
}
void save(const Dicom::FrameDescriptor& frame, const SharedImageSet& sis) const override {}
private:
// Helper class for using the same code for enhanced- and classic DICOMs
class Windowing
{
public:
Windowing(DcmItem& parent)
: center(parent, DCM_WindowCenter, Dicom::ElementBase::Conditional, true)
, width(parent, DCM_WindowWidth, Dicom::ElementBase::Conditional, true)
{
}
bool exists() { return center.exists() && width.exists(); }
void load(SharedImageSet& sis)
{
// ... e.g. set window/center in DisplayOptions2d
}
};
};
@ Conditional
Element is optional. If a condition is met (see setCondition), it has to satisfy that.
Definition DicomElement.h:80
virtual bool exists() const
Returns true if the elements exists in the dataset.
Dicom Element with a concrete value type.
Definition VolumeReconstruction.h:20
Class representing Enhanced CT Image IOD (PS 3.3 A.38)
Definition DicomIOD.h:292
Interface for adding custom functionality to DicomLoader and DicomWriter An Extension might be called...
Definition Extension.h:26
DcmDataset & dataset() override
Returns the dataset represented by this IOD.
Set of images independent of their storage location.
Definition SharedImageSet.h:42
T make_unique(T... args)
Namespace of the ImFusion SDK.
Definition Assert.h:7
Descriptor for a single DICOM frame that is used during the loading process as intermediate represent...
Definition DicomIOD.h:33
IOD * iod
Parent IOD that loaded the frame. Never nullptr and must not be re-assigned.
Definition DicomIOD.h:52
int index
Index of the frame in the iod.
Definition DicomIOD.h:53
Search Tab / S to search, Esc to close