22 : FEATURE_ID_LONGESTDIAMETER(this->AddFeature(
"Longest Axis",
"mm")),
23 FEATURE_ID_SHORTAXISDIAMETER(this->AddFeature(
"Short Axis",
"mm"))
47 if (singleLineMode !=
nullptr)
56 return this->GetSingleLineMode() ==
false || (m_SelectedControlPoint >= 0 && m_SelectedControlPoint <= 3);
61 if (this->GetSingleLineMode())
67 switch (m_SelectedControlPoint)
76 const Point2D tmpPoint = this->GetControlPoint(0);
77 this->SetControlPoint(0, this->GetControlPoint(1));
78 this->SetControlPoint(1, tmpPoint);
85 this->ResetNumberOfControlPoints(2);
86 this->SelectControlPoint(1);
93 this->SetControlPoint(0, this->GetControlPoint(3));
94 this->SetControlPoint(1, this->GetControlPoint(2));
97 this->ResetNumberOfControlPoints(2);
98 this->SelectControlPoint(1);
106 this->SetControlPoint(0, this->GetControlPoint(2));
107 this->SetControlPoint(1, this->GetControlPoint(3));
110 this->ResetNumberOfControlPoints(2);
111 this->SelectControlPoint(1);
119 if (this->GetSingleLineMode() || (this->GetNumberOfControlPoints() < 4))
137 unsigned int count = 0;
139 Point2D superclassConfinedPoint;
142 superclassConfinedPoint = Superclass::ApplyControlPointConstraints(index, confinedPoint);
143 confinedPoint = this->InternalApplyControlPointConstraints(index, superclassConfinedPoint);
145 }
while ((confinedPoint.EuclideanDistanceTo(superclassConfinedPoint) >
mitk::eps) && (count < 32));
147 return confinedPoint;
150 mitk::Point2D mitk::PlanarCross::InternalApplyControlPointConstraints(
unsigned int index,
const Point2D &point)
159 const Point2D p1 = this->GetControlPoint(0);
160 const Point2D p2 = this->GetControlPoint(1);
166 const double dotProduct = n1 * v1;
167 const Point2D crossPoint = p1 + n1 * dotProduct;
169 const Vector2D crossVector = point - crossPoint;
171 if (dotProduct < 0.0)
174 return (p1 + crossVector);
176 else if (dotProduct > p2.EuclideanDistanceTo(p1))
179 return (p2 + crossVector);
194 const Point2D p1 = this->GetControlPoint(0);
195 const Point2D p2 = this->GetControlPoint(1);
196 const Point2D p3 = this->GetControlPoint(2);
204 const double dotProduct1 = n1 * v1;
206 const Point2D pointOnLine = point - n1 * dotProduct1;
209 const Vector2D v2 = pointOnLine - p1;
210 double dotProduct2 = n1 * v2;
212 const Point2D crossingPoint = p1 + n1 * dotProduct2;
216 if ((pointOnLine.SquaredEuclideanDistanceTo(p3) > crossingPoint.SquaredEuclideanDistanceTo(p3)) &&
217 (pointOnLine.SquaredEuclideanDistanceTo(p3) > pointOnLine.SquaredEuclideanDistanceTo(crossingPoint)))
223 return crossingPoint;
234 this->SetNumberOfPolyLines(1);
235 this->ClearPolyLines();
237 if (this->GetNumberOfControlPoints() > 2)
238 this->SetNumberOfPolyLines(2);
240 for (
unsigned int i = 0; i < this->GetNumberOfControlPoints(); ++i)
243 this->AppendPointToPolyLine(0, this->GetControlPoint(i));
246 this->AppendPointToPolyLine(1, this->GetControlPoint(i));
254 if (this->GetNumberOfControlPoints() != 3)
256 m_HelperPolyLinesToBePainted->SetElement(0,
false);
260 m_HelperPolyLinesToBePainted->SetElement(0,
true);
262 this->ClearHelperPolyLines();
266 const Point2D p1 = this->GetControlPoint(0);
267 const Point2D p2 = this->GetControlPoint(1);
268 const Point2D p3 = this->GetControlPoint(2);
274 const Point2D crossPoint = p1 + n1 * (n1 * v1);
276 const Vector2D v2 = crossPoint - p3;
277 if (v2.GetNorm() < 1.0)
284 this->AppendPointToHelperPolyLine(0,
Point2D(p3 - v0 * 10000.0));
285 this->AppendPointToHelperPolyLine(0,
Point2D(p3 + v0 * 10000.0));
291 this->AppendPointToHelperPolyLine(0, p3);
292 this->AppendPointToHelperPolyLine(0,
Point2D(p3 + v2 * 10000.0));
299 const Point3D &p0 = this->GetWorldControlPoint(0);
300 const Point3D &p1 = this->GetWorldControlPoint(1);
301 double l1 = p0.EuclideanDistanceTo(p1);
305 if (!this->GetSingleLineMode() && (this->GetNumberOfControlPoints() > 3))
307 const Point3D &p2 = this->GetWorldControlPoint(2);
308 const Point3D &p3 = this->GetWorldControlPoint(3);
309 l2 = p2.EuclideanDistanceTo(p3);
312 double longestDiameter;
313 double shortAxisDiameter;
316 longestDiameter = l1;
317 shortAxisDiameter = l2;
321 longestDiameter = l2;
322 shortAxisDiameter = l1;
325 this->SetQuantity(FEATURE_ID_LONGESTDIAMETER, longestDiameter);
326 this->SetQuantity(FEATURE_ID_SHORTAXISDIAMETER, shortAxisDiameter);
331 Superclass::PrintSelf(os, indent);
339 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...
Point< ScalarType, 2 > Point2D
virtual Point2D ApplyControlPointConstraints(unsigned int index, const Point2D &point) override
Spatially constrain control points of second (orthogonal) line.
virtual unsigned int GetNumberOfFeatures() const override
Returns the number of features available for this PlanarCross (1 or 2).
virtual void PrintSelf(std::ostream &os, itk::Indent indent) const override
bool GetSingleLineMode() const
Indicates whether the PlanarFigure shall represent only a single line instead of an orthogonal cross...
void SetProperty(const char *propertyKey, BaseProperty *property)
Vector< ScalarType, 2 > Vector2D
virtual bool ResetOnPointSelect() override
The cross shall be reset to a single line when a control point is selected.
void SetSingleLineMode(bool singleLineMode)
Indicates whether the PlanarFigure shall represent only a single line instead of an orthogonal cross...
virtual bool ResetOnPointSelectNeeded() const override
Implementation of PlanarFigure modeling a cross with two orthogonal lines on a plane.
virtual void GeneratePolyLine() override
Generates the poly-line representation of the planar figure.
MITKCORE_EXPORT const ScalarType eps
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 EvaluateFeaturesInternal() override
Calculates feature quantities of the planar figure.
virtual T GetValue() const