Directory: | ./ |
---|---|
File: | libs/io/dicom/helper/functions.cpp |
Date: | 2024-04-26 11:06:17 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 16 | 16 | 100.0% |
Branches: | 11 | 22 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /************************************************************************ | ||
2 | * | ||
3 | * Copyright (C) 2009-2023 IRCAD France | ||
4 | * Copyright (C) 2012-2019 IHU Strasbourg | ||
5 | * | ||
6 | * This file is part of Sight. | ||
7 | * | ||
8 | * Sight is free software: you can redistribute it and/or modify it under | ||
9 | * the terms of the GNU Lesser General Public License as published by | ||
10 | * the Free Software Foundation, either version 3 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * Sight is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU Lesser General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU Lesser General Public | ||
19 | * License along with Sight. If not, see <https://www.gnu.org/licenses/>. | ||
20 | * | ||
21 | ***********************************************************************/ | ||
22 | |||
23 | #include "io/dicom/helper/functions.hpp" | ||
24 | |||
25 | #include <boost/date_time/posix_time/posix_time.hpp> | ||
26 | |||
27 | #include <gdcmUIDGenerator.h> | ||
28 | |||
29 | #include <sstream> | ||
30 | #include <string> | ||
31 | |||
32 | namespace sight::io::dicom::helper | ||
33 | { | ||
34 | |||
35 | //------------------------------------------------------------------------------ | ||
36 | |||
37 | 1 | std::string generate_patient_id() | |
38 | { | ||
39 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | gdcm::UIDGenerator uid; |
40 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | const char* id = uid.Generate(); |
41 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | return {id}; |
42 | 1 | } | |
43 | |||
44 | //------------------------------------------------------------------------------ | ||
45 | |||
46 | 1 | std::string generate_study_instance_uid() | |
47 | { | ||
48 | 1 | using boost::posix_time::ptime; | |
49 | 1 | using boost::posix_time::microsec_clock; | |
50 | 1 | using boost::posix_time::time_facet; | |
51 | |||
52 | 1 | ptime now = microsec_clock::local_time(); | |
53 |
4/8✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
|
1 | auto* facet = new time_facet("%f%S%M%H%d%m"); |
54 | |||
55 | 1 | std::stringstream ss; | |
56 | // facet ownership is given to the std::locale | ||
57 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
1 | ss.imbue(std::locale(ss.getloc(), facet)); |
58 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | ss << now; |
59 | |||
60 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return ss.str(); |
61 | 1 | } | |
62 | |||
63 | } // namespace sight::io::dicom::helper | ||
64 |