int mitk::PointSetDataInteractor::GetPointIndexByPosition(Point3D position, unsigned int time, float accuracy) { // iterate over point set and check if it contains a point close enough to the pointer to be selected PointSet* points = dynamic_cast<PointSet*>(GetDataNode()->GetData()); int index = -1; if (points == NULL) { return index; } if (points->GetPointSet(time) == nullptr) return -1; PointSet::PointsContainer* pointsContainer = points->GetPointSet(time)->GetPoints(); float minDistance = m_SelectionAccuracy; if (accuracy != -1 ) minDistance = accuracy; for (PointSet::PointsIterator it = pointsContainer->Begin(); it != pointsContainer->End(); it++) { float distance = sqrt(position.SquaredEuclideanDistanceTo(points->GetPoint(it->Index(), time))); if (distance < minDistance) // if several points fall within the margin, choose the one with minimal distance to position { index = it->Index(); } } return index; }
int mitk::PointSetDataInteractor::GetPointIndexByPosition(Point3D position, int time) { // iterate over point set and check if it contains a point close enough to the pointer to be selected PointSet* points = dynamic_cast<PointSet*>(GetDataNode()->GetData()); int index = -1; if (points == NULL) { return index; } PointSet::PointsContainer* pointsContainer = points->GetPointSet(time)->GetPoints(); float minDistance = m_SelectionAccuracy; for (PointSet::PointsIterator it = pointsContainer->Begin(); it != pointsContainer->End(); it++) { float distance = sqrt(position.SquaredEuclideanDistanceTo(points->GetPoint(it->Index(), time))); // TODO: support time! if (distance < minDistance) // if several points fall within the margin, choose the one with minimal distance to position { // TODO: does this make sense, which unit is it? index = it->Index(); } } return index; }