|
PACS System 0.1.0
PACS DICOM system library
|
#include <dicom_file.h>

Public Member Functions | |
| auto | save (const std::filesystem::path &path) const -> kcenon::pacs::VoidResult |
| Save the DICOM file to disk. | |
| auto | to_bytes () const -> std::vector< uint8_t > |
| Encode the DICOM file to raw bytes. | |
| auto | meta_information () const noexcept -> const dicom_dataset & |
| Get read-only access to the File Meta Information. | |
| auto | meta_information () noexcept -> dicom_dataset & |
| Get mutable access to the File Meta Information. | |
| auto | dataset () const noexcept -> const dicom_dataset & |
| Get read-only access to the main dataset. | |
| auto | dataset () noexcept -> dicom_dataset & |
| Get mutable access to the main dataset. | |
| auto | transfer_syntax () const -> encoding::transfer_syntax |
| Get the Transfer Syntax of this file. | |
| auto | sop_class_uid () const -> std::string |
| Get the SOP Class UID. | |
| auto | sop_instance_uid () const -> std::string |
| Get the SOP Instance UID. | |
| dicom_file ()=default | |
| Default constructor - creates an empty file. | |
| dicom_file (const dicom_file &)=default | |
| Copy constructor. | |
| dicom_file (dicom_file &&) noexcept=default | |
| Move constructor. | |
| auto | operator= (const dicom_file &) -> dicom_file &=default |
| Copy assignment. | |
| auto | operator= (dicom_file &&) noexcept -> dicom_file &=default |
| Move assignment. | |
| ~dicom_file ()=default | |
| Destructor. | |
Static Public Member Functions | |
| static auto | open (const std::filesystem::path &path) -> kcenon::pacs::Result< dicom_file > |
| Open and read a DICOM file from disk. | |
| static auto | from_bytes (std::span< const uint8_t > data) -> kcenon::pacs::Result< dicom_file > |
| Parse a DICOM file from raw bytes. | |
| static auto | create (dicom_dataset dataset, const encoding::transfer_syntax &ts) -> dicom_file |
| Create a new DICOM file from a dataset. | |
Private Member Functions | |
| dicom_file (dicom_dataset meta_info, dicom_dataset main_dataset) | |
| Private constructor for internal use. | |
Static Private Member Functions | |
| static auto | parse_meta_information (std::span< const uint8_t > data, size_t &bytes_read) -> kcenon::pacs::Result< dicom_dataset > |
| Parse file meta information from raw data. | |
| static auto | generate_meta_information (const dicom_dataset &dataset, const encoding::transfer_syntax &ts) -> dicom_dataset |
| Generate File Meta Information for a dataset. | |
| static auto | encode_explicit_vr_le (const dicom_dataset &dataset) -> std::vector< uint8_t > |
| Encode a dataset using Explicit VR Little Endian. | |
| static auto | decode_explicit_vr_le (std::span< const uint8_t > data, size_t &bytes_read) -> kcenon::pacs::Result< dicom_dataset > |
| Decode a dataset from Explicit VR Little Endian format. | |
| static auto | decode_implicit_vr_le (std::span< const uint8_t > data, size_t &bytes_read) -> kcenon::pacs::Result< dicom_dataset > |
| Decode a dataset from Implicit VR Little Endian format. | |
| static auto | decode_explicit_vr_be (std::span< const uint8_t > data, size_t &bytes_read) -> kcenon::pacs::Result< dicom_dataset > |
| Decode a dataset from Explicit VR Big Endian format. | |
| static auto | encode_implicit_vr_le (const dicom_dataset &dataset) -> std::vector< uint8_t > |
| Encode a dataset using Implicit VR Little Endian. | |
| static auto | encode_explicit_vr_be (const dicom_dataset &dataset) -> std::vector< uint8_t > |
| Encode a dataset using Explicit VR Big Endian. | |
| static auto | decode_dataset (std::span< const uint8_t > data, const encoding::transfer_syntax &ts, size_t &bytes_read) -> kcenon::pacs::Result< dicom_dataset > |
| Decode a dataset based on its Transfer Syntax. | |
| static auto | encode_dataset (const dicom_dataset &dataset, const encoding::transfer_syntax &ts) -> std::vector< uint8_t > |
| Encode a dataset based on its Transfer Syntax. | |
| static auto | parse_undefined_length_sequence (std::span< const uint8_t > data, size_t &bytes_read, bool explicit_vr, bool big_endian) -> kcenon::pacs::Result< std::vector< dicom_dataset > > |
| Parse a sequence with undefined length. | |
| static auto | parse_encapsulated_frames (std::span< const uint8_t > data) -> std::vector< std::vector< uint8_t > > |
| Parse encapsulated pixel data frames. | |
Private Attributes | |
| dicom_dataset | meta_info_ |
| File Meta Information (Group 0002) | |
| dicom_dataset | dataset_ |
| Main dataset (encoded per Transfer Syntax) | |
Static Private Attributes | |
| static constexpr std::string_view | kImplementationClassUid |
| Implementation Class UID for this library. | |
| static constexpr std::string_view | kImplementationVersionName = "PACS_SYS_001" |
| Implementation Version Name. | |
| static constexpr uint8_t | kDicmPrefix [4] = {'D', 'I', 'C', 'M'} |
| DICOM magic bytes. | |
| static constexpr size_t | kPreambleSize = 128 |
| Preamble size. | |
Definition at line 67 of file dicom_file.h.
|
default |
Default constructor - creates an empty file.
|
default |
Copy constructor.
|
defaultnoexcept |
Move constructor.
|
default |
Destructor.
|
private |
Private constructor for internal use.
Definition at line 142 of file dicom_file.cpp.
|
staticnodiscard |
Create a new DICOM file from a dataset.
| dataset | The main dataset (SOP Class UID and Instance UID required) |
| ts | The transfer syntax to use for encoding |
The File Meta Information will be automatically generated with:
Definition at line 232 of file dicom_file.cpp.
Referenced by kcenon::pacs::storage::file_storage::store(), kcenon::pacs::storage::azure_blob_storage::store_with_progress(), and kcenon::pacs::storage::s3_storage::store_with_progress().

