Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Toolbox/DicomStructurePolygon2.cpp @ 1895:14c8f339d480
removed redundant definitions Point2D, Point3D and Vector3D from DicomStructureSetUtils.h
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 19 Jan 2022 14:51:55 +0100 |
parents | 7053b8a0aaec |
children |
comparison
equal
deleted
inserted
replaced
1894:438071a29f77 | 1895:14c8f339d480 |
---|---|
35 ORTHANC_ASSERT(state_ == Building); | 35 ORTHANC_ASSERT(state_ == Building); |
36 | 36 |
37 for (size_t j = 0; j < points_.size(); ++j) | 37 for (size_t j = 0; j < points_.size(); ++j) |
38 { | 38 { |
39 // TODO: move to AddPoint! | 39 // TODO: move to AddPoint! |
40 const Point3D& p = points_[j]; | 40 const Vector& p = points_[j]; |
41 if (p[0] < minX_) | 41 if (p[0] < minX_) |
42 minX_ = p[0]; | 42 minX_ = p[0]; |
43 if (p[0] > maxX_) | 43 if (p[0] > maxX_) |
44 maxX_ = p[0]; | 44 maxX_ = p[0]; |
45 | 45 |
81 state_ = Valid; | 81 state_ = Valid; |
82 } | 82 } |
83 | 83 |
84 | 84 |
85 void DicomStructurePolygon2::ProjectOnConstantPlane( | 85 void DicomStructurePolygon2::ProjectOnConstantPlane( |
86 std::vector<Point2D>& intersections, const CoordinateSystem3D& plane) const | 86 std::vector<ScenePoint2D>& intersections, const CoordinateSystem3D& plane) const |
87 { | 87 { |
88 // the plane can either have constant X, or constant Y. | 88 // the plane can either have constant X, or constant Y. |
89 // - for constant Z planes, use the ProjectOnParallelPlane method | 89 // - for constant Z planes, use the ProjectOnParallelPlane method |
90 // - other type of planes are not supported | 90 // - other type of planes are not supported |
91 | 91 |
175 if (LinearAlgebra::IsNear(v1, v2)) | 175 if (LinearAlgebra::IsNear(v1, v2)) |
176 { | 176 { |
177 // in that case, we choose to label both points as an intersection | 177 // in that case, we choose to label both points as an intersection |
178 double x, y; | 178 double x, y; |
179 plane.ProjectPoint(x, y, points_[iPoint]); | 179 plane.ProjectPoint(x, y, points_[iPoint]); |
180 intersections.push_back(Point2D(x, y)); | 180 intersections.push_back(ScenePoint2D(x, y)); |
181 | 181 |
182 plane.ProjectPoint(x, y, points_[iPoint + 1]); | 182 plane.ProjectPoint(x, y, points_[iPoint + 1]); |
183 intersections.push_back(Point2D(x, y)); | 183 intersections.push_back(ScenePoint2D(x, y)); |
184 } | 184 } |
185 else | 185 else |
186 { | 186 { |
187 // we are looking for u so that (u,planeV) belongs to the segment | 187 // we are looking for u so that (u,planeV) belongs to the segment |
188 // let's define alpha = (u-u2)/(u1-u2) --> u = alpha*(u1-u2) + u2 | 188 // let's define alpha = (u-u2)/(u1-u2) --> u = alpha*(u1-u2) + u2 |
233 // TODO: same hypothesis as above: plane is perpendicular to polygons, | 233 // TODO: same hypothesis as above: plane is perpendicular to polygons, |
234 // plane is parallel to the XZ (constant Y) or YZ (constant X) 3D planes | 234 // plane is parallel to the XZ (constant Y) or YZ (constant X) 3D planes |
235 for (size_t i = 0; i < uIntersections.size(); ++i) | 235 for (size_t i = 0; i < uIntersections.size(); ++i) |
236 { | 236 { |
237 double x = uIntersections[i]; | 237 double x = uIntersections[i]; |
238 intersections.push_back(Point2D(x, minZ_)); | 238 intersections.push_back(ScenePoint2D(x, minZ_)); |
239 } | 239 } |
240 } // end of if (pointCount >= 3) | 240 } // end of if (pointCount >= 3) |
241 else | 241 else |
242 { | 242 { |
243 LOG(ERROR) << "This polygon has " << pointCount << " vertices, which is less than 3 --> skipping"; | 243 LOG(ERROR) << "This polygon has " << pointCount << " vertices, which is less than 3 --> skipping"; |
244 } | 244 } |
245 } | 245 } |
246 | 246 |
247 void DicomStructurePolygon2::ProjectOnParallelPlane( | 247 void DicomStructurePolygon2::ProjectOnParallelPlane( |
248 std::vector< std::pair<Point2D, Point2D> >& segments, | 248 std::vector< std::pair<ScenePoint2D, ScenePoint2D> >& segments, |
249 const CoordinateSystem3D& plane) const | 249 const CoordinateSystem3D& plane) const |
250 { | 250 { |
251 if (points_.size() < 3) | 251 if (points_.size() < 3) |
252 return; | 252 return; |
253 | 253 |
266 // precondition: points_.size() >= 3 | 266 // precondition: points_.size() >= 3 |
267 for (size_t j = 0; j < points_.size()-1; ++j) | 267 for (size_t j = 0; j < points_.size()-1; ++j) |
268 { | 268 { |
269 // segment between point j and j+1 | 269 // segment between point j and j+1 |
270 | 270 |
271 const Point3D& point0 = GetPoint(j); | 271 const Vector& point0 = GetPoint(j); |
272 // subtract plane origin x and y | 272 // subtract plane origin x and y |
273 Point2D p0(point0[0] - planeOriginX, point0[1] - planeOriginY); | 273 ScenePoint2D p0(point0[0] - planeOriginX, point0[1] - planeOriginY); |
274 | 274 |
275 const Point3D& point1 = GetPoint(j+1); | 275 const Vector& point1 = GetPoint(j+1); |
276 // subtract plane origin x and y | 276 // subtract plane origin x and y |
277 Point2D p1(point1[0] - planeOriginX, point1[1] - planeOriginY); | 277 ScenePoint2D p1(point1[0] - planeOriginX, point1[1] - planeOriginY); |
278 | 278 |
279 segments.push_back(std::pair<Point2D, Point2D>(p0,p1)); | 279 segments.push_back(std::pair<ScenePoint2D, ScenePoint2D>(p0,p1)); |
280 } | 280 } |
281 | 281 |
282 | 282 |
283 // final segment | 283 // final segment |
284 | 284 |
285 const Point3D& point0 = GetPoint(points_.size() - 1); | 285 const Vector& point0 = GetPoint(points_.size() - 1); |
286 // subtract plane origin x and y | 286 // subtract plane origin x and y |
287 Point2D p0(point0[0] - planeOriginX, point0[1] - planeOriginY); | 287 ScenePoint2D p0(point0[0] - planeOriginX, point0[1] - planeOriginY); |
288 | 288 |
289 const Point3D& point1 = GetPoint(0); | 289 const Vector& point1 = GetPoint(0); |
290 // subtract plane origin x and y | 290 // subtract plane origin x and y |
291 Point2D p1(point1[0] - planeOriginX, point1[1] - planeOriginY); | 291 ScenePoint2D p1(point1[0] - planeOriginX, point1[1] - planeOriginY); |
292 | 292 |
293 segments.push_back(std::pair<Point2D, Point2D>(p0, p1)); | 293 segments.push_back(std::pair<ScenePoint2D, ScenePoint2D>(p0, p1)); |
294 } | 294 } |
295 | 295 |
296 double DicomStructurePolygon2::GetZ() const | 296 double DicomStructurePolygon2::GetZ() const |
297 { | 297 { |
298 ORTHANC_ASSERT(LinearAlgebra::IsNear(normal_[0], 0.0)); | 298 ORTHANC_ASSERT(LinearAlgebra::IsNear(normal_[0], 0.0)); |