Page MenuHomePhabricator

PointSet cloning method is not working properly
Closed, ResolvedPublic

Description

The clone method of the PointSet is not working properly. The cloned points does not match the original points if the index are not in line.

It is also possible to access points that have not been set without any warning or notice.

An 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);
pointSet->Update();
MITK_INFO<< pointSet->GetPoint(0); // Should not be possible
MITK_INFO<< pointSet->GetPoint(1);
MITK_INFO<< pointSet->GetPoint(2);
MITK_INFO<< pointSet->GetPoint(3);

mitk::PointSet::Pointer pointSet2 = pointSet->Clone();
MITK_INFO<< pointSet2->GetPoint(0); // Point is now in PointSet
MITK_INFO<< pointSet2->GetPoint(1);
MITK_INFO<< pointSet2->GetPoint(2);
MITK_INFO<< pointSet2->GetPoint(3); // Point is no longer in PointSet

returns
[0, 0, 0]
[1, 1, 1]
[2, 2, 2]
[3, 3, 3]
[0, 0, 0]
[1, 1, 1]
[2, 2, 2]
[0, 0, 0]

Event Timeline

What is the status of this bug? Please change the target milestone to "AfterNextRelease" if this bug is not relevant or cannot be fixed in time for the 2013-06 release.

New remote branch pushed: bug-15263-PointSetCloningBug

When points are set in the PointSet, but single indices are left out (as it is the case for index 0 in the example below), the left out points are nevertheless inserted as zero-Points (0,0,0). Consequently, problem arises during cloning within the mitk::PointSet copy c'tor: copying the stored points is performed times the number of only those points that got a valid index before (i.e. not of those left out index zero-Points). Then, there are more stored points than copy actions as the left-out indices do not count for copy, and not all stored points are duplicated.

Topic has been handled by determining the correct number of stored points. This is done by retrieving the index of the last point entry via iterator in the encapsuled itk map container.

The copy constructor of mitk::PointSet used a false notion of point identifiers, assuming they represent contiguous indices starting from zero.

[19eb96]: Merge branch 'bug-15263-fix-pointset-copy-constructor'

Merged commits:

2013-06-26 23:26:17 Sascha Zelzer [1fe62f]
Fixed PointSet copy constructor and test code.

The copy constructor of mitk::PointSet and the clone unit test
used a false notion of point identifiers, assuming they represent
contiguous indices starting from zero.

Conflicts:

Core/Code/DataManagement/mitkPointSet.cpp

New remote branch pushed: bug-15263-fix-pointset-copy-constructor

[01cfd1]: Merge branch 'bug-15263-fix-pointset-copy-constructor'

Merged commits:

2013-06-27 00:15:12 Sascha Zelzer [b9505e]
COMP: Added missing export macro.

This bug could not be fixed for release 2013-06. Setting target milestone to next release