|
nodiscardnoexcept |
Get read-only access to the main dataset.
Definition at line 300 of file dicom_file.cpp.
References dataset_.
|
nodiscardnoexcept |
Get mutable access to the main dataset.
Definition at line 304 of file dicom_file.cpp.
References dataset_.
|
staticnodiscardprivate |
Decode a dataset based on its Transfer Syntax.
| data | The raw byte data |
| ts | The Transfer Syntax to use for decoding |
| bytes_read | Output parameter for bytes consumed |
Definition at line 993 of file dicom_file.cpp.
References kcenon::pacs::encoding::big_endian, and kcenon::pacs::encoding::implicit.
|
staticnodiscardprivate |
Decode a dataset from Explicit VR Big Endian format.
| data | The raw byte data |
| bytes_read | Output parameter for bytes consumed |
Definition at line 765 of file dicom_file.cpp.
References kcenon::pacs::encoding::fixed_length(), kcenon::pacs::encoding::from_string(), kcenon::pacs::encoding::has_explicit_32bit_length(), kcenon::pacs::core::dicom_dataset::insert(), kcenon::pacs::encoding::is_numeric_vr(), kcenon::pacs::encoding::OB, kcenon::pacs::core::tags::pixel_data, kcenon::pacs::encoding::SQ, kcenon::pacs::encoding::UN, and vr.

|
staticnodiscardprivate |
Decode a dataset from Explicit VR Little Endian format.
| data | The raw byte data |
| bytes_read | Output parameter for bytes consumed |
Definition at line 500 of file dicom_file.cpp.
References kcenon::pacs::encoding::from_string(), kcenon::pacs::encoding::has_explicit_32bit_length(), kcenon::pacs::core::dicom_dataset::insert(), kcenon::pacs::encoding::OB, kcenon::pacs::core::tags::pixel_data, kcenon::pacs::encoding::SQ, kcenon::pacs::encoding::UN, and vr.

