Page MenuHomePhabricator

Method SetPoint() of class mitk::Line does not compile
Closed, ResolvedPublic

Description

When using the inline method SetPoint() of class mitk::Line, there appears a compiler error:

Error 1 error C2679: binary '=' : no operator found which takes a right-hand operand of type 'itk::Point<TCoordRep,NPointDimension>' (or there is no acceptable conversion) D:\prg\MBI-02-src\MITK\Core\Code\DataManagement\mitkLine.h 80

Here is an example usage to reproduce the error:

mitk::Line<double,2> returnValue = mitk::Line<double,2>();
itk::Point<double,2> origin;
origin[0] = [TODO];
origin[1] = [TODO];
itk::Vector<double,2> direction;
direction[0] = [TODO];
direction[1] = [TODO];
returnValue.SetDirection(direction);
returnValue.SetPoint(origin);

To fix it, the inline method SetPoint(...) has to be adapted as follows:

void SetPoint( const itk::Point<TCoordRep,NPointDimension>& point1 )

{
  itk::Point<TCoordRep,NPointDimension> point2;
  point2 = m_Point + m_Direction;

  m_Point = point1;
  m_Direction = point2.GetVectorFromOrigin() - point1.GetVectorFromOrigin();
}

Event Timeline

In addition we might want to convert the mitk::Line class from the header only inline implementation to a normal cpp class implementation. Or are there any reasons to don't do this?

mitk::Line is a template, so you cannot move the code into a .cpp file. SetPoint() was probably never used before and hence the compiler didn't instantiate the code.

Adding a simple unit test is the way to go.

User franza has pushed new remote branch:

bug-17742-mitkLineDoesNotCompile

[acc8f7]: Merge branch 'bug-17742-mitkLineDoesNotCompile'

Merged commits:

2014-04-30 16:29:09 Alfred Franz [efd90f]
added very simple test cases for a 2D and a 3D line which tests a minimum of functionality of that class. Extensions are still welcome...


2014-04-30 16:19:33 Alfred Franz [b53093]
fixed the bug...


2014-04-30 16:19:17 Alfred Franz [18ba00]
added a simple unit test for mitk::Line (to be extended)