Mercurial > hg > orthanc-stone
annotate Framework/Oracle/ParseDicomFileCommand.cpp @ 1145:4f99c7905f8d broker
mingw qt
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 12 Nov 2019 18:28:46 +0100 |
parents | a0a33e5ea5bb |
children |
rev | line source |
---|---|
1110 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium | |
6 * | |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #include "ParseDicomFileCommand.h" | |
23 | |
1111
3730956f41a5
ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1110
diff
changeset
|
24 #include <Core/OrthancException.h> |
3730956f41a5
ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1110
diff
changeset
|
25 |
3730956f41a5
ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1110
diff
changeset
|
26 #include <boost/filesystem/path.hpp> |
3730956f41a5
ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1110
diff
changeset
|
27 |
1110 | 28 namespace OrthancStone |
29 { | |
1135
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
30 ParseDicomFileCommand::SuccessMessage::SuccessMessage(const ParseDicomFileCommand& command, |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1124
diff
changeset
|
31 Orthanc::ParsedDicomFile& dicom, |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1124
diff
changeset
|
32 size_t fileSize, |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1124
diff
changeset
|
33 bool hasPixelData) : |
1135
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
34 OriginMessage(command), |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1124
diff
changeset
|
35 dicom_(dicom), |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1124
diff
changeset
|
36 fileSize_(fileSize), |
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1124
diff
changeset
|
37 hasPixelData_(hasPixelData) |
1110 | 38 { |
1134
87fbeb823375
allocating messages from oracle commands on the stack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1124
diff
changeset
|
39 if (!dicom.GetTagValue(sopInstanceUid_, Orthanc::DICOM_TAG_SOP_INSTANCE_UID)) |
1111
3730956f41a5
ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1110
diff
changeset
|
40 { |
1116
a08699daf78b
ParsedDicomFileCache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1111
diff
changeset
|
41 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat, |
a08699daf78b
ParsedDicomFileCache
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1111
diff
changeset
|
42 "DICOM instance missing tag SOPInstanceUID"); |
1111
3730956f41a5
ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1110
diff
changeset
|
43 } |
3730956f41a5
ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1110
diff
changeset
|
44 } |
3730956f41a5
ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1110
diff
changeset
|
45 |
3730956f41a5
ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1110
diff
changeset
|
46 |
3730956f41a5
ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1110
diff
changeset
|
47 std::string ParseDicomFileCommand::GetDicomDirPath(const std::string& dicomDirPath, |
3730956f41a5
ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1110
diff
changeset
|
48 const std::string& file) |
3730956f41a5
ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1110
diff
changeset
|
49 { |
3730956f41a5
ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1110
diff
changeset
|
50 std::string tmp = file; |
3730956f41a5
ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1110
diff
changeset
|
51 |
3730956f41a5
ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1110
diff
changeset
|
52 #if !defined(_WIN32) |
3730956f41a5
ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1110
diff
changeset
|
53 std::replace(tmp.begin(), tmp.end(), '\\', '/'); |
3730956f41a5
ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1110
diff
changeset
|
54 #endif |
3730956f41a5
ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1110
diff
changeset
|
55 |
3730956f41a5
ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1110
diff
changeset
|
56 boost::filesystem::path base = boost::filesystem::path(dicomDirPath).parent_path(); |
3730956f41a5
ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1110
diff
changeset
|
57 |
3730956f41a5
ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1110
diff
changeset
|
58 return (base / tmp).string(); |
3730956f41a5
ParseDicomFileCommand::GetDicomDirPath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1110
diff
changeset
|
59 } |
1110 | 60 } |