lassoan
(Andras Lasso)
December 10, 2019, 9:21pm
3
Since it is very easy to find closest point on a line and we want to allow some picking tolerance, we found that a fast and robust solution is to transform all the lines to display coordinates and find the closest line segment there:
void vtkSlicerMarkupsWidgetRepresentation2D::CanInteractWithLine(
vtkMRMLInteractionEventData* interactionEventData,
int &foundComponentType, int &foundComponentIndex, double &closestDistance2)
{
foundComponentType = vtkMRMLMarkupsDisplayNode::ComponentNone;
vtkMRMLSliceNode *sliceNode = this->GetSliceNode();
vtkMRMLMarkupsNode* markupsNode = this->GetMarkupsNode();
if ( !sliceNode || !markupsNode || markupsNode->GetLocked() || markupsNode->GetNumberOfControlPoints() < 1
|| !this->GetVisibility() || !interactionEventData )
{
return;
}
const int* displayPosition = interactionEventData->GetDisplayPosition();
double displayPosition3[3] = { static_cast<double>(displayPosition[0]), static_cast<double>(displayPosition[1]), 0.0 };
double maxPickingDistanceFromControlPoint2 = this->GetMaximumControlPointPickingDistance2();
vtkIdType numberOfPoints = markupsNode->GetNumberOfControlPoints();
This file has been truncated. show original