23 : FEATURE_ID_LENGTH(
Superclass::AddFeature(
"Length",
"mm")), m_NumberOfSegments(100)
34 for (
unsigned int i = 0; i < m_NumberOfSegments; ++i)
35 length += static_cast<Point2D>(m_PolyLines[0][i]).EuclideanDistanceTo(static_cast<Point2D>(m_PolyLines[0][i + 1]));
37 this->SetQuantity(FEATURE_ID_LENGTH, length);
42 return m_NumberOfSegments;
47 m_NumberOfSegments =
std::max(1U, numSegments);
51 this->GeneratePolyLine();
58 this->ClearHelperPolyLines();
60 unsigned int numHelperPolyLinePoints = m_ControlPoints.size();
62 for (
unsigned int i = 0; i < numHelperPolyLinePoints; ++i)
63 this->AppendPointToHelperPolyLine(0, m_ControlPoints[i]);
68 this->ClearPolyLines();
70 const unsigned int numPolyLinePoints = m_NumberOfSegments + 1;
72 for (
unsigned int i = 0; i < numPolyLinePoints; ++i)
73 this->AppendPointToPolyLine(0, this->ComputeDeCasteljauPoint(i / static_cast<ScalarType>(m_NumberOfSegments)));
78 unsigned int n = m_ControlPoints.size() - 1;
80 if (m_DeCasteljauPoints.size() != n)
81 m_DeCasteljauPoints.resize(n);
83 for (
unsigned int i = 0; i < n; ++i)
85 m_DeCasteljauPoints[i][0] = (1 - t) * m_ControlPoints[i][0] + t * m_ControlPoints[i + 1][0];
86 m_DeCasteljauPoints[i][1] = (1 - t) * m_ControlPoints[i][1] + t * m_ControlPoints[i + 1][1];
91 for (
unsigned int i = 0; i < n; ++i)
93 m_DeCasteljauPoints[i][0] = (1 - t) * m_DeCasteljauPoints[i][0] + t * m_DeCasteljauPoints[i + 1][0];
94 m_DeCasteljauPoints[i][1] = (1 - t) * m_DeCasteljauPoints[i][1] + t * m_DeCasteljauPoints[i + 1][1];
98 return m_DeCasteljauPoints[0];
105 if (indexOfPolylinePoint < 0 || indexOfPolylinePoint > static_cast<int>(polyLine.size()))
108 mitk::PlanarFigure::ControlPointListType::const_iterator elem;
109 mitk::PlanarFigure::ControlPointListType::const_iterator first = m_ControlPoints.cbegin();
110 mitk::PlanarFigure::ControlPointListType::const_iterator end = m_ControlPoints.cend();
112 mitk::PlanarFigure::PolyLineType::const_iterator polyLineIter;
113 mitk::PlanarFigure::PolyLineType::const_iterator polyLineEnd = polyLine.cend();
114 mitk::PlanarFigure::PolyLineType::const_iterator polyLineStart = polyLine.cbegin();
115 polyLineStart += indexOfPolylinePoint;
117 for (polyLineIter = polyLineStart; polyLineIter != polyLineEnd; ++polyLineIter)
119 elem = std::find(first, end, *polyLineIter);
122 return std::distance(first, elem);
125 return GetNumberOfControlPoints();
140 return index == 0 && m_ControlPoints.size() > 2;
146 if (otherBezierCurve)
148 if (this->m_NumberOfSegments != otherBezierCurve->m_NumberOfSegments)
150 if (this->m_DeCasteljauPoints != otherBezierCurve->m_DeCasteljauPoints)
152 return Superclass::Equals(other);
virtual void GenerateHelperPolyLine(double, unsigned int) override
Generates the poly-lines that should be drawn the same size regardless of zoom. Must be implemented i...
virtual bool IsHelperToBePainted(unsigned int index) const override
Returns whether a helper polyline should be painted or not.
unsigned int GetNumberOfSegments() const
itk::DataObject Superclass
virtual unsigned int GetMinimumNumberOfControlPoints() const override
Returns the minimum number of control points needed to represent this figure.
virtual unsigned int GetMaximumNumberOfControlPoints() const override
Returns the maximum number of control points allowed for this figure (e.g. 3 for triangles).
virtual void GeneratePolyLine() override
Generates the poly-line representation of the planar figure. Must be implemented in sub-classes...
int GetControlPointForPolylinePoint(int indexOfPolylinePoint, int polyLineIndex) const override
Returns the id of the control-point that corresponds to the given polyline-point. ...
virtual bool Equals(const mitk::PlanarFigure &other) const override
Compare two PlanarFigure objects Note: all subclasses have to implement the method on their own...
void SetNumberOfSegments(unsigned int numSegments)