20 : FEATURE_ID_MAJOR_AXIS(
Superclass::AddFeature(
"Major Axis",
"mm")),
21 FEATURE_ID_MINOR_AXIS(
Superclass::AddFeature(
"Minor Axis",
"mm")),
22 FEATURE_ID_AREA(
Superclass::AddFeature(
"Area",
"mm2")),
25 m_MinMaxRadiusContraintsActive(false),
42 const vnl_vector<ScalarType> vec = (point.GetVnlVector() - centerPoint.GetVnlVector());
44 boundaryPoint1[0] += vec[0];
45 boundaryPoint1[1] += vec[1];
46 boundaryPoint2[0] += vec[0];
47 boundaryPoint2[1] += vec[1];
48 boundaryPoint3[0] += vec[0];
49 boundaryPoint3[1] += vec[1];
59 int otherIndex = index + 1;
67 const Vector2D vec1 = point - centerPoint;
72 const float x = vec1[0];
81 otherPoint = centerPoint + vec2;
83 const float r = centerPoint.EuclideanDistanceTo(otherPoint);
88 vec3[0] = p3[0] - centerPoint[0];
89 vec3[1] = p3[1] - centerPoint[1];
90 if (vec3[0] != 0 || vec3[1] != 0)
100 point3 = centerPoint + vec3;
103 else if (vec1.GetNorm() > 0)
105 const float r = centerPoint.EuclideanDistanceTo(otherPoint);
106 const float x = vec1[0];
118 if (vec2.GetNorm() > 0)
120 otherPoint = centerPoint + vec2;
125 Vector2D vec3 = point3 - centerPoint;
139 Vector2D vec3 = point - centerPoint;
165 if (indexPoint[0] < bounds[0])
167 indexPoint[0] = bounds[0];
169 if (indexPoint[0] > bounds[1])
171 indexPoint[0] = bounds[1];
173 if (indexPoint[1] < bounds[2])
175 indexPoint[1] = bounds[2];
177 if (indexPoint[1] > bounds[3])
179 indexPoint[1] = bounds[3];
190 const double euclideanDinstanceFromCenterToPoint1 = centerPoint.EuclideanDistanceTo(point);
192 Vector2D vectorProjectedPoint = point - centerPoint;
193 vectorProjectedPoint.Normalize();
195 if (euclideanDinstanceFromCenterToPoint1 >
m_MaxRadius)
198 constrainedPoint = centerPoint;
199 constrainedPoint += vectorProjectedPoint;
201 else if (euclideanDinstanceFromCenterToPoint1 <
m_MinRadius)
204 constrainedPoint = centerPoint;
205 constrainedPoint += vectorProjectedPoint;
210 return constrainedPoint;
222 Vector2D dir = boundaryPoint1 - centerPoint;
224 vnl_matrix_fixed<float, 2, 2> rot;
237 rot[1][1] = rot[0][0];
238 rot[1][0] = sin(acos(rot[0][0]));
239 rot[0][1] = -rot[1][0];
241 const double radius1 = centerPoint.EuclideanDistanceTo(boundaryPoint1);
242 const double radius2 = centerPoint.EuclideanDistanceTo(boundaryPoint2);
245 for (
int t = start; t < end; ++t)
247 const double alpha = (double)t * vnl_math::pi / 32.0;
250 vnl_vector_fixed<float, 2> vec;
251 vec[0] = radius1 * cos(alpha);
252 vec[1] = radius2 * sin(alpha);
256 polyLinePoint[0] = centerPoint[0] + vec[0];
257 polyLinePoint[1] = centerPoint[1] + vec[1];
277 const auto longAxisLength = centerPoint.EuclideanDistanceTo(this->
GetControlPoint(1));
278 const auto shortAxisLength = centerPoint.EuclideanDistanceTo(this->
GetControlPoint(2));
287 Superclass::PrintSelf(os, indent);
298 return Superclass::Equals(other);
bool SetControlPoint(unsigned int index, const Point2D &point, bool createIfDoesNotExist=true) override
const unsigned int FEATURE_ID_MAJOR_AXIS
Implementation of PlanarFigure representing a circle through two control points.
void PlaceFigure(const Point2D &point) override
Place figure in its minimal configuration (a point at least) onto the given 2D geometry.
void PrintSelf(std::ostream &os, itk::Indent indent) const override
itk::DataObject Superclass
virtual void IndexToWorld(const Point2D &pt_units, Point2D &pt_mm) const
bool Equals(const mitk::PlanarFigure &other) const override
Compare two PlanarFigure objects Note: all subclasses have to implement the method on their own...
void SetProperty(const std::string &propertyKey, BaseProperty *property, const std::string &contextName="", bool fallBackOnDefaultContext=false) override
Add new or change existent property.
virtual void WorldToIndex(const Point2D &pt_mm, Point2D &pt_units) const
void EvaluateFeaturesInternal() override
Calculates feature quantities of the planar figure.
bool m_MinMaxRadiusContraintsActive
const unsigned int FEATURE_ID_AREA
void GenerateHelperPolyLine(double mmPerDisplayUnit, unsigned int displayHeight) override
Generates the poly-lines that should be drawn the same size regardless of zoom.
const unsigned int FEATURE_ID_MINOR_AXIS
Point2D ApplyControlPointConstraints(unsigned int index, const Point2D &point) override
Spatially constrain control points of second (orthogonal) line.
void GeneratePolyLine() override
Generates the poly-line representation of the planar figure.
const BoundsArrayType GetBounds() const
BoundingBoxType::BoundsArrayType BoundsArrayType