|
staticnodiscardprivate |
Decode a dataset from Implicit VR Little Endian format.
| data | The raw byte data |
| bytes_read | Output parameter for bytes consumed |
Uses dicom_dictionary for VR lookup since VR is not encoded in data.
Definition at line 627 of file dicom_file.cpp.
References kcenon::pacs::encoding::from_string(), kcenon::pacs::core::dicom_dataset::get_private_creator(), kcenon::pacs::core::dicom_dataset::insert(), kcenon::pacs::core::dicom_dictionary::instance(), kcenon::pacs::core::private_tag_registry::instance(), kcenon::pacs::encoding::LO, kcenon::pacs::encoding::OB, kcenon::pacs::core::tags::pixel_data, kcenon::pacs::encoding::SQ, kcenon::pacs::encoding::to_string(), kcenon::pacs::encoding::UN, kcenon::pacs::core::tag_info::vr, and vr.

|
staticnodiscardprivate |
Encode a dataset based on its Transfer Syntax.
| dataset | The dataset to encode |
| ts | The Transfer Syntax to use for encoding |
Definition at line 1015 of file dicom_file.cpp.
References kcenon::pacs::encoding::big_endian, and kcenon::pacs::encoding::implicit.
Referenced by to_bytes().

|
staticnodiscardprivate |
Encode a dataset using Explicit VR Big Endian.
| dataset | The dataset to encode |
Definition at line 934 of file dicom_file.cpp.
References kcenon::pacs::encoding::fixed_length(), kcenon::pacs::encoding::has_explicit_32bit_length(), kcenon::pacs::encoding::is_numeric_vr(), and kcenon::pacs::encoding::to_string().

|
staticnodiscardprivate |
Encode a dataset using Explicit VR Little Endian.
| dataset | The dataset to encode |
Definition at line 465 of file dicom_file.cpp.
References kcenon::pacs::encoding::has_explicit_32bit_length(), and kcenon::pacs::encoding::to_string().
Referenced by to_bytes().


|
staticnodiscardprivate |
Encode a dataset using Implicit VR Little Endian.
| dataset | The dataset to encode |
Definition at line 913 of file dicom_file.cpp.
|
staticnodiscard |
Parse a DICOM file from raw bytes.
| data | Raw byte data of the DICOM file |
Definition at line 166 of file dicom_file.cpp.
References kcenon::pacs::error_codes::invalid_dicom_file, kcenon::pacs::error_codes::missing_dicm_prefix, kcenon::pacs::error_codes::missing_transfer_syntax, kcenon::pacs::pacs_error(), kcenon::pacs::core::tags::transfer_syntax_uid, kcenon::pacs::error_codes::unsupported_transfer_syntax, and kcenon::pacs::error_codes::value_conversion_error.
Referenced by kcenon::pacs::storage::azure_blob_storage::find(), kcenon::pacs::storage::s3_storage::find(), kcenon::pacs::storage::azure_blob_storage::rebuild_index(), kcenon::pacs::storage::s3_storage::rebuild_index(), kcenon::pacs::web::dicomweb::render_dicom_image(), kcenon::pacs::storage::azure_blob_storage::retrieve_with_progress(), and kcenon::pacs::storage::s3_storage::retrieve_with_progress().


|
staticnodiscardprivate |
Generate File Meta Information for a dataset.
| dataset | The main dataset |
| ts | The transfer syntax |
Definition at line 412 of file dicom_file.cpp.
References kcenon::pacs::core::tags::file_meta_information_version, kcenon::pacs::core::tags::implementation_class_uid, kcenon::pacs::core::tags::implementation_version_name, kcenon::pacs::core::dicom_dataset::insert(), kcenon::pacs::core::tags::media_storage_sop_class_uid, kcenon::pacs::core::tags::media_storage_sop_instance_uid, kcenon::pacs::encoding::OB, kcenon::pacs::core::dicom_dataset::set_string(), kcenon::pacs::encoding::SH, kcenon::pacs::core::tags::sop_class_uid, kcenon::pacs::core::tags::sop_instance_uid, kcenon::pacs::core::tags::transfer_syntax_uid, and kcenon::pacs::encoding::UI.

