comparison Framework/Algorithms/ReconstructPyramidCommand.cpp @ 199:a1c265cb2174

replacing deprecated std::auto_ptr by std::unique_ptr
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 06 Jul 2020 16:29:41 +0200
parents f299c191cd76
children 1e864138f0da
comparison
equal deleted inserted replaced
198:2d3fe6967894 199:a1c265cb2174
21 21
22 #include "../PrecompiledHeadersWSI.h" 22 #include "../PrecompiledHeadersWSI.h"
23 #include "ReconstructPyramidCommand.h" 23 #include "ReconstructPyramidCommand.h"
24 24
25 #include "../ImageToolbox.h" 25 #include "../ImageToolbox.h"
26
27 #include <Compatibility.h> // For std::unique_ptr
26 #include <Logging.h> 28 #include <Logging.h>
27 #include <OrthancException.h> 29 #include <OrthancException.h>
28 #include <Images/Image.h> 30 #include <Images/Image.h>
29 31
30 #include <cassert> 32 #include <cassert>
44 y >= target_.GetCountTilesY(level + shiftTargetLevel_)) 46 y >= target_.GetCountTilesY(level + shiftTargetLevel_))
45 { 47 {
46 return NULL; 48 return NULL;
47 } 49 }
48 50
49 std::auto_ptr<Orthanc::ImageAccessor> result; 51 std::unique_ptr<Orthanc::ImageAccessor> result;
50 52
51 if (level == 0) 53 if (level == 0)
52 { 54 {
53 result.reset(new Orthanc::ImageAccessor); 55 result.reset(new Orthanc::ImageAccessor);
54 source_.GetDecodedTile(*result, x, y); 56 source_.GetDecodedTile(*result, x, y);
67 target_.EncodeTile(*result, level + shiftTargetLevel_, x, y); 69 target_.EncodeTile(*result, level + shiftTargetLevel_, x, y);
68 } 70 }
69 } 71 }
70 else 72 else
71 { 73 {
72 std::auto_ptr<Orthanc::ImageAccessor> mosaic(ImageToolbox::Allocate(source_.GetPixelFormat(), 74 std::unique_ptr<Orthanc::ImageAccessor> mosaic(ImageToolbox::Allocate(source_.GetPixelFormat(),
73 2 * target_.GetTileWidth(), 75 2 * target_.GetTileWidth(),
74 2 * target_.GetTileHeight())); 76 2 * target_.GetTileHeight()));
75 ImageToolbox::Set(*mosaic, 77 ImageToolbox::Set(*mosaic,
76 source_.GetParameters().GetBackgroundColorRed(), 78 source_.GetParameters().GetBackgroundColorRed(),
77 source_.GetParameters().GetBackgroundColorGreen(), 79 source_.GetParameters().GetBackgroundColorGreen(),
78 source_.GetParameters().GetBackgroundColorBlue()); 80 source_.GetParameters().GetBackgroundColorBlue());
79 81
80 { 82 {
81 std::auto_ptr<Orthanc::ImageAccessor> subTile(Explore(level - 1, 2 * offsetX, 2 * offsetY)); 83 std::unique_ptr<Orthanc::ImageAccessor> subTile(Explore(level - 1, 2 * offsetX, 2 * offsetY));
82 if (subTile.get() != NULL) 84 if (subTile.get() != NULL)
83 { 85 {
84 ImageToolbox::Embed(*mosaic, *subTile, 0, 0); 86 ImageToolbox::Embed(*mosaic, *subTile, 0, 0);
85 } 87 }
86 } 88 }
87 89
88 { 90 {
89 std::auto_ptr<Orthanc::ImageAccessor> subTile(Explore(level - 1, 2 * offsetX + 1, 2 * offsetY)); 91 std::unique_ptr<Orthanc::ImageAccessor> subTile(Explore(level - 1, 2 * offsetX + 1, 2 * offsetY));
90 if (subTile.get() != NULL) 92 if (subTile.get() != NULL)
91 { 93 {
92 ImageToolbox::Embed(*mosaic, *subTile, target_.GetTileWidth(), 0); 94 ImageToolbox::Embed(*mosaic, *subTile, target_.GetTileWidth(), 0);
93 } 95 }
94 } 96 }
95 97
96 { 98 {
97 std::auto_ptr<Orthanc::ImageAccessor> subTile(Explore(level - 1, 2 * offsetX, 2 * offsetY + 1)); 99 std::unique_ptr<Orthanc::ImageAccessor> subTile(Explore(level - 1, 2 * offsetX, 2 * offsetY + 1));
98 if (subTile.get() != NULL) 100 if (subTile.get() != NULL)
99 { 101 {
100 ImageToolbox::Embed(*mosaic, *subTile, 0, target_.GetTileHeight()); 102 ImageToolbox::Embed(*mosaic, *subTile, 0, target_.GetTileHeight());
101 } 103 }
102 } 104 }
103 105
104 { 106 {
105 std::auto_ptr<Orthanc::ImageAccessor> subTile(Explore(level - 1, 2 * offsetX + 1, 2 * offsetY + 1)); 107 std::unique_ptr<Orthanc::ImageAccessor> subTile(Explore(level - 1, 2 * offsetX + 1, 2 * offsetY + 1));
106 if (subTile.get() != NULL) 108 if (subTile.get() != NULL)
107 { 109 {
108 ImageToolbox::Embed(*mosaic, *subTile, target_.GetTileWidth(), target_.GetTileHeight()); 110 ImageToolbox::Embed(*mosaic, *subTile, target_.GetTileWidth(), target_.GetTileHeight());
109 } 111 }
110 } 112 }
145 } 147 }
146 148
147 149
148 bool ReconstructPyramidCommand::Execute() 150 bool ReconstructPyramidCommand::Execute()
149 { 151 {
150 std::auto_ptr<Orthanc::ImageAccessor> root(Explore(upToLevel_, 0, 0)); 152 std::unique_ptr<Orthanc::ImageAccessor> root(Explore(upToLevel_, 0, 0));
151 return true; 153 return true;
152 } 154 }
153 155
154 156
155 void ReconstructPyramidCommand::PrepareBagOfTasks(Orthanc::BagOfTasks& tasks, 157 void ReconstructPyramidCommand::PrepareBagOfTasks(Orthanc::BagOfTasks& tasks,
175 177
176 for (unsigned int y = 0; y < targetCountTilesY; y += step) 178 for (unsigned int y = 0; y < targetCountTilesY; y += step)
177 { 179 {
178 for (unsigned int x = 0; x < targetCountTilesX; x += step) 180 for (unsigned int x = 0; x < targetCountTilesX; x += step)
179 { 181 {
180 std::auto_ptr<ReconstructPyramidCommand> command; 182 std::unique_ptr<ReconstructPyramidCommand> command;
181 command.reset(new ReconstructPyramidCommand 183 command.reset(new ReconstructPyramidCommand
182 (target, source, countLevels - 1, x, y, parameters)); 184 (target, source, countLevels - 1, x, y, parameters));
183 command->SetShiftTargetLevel(shiftTargetLevel); 185 command->SetShiftTargetLevel(shiftTargetLevel);
184 tasks.Push(command.release()); 186 tasks.Push(command.release());
185 } 187 }