Page MenuHomePhabricator

PointSet size is missleading
Closed, WontfixPublic

Description

The PointSet is using a std::map to save the points. But the developer can also access the number of saved points. So often something like

for (int i=0; i<pointSet->GetSize();++i)
{

// Do something with pointSet-GetPoint(i)

}

is done. This will lead to wrong results if a point has been deleted or the pointset has not initialized starting from zero. For example:

mitk::PointSet::Pointer pointSet = mitk::PointSet::New();
mitk::Point3D pointA, pointB, pointC;
pointA.Fill(1);
pointB.Fill(2);
pointC.Fill(3);
pointSet->SetPoint(1,pointA);
pointSet->SetPoint(2,pointB);
pointSet->SetPoint(3,pointC);

Event Timeline

FileNames containing misuse cases.

mitkPointSetBug-FileNames-1.jpg (852×1 px, 339 KB)

New remote branch pushed: bug-15264-PointSetMisuseCorrection

New remote branch pushed: bug-15264-PointSetMisuseProperInterfaceUse

New remote branch pushed: bug-15264-PointSetInterfaceChanges

bug-15264-PointSetMisuseCorrection and bug-15264-PointSetMisuseProperInterfaceUse are deprecated.

Two remarks below. Otherwise, this looks good to me.

  1. In mitkPointSet.h make GetMaxId() const
  1. Fix iterator increment logic in Plugins/org.mitk.gui.qt.examples/src/internal/simplemeasurement/QmitkSimpleMeasurement.cpp

User norajitr has pushed new remote branch:

bug-15264-AdaptCallsToNewPointSetInterface

Removing dependency from 16698, as that bug can be solved independently from the point set changes.

kislinsk added a subscriber: kislinsk.
This task was automatically closed because it wasn't updated at least since July 2016 (over 2 years). Please re-open this task if you think that it is still relevant. This most probably means that you will resolve it.