|
nodiscardnoexcept |
Get read-only access to the File Meta Information.
Definition at line 292 of file dicom_file.cpp.
References meta_info_.
|
nodiscardnoexcept |
Get mutable access to the File Meta Information.
Definition at line 296 of file dicom_file.cpp.
References meta_info_.
|
staticnodiscard |
Open and read a DICOM file from disk.
| path | Path to the DICOM file |
Definition at line 149 of file dicom_file.cpp.
References kcenon::pacs::core::memory_mapped_file::open().
Referenced by kcenon::pacs::storage::file_storage::find(), kcenon::pacs::web::metadata_service::get_frame_info(), kcenon::pacs::web::metadata_service::get_sorted_instances(), kcenon::pacs::storage::file_storage::get_statistics(), kcenon::pacs::web::metadata_service::get_voi_lut(), kcenon::pacs::example::pacs_server_app::handle_retrieve(), kcenon::pacs::storage::file_storage::import_directory(), kcenon::pacs::web::metadata_service::read_dicom_tags(), kcenon::pacs::storage::file_storage::rebuild_index(), kcenon::pacs::storage::file_storage::retrieve(), kcenon::pacs::services::storage_scu::store_file(), and kcenon::pacs::storage::file_storage::verify_integrity().


|
default |
Copy assignment.
|
defaultnoexcept |
Move assignment.
|
staticnodiscardprivate |
Parse encapsulated pixel data frames.
| data | The raw encapsulated pixel data |
Definition at line 1119 of file dicom_file.cpp.
|
staticnodiscardprivate |
Parse file meta information from raw data.
| data | Raw byte data starting at the meta information |
| bytes_read | Output parameter for bytes consumed |
Definition at line 329 of file dicom_file.cpp.
References kcenon::pacs::error_codes::decode_error, kcenon::pacs::encoding::from_string(), kcenon::pacs::encoding::has_explicit_32bit_length(), kcenon::pacs::core::dicom_dataset::insert(), kcenon::pacs::pacs_error(), and vr.

|
staticnodiscardprivate |
Parse a sequence with undefined length.
| data | The raw byte data starting at sequence value |
| bytes_read | Output parameter for bytes consumed |
| explicit_vr | Whether to use explicit VR parsing |
| big_endian | Whether data is big endian |
Definition at line 1032 of file dicom_file.cpp.
|
nodiscard |
Save the DICOM file to disk.
| path | Destination file path |
Definition at line 243 of file dicom_file.cpp.
References kcenon::pacs::error_codes::file_write_error, and kcenon::pacs::pacs_void_error().

|
nodiscard |
Get the SOP Class UID.
Definition at line 317 of file dicom_file.cpp.
References dataset_, kcenon::pacs::core::dicom_dataset::get_string(), and kcenon::pacs::core::tags::sop_class_uid.

|
nodiscard |
Get the SOP Instance UID.
Definition at line 321 of file dicom_file.cpp.
References dataset_, kcenon::pacs::core::dicom_dataset::get_string(), and kcenon::pacs::core::tags::sop_instance_uid.

|
nodiscard |
Encode the DICOM file to raw bytes.
Definition at line 264 of file dicom_file.cpp.
References dataset_, encode_dataset(), encode_explicit_vr_le(), kDicmPrefix, kPreambleSize, meta_info_, and transfer_syntax().

|
nodiscard |
Get the Transfer Syntax of this file.
Definition at line 312 of file dicom_file.cpp.
References kcenon::pacs::core::dicom_dataset::get_string(), meta_info_, and kcenon::pacs::core::tags::transfer_syntax_uid.
Referenced by to_bytes().


|
private |
Main dataset (encoded per Transfer Syntax)
Definition at line 346 of file dicom_file.h.
Referenced by dataset(), dataset(), sop_class_uid(), sop_instance_uid(), and to_bytes().
|
staticconstexprprivate |
DICOM magic bytes.
Definition at line 356 of file dicom_file.h.
Referenced by to_bytes().
|
staticconstexprprivate |
Implementation Class UID for this library.
Definition at line 349 of file dicom_file.h.
|
staticconstexprprivate |
Implementation Version Name.
Definition at line 353 of file dicom_file.h.
|
staticconstexprprivate |
|
private |
File Meta Information (Group 0002)
Definition at line 343 of file dicom_file.h.
Referenced by meta_information(), meta_information(), to_bytes(), and transfer_syntax().