comparison Framework/Toolbox/DicomStructureSet.cpp @ 988:4c9b4c4de814 toa2019090901

Fixed bug in DicomStructureSet that prevented points from being added to polygons
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 09 Sep 2019 16:15:28 +0200
parents c20dbaab360c
children 1f74bc3459ba
comparison
equal deleted inserted replaced
987:d225bccd4d4a 988:4c9b4c4de814
147 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); 147 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
148 } 148 }
149 } 149 }
150 } 150 }
151 151
152 bool DicomStructureSet::Polygon::IsPointOnSlice(const Vector& v) const 152 bool DicomStructureSet::Polygon::IsPointOnSliceIfAny(const Vector& v) const
153 { 153 {
154 if (hasSlice_) 154 if (hasSlice_)
155 { 155 {
156 double magnitude = 156 double magnitude =
157 GeometryToolbox::ProjectAlongNormal(v, geometry_.GetNormal()); 157 GeometryToolbox::ProjectAlongNormal(v, geometry_.GetNormal());
169 } 169 }
170 return onSlice; 170 return onSlice;
171 } 171 }
172 else 172 else
173 { 173 {
174 return false; 174 return true;
175 } 175 }
176 } 176 }
177 177
178 void DicomStructureSet::Polygon::AddPoint(const Vector& v) 178 void DicomStructureSet::Polygon::AddPoint(const Vector& v)
179 { 179 {
180 #if 1 180 #if 1
181 // BGO 2019-09-03 181 // BGO 2019-09-03
182 if (IsPointOnSlice(v)) 182 if (IsPointOnSliceIfAny(v))
183 { 183 {
184 points_.push_back(v); 184 points_.push_back(v);
185 } 185 }
186 #else 186 #else
187 CheckPoint(v); 187 CheckPoint(v);
215 215
216 extent_.Reset(); 216 extent_.Reset();
217 217
218 for (Points::const_iterator it = points_.begin(); it != points_.end(); ++it) 218 for (Points::const_iterator it = points_.begin(); it != points_.end(); ++it)
219 { 219 {
220 if (IsPointOnSlice(*it)) 220 if (IsPointOnSliceIfAny(*it))
221 { 221 {
222 double x, y; 222 double x, y;
223 geometry.ProjectPoint(x, y, *it); 223 geometry.ProjectPoint(x, y, *it);
224 extent_.AddPoint(x, y); 224 extent_.AddPoint(x, y);
225 } 225 }