35 this->ClearPolyLines();
38 subdivisionPoints.clear();
39 subdivisionPoints = m_ControlPoints;
41 if (m_ControlPoints.size() >= GetMinimumNumberOfControlPoints())
43 for (
unsigned int i = 0; i < GetSubdivisionRounds(); i++)
46 unsigned int index, indexPrev, indexNext, indexNextNext;
48 const unsigned int numberOfPoints = subdivisionPoints.size();
53 for (index = 0; index < numberOfPoints; ++index)
57 indexPrev = (numberOfPoints + index - 1) % numberOfPoints;
58 indexNext = (index + 1) % numberOfPoints;
59 indexNextNext = (index + 2) % numberOfPoints;
62 (0.5 + GetTensionParameter()) * (
double)(subdivisionPoints[index][0] + subdivisionPoints[indexNext][0]) -
63 GetTensionParameter() * (double)(subdivisionPoints[indexPrev][0] + subdivisionPoints[indexNextNext][0]);
65 (0.5 + GetTensionParameter()) * (
double)(subdivisionPoints[index][1] + subdivisionPoints[indexNext][1]) -
66 GetTensionParameter() * (double)(subdivisionPoints[indexPrev][1] + subdivisionPoints[indexNextNext][1]);
68 newSubdivisionPoints.push_back(newPoint);
72 ControlPointListType::const_iterator it, itNew;
74 for (it = subdivisionPoints.cbegin(), itNew = newSubdivisionPoints.cbegin(); it != subdivisionPoints.cend();
77 mergedSubdivisionPoints.push_back(*it);
78 mergedSubdivisionPoints.push_back(*itNew);
81 subdivisionPoints = mergedSubdivisionPoints;
83 newSubdivisionPoints.clear();
87 const bool isInitiallyPlaced = this->GetProperty(
"initiallyplaced");
90 ControlPointListType::const_iterator it;
91 for (it = subdivisionPoints.cbegin(), i = 0; it != subdivisionPoints.cend(); ++it, ++i)
96 unsigned int nextIndex;
101 nextIndex = m_ControlPoints.size() - 1;
108 nextIndex = (((i - 1) >> this->GetSubdivisionRounds()) + 1) % m_ControlPoints.size();
109 if (!isInitiallyPlaced && nextIndex > m_ControlPoints.size() - 2)
111 this->AppendPointToPolyLine(0, m_ControlPoints[m_ControlPoints.size() - 1]);
116 this->AppendPointToPolyLine(0, *it);
118 subdivisionPoints.clear();
130 return Superclass::Equals(other);
142 if (indexOfPolylinePoint < 0 || indexOfPolylinePoint > static_cast<int>(polyLine.size()))
145 mitk::PlanarFigure::ControlPointListType::const_iterator elem;
146 mitk::PlanarFigure::ControlPointListType::const_iterator first = m_ControlPoints.cbegin();
147 mitk::PlanarFigure::ControlPointListType::const_iterator end = m_ControlPoints.cend();
149 mitk::PlanarFigure::PolyLineType::const_iterator polyLineIter;
150 mitk::PlanarFigure::PolyLineType::const_iterator polyLineEnd = polyLine.cend();
151 mitk::PlanarFigure::PolyLineType::const_iterator polyLineStart = polyLine.cbegin();
152 polyLineStart += indexOfPolylinePoint;
154 for (polyLineIter = polyLineStart; polyLineIter != polyLineEnd; ++polyLineIter)
156 elem = std::find(first, end, *polyLineIter);
159 return std::distance(first, elem);
162 return GetNumberOfControlPoints();
virtual bool Equals(const mitk::PlanarFigure &other) const override
Compare two PlanarFigure objects Note: all subclasses have to implement the method on their own...
int GetControlPointForPolylinePoint(int indexOfPolylinePoint, int polyLineIndex) const
Returns the id of the control-point that corresponds to the given polyline-point. ...
virtual void GeneratePolyLine() override
Generates the poly-line representation of the planar figure.
void SetProperty(const char *propertyKey, BaseProperty *property)
Implementation of PlanarFigure representing a polygon with two or more control points.
PlanarSubdivisionPolygon()
MITKCORE_EXPORT const ScalarType eps