| 91 | } |
| 92 | |
| 93 | void mitk::ContourModelInteractor::OnAddPoint(StateMachineAction*, InteractionEvent* interactionEvent) |
| 94 | { |
| 95 | const auto* positionEvent = dynamic_cast<const InteractionPositionEvent*>(interactionEvent); |
| 96 | if (!positionEvent) |
| 97 | return; |
| 98 | |
| 99 | const auto timeStep = interactionEvent->GetSender()->GetTimeStep(GetDataNode()->GetData()); |
| 100 | |
| 101 | auto* contour = dynamic_cast<mitk::ContourModel*>(this->GetDataNode()->GetData()); |
| 102 | |
| 103 | Point3D currentPosition = positionEvent->GetPositionInWorld(); |
| 104 | |
| 105 | ContourElement::VertexSizeType segmentStart; |
| 106 | ContourElement::VertexSizeType segmentEnd; |
| 107 | Point3D closestContourPoint; |
| 108 | if (contour->GetLineSegmentForPoint(currentPosition, ContourModelInteractor::eps, timeStep, segmentStart, segmentEnd, closestContourPoint, true)) |
| 109 | { |
| 110 | const auto vertexList = contour->GetVertexList(timeStep); |
| 111 | //check if the segment is NOT within restricted control points. |
| 112 | auto controlStartIt = vertexList.begin(); |
| 113 | auto controlEndIt = vertexList.begin(); |
| 114 | for (auto searchIt = vertexList.begin() + segmentStart; searchIt != vertexList.begin(); searchIt--) |
| 115 | { |
| 116 | if ((*searchIt)->IsControlPoint) |
| 117 | { |
| 118 | controlStartIt = searchIt; |
| 119 | break; |
| 120 | } |
| 121 | } |
| 122 | for (auto searchIt = vertexList.begin() + segmentEnd; searchIt != vertexList.end(); searchIt++) |
| 123 | { |
| 124 | if ((*searchIt)->IsControlPoint) |
| 125 | { |
| 126 | controlEndIt = searchIt; |
| 127 | break; |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | const auto restrictedVs = m_RestrictedArea->GetVertexList(timeStep); |
| 132 | bool startIsRestricted = false; |
| 133 | bool stopIsRestricted = false; |
| 134 | |
| 135 | for (auto restrictedV : restrictedVs) |
| 136 | { |
| 137 | if (restrictedV->Coordinates == (*controlStartIt)->Coordinates) |
| 138 | { |
| 139 | startIsRestricted = true; |
| 140 | } |
| 141 | if (restrictedV->Coordinates == (*controlEndIt)->Coordinates) |
| 142 | { |
| 143 | stopIsRestricted = true; |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | if (!(startIsRestricted && stopIsRestricted)) |
| 148 | { |
| 149 | //add the point |
| 150 | contour->InsertVertexAtIndex(closestContourPoint, segmentEnd, true, timeStep); |
nothing calls this directly
no test coverage detected