Mercurial > hg > orthanc-stone
comparison Framework/Loaders/DicomStructureSetLoader2.cpp @ 998:38b6bb0bdd72
added a new set of classes that correctly handle non-convex polygons (not
used yet because of limitations in coordinates computing): DicomStructure2,
DicomStructureSet2, DicomStructurePolygon2, DicomStructureSetSlicer2. Too
many shortcuts have been taken when computing the actual position.
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Fri, 20 Sep 2019 11:58:00 +0200 |
parents | d225bccd4d4a |
children | 29f5f2031310 |
comparison
equal
deleted
inserted
replaced
995:9893fa8cd7a6 | 998:38b6bb0bdd72 |
---|---|
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 #include "DicomStructureSetLoader2.h" | |
22 | |
23 #include "../Messages/IObservable.h" | |
24 #include "../Oracle/IOracle.h" | |
25 #include "../Oracle/OracleCommandExceptionMessage.h" | |
26 | |
27 namespace OrthancStone | |
28 { | |
29 | |
30 DicomStructureSetLoader2::DicomStructureSetLoader2( | |
31 DicomStructureSet2& structureSet | |
32 , IOracle& oracle | |
33 , IObservable& oracleObservable) | |
34 : IObserver(oracleObservable.GetBroker()) | |
35 , IObservable(oracleObservable.GetBroker()) | |
36 , structureSet_(structureSet) | |
37 , oracle_(oracle) | |
38 , oracleObservable_(oracleObservable) | |
39 , structuresReady_(false) | |
40 { | |
41 LOG(TRACE) << "DicomStructureSetLoader2(" << std::hex << this << std::dec << ")::DicomStructureSetLoader2()"; | |
42 | |
43 oracleObservable.RegisterObserverCallback( | |
44 new Callable<DicomStructureSetLoader2, OrthancRestApiCommand::SuccessMessage> | |
45 (*this, &DicomStructureSetLoader2::HandleSuccessMessage)); | |
46 | |
47 oracleObservable.RegisterObserverCallback( | |
48 new Callable<DicomStructureSetLoader2, OracleCommandExceptionMessage> | |
49 (*this, &DicomStructureSetLoader2::HandleExceptionMessage)); | |
50 } | |
51 | |
52 DicomStructureSetLoader2::~DicomStructureSetLoader2() | |
53 { | |
54 LOG(TRACE) << "DicomStructureSetLoader2(" << std::hex << this << std::dec << ")::~DicomStructureSetLoader2()"; | |
55 oracleObservable_.Unregister(this); | |
56 } | |
57 | |
58 void DicomStructureSetLoader2::LoadInstanceFromString(const std::string& body) | |
59 { | |
60 OrthancPlugins::FullOrthancDataset dicom(body); | |
61 //loader.content_.reset(new DicomStructureSet(dicom)); | |
62 structureSet_.Clear(); | |
63 structureSet_.SetContents(dicom); | |
64 SetStructuresReady(); | |
65 } | |
66 | |
67 void DicomStructureSetLoader2::HandleSuccessMessage(const OrthancRestApiCommand::SuccessMessage& message) | |
68 { | |
69 const std::string& body = message.GetAnswer(); | |
70 LoadInstanceFromString(body); | |
71 } | |
72 | |
73 void DicomStructureSetLoader2::HandleExceptionMessage(const OracleCommandExceptionMessage& message) | |
74 { | |
75 LOG(ERROR) << "DicomStructureSetLoader2::HandleExceptionMessage: error when trying to load data. " | |
76 << "Error: " << message.GetException().What() << " Details: " | |
77 << message.GetException().GetDetails(); | |
78 } | |
79 | |
80 void DicomStructureSetLoader2::LoadInstance(const std::string& instanceId) | |
81 { | |
82 std::auto_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand); | |
83 command->SetHttpHeader("Accept-Encoding", "gzip"); | |
84 | |
85 std::string uri = "/instances/" + instanceId + "/tags?ignore-length=3006-0050"; | |
86 | |
87 command->SetUri(uri); | |
88 oracle_.Schedule(*this, command.release()); | |
89 } | |
90 | |
91 void DicomStructureSetLoader2::SetStructuresReady() | |
92 { | |
93 structuresReady_ = true; | |
94 } | |
95 | |
96 bool DicomStructureSetLoader2::AreStructuresReady() const | |
97 { | |
98 return structuresReady_; | |
99 } | |
100 | |
101 /* | |
102 | |
103 void LoaderStateMachine::HandleExceptionMessage(const OracleCommandExceptionMessage& message) | |
104 { | |
105 LOG(ERROR) << "LoaderStateMachine::HandleExceptionMessage: error in the state machine, stopping all processing"; | |
106 LOG(ERROR) << "Error: " << message.GetException().What() << " Details: " << | |
107 message.GetException().GetDetails(); | |
108 Clear(); | |
109 } | |
110 | |
111 LoaderStateMachine::~LoaderStateMachine() | |
112 { | |
113 Clear(); | |
114 } | |
115 | |
116 | |
117 */ | |
118 | |
119 } |