Mercurial > hg > orthanc-stone
comparison Applications/Samples/SingleVolumeApplication.h @ 117:42c05a3baee3 wasm
loading multi-frame instances as 3D volumes
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 28 Sep 2017 16:55:51 +0200 |
parents | 4c5f7cda8624 |
children | ba83e38cf3ff |
comparison
equal
deleted
inserted
replaced
116:4c5f7cda8624 | 117:42c05a3baee3 |
---|---|
43 { | 43 { |
44 boost::program_options::options_description generic("Sample options"); | 44 boost::program_options::options_description generic("Sample options"); |
45 generic.add_options() | 45 generic.add_options() |
46 ("series", boost::program_options::value<std::string>(), | 46 ("series", boost::program_options::value<std::string>(), |
47 "Orthanc ID of the series") | 47 "Orthanc ID of the series") |
48 ("instance", boost::program_options::value<std::string>(), | |
49 "Orthanc ID of a multi-frame instance that describes a 3D volume") | |
48 ("threads", boost::program_options::value<unsigned int>()->default_value(3), | 50 ("threads", boost::program_options::value<unsigned int>()->default_value(3), |
49 "Number of download threads") | 51 "Number of download threads") |
50 ("projection", boost::program_options::value<std::string>()->default_value("axial"), | 52 ("projection", boost::program_options::value<std::string>()->default_value("axial"), |
51 "Projection of interest (can be axial, sagittal or coronal)") | 53 "Projection of interest (can be axial, sagittal or coronal)") |
52 ("reverse", boost::program_options::value<bool>()->default_value(false), | 54 ("reverse", boost::program_options::value<bool>()->default_value(false), |
60 IStatusBar& statusBar, | 62 IStatusBar& statusBar, |
61 const boost::program_options::variables_map& parameters) | 63 const boost::program_options::variables_map& parameters) |
62 { | 64 { |
63 using namespace OrthancStone; | 65 using namespace OrthancStone; |
64 | 66 |
65 if (parameters.count("series") != 1) | 67 if (parameters.count("series") > 1 || |
68 parameters.count("instance") > 1) | |
66 { | 69 { |
67 LOG(ERROR) << "The series ID is missing"; | 70 LOG(ERROR) << "Only one series or instance is allowed"; |
68 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | 71 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
69 } | 72 } |
70 | 73 |
71 std::string series = parameters["series"].as<std::string>(); | 74 if (parameters.count("series") == 1 && |
75 parameters.count("instance") == 1) | |
76 { | |
77 LOG(ERROR) << "Cannot specify both a series and an instance"; | |
78 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
79 } | |
80 | |
81 std::string series; | |
82 if (parameters.count("series") == 1) | |
83 { | |
84 series = parameters["series"].as<std::string>(); | |
85 } | |
86 | |
87 std::string instance; | |
88 if (parameters.count("instance") == 1) | |
89 { | |
90 instance = parameters["instance"].as<std::string>(); | |
91 } | |
92 | |
93 if (series.empty() && | |
94 instance.empty()) | |
95 { | |
96 LOG(ERROR) << "The series ID or instance ID is missing"; | |
97 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
98 } | |
99 | |
72 unsigned int threads = parameters["threads"].as<unsigned int>(); | 100 unsigned int threads = parameters["threads"].as<unsigned int>(); |
73 bool reverse = parameters["reverse"].as<bool>(); | 101 bool reverse = parameters["reverse"].as<bool>(); |
74 | 102 |
75 std::string tmp = parameters["projection"].as<std::string>(); | 103 std::string tmp = parameters["projection"].as<std::string>(); |
76 Orthanc::Toolbox::ToLowerCase(tmp); | 104 Orthanc::Toolbox::ToLowerCase(tmp); |
96 | 124 |
97 std::auto_ptr<LayerWidget> widget(new LayerWidget); | 125 std::auto_ptr<LayerWidget> widget(new LayerWidget); |
98 | 126 |
99 #if 1 | 127 #if 1 |
100 std::auto_ptr<OrthancVolumeImage> volume(new OrthancVolumeImage(context.GetWebService())); | 128 std::auto_ptr<OrthancVolumeImage> volume(new OrthancVolumeImage(context.GetWebService())); |
101 volume->ScheduleLoadSeries(series); | 129 if (series.empty()) |
130 { | |
131 volume->ScheduleLoadInstance(instance); | |
132 } | |
133 else | |
134 { | |
135 volume->ScheduleLoadSeries(series); | |
136 } | |
102 | 137 |
103 widget->AddLayer(new VolumeImageSource(*volume)); | 138 widget->AddLayer(new VolumeImageSource(*volume)); |
104 | 139 |
105 context.AddInteractor(new VolumeImageInteractor(*volume, *widget, projection)); | 140 context.AddInteractor(new VolumeImageInteractor(*volume, *widget, projection)); |
106 context.AddVolume(volume.release()); | 141 context.AddVolume(volume.release()); |