33 this->ClearPolyLines();
35 for (
unsigned int i = 0; i < this->GetNumberOfControlPoints(); i++)
36 this->AppendPointToPolyLine(0, this->GetControlPoint(i));
42 if (this->GetNumberOfControlPoints() < 3)
44 m_HelperPolyLinesToBePainted->SetElement(0,
false);
48 this->ClearHelperPolyLines();
50 const Point2D centerPoint = this->GetControlPoint(1);
51 const Point2D boundaryPointOne = this->GetControlPoint(0);
52 const Point2D boundaryPointTwo = this->GetControlPoint(2);
54 double radius = centerPoint.EuclideanDistanceTo(boundaryPointOne);
55 if (radius > centerPoint.EuclideanDistanceTo(boundaryPointTwo))
57 radius = centerPoint.EuclideanDistanceTo(boundaryPointTwo);
61 double nonScalingRadius = displayHeight * mmPerDisplayUnit * 0.05;
63 if (nonScalingRadius > radius)
65 m_HelperPolyLinesToBePainted->SetElement(0,
false);
69 m_HelperPolyLinesToBePainted->SetElement(0,
true);
70 radius = nonScalingRadius;
72 double angle = this->GetQuantity(FEATURE_ID_ANGLE);
76 Vector2D v0 = boundaryPointOne - centerPoint;
77 Vector2D v1 = boundaryPointTwo - centerPoint;
82 v0[0] = v0[0] * cos(0.001) - v0[1] * sin(0.001);
83 v0[1] = v0[0] * sin(0.001) + v0[1] * cos(0.001);
86 double testAngle = acos(v0 * v1);
89 if (angle > testAngle)
91 v1[0] = v0[0] * cos(-0.001) - v0[1] * sin(-0.001);
92 v1[1] = v0[0] * sin(-0.001) + v0[1] * cos(-0.001);
96 if (acos(v0 * v2) > acos(v1 * v2))
98 testAngle = acos(v1 * v2);
102 testAngle = -acos(v1 * v2);
107 v0[0] = v1[0] * cos(-0.001) - v1[1] * sin(-0.001);
108 v0[1] = v1[0] * sin(-0.001) + v1[1] * cos(-0.001);
111 if (acos(v0 * v2) < acos(v1 * v2))
113 testAngle = acos(v1 * v2);
117 testAngle = -acos(v1 * v2);
121 for (
int t = 0; t < 16; ++t)
123 double alpha = (double)t * angle / 15.0 + testAngle;
126 polyLinePoint[0] = centerPoint[0] + radius * cos(alpha);
127 polyLinePoint[1] = centerPoint[1] + radius * sin(alpha);
129 this->AppendPointToHelperPolyLine(0, polyLinePoint);
135 if (this->GetNumberOfControlPoints() < 3)
142 const Point2D &p0 = this->GetControlPoint(0);
143 const Point2D &p1 = this->GetControlPoint(1);
144 const Point2D &p2 = this->GetControlPoint(2);
151 double angle = acos(v0 * v1);
153 this->SetQuantity(FEATURE_ID_ANGLE, angle);
158 Superclass::PrintSelf(os, indent);
166 return Superclass::Equals(other);
virtual bool Equals(const mitk::PlanarFigure &other) const override
Compare two PlanarFigure objects Note: all subclasses have to implement the method on their own...
virtual void PrintSelf(std::ostream &os, itk::Indent indent) const override
Implementation of PlanarFigure to display an angle through three control points.
virtual void GenerateHelperPolyLine(double mmPerDisplayUnit, unsigned int displayHeight) override
Generates the poly-lines that should be drawn the same size regardless of zoom.
virtual void GeneratePolyLine() override
Generates the poly-line representation of the planar figure.
virtual void EvaluateFeaturesInternal() override
Calculates feature quantities of the planar figure.