15 #define ROUND_P(x) ((x) >= 0 ? (int)((x) + 0.5) : (int)((x)-0.5)) 19 : m_PlaneGeometry(nullptr), m_Geometry3D(nullptr), m_Image(nullptr)
49 for (
int i = 0; i < 3; i++)
61 if (geometry && image)
72 if (geometry && image)
83 if (!pointlist.empty() &&
image)
111 for (
int i = 0; i < 3; i++)
123 const auto *slicedGeometry3D =
125 int allSlices = slicedGeometry3D->
GetSlices();
128 dynamic_cast<mitk::PlaneGeometry *>(slicedGeometry3D->GetPlaneGeometry(allSlices - 1)));
144 Point3D origin = imageGeometry->GetCornerPoint(0);
147 const Vector3D xDirection = imageGeometry->GetAxisVector(0);
148 const Vector3D yDirection = imageGeometry->GetAxisVector(1);
149 const Vector3D zDirection = imageGeometry->GetAxisVector(2);
151 const Point3D leftBottomFront = origin;
152 const Point3D leftTopFront = origin + yDirection;
153 const Point3D leftBottomBack = origin + zDirection;
154 const Point3D leftTopBack = origin + yDirection + zDirection;
155 const Point3D rightBottomFront = origin + xDirection;
156 const Point3D rightTopFront = origin + xDirection + yDirection;
157 const Point3D rightBottomBack = origin + xDirection + zDirection;
158 const Point3D rightTopBack = origin + xDirection + yDirection + zDirection;
160 typedef std::vector<std::pair<mitk::Point3D, mitk::Point3D>> EdgesVector;
161 EdgesVector edgesOf3DBox;
162 edgesOf3DBox.reserve(12);
164 edgesOf3DBox.push_back(std::make_pair(leftBottomFront,
167 edgesOf3DBox.push_back(std::make_pair(leftBottomFront,
170 edgesOf3DBox.push_back(std::make_pair(leftBottomFront,
173 edgesOf3DBox.push_back(std::make_pair(leftTopFront,
176 edgesOf3DBox.push_back(std::make_pair(leftTopFront,
179 edgesOf3DBox.push_back(std::make_pair(rightTopFront,
182 edgesOf3DBox.push_back(std::make_pair(rightTopFront,
185 edgesOf3DBox.push_back(std::make_pair(rightBottomFront,
188 edgesOf3DBox.push_back(std::make_pair(rightBottomBack,
191 edgesOf3DBox.push_back(std::make_pair(rightBottomBack,
194 edgesOf3DBox.push_back(std::make_pair(rightTopBack,
197 edgesOf3DBox.push_back(std::make_pair(leftTopBack,
200 for (
auto iterator = edgesOf3DBox.cbegin(); iterator != edgesOf3DBox.cend(); ++iterator)
202 const Point3D startPoint = (*iterator).first;
203 const Point3D endPoint = (*iterator).second;
204 const Vector3D lineDirection = endPoint - startPoint;
212 bool doesLineIntersectWithPlane(
false);
219 doesLineIntersectWithPlane =
true;
220 intersectionWorldPoint = line.
GetPoint1();
230 imageGeometry->WorldToIndex(intersectionWorldPoint, intersectionIndexPoint);
234 if (doesLineIntersectWithPlane && lowerBoundGood && upperBoundGood)
236 for (
int dim = 0; dim < 3; ++dim)
248 PointListType::const_iterator pointIterator;
251 for (pointIterator = pointList.cbegin(); pointIterator != pointList.cend(); ++pointIterator)
254 imageGeometry->WorldToIndex((*pointIterator), pntInIndexCoordinates);
OutputType GetMinMaxSpatialDirectionZ()
What Z coordinates (slice indices) are cut/visible in given plane.
void CalculateIntersectionPoints(const mitk::PlaneGeometry *geometry)
mitk::PlaneGeometry::ConstPointer m_PlaneGeometry
void SetInput(const mitk::PlaneGeometry *geometry, mitk::Image *image)
void Update()
Request calculation.
virtual ~ClippedSurfaceBoundsCalculator()
bool IntersectionPointParam(const Line3D &line, double &t) const
Calculate line parameter of intersection point between the plane and a line.
virtual unsigned int GetSlices() const
Get the number of slices.
bool IntersectionPoint(const Line3D &line, Point3D &intersectionPoint) const
Calculate intersection point between the plane and a line.
mitk::BaseGeometry::ConstPointer m_Geometry3D
const itk::Point< TCoordRep, NPointDimension > & GetPoint1() const
Get start point of the line.
const itk::Vector< TCoordRep, NPointDimension > & GetDirection() const
Get the direction vector of the line.
void EnforceImageBounds()
Clips the resulting index-coordinates to make sure they do not exceed the imagebounds.
Image class for storing images.
ClippedSurfaceBoundsCalculator(const mitk::PlaneGeometry *geometry=nullptr, mitk::Image::Pointer image=nullptr)
std::vector< mitk::Point3D > m_ObjectPointsInWorldCoordinates
std::vector< mitk::Point3D > PointListType
std::vector< OutputType > m_MinMaxOutput
mitk::Image::Pointer image
Describes the geometry of a data object consisting of slices.
MITKCORE_EXPORT const ScalarType sqrteps
MITKCORE_EXPORT const ScalarType eps
ScalarType Distance(const Point3D &pt3d_mm) const
Distance of the point from the geometry (bounding-box not considered)
OutputType GetMinMaxSpatialDirectionY()
What Y coordinates (slice indices) are cut/visible in given plane.
mitk::Image::Pointer m_Image
Describes a two-dimensional, rectangular plane.
OutputType GetMinMaxSpatialDirectionX()
What X coordinates (slice indices) are cut/visible in given plane.
std::pair< int, int > OutputType
Minimum (first) and maximum (second) slice index.
BaseGeometry Describes the geometry of a data object.