#include <ImFusion/Base/DataComponent.h>
#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>
class PrivateTagsDataComponent :
public DataComponent<PrivateTagsDataComponent>
{
public:
PrivateTagsDataComponent() = default;
PrivateTagsDataComponent(const PrivateTagsDataComponent& other) = default;
PrivateTagsDataComponent& operator=(const PrivateTagsDataComponent& other) = default;
bool operator==(const PrivateTagsDataComponent& other) const { return other.someString == someString && other.someInt == someInt; }
void configuration(
Properties* p)
const override {};
int someInt = 0;
};
{
public:
ExtensionExample3()
{
DcmDataDictionary& dict = dcmDataDict.wrlock();
dict.addEntry(
new DcmDictEntry(someStringTag.getGTag(), someStringTag.getETag(), EVR_LO, "PrivateText", 1, 1, "private", OFTrue, creatorName.c_str()));
dict.addEntry(
new DcmDictEntry(someIntTag.getGTag(), someIntTag.getETag(), EVR_US, "PrivateInteger", 1, 1, "private", OFTrue, creatorName.c_str()));
#if OFFIS_DCMTK_VERSION_NUMBER < 364
dcmDataDict.unlock();
#else
dcmDataDict.wrunlock();
#endif
}
std::string name() const override { return "Extension Example3"; }
std::vector<std::unique_ptr<Data>>
load(
const Dicom::FrameDescriptor& frame, SharedImageSet& sis)
const override
{
return {};
Dicom::Element<std::string> creator(*frame.
iod, creatorTag);
if (creator.isValid() && creator.value() == creatorName)
{
Dicom::Element<std::string> someString(*frame.
iod, someStringTag);
Dicom::Element<int> someInt(*frame.
iod, someIntTag);
if (someString.isValid())
dc.someString = someString.value();
if (someInt.isValid())
dc.someInt = someInt.value();
}
return {};
}
void save(
const Dicom::FrameDescriptor& frame,
const SharedImageSet& sis)
const override
{
{
Dicom::Element<std::string> creator(*frame.
iod, creatorTag);
creator.setValue(creatorName);
Dicom::Element<std::string> someString(*frame.
iod, someStringTag);
someString.setValue(dc->someString);
Dicom::Element<int> someInt(*frame.
iod, someIntTag);
someInt.setValue(dc->someInt);
}
}
private:
const std::string creatorName = "ImFusion";
const DcmTag creatorTag = DcmTag(DcmTagKey(0x0029, 0x0010), EVR_LO);
const DcmTag someStringTag = DcmTag(DcmTagKey(0x0029, 0x1000), EVR_LO);
const DcmTag someIntTag = DcmTag(DcmTagKey(0x0029, 0x1010), EVR_US);
};
Main specialization of DataComponentBase for regular types.
Definition DataComponent.h:109
T & getOrCreate(Args &&... ctorArgs)
Returns the DataComponent exactly matching the given type.
Definition DataComponentList.h:231
T * get()
Returns the DataComponent exactly matching the given type.
Definition DataComponentList.h:210
Interface for adding custom functionality to DicomLoader and DicomWriter An Extension might be called...
Definition Extension.h:26
Storage container for serialization of arbitrary types, internally backed by strings.
Definition Properties.h:50
const DataComponentList & components() const
Returns the list of DataComponents for this data.
Definition Data.h:179
Mesh * load(const char *buffer, size_t bufferLength, const std::string &sourceFilename="", Progress *progressBar=nullptr, bool log=false)
Loads a mesh from a memory buffer.
void save(const char *filename, const std::vector< mat4 > &matrices, bool rigidPars=false)
Save matrices or its rigid pose parameters to a text file.
Namespace of the ImFusion SDK.
Definition Assert.h:7
IOD * iod
Parent IOD that loaded the frame. Never nullptr and must not be re-assigned.
Definition DicomIOD.h:52
int sharedImageIndex
index of the SharedImage in the SharedImageSet
Definition DicomIOD.h:59
int sliceIndex
slice index of the frame in the volume (or 0 for 2D images)
Definition DicomIOD.h:60