Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Volumes/DicomVolumeImageReslicer.cpp @ 1771:f302bbddf94d
sync, trying to fix DicomVolumeImageReslicer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 12 May 2021 15:09:32 +0200 |
parents | 9ac2a65d4172 |
children | fca942f4b4a7 |
comparison
equal
deleted
inserted
replaced
1770:073484e33bee | 1771:f302bbddf94d |
---|---|
58 if (configurator == NULL) | 58 if (configurator == NULL) |
59 { | 59 { |
60 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, | 60 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, |
61 "Must provide a layer style configurator"); | 61 "Must provide a layer style configurator"); |
62 } | 62 } |
63 | 63 |
64 reslicer.SetOutputFormat(that_.volume_->GetPixelData().GetFormat()); | 64 reslicer.SetOutputFormat(that_.volume_->GetPixelData().GetFormat()); |
65 reslicer.Apply(that_.volume_->GetPixelData(), | 65 reslicer.Apply(that_.volume_->GetPixelData(), |
66 that_.volume_->GetGeometry(), | 66 that_.volume_->GetGeometry(), |
67 cuttingPlane); | 67 cuttingPlane); |
68 | 68 |
69 if (reslicer.IsSuccess()) | 69 if (reslicer.IsSuccess()) |
70 { | 70 { |
71 std::unique_ptr<TextureBaseSceneLayer> layer | 71 std::unique_ptr<TextureBaseSceneLayer> texture |
72 (configurator->CreateTextureFromDicom(reslicer.GetOutputSlice(), | 72 (configurator->CreateTextureFromDicom(reslicer.GetOutputSlice(), |
73 that_.volume_->GetDicomParameters())); | 73 that_.volume_->GetDicomParameters())); |
74 if (layer.get() == NULL) | 74 if (texture.get() == NULL) |
75 { | 75 { |
76 return NULL; | 76 return NULL; |
77 } | 77 } |
78 | 78 |
79 double s = reslicer.GetPixelSpacing(); | 79 const double s = reslicer.GetPixelSpacing(); |
80 layer->SetPixelSpacing(s, s); | 80 |
81 layer->SetOrigin(reslicer.GetOutputExtent().GetX1() + 0.5 * s, | 81 #if 1 |
82 reslicer.GetOutputExtent().GetY1() + 0.5 * s); | 82 const double x1 = reslicer.GetOutputExtent().GetX1(); |
83 //const double x2 = reslicer.GetOutputExtent().GetX2(); | |
84 const double y1 = reslicer.GetOutputExtent().GetY1(); | |
85 const double y2 = reslicer.GetOutputExtent().GetY2(); | |
86 | |
87 const Vector p1 = cuttingPlane.MapSliceToWorldCoordinates(x1, y1); | |
88 const Vector p2 = cuttingPlane.MapSliceToWorldCoordinates(x1, y2); | |
89 | |
90 if (1) | |
91 { | |
92 texture->SetCuttingPlaneTransform(cuttingPlane, p1, | |
93 s * cuttingPlane.GetAxisX(), | |
94 s * cuttingPlane.GetAxisY()); | |
95 } | |
96 else | |
97 { | |
98 /** | |
99 * TODO - ONE WAS TO SOMETIMES FLIP the Y axis. Is it also | |
100 * possible for the X axis? | |
101 **/ | |
102 | |
103 texture->SetCuttingPlaneTransform(cuttingPlane, p2, | |
104 s * cuttingPlane.GetAxisX(), | |
105 -s * cuttingPlane.GetAxisY()); | |
106 } | |
107 | |
108 #else | |
109 texture->SetPixelSpacing(s, s); | |
110 texture->SetOrigin(reslicer.GetOutputExtent().GetX1() + 0.5 * s, | |
111 reslicer.GetOutputExtent().GetY1() + 0.5 * s); | |
112 //texture->SetFlipY(true); | |
83 | 113 |
84 // TODO - Angle!! | 114 // TODO - Angle!! |
115 #endif | |
85 | 116 |
86 return layer.release(); | 117 return texture.release(); |
87 } | 118 } |
88 else | 119 else |
89 { | 120 { |
90 return NULL; | 121 return NULL; |
91 } | 122 } |