comparison Framework/Volumes/ImageBuffer3D.cpp @ 735:c3bbb130abc4

removing dependencies in ImageBuffer3D
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 21 May 2019 16:15:06 +0200
parents be3671662eec
children 32eaf4929b08
comparison
equal deleted inserted replaced
734:be3671662eec 735:c3bbb130abc4
19 **/ 19 **/
20 20
21 21
22 #include "ImageBuffer3D.h" 22 #include "ImageBuffer3D.h"
23 23
24 #include "../Toolbox/GeometryToolbox.h"
25
26 #include <Core/Images/ImageProcessing.h> 24 #include <Core/Images/ImageProcessing.h>
27 #include <Core/Logging.h> 25 #include <Core/Logging.h>
28 #include <Core/OrthancException.h> 26 #include <Core/OrthancException.h>
29 27
30 #include <string.h> 28 #include <string.h>
116 height_(height), 114 height_(height),
117 depth_(depth), 115 depth_(depth),
118 computeRange_(computeRange), 116 computeRange_(computeRange),
119 hasRange_(false) 117 hasRange_(false)
120 { 118 {
121 geometry_.SetSize(width, height, depth);
122
123 LOG(INFO) << "Created a 3D image of size " << width << "x" << height 119 LOG(INFO) << "Created a 3D image of size " << width << "x" << height
124 << "x" << depth << " in " << Orthanc::EnumerationToString(format) 120 << "x" << depth << " in " << Orthanc::EnumerationToString(format)
125 << " (" << (GetEstimatedMemorySize() / (1024ll * 1024ll)) << "MB)"; 121 << " (" << (GetEstimatedMemorySize() / (1024ll * 1024ll)) << "MB)";
126 } 122 }
127 123
128 124
129 void ImageBuffer3D::Clear() 125 void ImageBuffer3D::Clear()
130 { 126 {
131 memset(image_.GetBuffer(), 0, image_.GetHeight() * image_.GetPitch()); 127 memset(image_.GetBuffer(), 0, image_.GetHeight() * image_.GetPitch());
132 }
133
134
135
136
137 ParallelSlices* ImageBuffer3D::GetGeometry(VolumeProjection projection) const
138 {
139 const Vector dimensions = geometry_.GetVoxelDimensions(VolumeProjection_Axial);
140 const CoordinateSystem3D& axial = geometry_.GetAxialGeometry();
141
142 std::auto_ptr<ParallelSlices> result(new ParallelSlices);
143
144 switch (projection)
145 {
146 case VolumeProjection_Axial:
147 for (unsigned int z = 0; z < depth_; z++)
148 {
149 Vector origin = axial.GetOrigin();
150 origin += static_cast<double>(z) * dimensions[2] * axial.GetNormal();
151
152 result->AddSlice(origin,
153 axial.GetAxisX(),
154 axial.GetAxisY());
155 }
156 break;
157
158 case VolumeProjection_Coronal:
159 for (unsigned int y = 0; y < height_; y++)
160 {
161 Vector origin = axial.GetOrigin();
162 origin += static_cast<double>(y) * dimensions[1] * axial.GetAxisY();
163 origin += static_cast<double>(depth_ - 1) * dimensions[2] * axial.GetNormal();
164
165 result->AddSlice(origin,
166 axial.GetAxisX(),
167 -axial.GetNormal());
168 }
169 break;
170
171 case VolumeProjection_Sagittal:
172 for (unsigned int x = 0; x < width_; x++)
173 {
174 Vector origin = axial.GetOrigin();
175 origin += static_cast<double>(x) * dimensions[0] * axial.GetAxisX();
176 origin += static_cast<double>(depth_ - 1) * dimensions[2] * axial.GetNormal();
177
178 result->AddSlice(origin,
179 axial.GetAxisY(),
180 -axial.GetNormal());
181 }
182 break;
183
184 default:
185 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
186 }
187
188 return result.release();
189 } 128 }
190 129
191 130
192 uint64_t ImageBuffer3D::GetEstimatedMemorySize() const 131 uint64_t ImageBuffer3D::GetEstimatedMemorySize() const
193 { 132 {