diff options
Diffstat (limited to 'src/ProjectionGeometry3D.cpp')
-rw-r--r-- | src/ProjectionGeometry3D.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/ProjectionGeometry3D.cpp b/src/ProjectionGeometry3D.cpp index 71c8df5..39c9af5 100644 --- a/src/ProjectionGeometry3D.cpp +++ b/src/ProjectionGeometry3D.cpp @@ -249,4 +249,64 @@ bool CProjectionGeometry3D::_initialize(int _iProjectionAngleCount, return true; } +void CProjectionGeometry3D::getProjectedBBox(double fXMin, double fXMax, + double fYMin, double fYMax, + double fZMin, double fZMax, + double &fUMin, double &fUMax, + double &fVMin, double &fVMax) const +{ + double vmin_g, vmax_g; + double umin_g, umax_g; + + // Default implementation, correct for flat panel detectors: + // Project corners of volume, take bounding box + + assert(getProjectionCount() > 0); + for (int i = 0; i < getProjectionCount(); ++i) { + + double vol_u[8]; + double vol_v[8]; + + projectPoint(fXMin, fYMin, fZMin, i, vol_u[0], vol_v[0]); + projectPoint(fXMin, fYMin, fZMax, i, vol_u[1], vol_v[1]); + projectPoint(fXMin, fYMax, fZMin, i, vol_u[2], vol_v[2]); + projectPoint(fXMin, fYMax, fZMax, i, vol_u[3], vol_v[3]); + projectPoint(fXMax, fYMin, fZMin, i, vol_u[4], vol_v[4]); + projectPoint(fXMax, fYMin, fZMax, i, vol_u[5], vol_v[5]); + projectPoint(fXMax, fYMax, fZMin, i, vol_u[6], vol_v[6]); + projectPoint(fXMax, fYMax, fZMax, i, vol_u[7], vol_v[7]); + + double umin = vol_u[0]; + double umax = vol_u[0]; + double vmin = vol_v[0]; + double vmax = vol_v[0]; + + for (int j = 1; j < 8; ++j) { + if (vol_u[j] < umin) + umin = vol_u[j]; + if (vol_u[j] > umax) + umax = vol_u[j]; + if (vol_v[j] < vmin) + vmin = vol_v[j]; + if (vol_v[j] > vmax) + vmax = vol_v[j]; + } + + if (i == 0 || umin < umin_g) + umin_g = umin; + if (i == 0 || umax > umax_g) + umax_g = umax; + if (i == 0 || vmin < vmin_g) + vmin_g = vmin; + if (i == 0 || vmax > vmax_g) + vmax_g = vmax; + } + + fUMin = umin_g; + fUMax = umax_g; + fVMin = vmin_g; + fVMax = vmax_g; +} + + } // namespace astra |