PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
generate_test_data.cpp
Go to the documentation of this file.
1
19#include "test_fixtures.h"
21
22#include <filesystem>
23#include <iostream>
24
25namespace {
26
27using namespace kcenon::pacs::integration_test;
28using namespace kcenon::pacs::core;
29
33bool save_dataset(
34 const dicom_dataset& ds,
35 const std::filesystem::path& path) {
36
37 // Create DICOM file with Explicit VR Little Endian transfer syntax
38 auto file = dicom_file::create(
39 dicom_dataset{ds}, // Copy the dataset
41
42 auto result = file.save(path);
43 if (result.is_err()) {
44 std::cerr << "Failed to save " << path << ": "
45 << result.error().message << "\n";
46 return false;
47 }
48
49 std::cout << " Created: " << path.filename() << " ("
50 << std::filesystem::file_size(path) << " bytes)\n";
51 return true;
52}
53
57bool generate_all(const std::filesystem::path& output_dir) {
58 std::cout << "\nGenerating test DICOM files in: " << output_dir << "\n\n";
59
60 // Create output directory if it doesn't exist
61 if (!std::filesystem::exists(output_dir)) {
62 std::filesystem::create_directories(output_dir);
63 }
64
65 bool success = true;
66
67 // Generate CT dataset
68 std::cout << "Generating CT image...\n";
69 auto ct_ds = generate_ct_dataset();
70 if (!save_dataset(ct_ds, output_dir / "ct_minimal.dcm")) {
71 success = false;
72 }
73
74 // Generate MR dataset
75 std::cout << "Generating MR image...\n";
76 auto mr_ds = generate_mr_dataset();
77 if (!save_dataset(mr_ds, output_dir / "mr_minimal.dcm")) {
78 success = false;
79 }
80
81 // Generate XA dataset
82 std::cout << "Generating XA image...\n";
83 auto xa_ds = generate_xa_dataset();
84 if (!save_dataset(xa_ds, output_dir / "xa_minimal.dcm")) {
85 success = false;
86 }
87
88 return success;
89}
90
91} // namespace
92
93int main(int argc, char* argv[]) {
94 std::cout << R"(
95 ____ ___ ____ ___ __ __ _____ _
96 | _ \|_ _/ ___/ _ \| \/ | |_ _|__ ___| |_
97 | | | || | | | | | | |\/| | | |/ _ \/ __| __|
98 | |_| || | |__| |_| | | | | | | __/\__ \ |_
99 |____/|___\____\___/|_| |_| |_|\___||___/\__|
100
101 Data Generator for Integration Tests
102)" << "\n";
103
104 // Determine output directory
105 std::filesystem::path output_dir;
106
107 if (argc > 1) {
108 output_dir = argv[1];
109 } else {
110 // Default: test_data directory relative to executable
111 output_dir = std::filesystem::path(argv[0]).parent_path() / ".." / ".." /
112 "examples" / "integration_tests" / "test_data";
113 }
114
115 if (!generate_all(output_dir)) {
116 std::cerr << "\nSome files failed to generate\n";
117 return 1;
118 }
119
120 std::cout << "\nAll test data files generated successfully!\n";
121 std::cout << "\nFiles can be used with binary integration tests:\n";
122 std::cout << " ./test_store_retrieve.sh\n";
123 std::cout << " store_scu localhost 11112 PACS_SCP " << output_dir / "ct_minimal.dcm" << "\n";
124
125 return 0;
126}
static const transfer_syntax explicit_vr_little_endian
Explicit VR Little Endian (1.2.840.10008.1.2.1)
DICOM Part 10 file handling for reading/writing DICOM files.
int main()
Definition main.cpp:84
core::dicom_dataset generate_mr_dataset(const std::string &study_uid="")
Generate a MR image dataset for testing.
core::dicom_dataset generate_ct_dataset(const std::string &study_uid="", const std::string &series_uid="", const std::string &instance_uid="")
Generate a minimal CT image dataset for testing.
core::dicom_dataset generate_xa_dataset(const std::string &study_uid="")
Generate a XA (X-Ray Angiographic) image dataset for testing.
Common test fixtures and utilities for integration tests.