23 : FEATURE_ID_RADIUS(this->AddFeature(
"Radius",
"mm")),
24 FEATURE_ID_DIAMETER(this->AddFeature(
"Diameter",
"mm")),
25 FEATURE_ID_AREA(this->AddFeature(
"Area",
"mm2")),
28 m_MinMaxRadiusContraintsActive(false)
41 const Point2D ¢erPoint = GetControlPoint(0);
42 Point2D boundaryPoint = GetControlPoint(1);
43 const vnl_vector<ScalarType> vec = (point.GetVnlVector() - centerPoint.GetVnlVector());
45 boundaryPoint[0] += vec[0];
46 boundaryPoint[1] += vec[1];
61 if (this->GetPlaneGeometry() ==
nullptr)
67 this->GetPlaneGeometry()->WorldToIndex(point, indexPoint);
70 if (indexPoint[0] < bounds[0])
72 indexPoint[0] = bounds[0];
74 if (indexPoint[0] > bounds[1])
76 indexPoint[0] = bounds[1];
78 if (indexPoint[1] < bounds[2])
80 indexPoint[1] = bounds[2];
82 if (indexPoint[1] > bounds[3])
84 indexPoint[1] = bounds[3];
88 this->GetPlaneGeometry()->IndexToWorld(indexPoint, constrainedPoint);
90 if (m_MinMaxRadiusContraintsActive)
94 const Point2D ¢erPoint = this->GetControlPoint(0);
95 const double euclideanDinstanceFromCenterToPoint1 = centerPoint.EuclideanDistanceTo(point);
97 Vector2D vectorProjectedPoint = point - centerPoint;
98 vectorProjectedPoint.Normalize();
100 if (euclideanDinstanceFromCenterToPoint1 > m_MaxRadius)
102 vectorProjectedPoint *= m_MaxRadius;
103 constrainedPoint = centerPoint;
104 constrainedPoint += vectorProjectedPoint;
106 else if (euclideanDinstanceFromCenterToPoint1 < m_MinRadius)
108 vectorProjectedPoint *= m_MinRadius;
109 constrainedPoint = centerPoint;
110 constrainedPoint += vectorProjectedPoint;
115 return constrainedPoint;
123 this->ClearPolyLines();
125 const Point2D ¢erPoint = GetControlPoint(0);
126 const Point2D &boundaryPoint = GetControlPoint(1);
128 const double radius = centerPoint.EuclideanDistanceTo(boundaryPoint);
131 for (
int t = 0; t < 64; ++t)
133 const double alpha = (double)t * vnl_math::pi / 32.0;
137 polyLinePoint[0] = centerPoint[0] + radius * cos(alpha);
138 polyLinePoint[1] = centerPoint[1] + radius * sin(alpha);
142 this->AppendPointToPolyLine(0, polyLinePoint);
154 const Point3D &p0 = this->GetWorldControlPoint(0);
155 const Point3D &p1 = this->GetWorldControlPoint(1);
157 const double radius = p0.EuclideanDistanceTo(p1);
158 const double area = vnl_math::pi * radius * radius;
160 this->SetQuantity(FEATURE_ID_RADIUS, radius);
161 this->SetQuantity(FEATURE_ID_DIAMETER, 2 * radius);
162 this->SetQuantity(FEATURE_ID_AREA, area);
167 Superclass::PrintSelf(os, indent);
172 if (m_SelectedControlPoint < 0)
174 m_SelectedControlPoint = 1;
177 return this->SetControlPoint(m_SelectedControlPoint, point,
false);
185 return Superclass::Equals(other);
virtual Point2D ApplyControlPointConstraints(unsigned int index, const Point2D &point) override
Spatially constrain control points of second (orthogonal) line.
virtual void GeneratePolyLine() override
Generates the poly-line representation of the planar figure.
bool SetControlPoint(unsigned int index, const Point2D &point, bool createIfDoesNotExist=false) override
Place figure in its minimal configuration (a point at least) onto the given 2D geometry.
virtual bool SetCurrentControlPoint(const Point2D &point) override
void SetProperty(const char *propertyKey, BaseProperty *property)
virtual void EvaluateFeaturesInternal() override
Calculates feature quantities of the planar figure.
virtual void PrintSelf(std::ostream &os, itk::Indent indent) const override
virtual bool Equals(const mitk::PlanarFigure &other) const override
Compare two PlanarFigure objects Note: all subclasses have to implement the method on their own...
Implementation of PlanarFigure representing a circle through two 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.
BoundingBoxType::BoundsArrayType BoundsArrayType